On 2024/7/16 19:29, Huang Xiaojia wrote:
FS_IOC_GETFSSYSFSPATH ioctl exposes /sys/fs path of a given filesystem,
potentially standarizing sysfs reporting. This patch add support for
FS_IOC_GETFSSYSFSPATH for erofs, "erofs/<dev>" will be outpt for bdev
                                                 ^ will be outputted

case, and "erofs/[domain_id,]<fs_id>" will be output for non-bdev case.

  ^ cases,

            ^ "erofs/[domainid,]<fsid>" will be outputed for fscache cases.


Signed-off-by: Huang Xiaojia <huangxiaoj...@huawei.com>
---
v2: handle non-bdev case.
v1: 
https://lore.kernel.org/all/20240624063801.2476116-1-huangxiaoj...@huawei.com/
---
  fs/erofs/super.c | 15 +++++++++++++++
  1 file changed, 15 insertions(+)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 1b91d9513013..a24b6907363c 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -576,6 +576,20 @@ static const struct export_operations erofs_export_ops = {
        .get_parent = erofs_get_parent,
  };
+static void erofs_set_sysfs_name(struct super_block *sb)
+{
+       struct erofs_sb_info *sbi = EROFS_SB(sb);
+
+       if (erofs_is_fscache_mode(sb)) {
+               if (sbi->domain_id)
+                       super_set_sysfs_name_generic(sb, "%s,%s", sbi->domain_id, 
sbi->fsid);

Overly long line.

+               else
+                       super_set_sysfs_name_generic(sb, "%s", sbi->fsid);

How about just get rid of the else arm, like:

                ...
                return;
        }
        super_set_sysfs_name_id(sb);
}

Otherwise it looks good to me, but I may need to find time to
test myself.

Thanks,
Gao Xiang


+       } else {
+               super_set_sysfs_name_id(sb);
+       }
+}
+
  static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
  {
        struct inode *inode;
@@ -643,6 +657,7 @@ static int erofs_fc_fill_super(struct super_block *sb, 
struct fs_context *fc)
                sb->s_flags |= SB_POSIXACL;
        else
                sb->s_flags &= ~SB_POSIXACL;
+       erofs_set_sysfs_name(sb);
#ifdef CONFIG_EROFS_FS_ZIP
        xa_init(&sbi->managed_pslots);

Reply via email to