on 1/2/2024 9:10 PM, Jan Kara wrote: > 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@xxxxxxxxxxxxxxx> > > 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. Thanks for review! Sure, 'needed' looks meaningless to the tracepoint. I will remove it in next version. > > Honza >