From: Zhang Yi <yi.zhang@huaweicloud.com>
To: linux-ext4@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz,
yi.zhang@huawei.com, yi.zhang@huaweicloud.com,
libaokun1@huawei.com, yukuai3@huawei.com, yangerkun@huawei.com
Subject: [PATCH v2 01/13] ext4: fix an off-by-one issue during moving extents
Date: Thu, 25 Sep 2025 17:25:57 +0800 [thread overview]
Message-ID: <20250925092610.1936929-2-yi.zhang@huaweicloud.com> (raw)
In-Reply-To: <20250925092610.1936929-1-yi.zhang@huaweicloud.com>
From: Zhang Yi <yi.zhang@huawei.com>
During the movement of a written extent, mext_page_mkuptodate() is
called to read data in the range [from, to) into the page cache and to
update the corresponding buffers. Therefore, we should not wait on any
buffer whose start offset is >= 'to'. Otherwise, it will return -EIO and
fail the extents movement.
$ for i in `seq 3 -1 0`; \
do xfs_io -fs -c "pwrite -b 1024 $((i * 1024)) 1024" /mnt/foo; \
done
$ umount /mnt && mount /dev/pmem1s /mnt # drop cache
$ e4defrag /mnt/foo
e4defrag 1.47.0 (5-Feb-2023)
ext4 defragmentation for /mnt/foo
[1/1]/mnt/foo: 0% [ NG ]
Success: [0/1]
Fixes: a40759fb16ae ("ext4: remove array of buffer_heads from mext_page_mkuptodate()")
Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
fs/ext4/move_extent.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index adae3caf175a..4b091c21908f 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -225,7 +225,7 @@ static int mext_page_mkuptodate(struct folio *folio, size_t from, size_t to)
do {
if (bh_offset(bh) + blocksize <= from)
continue;
- if (bh_offset(bh) > to)
+ if (bh_offset(bh) >= to)
break;
wait_on_buffer(bh);
if (buffer_uptodate(bh))
--
2.46.1
next prev parent reply other threads:[~2025-09-25 9:27 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-25 9:25 [PATCH v2 00/13] ext4: optimize online defragment Zhang Yi
2025-09-25 9:25 ` Zhang Yi [this message]
2025-09-25 9:25 ` [PATCH v2 02/13] ext4: correct the checking of quota files before moving extents Zhang Yi
2025-10-08 11:17 ` Jan Kara
2025-09-25 9:25 ` [PATCH v2 03/13] ext4: introduce seq counter for the extent status entry Zhang Yi
2025-10-08 11:26 ` Jan Kara
2025-10-08 11:44 ` Jan Kara
2025-10-09 6:52 ` Zhang Yi
2025-09-25 9:26 ` [PATCH v2 04/13] ext4: make ext4_es_lookup_extent() pass out the extent seq counter Zhang Yi
2025-10-08 11:28 ` Jan Kara
2025-09-25 9:26 ` [PATCH v2 05/13] ext4: pass out extent seq counter when mapping blocks Zhang Yi
2025-10-08 11:36 ` Jan Kara
2025-09-25 9:26 ` [PATCH v2 06/13] ext4: use EXT4_B_TO_LBLK() in mext_check_arguments() Zhang Yi
2025-10-08 11:45 ` Jan Kara
2025-09-25 9:26 ` [PATCH v2 07/13] ext4: add mext_check_validity() to do basic check Zhang Yi
2025-10-08 11:47 ` Jan Kara
2025-09-25 9:26 ` [PATCH v2 08/13] ext4: refactor mext_check_arguments() Zhang Yi
2025-10-08 11:51 ` Jan Kara
2025-09-25 9:26 ` [PATCH v2 09/13] ext4: rename mext_page_mkuptodate() to mext_folio_mkuptodate() Zhang Yi
2025-10-08 11:51 ` Jan Kara
2025-09-25 9:26 ` [PATCH v2 10/13] ext4: introduce mext_move_extent() Zhang Yi
2025-10-08 12:16 ` Jan Kara
2025-09-25 9:26 ` [PATCH v2 11/13] ext4: switch to using the new extent movement method Zhang Yi
2025-10-08 12:49 ` Jan Kara
2025-10-09 7:20 ` Zhang Yi
2025-10-09 9:14 ` Jan Kara
2025-10-09 12:24 ` Zhang Yi
2025-09-25 9:26 ` [PATCH v2 12/13] ext4: add large folios support for moving extents Zhang Yi
2025-10-08 12:53 ` Jan Kara
2025-10-09 7:23 ` Zhang Yi
2025-09-25 9:26 ` [PATCH v2 13/13] ext4: add two trace points " Zhang Yi
2025-10-08 12:54 ` Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250925092610.1936929-2-yi.zhang@huaweicloud.com \
--to=yi.zhang@huaweicloud.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=libaokun1@huawei.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).