Skip to contentSkip to conversation

gfs2: fs: derive f_fsid from s_uuid

PATCH Applied Amir Goldstein 3 participants 3 messages Oct 24, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gfs2: fs: derive f_fsid from s_uuid

gfs2 already has optional persistent uuid.

Use that uuid to report f_fsid in statfs(2), same as ext2/ext4/zonefs.

This allows gfs2 to be monitored by fanotify filesystem watch. for example, with inotify-tools 4.23.8.0, the following command can be used to watch changes over entire filesystem:

  fsnotifywatch --filesystem /mnt/gfs2

---

Andreas,

I do not have a test setup for gfs2, but this change it quite trivial, so I am posting it only compile tested.

There is no need to test fanotify. It enough to test statfs returns a non-zero f_fsid, e.g.:

strace -e fstatfs du /mnt/gfs2

Thanks,
Amir.

 fs/gfs2/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/gfs2/super.c +1 -0
index 02d93da21b2b..ea769af6bb23 100644
@@ -1006,6 +1006,7 @@ static int gfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_files = sc.sc_dinodes + sc.sc_free;
 	buf->f_ffree = sc.sc_free;
 	buf->f_namelen = GFS2_FNAMESIZE;
+	buf->f_fsid = uuid_to_fsid(sb->s_uuid.b);
 
 	return 0;
 }
Signature · 1 line
2.34.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Amir Goldstein

gfs2 already has optional persistent uuid.

Use that uuid to report f_fsid in statfs(2), same as ext2/ext4/zonefs.

This allows gfs2 to be monitored by fanotify filesystem watch. for example, with inotify-tools 4.23.8.0, the following command can be used to watch changes over entire filesystem:

  fsnotifywatch --filesystem /mnt/gfs2

Looks good. Feel free to add:

Honza

Quoted 33 lines

---

Andreas,

I do not have a test setup for gfs2, but this change it quite trivial, so I am posting it only compile tested.

There is no need to test fanotify. It enough to test statfs returns a non-zero f_fsid, e.g.:

strace -e fstatfs du /mnt/gfs2

Thanks,
Amir.

 fs/gfs2/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/gfs2/super.c +1 -0
index 02d93da21b2b..ea769af6bb23 100644
@@ -1006,6 +1006,7 @@ static int gfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_files = sc.sc_dinodes + sc.sc_free;
 	buf->f_ffree = sc.sc_free;
 	buf->f_namelen = GFS2_FNAMESIZE;
+	buf->f_fsid = uuid_to_fsid(sb->s_uuid.b);
 
 	return 0;
 }
Signature · 1 line
2.34.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer Applied
#2 lore raw
In reply to Amir Goldstein

Amir,

Quoted 3 lines · Amir Goldstein

gfs2 already has optional persistent uuid.

Use that uuid to report f_fsid in statfs(2), same as ext2/ext4/zonefs.

I've applied this patch, thank you.

Andreas