Skip to contentSkip to conversation

Btrfs: remove repeated eb->pages check in, disk-io.c/csum_dirty_buffer

PATCH In review Wang Sheng-Hui 2 participants 2 messages Oct 8, 2012 – Oct 9, 2012 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: remove repeated eb->pages check in, disk-io.c/csum_dirty_buffer

In csum_dirty_buffer, we first get eb from page->private. Then we check if the page is the first page of eb. Later we check it again. Remove the repeated check here.

---
 fs/btrfs/disk-io.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
fs/btrfs/disk-io.c +3 -5
index 22e98e0..8919c56 100644
@@ -432,14 +432,12 @@ static int csum_dirty_buffer(struct btrfs_root *root, struct page *page)
 	tree = &BTRFS_I(page->mapping->host)->io_tree;
 
 	eb = (struct extent_buffer *)page->private;
-	if (page != eb->pages[0])
-		return 0;
-	found_start = btrfs_header_bytenr(eb);
-	if (found_start != start) {
+	if (page != eb->pages[0]) {
 		WARN_ON(1);
 		return 0;
 	}
-	if (eb->pages[0] != page) {
+	found_start = btrfs_header_bytenr(eb);
+	if (found_start != start) {
 		WARN_ON(1);
 		return 0;
 	}
Signature · 1 line
1.7.5.4
#1 lore raw
Quoted 3 lines · Wang Sheng-Hui

In csum_dirty_buffer, we first get eb from page->private. Then we check if the page is the first page of eb. Later we check it again. Remove the repeated check here.

You had the right idea here, two checks and one has a warning, so you kept the warning. But when the metadata block size is bigger than a page, the WARN_ON triggers for any page that isn't the first one in the extent buffer.

I kept this commit but removed the WARN_ON(1)

-chris