All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Better fanotify support for tmpfs
@ 2021-03-22 17:39 Amir Goldstein
  2021-03-22 17:39 ` [PATCH 1/2] fs: introduce a wrapper uuid_to_fsid() Amir Goldstein
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Amir Goldstein @ 2021-03-22 17:39 UTC (permalink / raw)
  To: Jan Kara; +Cc: Hugh Dickins, Theodore Tso, Damien Le Moal, linux-fsdevel

Jan,

I needed the tmpfs patch for the userns filesystem mark POC, but it
looks useful for its own right to be able to set filesystem mount or
inode marks on tmpfs with FAN_REPORT_FID.

I can break the cleanup patch into helper and individual patches
for the fs maintainers, but since its so dummy, I thought it might
be best to get an ACK from fs maintainers and carry this as a single
patch.

Thanks,
Amir.

Amir Goldstein (2):
  fs: introduce a wrapper uuid_to_fsid()
  shmem: allow reporting fanotify events with file handles on tmpfs

 fs/ext2/super.c        | 5 +----
 fs/ext4/super.c        | 5 +----
 fs/zonefs/super.c      | 5 +----
 include/linux/statfs.h | 7 +++++++
 mm/shmem.c             | 3 +++
 5 files changed, 13 insertions(+), 12 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/2] fs: introduce a wrapper uuid_to_fsid()
  2021-03-22 17:39 [PATCH 0/2] Better fanotify support for tmpfs Amir Goldstein
@ 2021-03-22 17:39 ` Amir Goldstein
  2021-03-23  5:19   ` Damien Le Moal
  2021-03-23 14:09   ` Christian Brauner
  2021-03-22 17:39 ` [PATCH 2/2] shmem: allow reporting fanotify events with file handles on tmpfs Amir Goldstein
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ messages in thread
From: Amir Goldstein @ 2021-03-22 17:39 UTC (permalink / raw)
  To: Jan Kara; +Cc: Hugh Dickins, Theodore Tso, Damien Le Moal, linux-fsdevel

Some filesystem's use a digest of their uuid for f_fsid.
Create a simple wrapper for this open coded folding.

Filesystems that have a non null uuid but use the block device
number for f_fsid may also consider using this helper.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/ext2/super.c        | 5 +----
 fs/ext4/super.c        | 5 +----
 fs/zonefs/super.c      | 5 +----
 include/linux/statfs.h | 7 +++++++
 4 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 6c4753277916..0d679451657c 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -1399,7 +1399,6 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
 	struct super_block *sb = dentry->d_sb;
 	struct ext2_sb_info *sbi = EXT2_SB(sb);
 	struct ext2_super_block *es = sbi->s_es;
-	u64 fsid;
 
 	spin_lock(&sbi->s_lock);
 
@@ -1453,9 +1452,7 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
 	buf->f_ffree = ext2_count_free_inodes(sb);
 	es->s_free_inodes_count = cpu_to_le32(buf->f_ffree);
 	buf->f_namelen = EXT2_NAME_LEN;
-	fsid = le64_to_cpup((void *)es->s_uuid) ^
-	       le64_to_cpup((void *)es->s_uuid + sizeof(u64));
-	buf->f_fsid = u64_to_fsid(fsid);
+	buf->f_fsid = uuid_to_fsid(es->s_uuid);
 	spin_unlock(&sbi->s_lock);
 	return 0;
 }
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index ad34a37278cd..3581c1cdc19e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -6148,7 +6148,6 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	struct ext4_super_block *es = sbi->s_es;
 	ext4_fsblk_t overhead = 0, resv_blocks;
-	u64 fsid;
 	s64 bfree;
 	resv_blocks = EXT4_C2B(sbi, atomic64_read(&sbi->s_resv_clusters));
 
@@ -6169,9 +6168,7 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_files = le32_to_cpu(es->s_inodes_count);
 	buf->f_ffree = percpu_counter_sum_positive(&sbi->s_freeinodes_counter);
 	buf->f_namelen = EXT4_NAME_LEN;
-	fsid = le64_to_cpup((void *)es->s_uuid) ^
-	       le64_to_cpup((void *)es->s_uuid + sizeof(u64));
-	buf->f_fsid = u64_to_fsid(fsid);
+	buf->f_fsid = uuid_to_fsid(es->s_uuid);
 
 #ifdef CONFIG_QUOTA
 	if (ext4_test_inode_flag(dentry->d_inode, EXT4_INODE_PROJINHERIT) &&
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 0fe76f376dee..e09810311162 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -1104,7 +1104,6 @@ static int zonefs_statfs(struct dentry *dentry, struct kstatfs *buf)
 	struct super_block *sb = dentry->d_sb;
 	struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
 	enum zonefs_ztype t;
-	u64 fsid;
 
 	buf->f_type = ZONEFS_MAGIC;
 	buf->f_bsize = sb->s_blocksize;
@@ -1127,9 +1126,7 @@ static int zonefs_statfs(struct dentry *dentry, struct kstatfs *buf)
 
 	spin_unlock(&sbi->s_lock);
 
-	fsid = le64_to_cpup((void *)sbi->s_uuid.b) ^
-		le64_to_cpup((void *)sbi->s_uuid.b + sizeof(u64));
-	buf->f_fsid = u64_to_fsid(fsid);
+	buf->f_fsid = uuid_to_fsid(sbi->s_uuid.b);
 
 	return 0;
 }
diff --git a/include/linux/statfs.h b/include/linux/statfs.h
index 20f695b90aab..ed86ac090a1b 100644
--- a/include/linux/statfs.h
+++ b/include/linux/statfs.h
@@ -50,4 +50,11 @@ static inline __kernel_fsid_t u64_to_fsid(u64 v)
 	return (__kernel_fsid_t){.val = {(u32)v, (u32)(v>>32)}};
 }
 
+/* Fold 16 bytes uuid to 64 bit fsid */
+static inline __kernel_fsid_t uuid_to_fsid(__u8 *uuid)
+{
+	return u64_to_fsid(le64_to_cpup((void *)uuid) ^
+		le64_to_cpup((void *)(uuid + sizeof(u64))));
+}
+
 #endif
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/2] shmem: allow reporting fanotify events with file handles on tmpfs
  2021-03-22 17:39 [PATCH 0/2] Better fanotify support for tmpfs Amir Goldstein
  2021-03-22 17:39 ` [PATCH 1/2] fs: introduce a wrapper uuid_to_fsid() Amir Goldstein
@ 2021-03-22 17:39 ` Amir Goldstein
  2021-03-25 15:00   ` Jan Kara
  2021-03-23 13:25 ` [PATCH 0/2] Better fanotify support for tmpfs Jan Kara
  2021-03-23 14:13 ` Christian Brauner
  3 siblings, 1 reply; 11+ messages in thread
From: Amir Goldstein @ 2021-03-22 17:39 UTC (permalink / raw)
  To: Jan Kara; +Cc: Hugh Dickins, Theodore Tso, Damien Le Moal, linux-fsdevel

Since kernel v5.1, fanotify_init(2) supports the flag FAN_REPORT_FID
for identifying objects using file handle and fsid in events.

fanotify_mark(2) fails with -ENODEV when trying to set a mark on
filesystems that report null f_fsid in stasfs(2).

Use the digest of uuid as f_fsid for tmpfs to uniquely identify tmpfs
objects as best as possible and allow setting an fanotify mark that
reports events with file handles on tmpfs.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 mm/shmem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/shmem.c b/mm/shmem.c
index b2db4ed0fbc7..162d8f8993bb 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2846,6 +2846,9 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf)
 		buf->f_ffree = sbinfo->free_inodes;
 	}
 	/* else leave those fields 0 like simple_statfs */
+
+	buf->f_fsid = uuid_to_fsid(dentry->d_sb->s_uuid.b);
+
 	return 0;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] fs: introduce a wrapper uuid_to_fsid()
  2021-03-22 17:39 ` [PATCH 1/2] fs: introduce a wrapper uuid_to_fsid() Amir Goldstein
@ 2021-03-23  5:19   ` Damien Le Moal
  2021-03-23 14:09   ` Christian Brauner
  1 sibling, 0 replies; 11+ messages in thread
From: Damien Le Moal @ 2021-03-23  5:19 UTC (permalink / raw)
  To: Amir Goldstein, Jan Kara; +Cc: Hugh Dickins, Theodore Tso, linux-fsdevel

On 2021/03/23 2:39, Amir Goldstein wrote:
> Some filesystem's use a digest of their uuid for f_fsid.
> Create a simple wrapper for this open coded folding.
> 
> Filesystems that have a non null uuid but use the block device
> number for f_fsid may also consider using this helper.
> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>  fs/ext2/super.c        | 5 +----
>  fs/ext4/super.c        | 5 +----
>  fs/zonefs/super.c      | 5 +----
>  include/linux/statfs.h | 7 +++++++
>  4 files changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> index 6c4753277916..0d679451657c 100644
> --- a/fs/ext2/super.c
> +++ b/fs/ext2/super.c
> @@ -1399,7 +1399,6 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
>  	struct super_block *sb = dentry->d_sb;
>  	struct ext2_sb_info *sbi = EXT2_SB(sb);
>  	struct ext2_super_block *es = sbi->s_es;
> -	u64 fsid;
>  
>  	spin_lock(&sbi->s_lock);
>  
> @@ -1453,9 +1452,7 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
>  	buf->f_ffree = ext2_count_free_inodes(sb);
>  	es->s_free_inodes_count = cpu_to_le32(buf->f_ffree);
>  	buf->f_namelen = EXT2_NAME_LEN;
> -	fsid = le64_to_cpup((void *)es->s_uuid) ^
> -	       le64_to_cpup((void *)es->s_uuid + sizeof(u64));
> -	buf->f_fsid = u64_to_fsid(fsid);
> +	buf->f_fsid = uuid_to_fsid(es->s_uuid);
>  	spin_unlock(&sbi->s_lock);
>  	return 0;
>  }
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index ad34a37278cd..3581c1cdc19e 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -6148,7 +6148,6 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
>  	struct ext4_sb_info *sbi = EXT4_SB(sb);
>  	struct ext4_super_block *es = sbi->s_es;
>  	ext4_fsblk_t overhead = 0, resv_blocks;
> -	u64 fsid;
>  	s64 bfree;
>  	resv_blocks = EXT4_C2B(sbi, atomic64_read(&sbi->s_resv_clusters));
>  
> @@ -6169,9 +6168,7 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
>  	buf->f_files = le32_to_cpu(es->s_inodes_count);
>  	buf->f_ffree = percpu_counter_sum_positive(&sbi->s_freeinodes_counter);
>  	buf->f_namelen = EXT4_NAME_LEN;
> -	fsid = le64_to_cpup((void *)es->s_uuid) ^
> -	       le64_to_cpup((void *)es->s_uuid + sizeof(u64));
> -	buf->f_fsid = u64_to_fsid(fsid);
> +	buf->f_fsid = uuid_to_fsid(es->s_uuid);
>  
>  #ifdef CONFIG_QUOTA
>  	if (ext4_test_inode_flag(dentry->d_inode, EXT4_INODE_PROJINHERIT) &&
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 0fe76f376dee..e09810311162 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -1104,7 +1104,6 @@ static int zonefs_statfs(struct dentry *dentry, struct kstatfs *buf)
>  	struct super_block *sb = dentry->d_sb;
>  	struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
>  	enum zonefs_ztype t;
> -	u64 fsid;
>  
>  	buf->f_type = ZONEFS_MAGIC;
>  	buf->f_bsize = sb->s_blocksize;
> @@ -1127,9 +1126,7 @@ static int zonefs_statfs(struct dentry *dentry, struct kstatfs *buf)
>  
>  	spin_unlock(&sbi->s_lock);
>  
> -	fsid = le64_to_cpup((void *)sbi->s_uuid.b) ^
> -		le64_to_cpup((void *)sbi->s_uuid.b + sizeof(u64));
> -	buf->f_fsid = u64_to_fsid(fsid);
> +	buf->f_fsid = uuid_to_fsid(sbi->s_uuid.b);
>  
>  	return 0;
>  }
> diff --git a/include/linux/statfs.h b/include/linux/statfs.h
> index 20f695b90aab..ed86ac090a1b 100644
> --- a/include/linux/statfs.h
> +++ b/include/linux/statfs.h
> @@ -50,4 +50,11 @@ static inline __kernel_fsid_t u64_to_fsid(u64 v)
>  	return (__kernel_fsid_t){.val = {(u32)v, (u32)(v>>32)}};
>  }
>  
> +/* Fold 16 bytes uuid to 64 bit fsid */
> +static inline __kernel_fsid_t uuid_to_fsid(__u8 *uuid)
> +{
> +	return u64_to_fsid(le64_to_cpup((void *)uuid) ^
> +		le64_to_cpup((void *)(uuid + sizeof(u64))));
> +}
> +
>  #endif
> 

For the zonefs bits, looks good to me.

Acked-by: Damien Le Moal <damien.lemoal@wdc.com>


-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/2] Better fanotify support for tmpfs
  2021-03-22 17:39 [PATCH 0/2] Better fanotify support for tmpfs Amir Goldstein
  2021-03-22 17:39 ` [PATCH 1/2] fs: introduce a wrapper uuid_to_fsid() Amir Goldstein
  2021-03-22 17:39 ` [PATCH 2/2] shmem: allow reporting fanotify events with file handles on tmpfs Amir Goldstein
@ 2021-03-23 13:25 ` Jan Kara
  2021-03-23 14:13 ` Christian Brauner
  3 siblings, 0 replies; 11+ messages in thread
From: Jan Kara @ 2021-03-23 13:25 UTC (permalink / raw)
  To: Amir Goldstein
  Cc: Jan Kara, Hugh Dickins, Theodore Tso, Damien Le Moal, linux-fsdevel

On Mon 22-03-21 19:39:42, Amir Goldstein wrote:
> Jan,
> 
> I needed the tmpfs patch for the userns filesystem mark POC, but it
> looks useful for its own right to be able to set filesystem mount or
> inode marks on tmpfs with FAN_REPORT_FID.
> 
> I can break the cleanup patch into helper and individual patches
> for the fs maintainers, but since its so dummy, I thought it might
> be best to get an ACK from fs maintainers and carry this as a single
> patch.

The series looks fine to me. I'll wait if I get some feedback from Hugh. If
Hugh doesn't object, I'll take the two patches to my tree.

								Honza

> Amir Goldstein (2):
>   fs: introduce a wrapper uuid_to_fsid()
>   shmem: allow reporting fanotify events with file handles on tmpfs
> 
>  fs/ext2/super.c        | 5 +----
>  fs/ext4/super.c        | 5 +----
>  fs/zonefs/super.c      | 5 +----
>  include/linux/statfs.h | 7 +++++++
>  mm/shmem.c             | 3 +++
>  5 files changed, 13 insertions(+), 12 deletions(-)
> 
> -- 
> 2.25.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] fs: introduce a wrapper uuid_to_fsid()
  2021-03-22 17:39 ` [PATCH 1/2] fs: introduce a wrapper uuid_to_fsid() Amir Goldstein
  2021-03-23  5:19   ` Damien Le Moal
@ 2021-03-23 14:09   ` Christian Brauner
  1 sibling, 0 replies; 11+ messages in thread
From: Christian Brauner @ 2021-03-23 14:09 UTC (permalink / raw)
  To: Amir Goldstein
  Cc: Jan Kara, Hugh Dickins, Theodore Tso, Damien Le Moal, linux-fsdevel

On Mon, Mar 22, 2021 at 07:39:43PM +0200, Amir Goldstein wrote:
> Some filesystem's use a digest of their uuid for f_fsid.
> Create a simple wrapper for this open coded folding.
> 
> Filesystems that have a non null uuid but use the block device
> number for f_fsid may also consider using this helper.
> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---

Seen that as part of your other series yesterday. Looks like a good
improvement and removes a bunch of open-coding.
Reviewed-by: Christian Brauner <christian.brauner@ubuntu.com>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/2] Better fanotify support for tmpfs
  2021-03-22 17:39 [PATCH 0/2] Better fanotify support for tmpfs Amir Goldstein
                   ` (2 preceding siblings ...)
  2021-03-23 13:25 ` [PATCH 0/2] Better fanotify support for tmpfs Jan Kara
@ 2021-03-23 14:13 ` Christian Brauner
  3 siblings, 0 replies; 11+ messages in thread
From: Christian Brauner @ 2021-03-23 14:13 UTC (permalink / raw)
  To: Amir Goldstein
  Cc: Jan Kara, Hugh Dickins, Theodore Tso, Damien Le Moal, linux-fsdevel

On Mon, Mar 22, 2021 at 07:39:42PM +0200, Amir Goldstein wrote:
> Jan,
> 
> I needed the tmpfs patch for the userns filesystem mark POC, but it
> looks useful for its own right to be able to set filesystem mount or
> inode marks on tmpfs with FAN_REPORT_FID.

Indeed.
Seems how to generate the fs_id part based on the uuid is a bit
controversial for some fses (from the xfs thread) but this series seems
useful. Being able to place marks on tmpfs is worth it.

Reviewed-by: Christian Brauner <christian.brauner@ubuntu.com>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] shmem: allow reporting fanotify events with file handles on tmpfs
  2021-03-22 17:39 ` [PATCH 2/2] shmem: allow reporting fanotify events with file handles on tmpfs Amir Goldstein
@ 2021-03-25 15:00   ` Jan Kara
  2021-04-16  9:59     ` Amir Goldstein
  0 siblings, 1 reply; 11+ messages in thread
From: Jan Kara @ 2021-03-25 15:00 UTC (permalink / raw)
  To: Amir Goldstein
  Cc: Jan Kara, Hugh Dickins, Theodore Tso, Damien Le Moal, linux-fsdevel

On Mon 22-03-21 19:39:44, Amir Goldstein wrote:
> Since kernel v5.1, fanotify_init(2) supports the flag FAN_REPORT_FID
> for identifying objects using file handle and fsid in events.
> 
> fanotify_mark(2) fails with -ENODEV when trying to set a mark on
> filesystems that report null f_fsid in stasfs(2).
> 
> Use the digest of uuid as f_fsid for tmpfs to uniquely identify tmpfs
> objects as best as possible and allow setting an fanotify mark that
> reports events with file handles on tmpfs.
> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>

Hugh, any opinion on this patch?

								Honza

> ---
>  mm/shmem.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/mm/shmem.c b/mm/shmem.c
> index b2db4ed0fbc7..162d8f8993bb 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -2846,6 +2846,9 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf)
>  		buf->f_ffree = sbinfo->free_inodes;
>  	}
>  	/* else leave those fields 0 like simple_statfs */
> +
> +	buf->f_fsid = uuid_to_fsid(dentry->d_sb->s_uuid.b);
> +
>  	return 0;
>  }
>  
> -- 
> 2.25.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] shmem: allow reporting fanotify events with file handles on tmpfs
  2021-03-25 15:00   ` Jan Kara
@ 2021-04-16  9:59     ` Amir Goldstein
  2021-04-17  3:54       ` Hugh Dickins
  0 siblings, 1 reply; 11+ messages in thread
From: Amir Goldstein @ 2021-04-16  9:59 UTC (permalink / raw)
  To: Hugh Dickins; +Cc: Jan Kara, Theodore Tso, Damien Le Moal, linux-fsdevel

On Thu, Mar 25, 2021 at 5:00 PM Jan Kara <jack@suse.cz> wrote:
>
> On Mon 22-03-21 19:39:44, Amir Goldstein wrote:
> > Since kernel v5.1, fanotify_init(2) supports the flag FAN_REPORT_FID
> > for identifying objects using file handle and fsid in events.
> >
> > fanotify_mark(2) fails with -ENODEV when trying to set a mark on
> > filesystems that report null f_fsid in stasfs(2).
> >
> > Use the digest of uuid as f_fsid for tmpfs to uniquely identify tmpfs
> > objects as best as possible and allow setting an fanotify mark that
> > reports events with file handles on tmpfs.
> >
> > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
>
> Hugh, any opinion on this patch?
>
>                                                                 Honza
>
> > ---
> >  mm/shmem.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/mm/shmem.c b/mm/shmem.c
> > index b2db4ed0fbc7..162d8f8993bb 100644
> > --- a/mm/shmem.c
> > +++ b/mm/shmem.c
> > @@ -2846,6 +2846,9 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf)
> >               buf->f_ffree = sbinfo->free_inodes;
> >       }
> >       /* else leave those fields 0 like simple_statfs */
> > +
> > +     buf->f_fsid = uuid_to_fsid(dentry->d_sb->s_uuid.b);
> > +
> >       return 0;
> >  }
> >


Ping.

Hugh, are you ok with this change?

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] shmem: allow reporting fanotify events with file handles on tmpfs
  2021-04-16  9:59     ` Amir Goldstein
@ 2021-04-17  3:54       ` Hugh Dickins
  2021-04-19  8:34         ` Jan Kara
  0 siblings, 1 reply; 11+ messages in thread
From: Hugh Dickins @ 2021-04-17  3:54 UTC (permalink / raw)
  To: Amir Goldstein, Jan Kara
  Cc: Hugh Dickins, Theodore Tso, Damien Le Moal, linux-fsdevel

On Fri, 16 Apr 2021, Amir Goldstein wrote:
> On Thu, Mar 25, 2021 at 5:00 PM Jan Kara <jack@suse.cz> wrote:
> >
> > On Mon 22-03-21 19:39:44, Amir Goldstein wrote:
> > > Since kernel v5.1, fanotify_init(2) supports the flag FAN_REPORT_FID
> > > for identifying objects using file handle and fsid in events.
> > >
> > > fanotify_mark(2) fails with -ENODEV when trying to set a mark on
> > > filesystems that report null f_fsid in stasfs(2).
> > >
> > > Use the digest of uuid as f_fsid for tmpfs to uniquely identify tmpfs
> > > objects as best as possible and allow setting an fanotify mark that
> > > reports events with file handles on tmpfs.
> > >
> > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> >
> > Hugh, any opinion on this patch?
> >
> >                                                                 Honza
> >
> > > ---
> > >  mm/shmem.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > >
> > > diff --git a/mm/shmem.c b/mm/shmem.c
> > > index b2db4ed0fbc7..162d8f8993bb 100644
> > > --- a/mm/shmem.c
> > > +++ b/mm/shmem.c
> > > @@ -2846,6 +2846,9 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf)
> > >               buf->f_ffree = sbinfo->free_inodes;
> > >       }
> > >       /* else leave those fields 0 like simple_statfs */
> > > +
> > > +     buf->f_fsid = uuid_to_fsid(dentry->d_sb->s_uuid.b);
> > > +
> > >       return 0;
> > >  }
> > >
> 
> 
> Ping.
> 
> Hugh, are you ok with this change?
> 
> Thanks,
> Amir.

Yes, apologies for my delay to you, Amir and Jan:
sure I'm ok with this change, and thank you for taking care of tmpfs.

Acked-by: Hugh Dickins <hughd@google.com>

But you have more valuable acks on this little series already,
so don't bother rebasing some tree to add mine in now.  I don't yet
see the uuid_to_fsid() 1/2 which this depends on in linux-next, and
fear that's my fault for holding you back: sorry, please go ahead now.

Hugh

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] shmem: allow reporting fanotify events with file handles on tmpfs
  2021-04-17  3:54       ` Hugh Dickins
@ 2021-04-19  8:34         ` Jan Kara
  0 siblings, 0 replies; 11+ messages in thread
From: Jan Kara @ 2021-04-19  8:34 UTC (permalink / raw)
  To: Hugh Dickins
  Cc: Amir Goldstein, Jan Kara, Theodore Tso, Damien Le Moal, linux-fsdevel

On Fri 16-04-21 20:54:46, Hugh Dickins wrote:
> On Fri, 16 Apr 2021, Amir Goldstein wrote:
> > On Thu, Mar 25, 2021 at 5:00 PM Jan Kara <jack@suse.cz> wrote:
> > >
> > > On Mon 22-03-21 19:39:44, Amir Goldstein wrote:
> > > > Since kernel v5.1, fanotify_init(2) supports the flag FAN_REPORT_FID
> > > > for identifying objects using file handle and fsid in events.
> > > >
> > > > fanotify_mark(2) fails with -ENODEV when trying to set a mark on
> > > > filesystems that report null f_fsid in stasfs(2).
> > > >
> > > > Use the digest of uuid as f_fsid for tmpfs to uniquely identify tmpfs
> > > > objects as best as possible and allow setting an fanotify mark that
> > > > reports events with file handles on tmpfs.
> > > >
> > > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > >
> > > Hugh, any opinion on this patch?
> > >
> > >                                                                 Honza
> > >
> > > > ---
> > > >  mm/shmem.c | 3 +++
> > > >  1 file changed, 3 insertions(+)
> > > >
> > > > diff --git a/mm/shmem.c b/mm/shmem.c
> > > > index b2db4ed0fbc7..162d8f8993bb 100644
> > > > --- a/mm/shmem.c
> > > > +++ b/mm/shmem.c
> > > > @@ -2846,6 +2846,9 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf)
> > > >               buf->f_ffree = sbinfo->free_inodes;
> > > >       }
> > > >       /* else leave those fields 0 like simple_statfs */
> > > > +
> > > > +     buf->f_fsid = uuid_to_fsid(dentry->d_sb->s_uuid.b);
> > > > +
> > > >       return 0;
> > > >  }
> > > >
> > 
> > 
> > Ping.
> > 
> > Hugh, are you ok with this change?
> > 
> > Thanks,
> > Amir.
> 
> Yes, apologies for my delay to you, Amir and Jan:
> sure I'm ok with this change, and thank you for taking care of tmpfs.
> 
> Acked-by: Hugh Dickins <hughd@google.com>

Thanks for the ack Hugh!

> But you have more valuable acks on this little series already,
> so don't bother rebasing some tree to add mine in now.  I don't yet
> see the uuid_to_fsid() 1/2 which this depends on in linux-next, and
> fear that's my fault for holding you back: sorry, please go ahead now.

Yeah, I was reluctant to push this patch without your ack and honestly I
forgot about the first patch while waiting for your ack. Anyway, both
patches are now in my tree and since Linus tagged rc8 and they are
nobrainers, I plan to push them to Linus for the next merge window.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-04-19  8:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22 17:39 [PATCH 0/2] Better fanotify support for tmpfs Amir Goldstein
2021-03-22 17:39 ` [PATCH 1/2] fs: introduce a wrapper uuid_to_fsid() Amir Goldstein
2021-03-23  5:19   ` Damien Le Moal
2021-03-23 14:09   ` Christian Brauner
2021-03-22 17:39 ` [PATCH 2/2] shmem: allow reporting fanotify events with file handles on tmpfs Amir Goldstein
2021-03-25 15:00   ` Jan Kara
2021-04-16  9:59     ` Amir Goldstein
2021-04-17  3:54       ` Hugh Dickins
2021-04-19  8:34         ` Jan Kara
2021-03-23 13:25 ` [PATCH 0/2] Better fanotify support for tmpfs Jan Kara
2021-03-23 14:13 ` Christian Brauner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.