lkml.org 
[lkml]   [2024]   [Jan]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 8/8] ext4: remove unnecessary parameter "needed" in ext4_discard_preallocations
On Sun 26-11-23 00:11:43, Kemeng Shi wrote:
> The "needed" controls the number of ext4_prealloc_space to discard in
> ext4_discard_preallocations. Function ext4_discard_preallocations is
> supposed to discard all non-used preallocated blocks when "needed"
> is 0 and now ext4_discard_preallocations is always called with "needed"
> = 0. Remove unnecessary parameter "needed" and remove all non-used
> preallocated spaces in ext4_discard_preallocations to simplify the
> code.
>
> Note: If count of non-used preallocated spaces could be more than
> UINT_MAX, there was a memory leak as some non-used preallocated
> spaces are left unused and this commit will fix it. Otherwise,
> there is no behavior change.
>
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>

Looks good, just one nit:

> @@ -5491,15 +5491,12 @@ void ext4_discard_preallocations(struct inode *inode, unsigned int needed)
> mb_debug(sb, "discard preallocation for inode %lu\n",
> inode->i_ino);
> trace_ext4_discard_preallocations(inode,
> - atomic_read(&ei->i_prealloc_active), needed);
> -
> - if (needed == 0)
> - needed = UINT_MAX;
> + atomic_read(&ei->i_prealloc_active), 0);

There's no point in always returning 0 in the tracepoint so I'd just update
it to not print the 'needed' value as well.

Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR

\
 
 \ /
  Last update: 2024-01-02 14:15    [W:0.509 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site