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 3/3] ext4: support flex_bg in ext4_mb_normalize_request
Date: Sat, 28 May 2022 19:00:17 +0800 [thread overview]
Message-ID: <20220528110017.354175-4-libaokun1@huawei.com> (raw)
In-Reply-To: <20220528110017.354175-1-libaokun1@huawei.com>
In ext4_mb_normalize_request, the size of the allocation request is
limited to no more than EXT4_BLOCKS_PER_GROUP. Ritesh mentions that this
does not take into account the case of flex_bg groups. So we should add
support for flex_bg to make the physical blocks of large files contiguous.
Signed-off-by: Baokun Li <libaokun1@huawei.com>
---
fs/ext4/mballoc.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 9e06334771a3..253fc250e9a0 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4028,6 +4028,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
loff_t size, start_off;
loff_t orig_size __maybe_unused;
ext4_lblk_t start;
+ ext4_lblk_t bpg;
struct ext4_inode_info *ei = EXT4_I(ac->ac_inode);
struct ext4_prealloc_space *pa;
@@ -4051,6 +4052,11 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
}
bsbits = ac->ac_sb->s_blocksize_bits;
+ bpg = EXT4_BLOCKS_PER_GROUP(ac->ac_sb);
+ if (ext4_has_feature_flex_bg(ac->ac_sb) && sbi->s_log_groups_per_flex) {
+ if (check_shl_overflow(bpg, sbi->s_log_groups_per_flex, &bpg))
+ bpg = EXT_MAX_BLOCKS;
+ }
/* first, let's learn actual file size
* given current request is allocated */
@@ -4110,8 +4116,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
* alignment does not move allocation to a different group which
* makes mballoc fail assertions later.
*/
- start = max(start, rounddown(ac->ac_o_ex.fe_logical,
- (ext4_lblk_t)EXT4_BLOCKS_PER_GROUP(ac->ac_sb)));
+ start = max(start, rounddown(ac->ac_o_ex.fe_logical, bpg));
/* don't cover already allocated blocks in selected range */
if (ar->pleft && start <= ar->lleft) {
@@ -4125,8 +4130,8 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
* Trim allocation request for filesystems with artificially small
* groups.
*/
- if (size > EXT4_BLOCKS_PER_GROUP(ac->ac_sb))
- size = EXT4_BLOCKS_PER_GROUP(ac->ac_sb);
+ if (size > bpg)
+ size = bpg;
end = start + size;
@@ -4208,7 +4213,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
(unsigned long) ac->ac_o_ex.fe_logical);
BUG();
}
- BUG_ON(size <= 0 || size > EXT4_BLOCKS_PER_GROUP(ac->ac_sb));
+ BUG_ON(size <= 0 || size > bpg);
/* now prepare goal request */
--
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 ` [PATCH v3 2/3] ext4: correct the judgment of BUG in ext4_mb_normalize_request Baokun Li
2022-05-28 15:12 ` Ritesh Harjani
2022-05-30 2:13 ` Baokun Li
2022-05-28 11:00 ` Baokun Li [this message]
2022-05-28 15:09 ` [PATCH v3 3/3] ext4: support flex_bg " 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-4-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®