From: Amir Goldstein <amir73il@gmail.com>
Date: Tue, 24 Oct 2023 07:55:35 +0000 (+0300)
Subject: gfs2: fs: derive f_fsid from s_uuid
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=d6fc6c93636ffefd3d209d90a749e4e4ea51d6c1;p=linux.git

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

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---

diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 4dad30dd72fce..726f062bc490a 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -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;
 }