lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <4CE358C3.7070903@cn.fujitsu.com>
Date:	Wed, 17 Nov 2010 12:23:31 +0800
From:	Miao Xie <miaox@...fujitsu.com>
To:	Josef Bacik <josef@...hat.com>,
	Chris Mason <chris.mason@...cle.com>
CC:	Linux Btrfs <linux-btrfs@...r.kernel.org>,
	Linux Kernel <linux-kernel@...r.kernel.org>,
	Linux Fsdevel <linux-fsdevel@...r.kernel.org>,
	Ito <t-itoh@...fujitsu.com>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: [PATCH 2/3] btrfs: restructure btrfs_merge_bio_hook()

We restructured btrfs_merge_bio_hook(). And the new function will be used to
fix a panic problem that caused by direct IO.

Signed-off-by: Miao Xie <miaox@...fujitsu.com>
---
 fs/btrfs/inode.c |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 3906e48..32b68fa 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1353,6 +1353,22 @@ static int btrfs_clear_bit_hook(struct inode *inode,
 	return 0;
 }
 
+static int __btrfs_can_merge_page_to_bio(struct btrfs_mapping_tree *map_tree,
+					 size_t size, struct bio *bio)
+{
+	u64 logical = (u64)bio->bi_sector << 9;
+	u64 map_length;
+	int ret;
+
+	map_length = bio->bi_size;
+	ret = btrfs_map_block(map_tree, READ, logical,
+			      &map_length, NULL, 0);
+
+	if (map_length < bio->bi_size + size)
+		return 1;
+	return ret;
+}
+
 /*
  * extent_io.c merge_bio_hook, this must check the chunk tree to make sure
  * we don't create bios that span stripes or chunks
@@ -1363,23 +1379,12 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
 {
 	struct btrfs_root *root = BTRFS_I(page->mapping->host)->root;
 	struct btrfs_mapping_tree *map_tree;
-	u64 logical = (u64)bio->bi_sector << 9;
-	u64 length = 0;
-	u64 map_length;
-	int ret;
 
 	if (bio_flags & EXTENT_BIO_COMPRESSED)
 		return 0;
 
-	length = bio->bi_size;
 	map_tree = &root->fs_info->mapping_tree;
-	map_length = length;
-	ret = btrfs_map_block(map_tree, READ, logical,
-			      &map_length, NULL, 0);
-
-	if (map_length < length + size)
-		return 1;
-	return ret;
+	return __btrfs_can_merge_page_to_bio(map_tree, size, bio);
 }
 
 /*
-- 
1.7.0.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ