Skip to contentSkip to conversation

btrfs: trivial cleanups in end_bbio_data_write()

PATCH In review Qu Wenruo 2 participants 5 messages Mar 3 – Mar 4 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

cover btrfs: trivial cleanups in end_bbio_data_write()

Please check the changelog of each patch. All of them are pretty trivial.

Qu Wenruo (2):
btrfs: remove the alignment check in end_bbio_data_write()
btrfs: move the mapping_set_error() out of the loop in
end_bbio_data_write()

 fs/btrfs/extent_io.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
Signature · 1 line
2.53.0
author
#1 lore raw

PATCH 1/2 btrfs: remove the alignment check in end_bbio_data_write()

The check is not necessary because:

- There is already assert_bbio_alignment() at btrfs_submit_bbio()

- There is also btrfs_subpage_assert() for all btrfs_folio_*() helpers

- No similar check in all other endio functions No matter if it's data read, compressed read or write.

- There is no such report for very long
I do not even remember if there is any such report.

Thus the need to do such check in end_bbio_data_write() is very weak, and we can just get rid of it.

---
 fs/btrfs/extent_io.c | 11 -----------
 1 file changed, 11 deletions(-)
fs/btrfs/extent_io.c +0 -11
index 33b1afbee0a6..de6e25475ce1 100644
@@ -520,7 +520,6 @@ static void end_bbio_data_write(struct btrfs_bio *bbio)
 	struct bio *bio = &bbio->bio;
 	int error = blk_status_to_errno(bio->bi_status);
 	struct folio_iter fi;
-	const u32 sectorsize = fs_info->sectorsize;
 	u32 bio_size = 0;
 
 	ASSERT(!bio_flagged(bio, BIO_CLONED));
@@ -530,16 +529,6 @@ static void end_bbio_data_write(struct btrfs_bio *bbio)
 		u32 len = fi.length;
 
 		bio_size += len;
-		/* Our read/write should always be sector aligned. */
-		if (!IS_ALIGNED(fi.offset, sectorsize))
-			btrfs_err(fs_info,
-		"partial page write in btrfs with offset %zu and length %zu",
-				  fi.offset, fi.length);
-		else if (!IS_ALIGNED(fi.length, sectorsize))
-			btrfs_info(fs_info,
-		"incomplete page write with offset %zu and length %zu",
-				   fi.offset, fi.length);
-
 		if (error)
 			mapping_set_error(folio->mapping, error);
 
Signature · 1 line
2.53.0
author
#3 lore raw

PATCH 2/2 btrfs: move the mapping_set_error() out of the loop in end_bbio_data_write()

In reply to Qu Wenruo

Previously we have to call mapping_set_error() inside the for_each_folio_all() loop, because we do not have a better way to grab an inode, other than through folio->mapping.

But nowadays every btrfs_bio has its inode member populated, thus we can easily grab the inode and its i_mapping easily, without the help from a folio.

Now we can move that mapping_set_error() out of the loop, and use bbio->inode to grab the i_mapping.

---
 fs/btrfs/extent_io.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/extent_io.c +3 -3
index de6e25475ce1..f972c1580374 100644
@@ -529,14 +529,14 @@ static void end_bbio_data_write(struct btrfs_bio *bbio)
 		u32 len = fi.length;
 
 		bio_size += len;
-		if (error)
-			mapping_set_error(folio->mapping, error);
-
 		ASSERT(btrfs_folio_test_ordered(fs_info, folio, start, len));
 		btrfs_folio_clear_ordered(fs_info, folio, start, len);
 		btrfs_folio_clear_writeback(fs_info, folio, start, len);
 	}
 
+	if (error)
+		mapping_set_error(bbio->inode->vfs_inode.i_mapping, error);
+
 	btrfs_finish_ordered_extent(bbio->ordered, bbio->file_offset, bio_size, !error);
 	bio_put(bio);
 }
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH 1/2] btrfs: remove the alignment check in end_bbio_data_write()

In reply to Qu Wenruo
Quoted 11 lines · Qu Wenruo

The check is not necessary because:

- There is already assert_bbio_alignment() at btrfs_submit_bbio()

- There is also btrfs_subpage_assert() for all btrfs_folio_*() helpers

- No similar check in all other endio functions No matter if it's data read, compressed read or write.

- There is no such report for very long
I do not even remember if there is any such report.

Going back in history the first warning was added in 2013 commit 17a5adccf3fd01 ("btrfs: do away with non-whole_page extent I/O") and then refactored a few times. The changelog says

" I've replaced the whole_page computations with warnings, just to be
sure that we're not issuing partial page reads or writes. The warnings should probably just go away some time."

I've checked my old logs, no hits and neither on a general web search so this counts as safe to remove.

Reviewed-by on the v1 series
#4 lore raw
In reply to Qu Wenruo
Quoted 7 lines · Qu Wenruo

Please check the changelog of each patch. All of them are pretty trivial.

Qu Wenruo (2):
btrfs: remove the alignment check in end_bbio_data_write()
btrfs: move the mapping_set_error() out of the loop in
end_bbio_data_write()

Please update 1st patch changelog with the historical notes about the checks.