From: Baokun Li <libaokun1@huawei.com>
To: <linux-ext4@vger.kernel.org>
Cc: <tytso@mit.edu>, <adilger.kernel@dilger.ca>, <jack@suse.cz>,
<ritesh.list@gmail.com>, <lczerner@redhat.com>,
<linux-kernel@vger.kernel.org>, <yi.zhang@huawei.com>,
<yebin10@huawei.com>, <yukuai3@huawei.com>,
<libaokun1@huawei.com>
Subject: [PATCH v3 2/3] ext4: correct the judgment of BUG in ext4_mb_normalize_request
Date: Sat, 28 May 2022 19:00:16 +0800 [thread overview]
Message-ID: <20220528110017.354175-3-libaokun1@huawei.com> (raw)
In-Reply-To: <20220528110017.354175-1-libaokun1@huawei.com>
ext4_mb_normalize_request() can move logical start of allocated blocks
to reduce fragmentation and better utilize preallocation. However logical
block requested as a start of allocation (ac->ac_o_ex.fe_logical) should
always be covered by allocated blocks so we should check that by
modifying and to or in the assertion.
Signed-off-by: Baokun Li <libaokun1@huawei.com>
---
V1->V2:
Change Fixes from dfe076c106f6 to c9de560ded61.
V2->V3:
Delete Fixes tag.
Add more comments and commit logs to make the code easier to understand.
fs/ext4/mballoc.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 4d3740fdff90..9e06334771a3 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4185,7 +4185,22 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
}
rcu_read_unlock();
- if (start + size <= ac->ac_o_ex.fe_logical &&
+ /*
+ * In this function "start" and "size" are normalized for better
+ * alignment and length such that we could preallocate more blocks.
+ * This normalization is done such that original request of
+ * ac->ac_o_ex.fe_logical & fe_len should always lie within "start" and
+ * "size" boundaries.
+ * (Note fe_len can be relaxed since FS block allocation API does not
+ * provide gurantee on number of contiguous blocks allocation since that
+ * depends upon free space left, etc).
+ * In case of inode pa, later we use the allocated blocks
+ * [pa_start + fe_logical - pa_lstart, fe_len/size] from the preallocated
+ * range of goal/best blocks [start, size] to put it at the
+ * ac_o_ex.fe_logical extent of this inode.
+ * (See ext4_mb_use_inode_pa() for more details)
+ */
+ if (start + size <= ac->ac_o_ex.fe_logical ||
start > ac->ac_o_ex.fe_logical) {
ext4_msg(ac->ac_sb, KERN_ERR,
"start %lu, size %lu, fe_logical %lu",
--
2.31.1
next prev parent reply other threads:[~2022-05-28 10:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-28 11:00 [PATCH v3 0/3] ext4: fix two bugs " Baokun Li
2022-05-28 11:00 ` [PATCH v3 1/3] ext4: fix bug_on ext4_mb_use_inode_pa Baokun Li
2022-05-28 15:10 ` Ritesh Harjani
2022-05-30 2:12 ` Baokun Li
2022-05-28 11:00 ` Baokun Li [this message]
2022-05-28 15:12 ` [PATCH v3 2/3] ext4: correct the judgment of BUG in ext4_mb_normalize_request Ritesh Harjani
2022-05-30 2:13 ` Baokun Li
2022-05-28 11:00 ` [PATCH v3 3/3] ext4: support flex_bg " Baokun Li
2022-05-28 15:09 ` Ritesh Harjani
2022-05-30 2:35 ` Baokun Li
2022-06-18 2:12 ` [PATCH v3 0/3] ext4: fix two bugs " Theodore Ts'o
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=20220528110017.354175-3-libaokun1@huawei.com \
--to=libaokun1@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=yebin10@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
all inboxes | Powered by JetHome®