* [PATCH] erofs: derive fsid from on-disk UUID for .statfs() if possible
@ 2024-04-09 8:11 Hongzhen Luo
2024-04-09 8:47 ` Gao Xiang
2024-04-09 9:36 ` Jingbo Xu
0 siblings, 2 replies; 4+ messages in thread
From: Hongzhen Luo @ 2024-04-09 8:11 UTC (permalink / raw)
To: xiang, chao, linux-erofs; +Cc: Hongzhen Luo, huyue2, linux-kernel
Use the superblock's UUID to generate the fsid when it's non-null.
Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
---
fs/erofs/super.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index c0eb139adb07..83bd8ee3b5ba 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -923,22 +923,20 @@ static int erofs_statfs(struct dentry *dentry, struct kstatfs *buf)
{
struct super_block *sb = dentry->d_sb;
struct erofs_sb_info *sbi = EROFS_SB(sb);
- u64 id = 0;
-
- if (!erofs_is_fscache_mode(sb))
- id = huge_encode_dev(sb->s_bdev->bd_dev);
buf->f_type = sb->s_magic;
buf->f_bsize = sb->s_blocksize;
buf->f_blocks = sbi->total_blocks;
buf->f_bfree = buf->f_bavail = 0;
-
buf->f_files = ULLONG_MAX;
buf->f_ffree = ULLONG_MAX - sbi->inos;
-
buf->f_namelen = EROFS_NAME_LEN;
- buf->f_fsid = u64_to_fsid(id);
+ if (uuid_is_null(&sb->s_uuid))
+ buf->f_fsid = u64_to_fsid(erofs_is_fscache_mode(sb) ? 0 :
+ huge_encode_dev(sb->s_bdev->bd_dev));
+ else
+ buf->f_fsid = uuid_to_fsid((__u8 *)&sb->s_uuid);
return 0;
}
--
2.37.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs: derive fsid from on-disk UUID for .statfs() if possible
2024-04-09 8:11 [PATCH] erofs: derive fsid from on-disk UUID for .statfs() if possible Hongzhen Luo
@ 2024-04-09 8:47 ` Gao Xiang
2024-04-09 9:36 ` Jingbo Xu
1 sibling, 0 replies; 4+ messages in thread
From: Gao Xiang @ 2024-04-09 8:47 UTC (permalink / raw)
To: Hongzhen Luo, xiang, chao, linux-erofs; +Cc: huyue2, linux-kernel
On 2024/4/9 16:11, Hongzhen Luo wrote:
> Use the superblock's UUID to generate the fsid when it's non-null.
>
> Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Thanks,
Gao Xiang
> ---
> fs/erofs/super.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/fs/erofs/super.c b/fs/erofs/super.c
> index c0eb139adb07..83bd8ee3b5ba 100644
> --- a/fs/erofs/super.c
> +++ b/fs/erofs/super.c
> @@ -923,22 +923,20 @@ static int erofs_statfs(struct dentry *dentry, struct kstatfs *buf)
> {
> struct super_block *sb = dentry->d_sb;
> struct erofs_sb_info *sbi = EROFS_SB(sb);
> - u64 id = 0;
> -
> - if (!erofs_is_fscache_mode(sb))
> - id = huge_encode_dev(sb->s_bdev->bd_dev);
>
> buf->f_type = sb->s_magic;
> buf->f_bsize = sb->s_blocksize;
> buf->f_blocks = sbi->total_blocks;
> buf->f_bfree = buf->f_bavail = 0;
> -
> buf->f_files = ULLONG_MAX;
> buf->f_ffree = ULLONG_MAX - sbi->inos;
> -
> buf->f_namelen = EROFS_NAME_LEN;
>
> - buf->f_fsid = u64_to_fsid(id);
> + if (uuid_is_null(&sb->s_uuid))
> + buf->f_fsid = u64_to_fsid(erofs_is_fscache_mode(sb) ? 0 :
> + huge_encode_dev(sb->s_bdev->bd_dev));
> + else
> + buf->f_fsid = uuid_to_fsid((__u8 *)&sb->s_uuid);
> return 0;
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs: derive fsid from on-disk UUID for .statfs() if possible
2024-04-09 8:11 [PATCH] erofs: derive fsid from on-disk UUID for .statfs() if possible Hongzhen Luo
2024-04-09 8:47 ` Gao Xiang
@ 2024-04-09 9:36 ` Jingbo Xu
2024-04-09 11:23 ` Hongzhen Luo
1 sibling, 1 reply; 4+ messages in thread
From: Jingbo Xu @ 2024-04-09 9:36 UTC (permalink / raw)
To: Hongzhen Luo, xiang, chao, linux-erofs; +Cc: huyue2, linux-kernel
On 4/9/24 4:11 PM, Hongzhen Luo wrote:
> Use the superblock's UUID to generate the fsid when it's non-null.
>
> Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
> ---
> fs/erofs/super.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/fs/erofs/super.c b/fs/erofs/super.c
> index c0eb139adb07..83bd8ee3b5ba 100644
> --- a/fs/erofs/super.c
> +++ b/fs/erofs/super.c
> @@ -923,22 +923,20 @@ static int erofs_statfs(struct dentry *dentry, struct kstatfs *buf)
> {
> struct super_block *sb = dentry->d_sb;
> struct erofs_sb_info *sbi = EROFS_SB(sb);
> - u64 id = 0;
> -
> - if (!erofs_is_fscache_mode(sb))
> - id = huge_encode_dev(sb->s_bdev->bd_dev);
>
> buf->f_type = sb->s_magic;
> buf->f_bsize = sb->s_blocksize;
> buf->f_blocks = sbi->total_blocks;
> buf->f_bfree = buf->f_bavail = 0;
> -
> buf->f_files = ULLONG_MAX;
> buf->f_ffree = ULLONG_MAX - sbi->inos;
> -
> buf->f_namelen = EROFS_NAME_LEN;
>
> - buf->f_fsid = u64_to_fsid(id);
> + if (uuid_is_null(&sb->s_uuid))
> + buf->f_fsid = u64_to_fsid(erofs_is_fscache_mode(sb) ? 0 :
> + huge_encode_dev(sb->s_bdev->bd_dev));
> + else
> + buf->f_fsid = uuid_to_fsid((__u8 *)&sb->s_uuid);
How about
buf->f_fsid = uuid_to_fsid(sb->s_uuid.b);
which looks cleaner.
Otherwise LGTM.
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
--
Thanks,
Jingbo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs: derive fsid from on-disk UUID for .statfs() if possible
2024-04-09 9:36 ` Jingbo Xu
@ 2024-04-09 11:23 ` Hongzhen Luo
0 siblings, 0 replies; 4+ messages in thread
From: Hongzhen Luo @ 2024-04-09 11:23 UTC (permalink / raw)
To: Jingbo Xu, xiang, chao, linux-erofs; +Cc: huyue2, linux-kernel
在 2024/4/9 17:36, Jingbo Xu 写道:
>
> On 4/9/24 4:11 PM, Hongzhen Luo wrote:
>> Use the superblock's UUID to generate the fsid when it's non-null.
>>
>> Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
>> ---
>> fs/erofs/super.c | 12 +++++-------
>> 1 file changed, 5 insertions(+), 7 deletions(-)
>>
>> diff --git a/fs/erofs/super.c b/fs/erofs/super.c
>> index c0eb139adb07..83bd8ee3b5ba 100644
>> --- a/fs/erofs/super.c
>> +++ b/fs/erofs/super.c
>> @@ -923,22 +923,20 @@ static int erofs_statfs(struct dentry *dentry, struct kstatfs *buf)
>> {
>> struct super_block *sb = dentry->d_sb;
>> struct erofs_sb_info *sbi = EROFS_SB(sb);
>> - u64 id = 0;
>> -
>> - if (!erofs_is_fscache_mode(sb))
>> - id = huge_encode_dev(sb->s_bdev->bd_dev);
>>
>> buf->f_type = sb->s_magic;
>> buf->f_bsize = sb->s_blocksize;
>> buf->f_blocks = sbi->total_blocks;
>> buf->f_bfree = buf->f_bavail = 0;
>> -
>> buf->f_files = ULLONG_MAX;
>> buf->f_ffree = ULLONG_MAX - sbi->inos;
>> -
>> buf->f_namelen = EROFS_NAME_LEN;
>>
>> - buf->f_fsid = u64_to_fsid(id);
>> + if (uuid_is_null(&sb->s_uuid))
>> + buf->f_fsid = u64_to_fsid(erofs_is_fscache_mode(sb) ? 0 :
>> + huge_encode_dev(sb->s_bdev->bd_dev));
>> + else
>> + buf->f_fsid = uuid_to_fsid((__u8 *)&sb->s_uuid);
> How about
>
> buf->f_fsid = uuid_to_fsid(sb->s_uuid.b);
>
> which looks cleaner.
>
> Otherwise LGTM.
>
> Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
>
>
Thanks. I will send v2 later.
---
Hongzhen
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-09 11:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-09 8:11 [PATCH] erofs: derive fsid from on-disk UUID for .statfs() if possible Hongzhen Luo
2024-04-09 8:47 ` Gao Xiang
2024-04-09 9:36 ` Jingbo Xu
2024-04-09 11:23 ` Hongzhen Luo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).