* [PATCH v2] ext4: delete invalid ac_b_extent backup inside ext4_mb_use_best_found()
@ 2020-08-07 11:32 brookxu
2020-08-13 8:44 ` Andreas Dilger
0 siblings, 1 reply; 4+ messages in thread
From: brookxu @ 2020-08-07 11:32 UTC (permalink / raw)
To: adilger.kernel, tytso, linux-ext4
Delete invalid ac_b_extent backup inside ext4_mb_use_best_found(),
we have done this operation in ext4_mb_new_group_pa() and
ext4_mb_new_inode_pa().
Signed-off-by: Chunguang Xu <brookxu@tencent.com>
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 9b1c3ad..fb63e9f 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -1704,10 +1704,6 @@ static void ext4_mb_use_best_found(struct ext4_allocation_context *ac,
ac->ac_b_ex.fe_logical = ac->ac_g_ex.fe_logical;
ret = mb_mark_used(e4b, &ac->ac_b_ex);
- /* preallocation can change ac_b_ex, thus we store actually
- * allocated blocks for history */
- ac->ac_f_ex = ac->ac_b_ex;
-
ac->ac_status = AC_STATUS_FOUND;
ac->ac_tail = ret & 0xffff;
ac->ac_buddy = ret >> 16;
@@ -1726,8 +1722,8 @@ static void ext4_mb_use_best_found(struct ext4_allocation_context *ac,
/* store last allocated for subsequent stream allocation */
if (ac->ac_flags & EXT4_MB_STREAM_ALLOC) {
spin_lock(&sbi->s_md_lock);
- sbi->s_mb_last_group = ac->ac_f_ex.fe_group;
- sbi->s_mb_last_start = ac->ac_f_ex.fe_start;
+ sbi->s_mb_last_group = ac->ac_b_ex.fe_group;
+ sbi->s_mb_last_start = ac->ac_b_ex.fe_start;
spin_unlock(&sbi->s_md_lock);
}
/*
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] ext4: delete invalid ac_b_extent backup inside ext4_mb_use_best_found()
2020-08-07 11:32 [PATCH v2] ext4: delete invalid ac_b_extent backup inside ext4_mb_use_best_found() brookxu
@ 2020-08-13 8:44 ` Andreas Dilger
2020-08-13 9:08 ` brookxu
2020-08-13 11:01 ` Ritesh Harjani
0 siblings, 2 replies; 4+ messages in thread
From: Andreas Dilger @ 2020-08-13 8:44 UTC (permalink / raw)
To: brookxu; +Cc: Theodore Ts'o, Ext4 Developers List
[-- Attachment #1: Type: text/plain, Size: 2555 bytes --]
On Aug 7, 2020, at 5:32 AM, brookxu <brookxu.cn@gmail.com> wrote:
>
> Delete invalid ac_b_extent backup inside ext4_mb_use_best_found(),
> we have done this operation in ext4_mb_new_group_pa() and
> ext4_mb_new_inode_pa().
I'm not sure I understand this patch completely.
The calls to ext4_mb_new_group_pa() and ext4_mb_new_inode_pa() are
done from ext4_mb_new_preallocation(), which is called at the *end*
of ext4_mb_use_best_found() (i.e. after the lines that are being
deleted).
Maybe I'm confused by the description "we *have done* this operation"
makes it seem like it was already done, but really it should be
"we *will do* this operation in ..."?
That said, it would make more sense to keep the one line here in
ext4_mb_use_best_found() and remove the two duplicate lines in
ext4_mb_new_group_pa() and ext4_mb_new_inode_pa()? In that case,
the patch description would be more correct, like:
Delete duplicate ac_b_extent backup in ext4_mb_new_group_pa()
and ext4_mb_new_inode_pa(), since we have done this operation
in ext4_mb_use_best_found() already.
Cheers, Andreas
PS: thank you for taking the time to look at this code and improve it.
I know it is complex and hard to understand, but going through it like
this and trimming off the bad bits makes it a bit easier to understand
and maintain with each small patch.
> Signed-off-by: Chunguang Xu <brookxu@tencent.com>
>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 9b1c3ad..fb63e9f 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -1704,10 +1704,6 @@ static void ext4_mb_use_best_found(struct ext4_allocation_context *ac,
> ac->ac_b_ex.fe_logical = ac->ac_g_ex.fe_logical;
> ret = mb_mark_used(e4b, &ac->ac_b_ex);
>
> - /* preallocation can change ac_b_ex, thus we store actually
> - * allocated blocks for history */
> - ac->ac_f_ex = ac->ac_b_ex;
> -
> ac->ac_status = AC_STATUS_FOUND;
> ac->ac_tail = ret & 0xffff;
> ac->ac_buddy = ret >> 16;
> @@ -1726,8 +1722,8 @@ static void ext4_mb_use_best_found(struct ext4_allocation_context *ac,
> /* store last allocated for subsequent stream allocation */
> if (ac->ac_flags & EXT4_MB_STREAM_ALLOC) {
> spin_lock(&sbi->s_md_lock);
> - sbi->s_mb_last_group = ac->ac_f_ex.fe_group;
> - sbi->s_mb_last_start = ac->ac_f_ex.fe_start;
> + sbi->s_mb_last_group = ac->ac_b_ex.fe_group;
> + sbi->s_mb_last_start = ac->ac_b_ex.fe_start;
> spin_unlock(&sbi->s_md_lock);
> }
> /*
> --
> 1.8.3.1
Cheers, Andreas
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] ext4: delete invalid ac_b_extent backup inside ext4_mb_use_best_found()
2020-08-13 8:44 ` Andreas Dilger
@ 2020-08-13 9:08 ` brookxu
2020-08-13 11:01 ` Ritesh Harjani
1 sibling, 0 replies; 4+ messages in thread
From: brookxu @ 2020-08-13 9:08 UTC (permalink / raw)
To: Andreas Dilger; +Cc: Theodore Ts'o, Ext4 Developers List
Thank you very much for taking the time to review this patch. Due to poor thinking, there are some
problems with this patch. I think this patch can be ignored. Thank you again for your time.
thanks
Andreas Dilger wrote on 2020/8/13 16:44:
> On Aug 7, 2020, at 5:32 AM, brookxu <brookxu.cn@gmail.com> wrote:
>>
>> Delete invalid ac_b_extent backup inside ext4_mb_use_best_found(),
>> we have done this operation in ext4_mb_new_group_pa() and
>> ext4_mb_new_inode_pa().
>
> I'm not sure I understand this patch completely.
>
> The calls to ext4_mb_new_group_pa() and ext4_mb_new_inode_pa() are
> done from ext4_mb_new_preallocation(), which is called at the *end*
> of ext4_mb_use_best_found() (i.e. after the lines that are being
> deleted).
>
> Maybe I'm confused by the description "we *have done* this operation"
> makes it seem like it was already done, but really it should be
> "we *will do* this operation in ..."?
>
> That said, it would make more sense to keep the one line here in
> ext4_mb_use_best_found() and remove the two duplicate lines in
> ext4_mb_new_group_pa() and ext4_mb_new_inode_pa()? In that case,
> the patch description would be more correct, like:
>
> Delete duplicate ac_b_extent backup in ext4_mb_new_group_pa()
> and ext4_mb_new_inode_pa(), since we have done this operation
> in ext4_mb_use_best_found() already.
>
> Cheers, Andreas
>
> PS: thank you for taking the time to look at this code and improve it.
> I know it is complex and hard to understand, but going through it like
> this and trimming off the bad bits makes it a bit easier to understand
> and maintain with each small patch.
>
>> Signed-off-by: Chunguang Xu <brookxu@tencent.com>
>>
>> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
>> index 9b1c3ad..fb63e9f 100644
>> --- a/fs/ext4/mballoc.c
>> +++ b/fs/ext4/mballoc.c
>> @@ -1704,10 +1704,6 @@ static void ext4_mb_use_best_found(struct ext4_allocation_context *ac,
>> ac->ac_b_ex.fe_logical = ac->ac_g_ex.fe_logical;
>> ret = mb_mark_used(e4b, &ac->ac_b_ex);
>>
>> - /* preallocation can change ac_b_ex, thus we store actually
>> - * allocated blocks for history */
>> - ac->ac_f_ex = ac->ac_b_ex;
>> -
>> ac->ac_status = AC_STATUS_FOUND;
>> ac->ac_tail = ret & 0xffff;
>> ac->ac_buddy = ret >> 16;
>> @@ -1726,8 +1722,8 @@ static void ext4_mb_use_best_found(struct ext4_allocation_context *ac,
>> /* store last allocated for subsequent stream allocation */
>> if (ac->ac_flags & EXT4_MB_STREAM_ALLOC) {
>> spin_lock(&sbi->s_md_lock);
>> - sbi->s_mb_last_group = ac->ac_f_ex.fe_group;
>> - sbi->s_mb_last_start = ac->ac_f_ex.fe_start;
>> + sbi->s_mb_last_group = ac->ac_b_ex.fe_group;
>> + sbi->s_mb_last_start = ac->ac_b_ex.fe_start;
>> spin_unlock(&sbi->s_md_lock);
>> }
>> /*
>> --
>> 1.8.3.1
>
>
> Cheers, Andreas
>
>
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] ext4: delete invalid ac_b_extent backup inside ext4_mb_use_best_found()
2020-08-13 8:44 ` Andreas Dilger
2020-08-13 9:08 ` brookxu
@ 2020-08-13 11:01 ` Ritesh Harjani
1 sibling, 0 replies; 4+ messages in thread
From: Ritesh Harjani @ 2020-08-13 11:01 UTC (permalink / raw)
To: Andreas Dilger, brookxu; +Cc: Theodore Ts'o, Ext4 Developers List
On 8/13/20 2:14 PM, Andreas Dilger wrote:
> On Aug 7, 2020, at 5:32 AM, brookxu <brookxu.cn@gmail.com> wrote:
>>
>> Delete invalid ac_b_extent backup inside ext4_mb_use_best_found(),
>> we have done this operation in ext4_mb_new_group_pa() and
>> ext4_mb_new_inode_pa().
>
> I'm not sure I understand this patch completely.
>
> The calls to ext4_mb_new_group_pa() and ext4_mb_new_inode_pa() are
> done from ext4_mb_new_preallocation(), which is called at the *end*
> of ext4_mb_use_best_found() (i.e. after the lines that are being
> deleted).
>
> Maybe I'm confused by the description "we *have done* this operation"
> makes it seem like it was already done, but really it should be
> "we *will do* this operation in ..."?
>
> That said, it would make more sense to keep the one line here in
> ext4_mb_use_best_found() and remove the two duplicate lines in
> ext4_mb_new_group_pa() and ext4_mb_new_inode_pa()? In that case,
> the patch description would be more correct, like:
>
> Delete duplicate ac_b_extent backup in ext4_mb_new_group_pa()
> and ext4_mb_new_inode_pa(), since we have done this operation
> in ext4_mb_use_best_found() already.
>
Looked into the mballoc code and I agree with Andreas points here.
-ritesh
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-13 11:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-07 11:32 [PATCH v2] ext4: delete invalid ac_b_extent backup inside ext4_mb_use_best_found() brookxu
2020-08-13 8:44 ` Andreas Dilger
2020-08-13 9:08 ` brookxu
2020-08-13 11:01 ` Ritesh Harjani
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.