* [PATCH 1/2] btrfs: remove the alignment check in end_bbio_data_write()
2026-03-03 8:15 [PATCH 0/2] btrfs: trivial cleanups in end_bbio_data_write() Qu Wenruo
@ 2026-03-03 8:15 ` Qu Wenruo
2026-03-04 3:20 ` David Sterba
2026-03-03 8:15 ` [PATCH 2/2] btrfs: move the mapping_set_error() out of the loop " Qu Wenruo
2026-03-04 3:29 ` [PATCH 0/2] btrfs: trivial cleanups " David Sterba
2 siblings, 1 reply; 5+ messages in thread
From: Qu Wenruo @ 2026-03-03 8:15 UTC (permalink / raw)
To: linux-btrfs
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.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/extent_io.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 33b1afbee0a6..de6e25475ce1 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -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);
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] btrfs: remove the alignment check in end_bbio_data_write()
2026-03-03 8:15 ` [PATCH 1/2] btrfs: remove the alignment check " Qu Wenruo
@ 2026-03-04 3:20 ` David Sterba
0 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2026-03-04 3:20 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs
On Tue, Mar 03, 2026 at 06:45:09PM +1030, Qu Wenruo wrote:
> 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] btrfs: move the mapping_set_error() out of the loop in end_bbio_data_write()
2026-03-03 8:15 [PATCH 0/2] btrfs: trivial cleanups in end_bbio_data_write() Qu Wenruo
2026-03-03 8:15 ` [PATCH 1/2] btrfs: remove the alignment check " Qu Wenruo
@ 2026-03-03 8:15 ` Qu Wenruo
2026-03-04 3:29 ` [PATCH 0/2] btrfs: trivial cleanups " David Sterba
2 siblings, 0 replies; 5+ messages in thread
From: Qu Wenruo @ 2026-03-03 8:15 UTC (permalink / raw)
To: linux-btrfs
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.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/extent_io.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index de6e25475ce1..f972c1580374 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -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);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] btrfs: trivial cleanups in end_bbio_data_write()
2026-03-03 8:15 [PATCH 0/2] btrfs: trivial cleanups in end_bbio_data_write() Qu Wenruo
2026-03-03 8:15 ` [PATCH 1/2] btrfs: remove the alignment check " Qu Wenruo
2026-03-03 8:15 ` [PATCH 2/2] btrfs: move the mapping_set_error() out of the loop " Qu Wenruo
@ 2026-03-04 3:29 ` David Sterba
2 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2026-03-04 3:29 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs
On Tue, Mar 03, 2026 at 06:45:08PM +1030, Qu Wenruo wrote:
> 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()
Reviewed-by: David Sterba <dsterba@suse.com>
Please update 1st patch changelog with the historical notes about the
checks.
^ permalink raw reply [flat|nested] 5+ messages in thread