* [PATCH v2] ext4: fix to report fstrim.minlen back to userspace
@ 2023-04-06 15:04 Chao Yu
2023-04-21 9:39 ` Jan Kara
0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2023-04-06 15:04 UTC (permalink / raw)
To: Theodore Ts'o, Andreas Dilger; +Cc: linux-ext4, linux-kernel, Chao Yu
Quoted from manual of fstrim(8):
"-m, --minimum minimum-size
..., if it's smaller than the device's minimum, and report that
(fstrim_range.minlen) back to userspace."
So this patch tries to report adjusted fstrim_range.minlen back to
userspace via FITRIM interface, if the value is smaller than device's
minimum discard granularity.
Signed-off-by: Chao Yu <chao@kernel.org>
---
v2:
- fix the wrong calculation of range->minlen.
fs/ext4/mballoc.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index d8b9d6a83d1e..4af51a16fc64 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -6491,6 +6491,10 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
discard_granularity >> sb->s_blocksize_bits);
if (minlen > EXT4_CLUSTERS_PER_GROUP(sb))
goto out;
+
+ /* Report adjusted minlen back to userspace */
+ range->minlen = EXT4_C2B(EXT4_SB(sb), minlen) <<
+ sb->s_blocksize_bits;
}
if (end >= max_blks - 1) {
end = max_blks - 1;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] ext4: fix to report fstrim.minlen back to userspace
2023-04-06 15:04 [PATCH v2] ext4: fix to report fstrim.minlen back to userspace Chao Yu
@ 2023-04-21 9:39 ` Jan Kara
2023-06-05 4:15 ` Chao Yu
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2023-04-21 9:39 UTC (permalink / raw)
To: Chao Yu; +Cc: Theodore Ts'o, Andreas Dilger, linux-ext4, linux-kernel
On Thu 06-04-23 23:04:10, Chao Yu wrote:
> Quoted from manual of fstrim(8):
>
> "-m, --minimum minimum-size
> ..., if it's smaller than the device's minimum, and report that
> (fstrim_range.minlen) back to userspace."
>
> So this patch tries to report adjusted fstrim_range.minlen back to
> userspace via FITRIM interface, if the value is smaller than device's
> minimum discard granularity.
>
> Signed-off-by: Chao Yu <chao@kernel.org>
Looks good to me. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> v2:
> - fix the wrong calculation of range->minlen.
> fs/ext4/mballoc.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index d8b9d6a83d1e..4af51a16fc64 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -6491,6 +6491,10 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
> discard_granularity >> sb->s_blocksize_bits);
> if (minlen > EXT4_CLUSTERS_PER_GROUP(sb))
> goto out;
> +
> + /* Report adjusted minlen back to userspace */
> + range->minlen = EXT4_C2B(EXT4_SB(sb), minlen) <<
> + sb->s_blocksize_bits;
> }
> if (end >= max_blks - 1) {
> end = max_blks - 1;
> --
> 2.25.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] ext4: fix to report fstrim.minlen back to userspace
2023-04-21 9:39 ` Jan Kara
@ 2023-06-05 4:15 ` Chao Yu
0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2023-06-05 4:15 UTC (permalink / raw)
To: Theodore Ts'o; +Cc: Andreas Dilger, linux-ext4, linux-kernel, Jan Kara
Ping,
On 2023/4/21 17:39, Jan Kara wrote:
> On Thu 06-04-23 23:04:10, Chao Yu wrote:
>> Quoted from manual of fstrim(8):
>>
>> "-m, --minimum minimum-size
>> ..., if it's smaller than the device's minimum, and report that
>> (fstrim_range.minlen) back to userspace."
>>
>> So this patch tries to report adjusted fstrim_range.minlen back to
>> userspace via FITRIM interface, if the value is smaller than device's
>> minimum discard granularity.
>>
>> Signed-off-by: Chao Yu <chao@kernel.org>
>
> Looks good to me. Feel free to add:
>
> Reviewed-by: Jan Kara <jack@suse.cz>
>
> Honza
>
>> ---
>> v2:
>> - fix the wrong calculation of range->minlen.
>> fs/ext4/mballoc.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
>> index d8b9d6a83d1e..4af51a16fc64 100644
>> --- a/fs/ext4/mballoc.c
>> +++ b/fs/ext4/mballoc.c
>> @@ -6491,6 +6491,10 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
>> discard_granularity >> sb->s_blocksize_bits);
>> if (minlen > EXT4_CLUSTERS_PER_GROUP(sb))
>> goto out;
>> +
>> + /* Report adjusted minlen back to userspace */
>> + range->minlen = EXT4_C2B(EXT4_SB(sb), minlen) <<
>> + sb->s_blocksize_bits;
>> }
>> if (end >= max_blks - 1) {
>> end = max_blks - 1;
>> --
>> 2.25.1
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-05 4:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06 15:04 [PATCH v2] ext4: fix to report fstrim.minlen back to userspace Chao Yu
2023-04-21 9:39 ` Jan Kara
2023-06-05 4:15 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox