linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/2] fuse: allow notify_inval for all inodes
@ 2025-02-16 16:50 Luis Henriques
  2025-02-16 16:50 ` [PATCH v5 1/2] vfs: export invalidate_inodes() Luis Henriques
  2025-02-16 16:50 ` [PATCH v5 2/2] fuse: add new function to invalidate cache for all inodes Luis Henriques
  0 siblings, 2 replies; 11+ messages in thread
From: Luis Henriques @ 2025-02-16 16:50 UTC (permalink / raw)
  To: Miklos Szeredi, Bernd Schubert
  Cc: Dave Chinner, Alexander Viro, Christian Brauner, Jan Kara,
	Matt Harvey, linux-fsdevel, linux-kernel, Luis Henriques

Hi!

In this version, invalidate_inodes() needs to be exported to be used by
fuse_reverse_inval_all().  This is a big simplification of this function,
which now simply calls shrink_dcache_sb() and invalidate_inodes().

It's clear that inodes still being referenced will not be invalidated --
but that's already the case for the single inode NOTIFY_INVAL_INODE fuse
operation.  

* Changes since v4
- Replaced superblock inodes iteration by a single call to
  invalidate_inodes().  Also do the shrink_dcache_sb() first. (Dave Chinner)

* Changes since v3
- Added comments to clarify semantic changes in fuse_reverse_inval_inode()
  when called with FUSE_INVAL_ALL_INODES (suggested by Bernd).
- Added comments to inodes iteration loop to clarify __iget/iput usage
  (suggested by Joanne)
- Dropped get_fuse_mount() call -- fuse_mount can be obtained from
  fuse_ilookup() directly (suggested by Joanne)

(Also dropped the RFC from the subject.)

* Changes since v2
- Use the new helper from fuse_reverse_inval_inode(), as suggested by Bernd.
- Also updated patch description as per checkpatch.pl suggestion.

* Changes since v1
As suggested by Bernd, this patch v2 simply adds an helper function that
will make it easier to replace most of it's code by a call to function
super_iter_inodes() when Dave Chinner's patch[1] eventually gets merged.

[1] https://lore.kernel.org/r/20241002014017.3801899-3-david@fromorbit.com


Luis Henriques (2):
  vfs: export invalidate_inodes()
  fuse: add new function to invalidate cache for all inodes

 fs/fuse/inode.c           | 33 +++++++++++++++++++++++++++++++++
 fs/inode.c                |  1 +
 fs/internal.h             |  1 -
 include/linux/fs.h        |  1 +
 include/uapi/linux/fuse.h |  3 +++
 5 files changed, 38 insertions(+), 1 deletion(-)


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

* [PATCH v5 1/2] vfs: export invalidate_inodes()
  2025-02-16 16:50 [PATCH v5 0/2] fuse: allow notify_inval for all inodes Luis Henriques
@ 2025-02-16 16:50 ` Luis Henriques
  2025-02-18 11:59   ` Jan Kara
  2025-02-16 16:50 ` [PATCH v5 2/2] fuse: add new function to invalidate cache for all inodes Luis Henriques
  1 sibling, 1 reply; 11+ messages in thread
From: Luis Henriques @ 2025-02-16 16:50 UTC (permalink / raw)
  To: Miklos Szeredi, Bernd Schubert
  Cc: Dave Chinner, Alexander Viro, Christian Brauner, Jan Kara,
	Matt Harvey, linux-fsdevel, linux-kernel, Luis Henriques

Signed-off-by: Luis Henriques <luis@igalia.com>
---
 fs/inode.c         | 1 +
 fs/internal.h      | 1 -
 include/linux/fs.h | 1 +
 3 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/inode.c b/fs/inode.c
index 5587aabdaa5e..88387ecb2c34 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -939,6 +939,7 @@ void invalidate_inodes(struct super_block *sb)
 
 	dispose_list(&dispose);
 }
+EXPORT_SYMBOL(invalidate_inodes);
 
 /*
  * Isolate the inode from the LRU in preparation for freeing it.
diff --git a/fs/internal.h b/fs/internal.h
index e7f02ae1e098..7cb515cede3f 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -207,7 +207,6 @@ bool in_group_or_capable(struct mnt_idmap *idmap,
  * fs-writeback.c
  */
 extern long get_nr_dirty_inodes(void);
-void invalidate_inodes(struct super_block *sb);
 
 /*
  * dcache.c
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2c3b2f8a621f..ff016885646e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3270,6 +3270,7 @@ extern void discard_new_inode(struct inode *);
 extern unsigned int get_next_ino(void);
 extern void evict_inodes(struct super_block *sb);
 void dump_mapping(const struct address_space *);
+extern void invalidate_inodes(struct super_block *sb);
 
 /*
  * Userspace may rely on the inode number being non-zero. For example, glibc

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

* [PATCH v5 2/2] fuse: add new function to invalidate cache for all inodes
  2025-02-16 16:50 [PATCH v5 0/2] fuse: allow notify_inval for all inodes Luis Henriques
  2025-02-16 16:50 ` [PATCH v5 1/2] vfs: export invalidate_inodes() Luis Henriques
@ 2025-02-16 16:50 ` Luis Henriques
  2025-02-17  0:40   ` Bernd Schubert
  1 sibling, 1 reply; 11+ messages in thread
From: Luis Henriques @ 2025-02-16 16:50 UTC (permalink / raw)
  To: Miklos Szeredi, Bernd Schubert
  Cc: Dave Chinner, Alexander Viro, Christian Brauner, Jan Kara,
	Matt Harvey, linux-fsdevel, linux-kernel, Luis Henriques

Currently userspace is able to notify the kernel to invalidate the cache
for an inode.  This means that, if all the inodes in a filesystem need to
be invalidated, then userspace needs to iterate through all of them and do
this kernel notification separately.

This patch adds a new option that allows userspace to invalidate all the
inodes with a single notification operation.  In addition to invalidate
all the inodes, it also shrinks the sb dcache.

Signed-off-by: Luis Henriques <luis@igalia.com>
---
 fs/fuse/inode.c           | 33 +++++++++++++++++++++++++++++++++
 include/uapi/linux/fuse.h |  3 +++
 2 files changed, 36 insertions(+)

diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index e9db2cb8c150..01a4dc5677ae 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -547,6 +547,36 @@ struct inode *fuse_ilookup(struct fuse_conn *fc, u64 nodeid,
 	return NULL;
 }
 
+static int fuse_reverse_inval_all(struct fuse_conn *fc)
+{
+	struct fuse_mount *fm;
+	struct inode *inode;
+
+	inode = fuse_ilookup(fc, FUSE_ROOT_ID, &fm);
+	if (!inode || !fm)
+		return -ENOENT;
+
+	/* Remove all possible active references to cached inodes */
+	shrink_dcache_sb(fm->sb);
+
+	/* Remove all unreferenced inodes from cache */
+	invalidate_inodes(fm->sb);
+
+	return 0;
+}
+
+/*
+ * Notify to invalidate inodes cache.  It can be called with @nodeid set to
+ * either:
+ *
+ * - An inode number - Any pending writebacks within the rage [@offset @len]
+ *   will be triggered and the inode will be validated.  To invalidate the whole
+ *   cache @offset has to be set to '0' and @len needs to be <= '0'; if @offset
+ *   is negative, only the inode attributes are invalidated.
+ *
+ * - FUSE_INVAL_ALL_INODES - All the inodes in the superblock are invalidated
+ *   and the whole dcache is shrinked.
+ */
 int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
 			     loff_t offset, loff_t len)
 {
@@ -555,6 +585,9 @@ int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
 	pgoff_t pg_start;
 	pgoff_t pg_end;
 
+	if (nodeid == FUSE_INVAL_ALL_INODES)
+		return fuse_reverse_inval_all(fc);
+
 	inode = fuse_ilookup(fc, nodeid, NULL);
 	if (!inode)
 		return -ENOENT;
diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
index 5e0eb41d967e..e5852b63f99f 100644
--- a/include/uapi/linux/fuse.h
+++ b/include/uapi/linux/fuse.h
@@ -669,6 +669,9 @@ enum fuse_notify_code {
 	FUSE_NOTIFY_CODE_MAX,
 };
 
+/* The nodeid to request to invalidate all inodes */
+#define FUSE_INVAL_ALL_INODES 0
+
 /* The read buffer is required to be at least 8k, but may be much larger */
 #define FUSE_MIN_READ_BUFFER 8192
 

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

* Re: [PATCH v5 2/2] fuse: add new function to invalidate cache for all inodes
  2025-02-16 16:50 ` [PATCH v5 2/2] fuse: add new function to invalidate cache for all inodes Luis Henriques
@ 2025-02-17  0:40   ` Bernd Schubert
  2025-02-17 10:07     ` Luis Henriques
  0 siblings, 1 reply; 11+ messages in thread
From: Bernd Schubert @ 2025-02-17  0:40 UTC (permalink / raw)
  To: Luis Henriques, Miklos Szeredi
  Cc: Dave Chinner, Alexander Viro, Christian Brauner, Jan Kara,
	Matt Harvey, linux-fsdevel, linux-kernel



On 2/16/25 17:50, Luis Henriques wrote:
> Currently userspace is able to notify the kernel to invalidate the cache
> for an inode.  This means that, if all the inodes in a filesystem need to
> be invalidated, then userspace needs to iterate through all of them and do
> this kernel notification separately.
> 
> This patch adds a new option that allows userspace to invalidate all the
> inodes with a single notification operation.  In addition to invalidate
> all the inodes, it also shrinks the sb dcache.
> 
> Signed-off-by: Luis Henriques <luis@igalia.com>
> ---
>  fs/fuse/inode.c           | 33 +++++++++++++++++++++++++++++++++
>  include/uapi/linux/fuse.h |  3 +++
>  2 files changed, 36 insertions(+)
> 
> diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
> index e9db2cb8c150..01a4dc5677ae 100644
> --- a/fs/fuse/inode.c
> +++ b/fs/fuse/inode.c
> @@ -547,6 +547,36 @@ struct inode *fuse_ilookup(struct fuse_conn *fc, u64 nodeid,
>  	return NULL;
>  }
>  
> +static int fuse_reverse_inval_all(struct fuse_conn *fc)
> +{
> +	struct fuse_mount *fm;
> +	struct inode *inode;
> +
> +	inode = fuse_ilookup(fc, FUSE_ROOT_ID, &fm);
> +	if (!inode || !fm)
> +		return -ENOENT;
> +
> +	/* Remove all possible active references to cached inodes */
> +	shrink_dcache_sb(fm->sb);
> +
> +	/* Remove all unreferenced inodes from cache */
> +	invalidate_inodes(fm->sb);
> +
> +	return 0;
> +}
> +
> +/*
> + * Notify to invalidate inodes cache.  It can be called with @nodeid set to
> + * either:
> + *
> + * - An inode number - Any pending writebacks within the rage [@offset @len]
> + *   will be triggered and the inode will be validated.  To invalidate the whole
> + *   cache @offset has to be set to '0' and @len needs to be <= '0'; if @offset
> + *   is negative, only the inode attributes are invalidated.
> + *
> + * - FUSE_INVAL_ALL_INODES - All the inodes in the superblock are invalidated
> + *   and the whole dcache is shrinked.
> + */
>  int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
>  			     loff_t offset, loff_t len)
>  {
> @@ -555,6 +585,9 @@ int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
>  	pgoff_t pg_start;
>  	pgoff_t pg_end;
>  
> +	if (nodeid == FUSE_INVAL_ALL_INODES)
> +		return fuse_reverse_inval_all(fc);
> +
>  	inode = fuse_ilookup(fc, nodeid, NULL);
>  	if (!inode)
>  		return -ENOENT;
> diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
> index 5e0eb41d967e..e5852b63f99f 100644
> --- a/include/uapi/linux/fuse.h
> +++ b/include/uapi/linux/fuse.h
> @@ -669,6 +669,9 @@ enum fuse_notify_code {
>  	FUSE_NOTIFY_CODE_MAX,
>  };
>  
> +/* The nodeid to request to invalidate all inodes */
> +#define FUSE_INVAL_ALL_INODES 0
> +
>  /* The read buffer is required to be at least 8k, but may be much larger */
>  #define FUSE_MIN_READ_BUFFER 8192
>  


I think this version might end up in 

static void fuse_evict_inode(struct inode *inode)
{
	struct fuse_inode *fi = get_fuse_inode(inode);

	/* Will write inode on close/munmap and in all other dirtiers */
	WARN_ON(inode->i_state & I_DIRTY_INODE);


if the fuse connection has writeback cache enabled.


Without having it tested, reproducer would probably be to run
something like passthrough_hp (without --direct-io), opening
and writing to a file and then sending FUSE_INVAL_ALL_INODES.



Thanks,
Bernd


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

* Re: [PATCH v5 2/2] fuse: add new function to invalidate cache for all inodes
  2025-02-17  0:40   ` Bernd Schubert
@ 2025-02-17 10:07     ` Luis Henriques
  2025-02-17 10:29       ` Bernd Schubert
  0 siblings, 1 reply; 11+ messages in thread
From: Luis Henriques @ 2025-02-17 10:07 UTC (permalink / raw)
  To: Bernd Schubert
  Cc: Miklos Szeredi, Dave Chinner, Alexander Viro, Christian Brauner,
	Jan Kara, Matt Harvey, linux-fsdevel, linux-kernel

On Mon, Feb 17 2025, Bernd Schubert wrote:

> On 2/16/25 17:50, Luis Henriques wrote:
>> Currently userspace is able to notify the kernel to invalidate the cache
>> for an inode.  This means that, if all the inodes in a filesystem need to
>> be invalidated, then userspace needs to iterate through all of them and do
>> this kernel notification separately.
>> 
>> This patch adds a new option that allows userspace to invalidate all the
>> inodes with a single notification operation.  In addition to invalidate
>> all the inodes, it also shrinks the sb dcache.
>> 
>> Signed-off-by: Luis Henriques <luis@igalia.com>
>> ---
>>  fs/fuse/inode.c           | 33 +++++++++++++++++++++++++++++++++
>>  include/uapi/linux/fuse.h |  3 +++
>>  2 files changed, 36 insertions(+)
>> 
>> diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
>> index e9db2cb8c150..01a4dc5677ae 100644
>> --- a/fs/fuse/inode.c
>> +++ b/fs/fuse/inode.c
>> @@ -547,6 +547,36 @@ struct inode *fuse_ilookup(struct fuse_conn *fc, u64 nodeid,
>>  	return NULL;
>>  }
>>  
>> +static int fuse_reverse_inval_all(struct fuse_conn *fc)
>> +{
>> +	struct fuse_mount *fm;
>> +	struct inode *inode;
>> +
>> +	inode = fuse_ilookup(fc, FUSE_ROOT_ID, &fm);
>> +	if (!inode || !fm)
>> +		return -ENOENT;
>> +
>> +	/* Remove all possible active references to cached inodes */
>> +	shrink_dcache_sb(fm->sb);
>> +
>> +	/* Remove all unreferenced inodes from cache */
>> +	invalidate_inodes(fm->sb);
>> +
>> +	return 0;
>> +}
>> +
>> +/*
>> + * Notify to invalidate inodes cache.  It can be called with @nodeid set to
>> + * either:
>> + *
>> + * - An inode number - Any pending writebacks within the rage [@offset @len]
>> + *   will be triggered and the inode will be validated.  To invalidate the whole
>> + *   cache @offset has to be set to '0' and @len needs to be <= '0'; if @offset
>> + *   is negative, only the inode attributes are invalidated.
>> + *
>> + * - FUSE_INVAL_ALL_INODES - All the inodes in the superblock are invalidated
>> + *   and the whole dcache is shrinked.
>> + */
>>  int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
>>  			     loff_t offset, loff_t len)
>>  {
>> @@ -555,6 +585,9 @@ int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
>>  	pgoff_t pg_start;
>>  	pgoff_t pg_end;
>>  
>> +	if (nodeid == FUSE_INVAL_ALL_INODES)
>> +		return fuse_reverse_inval_all(fc);
>> +
>>  	inode = fuse_ilookup(fc, nodeid, NULL);
>>  	if (!inode)
>>  		return -ENOENT;
>> diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
>> index 5e0eb41d967e..e5852b63f99f 100644
>> --- a/include/uapi/linux/fuse.h
>> +++ b/include/uapi/linux/fuse.h
>> @@ -669,6 +669,9 @@ enum fuse_notify_code {
>>  	FUSE_NOTIFY_CODE_MAX,
>>  };
>>  
>> +/* The nodeid to request to invalidate all inodes */
>> +#define FUSE_INVAL_ALL_INODES 0
>> +
>>  /* The read buffer is required to be at least 8k, but may be much larger */
>>  #define FUSE_MIN_READ_BUFFER 8192
>>  
>
>
> I think this version might end up in 
>
> static void fuse_evict_inode(struct inode *inode)
> {
> 	struct fuse_inode *fi = get_fuse_inode(inode);
>
> 	/* Will write inode on close/munmap and in all other dirtiers */
> 	WARN_ON(inode->i_state & I_DIRTY_INODE);
>
>
> if the fuse connection has writeback cache enabled.
>
>
> Without having it tested, reproducer would probably be to run
> something like passthrough_hp (without --direct-io), opening
> and writing to a file and then sending FUSE_INVAL_ALL_INODES.

Thanks, Bernd.  So far I couldn't trigger this warning.  But I just found
that there's a stupid bug in the code: a missing iput() after doing the
fuse_ilookup().

I'll spend some more time trying to understand how (or if) the warning you
mentioned can triggered before sending a new revision.

Cheers,
-- 
Luís

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

* Re: [PATCH v5 2/2] fuse: add new function to invalidate cache for all inodes
  2025-02-17 10:07     ` Luis Henriques
@ 2025-02-17 10:29       ` Bernd Schubert
  2025-02-17 11:47         ` Luis Henriques
  0 siblings, 1 reply; 11+ messages in thread
From: Bernd Schubert @ 2025-02-17 10:29 UTC (permalink / raw)
  To: Luis Henriques
  Cc: Miklos Szeredi, Dave Chinner, Alexander Viro, Christian Brauner,
	Jan Kara, Matt Harvey, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org

On 2/17/25 11:07, Luis Henriques wrote:
> On Mon, Feb 17 2025, Bernd Schubert wrote:
> 
>> On 2/16/25 17:50, Luis Henriques wrote:
>>> Currently userspace is able to notify the kernel to invalidate the cache
>>> for an inode.  This means that, if all the inodes in a filesystem need to
>>> be invalidated, then userspace needs to iterate through all of them and do
>>> this kernel notification separately.
>>>
>>> This patch adds a new option that allows userspace to invalidate all the
>>> inodes with a single notification operation.  In addition to invalidate
>>> all the inodes, it also shrinks the sb dcache.
>>>
>>> Signed-off-by: Luis Henriques <luis@igalia.com>
>>> ---
>>>  fs/fuse/inode.c           | 33 +++++++++++++++++++++++++++++++++
>>>  include/uapi/linux/fuse.h |  3 +++
>>>  2 files changed, 36 insertions(+)
>>>
>>> diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
>>> index e9db2cb8c150..01a4dc5677ae 100644
>>> --- a/fs/fuse/inode.c
>>> +++ b/fs/fuse/inode.c
>>> @@ -547,6 +547,36 @@ struct inode *fuse_ilookup(struct fuse_conn *fc, u64 nodeid,
>>>  	return NULL;
>>>  }
>>>  
>>> +static int fuse_reverse_inval_all(struct fuse_conn *fc)
>>> +{
>>> +	struct fuse_mount *fm;
>>> +	struct inode *inode;
>>> +
>>> +	inode = fuse_ilookup(fc, FUSE_ROOT_ID, &fm);
>>> +	if (!inode || !fm)
>>> +		return -ENOENT;
>>> +
>>> +	/* Remove all possible active references to cached inodes */
>>> +	shrink_dcache_sb(fm->sb);
>>> +
>>> +	/* Remove all unreferenced inodes from cache */
>>> +	invalidate_inodes(fm->sb);
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +/*
>>> + * Notify to invalidate inodes cache.  It can be called with @nodeid set to
>>> + * either:
>>> + *
>>> + * - An inode number - Any pending writebacks within the rage [@offset @len]
>>> + *   will be triggered and the inode will be validated.  To invalidate the whole
>>> + *   cache @offset has to be set to '0' and @len needs to be <= '0'; if @offset
>>> + *   is negative, only the inode attributes are invalidated.
>>> + *
>>> + * - FUSE_INVAL_ALL_INODES - All the inodes in the superblock are invalidated
>>> + *   and the whole dcache is shrinked.
>>> + */
>>>  int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
>>>  			     loff_t offset, loff_t len)
>>>  {
>>> @@ -555,6 +585,9 @@ int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
>>>  	pgoff_t pg_start;
>>>  	pgoff_t pg_end;
>>>  
>>> +	if (nodeid == FUSE_INVAL_ALL_INODES)
>>> +		return fuse_reverse_inval_all(fc);
>>> +
>>>  	inode = fuse_ilookup(fc, nodeid, NULL);
>>>  	if (!inode)
>>>  		return -ENOENT;
>>> diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
>>> index 5e0eb41d967e..e5852b63f99f 100644
>>> --- a/include/uapi/linux/fuse.h
>>> +++ b/include/uapi/linux/fuse.h
>>> @@ -669,6 +669,9 @@ enum fuse_notify_code {
>>>  	FUSE_NOTIFY_CODE_MAX,
>>>  };
>>>  
>>> +/* The nodeid to request to invalidate all inodes */
>>> +#define FUSE_INVAL_ALL_INODES 0
>>> +
>>>  /* The read buffer is required to be at least 8k, but may be much larger */
>>>  #define FUSE_MIN_READ_BUFFER 8192
>>>  
>>
>>
>> I think this version might end up in 
>>
>> static void fuse_evict_inode(struct inode *inode)
>> {
>> 	struct fuse_inode *fi = get_fuse_inode(inode);
>>
>> 	/* Will write inode on close/munmap and in all other dirtiers */
>> 	WARN_ON(inode->i_state & I_DIRTY_INODE);
>>
>>
>> if the fuse connection has writeback cache enabled.
>>
>>
>> Without having it tested, reproducer would probably be to run
>> something like passthrough_hp (without --direct-io), opening
>> and writing to a file and then sending FUSE_INVAL_ALL_INODES.
> 
> Thanks, Bernd.  So far I couldn't trigger this warning.  But I just found
> that there's a stupid bug in the code: a missing iput() after doing the
> fuse_ilookup().
> 
> I'll spend some more time trying to understand how (or if) the warning you
> mentioned can triggered before sending a new revision.
> 

Maybe I'm wrong, but it calls 

   invalidate_inodes()
      dispose_list()
        evict(inode)
           fuse_evict_inode()

and if at the same time something writes to inode page cache, the
warning would be triggered? 
There are some conditions in evict, like inode_wait_for_writeback()
that might protect us, but what is if it waited and then just
in the right time the another write comes and dirties the inode
again?


Thanks,
Bernd
 

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

* Re: [PATCH v5 2/2] fuse: add new function to invalidate cache for all inodes
  2025-02-17 10:29       ` Bernd Schubert
@ 2025-02-17 11:47         ` Luis Henriques
  2025-02-18 11:57           ` Jan Kara
  0 siblings, 1 reply; 11+ messages in thread
From: Luis Henriques @ 2025-02-17 11:47 UTC (permalink / raw)
  To: Bernd Schubert
  Cc: Miklos Szeredi, Dave Chinner, Alexander Viro, Christian Brauner,
	Jan Kara, Matt Harvey, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Mon, Feb 17 2025, Bernd Schubert wrote:

> On 2/17/25 11:07, Luis Henriques wrote:
>> On Mon, Feb 17 2025, Bernd Schubert wrote:
>> 
>>> On 2/16/25 17:50, Luis Henriques wrote:
>>>> Currently userspace is able to notify the kernel to invalidate the cache
>>>> for an inode.  This means that, if all the inodes in a filesystem need to
>>>> be invalidated, then userspace needs to iterate through all of them and do
>>>> this kernel notification separately.
>>>>
>>>> This patch adds a new option that allows userspace to invalidate all the
>>>> inodes with a single notification operation.  In addition to invalidate
>>>> all the inodes, it also shrinks the sb dcache.
>>>>
>>>> Signed-off-by: Luis Henriques <luis@igalia.com>
>>>> ---
>>>>  fs/fuse/inode.c           | 33 +++++++++++++++++++++++++++++++++
>>>>  include/uapi/linux/fuse.h |  3 +++
>>>>  2 files changed, 36 insertions(+)
>>>>
>>>> diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
>>>> index e9db2cb8c150..01a4dc5677ae 100644
>>>> --- a/fs/fuse/inode.c
>>>> +++ b/fs/fuse/inode.c
>>>> @@ -547,6 +547,36 @@ struct inode *fuse_ilookup(struct fuse_conn *fc, u64 nodeid,
>>>>  	return NULL;
>>>>  }
>>>>  
>>>> +static int fuse_reverse_inval_all(struct fuse_conn *fc)
>>>> +{
>>>> +	struct fuse_mount *fm;
>>>> +	struct inode *inode;
>>>> +
>>>> +	inode = fuse_ilookup(fc, FUSE_ROOT_ID, &fm);
>>>> +	if (!inode || !fm)
>>>> +		return -ENOENT;
>>>> +
>>>> +	/* Remove all possible active references to cached inodes */
>>>> +	shrink_dcache_sb(fm->sb);
>>>> +
>>>> +	/* Remove all unreferenced inodes from cache */
>>>> +	invalidate_inodes(fm->sb);
>>>> +
>>>> +	return 0;
>>>> +}
>>>> +
>>>> +/*
>>>> + * Notify to invalidate inodes cache.  It can be called with @nodeid set to
>>>> + * either:
>>>> + *
>>>> + * - An inode number - Any pending writebacks within the rage [@offset @len]
>>>> + *   will be triggered and the inode will be validated.  To invalidate the whole
>>>> + *   cache @offset has to be set to '0' and @len needs to be <= '0'; if @offset
>>>> + *   is negative, only the inode attributes are invalidated.
>>>> + *
>>>> + * - FUSE_INVAL_ALL_INODES - All the inodes in the superblock are invalidated
>>>> + *   and the whole dcache is shrinked.
>>>> + */
>>>>  int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
>>>>  			     loff_t offset, loff_t len)
>>>>  {
>>>> @@ -555,6 +585,9 @@ int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
>>>>  	pgoff_t pg_start;
>>>>  	pgoff_t pg_end;
>>>>  
>>>> +	if (nodeid == FUSE_INVAL_ALL_INODES)
>>>> +		return fuse_reverse_inval_all(fc);
>>>> +
>>>>  	inode = fuse_ilookup(fc, nodeid, NULL);
>>>>  	if (!inode)
>>>>  		return -ENOENT;
>>>> diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
>>>> index 5e0eb41d967e..e5852b63f99f 100644
>>>> --- a/include/uapi/linux/fuse.h
>>>> +++ b/include/uapi/linux/fuse.h
>>>> @@ -669,6 +669,9 @@ enum fuse_notify_code {
>>>>  	FUSE_NOTIFY_CODE_MAX,
>>>>  };
>>>>  
>>>> +/* The nodeid to request to invalidate all inodes */
>>>> +#define FUSE_INVAL_ALL_INODES 0
>>>> +
>>>>  /* The read buffer is required to be at least 8k, but may be much larger */
>>>>  #define FUSE_MIN_READ_BUFFER 8192
>>>>  
>>>
>>>
>>> I think this version might end up in 
>>>
>>> static void fuse_evict_inode(struct inode *inode)
>>> {
>>> 	struct fuse_inode *fi = get_fuse_inode(inode);
>>>
>>> 	/* Will write inode on close/munmap and in all other dirtiers */
>>> 	WARN_ON(inode->i_state & I_DIRTY_INODE);
>>>
>>>
>>> if the fuse connection has writeback cache enabled.
>>>
>>>
>>> Without having it tested, reproducer would probably be to run
>>> something like passthrough_hp (without --direct-io), opening
>>> and writing to a file and then sending FUSE_INVAL_ALL_INODES.
>> 
>> Thanks, Bernd.  So far I couldn't trigger this warning.  But I just found
>> that there's a stupid bug in the code: a missing iput() after doing the
>> fuse_ilookup().
>> 
>> I'll spend some more time trying to understand how (or if) the warning you
>> mentioned can triggered before sending a new revision.
>> 
>
> Maybe I'm wrong, but it calls 
>
>    invalidate_inodes()
>       dispose_list()
>         evict(inode)
>            fuse_evict_inode()
>
> and if at the same time something writes to inode page cache, the
> warning would be triggered? 
> There are some conditions in evict, like inode_wait_for_writeback()
> that might protect us, but what is if it waited and then just
> in the right time the another write comes and dirties the inode
> again?

Right, I have looked into that too but my understanding is that this can
not happen because, before doing that wait, the code does:

	inode_sb_list_del(inode);

and the inode state will include I_FREEING.

Thus, before writing to it again, the inode will need to get added back to
the sb list.  Also, reading the comments on evict(), if something writes
into the inode at that point that's likely a bug.  But this is just my
understanding, and I may be missing something.

Cheers,
-- 
Luís

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

* Re: [PATCH v5 2/2] fuse: add new function to invalidate cache for all inodes
  2025-02-17 11:47         ` Luis Henriques
@ 2025-02-18 11:57           ` Jan Kara
  2025-02-18 13:28             ` Luis Henriques
  0 siblings, 1 reply; 11+ messages in thread
From: Jan Kara @ 2025-02-18 11:57 UTC (permalink / raw)
  To: Luis Henriques
  Cc: Bernd Schubert, Miklos Szeredi, Dave Chinner, Alexander Viro,
	Christian Brauner, Jan Kara, Matt Harvey,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org

On Mon 17-02-25 11:47:09, Luis Henriques wrote:
> On Mon, Feb 17 2025, Bernd Schubert wrote:
> > On 2/17/25 11:07, Luis Henriques wrote:
> >> On Mon, Feb 17 2025, Bernd Schubert wrote:
> >> 
> >>> On 2/16/25 17:50, Luis Henriques wrote:
> >>>> Currently userspace is able to notify the kernel to invalidate the cache
> >>>> for an inode.  This means that, if all the inodes in a filesystem need to
> >>>> be invalidated, then userspace needs to iterate through all of them and do
> >>>> this kernel notification separately.
> >>>>
> >>>> This patch adds a new option that allows userspace to invalidate all the
> >>>> inodes with a single notification operation.  In addition to invalidate
> >>>> all the inodes, it also shrinks the sb dcache.
> >>>>
> >>>> Signed-off-by: Luis Henriques <luis@igalia.com>
> >>>> ---
> >>>>  fs/fuse/inode.c           | 33 +++++++++++++++++++++++++++++++++
> >>>>  include/uapi/linux/fuse.h |  3 +++
> >>>>  2 files changed, 36 insertions(+)
> >>>>
> >>>> diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
> >>>> index e9db2cb8c150..01a4dc5677ae 100644
> >>>> --- a/fs/fuse/inode.c
> >>>> +++ b/fs/fuse/inode.c
> >>>> @@ -547,6 +547,36 @@ struct inode *fuse_ilookup(struct fuse_conn *fc, u64 nodeid,
> >>>>  	return NULL;
> >>>>  }
> >>>>  
> >>>> +static int fuse_reverse_inval_all(struct fuse_conn *fc)
> >>>> +{
> >>>> +	struct fuse_mount *fm;
> >>>> +	struct inode *inode;
> >>>> +
> >>>> +	inode = fuse_ilookup(fc, FUSE_ROOT_ID, &fm);
> >>>> +	if (!inode || !fm)
> >>>> +		return -ENOENT;
> >>>> +
> >>>> +	/* Remove all possible active references to cached inodes */
> >>>> +	shrink_dcache_sb(fm->sb);
> >>>> +
> >>>> +	/* Remove all unreferenced inodes from cache */
> >>>> +	invalidate_inodes(fm->sb);
> >>>> +
> >>>> +	return 0;
> >>>> +}
> >>>> +
> >>>> +/*
> >>>> + * Notify to invalidate inodes cache.  It can be called with @nodeid set to
> >>>> + * either:
> >>>> + *
> >>>> + * - An inode number - Any pending writebacks within the rage [@offset @len]
> >>>> + *   will be triggered and the inode will be validated.  To invalidate the whole
> >>>> + *   cache @offset has to be set to '0' and @len needs to be <= '0'; if @offset
> >>>> + *   is negative, only the inode attributes are invalidated.
> >>>> + *
> >>>> + * - FUSE_INVAL_ALL_INODES - All the inodes in the superblock are invalidated
> >>>> + *   and the whole dcache is shrinked.
> >>>> + */
> >>>>  int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
> >>>>  			     loff_t offset, loff_t len)
> >>>>  {
> >>>> @@ -555,6 +585,9 @@ int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
> >>>>  	pgoff_t pg_start;
> >>>>  	pgoff_t pg_end;
> >>>>  
> >>>> +	if (nodeid == FUSE_INVAL_ALL_INODES)
> >>>> +		return fuse_reverse_inval_all(fc);
> >>>> +
> >>>>  	inode = fuse_ilookup(fc, nodeid, NULL);
> >>>>  	if (!inode)
> >>>>  		return -ENOENT;
> >>>> diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
> >>>> index 5e0eb41d967e..e5852b63f99f 100644
> >>>> --- a/include/uapi/linux/fuse.h
> >>>> +++ b/include/uapi/linux/fuse.h
> >>>> @@ -669,6 +669,9 @@ enum fuse_notify_code {
> >>>>  	FUSE_NOTIFY_CODE_MAX,
> >>>>  };
> >>>>  
> >>>> +/* The nodeid to request to invalidate all inodes */
> >>>> +#define FUSE_INVAL_ALL_INODES 0
> >>>> +
> >>>>  /* The read buffer is required to be at least 8k, but may be much larger */
> >>>>  #define FUSE_MIN_READ_BUFFER 8192
> >>>>  
> >>>
> >>>
> >>> I think this version might end up in 
> >>>
> >>> static void fuse_evict_inode(struct inode *inode)
> >>> {
> >>> 	struct fuse_inode *fi = get_fuse_inode(inode);
> >>>
> >>> 	/* Will write inode on close/munmap and in all other dirtiers */
> >>> 	WARN_ON(inode->i_state & I_DIRTY_INODE);
> >>>
> >>>
> >>> if the fuse connection has writeback cache enabled.
> >>>
> >>>
> >>> Without having it tested, reproducer would probably be to run
> >>> something like passthrough_hp (without --direct-io), opening
> >>> and writing to a file and then sending FUSE_INVAL_ALL_INODES.
> >> 
> >> Thanks, Bernd.  So far I couldn't trigger this warning.  But I just found
> >> that there's a stupid bug in the code: a missing iput() after doing the
> >> fuse_ilookup().
> >> 
> >> I'll spend some more time trying to understand how (or if) the warning you
> >> mentioned can triggered before sending a new revision.
> >> 
> >
> > Maybe I'm wrong, but it calls 
> >
> >    invalidate_inodes()
> >       dispose_list()
> >         evict(inode)
> >            fuse_evict_inode()
> >
> > and if at the same time something writes to inode page cache, the
> > warning would be triggered? 
> > There are some conditions in evict, like inode_wait_for_writeback()
> > that might protect us, but what is if it waited and then just
> > in the right time the another write comes and dirties the inode
> > again?
> 
> Right, I have looked into that too but my understanding is that this can
> not happen because, before doing that wait, the code does:
> 
> 	inode_sb_list_del(inode);
> 
> and the inode state will include I_FREEING.
> 
> Thus, before writing to it again, the inode will need to get added back to
> the sb list.  Also, reading the comments on evict(), if something writes
> into the inode at that point that's likely a bug.  But this is just my
> understanding, and I may be missing something.

Yes. invalidate_inodes() checks i_count == 0 and sets I_FREEING. Once
I_FREEING is set nobody can acquire inode reference until the inode is
fully destroyed. So nobody should be writing to the inode or anything like
that.

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

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

* Re: [PATCH v5 1/2] vfs: export invalidate_inodes()
  2025-02-16 16:50 ` [PATCH v5 1/2] vfs: export invalidate_inodes() Luis Henriques
@ 2025-02-18 11:59   ` Jan Kara
  2025-02-18 13:35     ` Luis Henriques
  0 siblings, 1 reply; 11+ messages in thread
From: Jan Kara @ 2025-02-18 11:59 UTC (permalink / raw)
  To: Luis Henriques
  Cc: Miklos Szeredi, Bernd Schubert, Dave Chinner, Alexander Viro,
	Christian Brauner, Jan Kara, Matt Harvey, linux-fsdevel,
	linux-kernel

On Sun 16-02-25 16:50:07, Luis Henriques wrote:
> Signed-off-by: Luis Henriques <luis@igalia.com>

Please use evict_inodes(). It is already exported and does exactly the same
these days. We should really merge the patch deleting invalidate_inodes()
:)

									Honza

> ---
>  fs/inode.c         | 1 +
>  fs/internal.h      | 1 -
>  include/linux/fs.h | 1 +
>  3 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/inode.c b/fs/inode.c
> index 5587aabdaa5e..88387ecb2c34 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -939,6 +939,7 @@ void invalidate_inodes(struct super_block *sb)
>  
>  	dispose_list(&dispose);
>  }
> +EXPORT_SYMBOL(invalidate_inodes);
>  
>  /*
>   * Isolate the inode from the LRU in preparation for freeing it.
> diff --git a/fs/internal.h b/fs/internal.h
> index e7f02ae1e098..7cb515cede3f 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -207,7 +207,6 @@ bool in_group_or_capable(struct mnt_idmap *idmap,
>   * fs-writeback.c
>   */
>  extern long get_nr_dirty_inodes(void);
> -void invalidate_inodes(struct super_block *sb);
>  
>  /*
>   * dcache.c
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 2c3b2f8a621f..ff016885646e 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -3270,6 +3270,7 @@ extern void discard_new_inode(struct inode *);
>  extern unsigned int get_next_ino(void);
>  extern void evict_inodes(struct super_block *sb);
>  void dump_mapping(const struct address_space *);
> +extern void invalidate_inodes(struct super_block *sb);
>  
>  /*
>   * Userspace may rely on the inode number being non-zero. For example, glibc
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v5 2/2] fuse: add new function to invalidate cache for all inodes
  2025-02-18 11:57           ` Jan Kara
@ 2025-02-18 13:28             ` Luis Henriques
  0 siblings, 0 replies; 11+ messages in thread
From: Luis Henriques @ 2025-02-18 13:28 UTC (permalink / raw)
  To: Jan Kara
  Cc: Bernd Schubert, Miklos Szeredi, Dave Chinner, Alexander Viro,
	Christian Brauner, Matt Harvey, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Tue, Feb 18 2025, Jan Kara wrote:

> On Mon 17-02-25 11:47:09, Luis Henriques wrote:
>> On Mon, Feb 17 2025, Bernd Schubert wrote:
>> > On 2/17/25 11:07, Luis Henriques wrote:
>> >> On Mon, Feb 17 2025, Bernd Schubert wrote:
>> >> 
>> >>> On 2/16/25 17:50, Luis Henriques wrote:
>> >>>> Currently userspace is able to notify the kernel to invalidate the cache
>> >>>> for an inode.  This means that, if all the inodes in a filesystem need to
>> >>>> be invalidated, then userspace needs to iterate through all of them and do
>> >>>> this kernel notification separately.
>> >>>>
>> >>>> This patch adds a new option that allows userspace to invalidate all the
>> >>>> inodes with a single notification operation.  In addition to invalidate
>> >>>> all the inodes, it also shrinks the sb dcache.
>> >>>>
>> >>>> Signed-off-by: Luis Henriques <luis@igalia.com>
>> >>>> ---
>> >>>>  fs/fuse/inode.c           | 33 +++++++++++++++++++++++++++++++++
>> >>>>  include/uapi/linux/fuse.h |  3 +++
>> >>>>  2 files changed, 36 insertions(+)
>> >>>>
>> >>>> diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
>> >>>> index e9db2cb8c150..01a4dc5677ae 100644
>> >>>> --- a/fs/fuse/inode.c
>> >>>> +++ b/fs/fuse/inode.c
>> >>>> @@ -547,6 +547,36 @@ struct inode *fuse_ilookup(struct fuse_conn *fc, u64 nodeid,
>> >>>>  	return NULL;
>> >>>>  }
>> >>>>  
>> >>>> +static int fuse_reverse_inval_all(struct fuse_conn *fc)
>> >>>> +{
>> >>>> +	struct fuse_mount *fm;
>> >>>> +	struct inode *inode;
>> >>>> +
>> >>>> +	inode = fuse_ilookup(fc, FUSE_ROOT_ID, &fm);
>> >>>> +	if (!inode || !fm)
>> >>>> +		return -ENOENT;
>> >>>> +
>> >>>> +	/* Remove all possible active references to cached inodes */
>> >>>> +	shrink_dcache_sb(fm->sb);
>> >>>> +
>> >>>> +	/* Remove all unreferenced inodes from cache */
>> >>>> +	invalidate_inodes(fm->sb);
>> >>>> +
>> >>>> +	return 0;
>> >>>> +}
>> >>>> +
>> >>>> +/*
>> >>>> + * Notify to invalidate inodes cache.  It can be called with @nodeid set to
>> >>>> + * either:
>> >>>> + *
>> >>>> + * - An inode number - Any pending writebacks within the rage [@offset @len]
>> >>>> + *   will be triggered and the inode will be validated.  To invalidate the whole
>> >>>> + *   cache @offset has to be set to '0' and @len needs to be <= '0'; if @offset
>> >>>> + *   is negative, only the inode attributes are invalidated.
>> >>>> + *
>> >>>> + * - FUSE_INVAL_ALL_INODES - All the inodes in the superblock are invalidated
>> >>>> + *   and the whole dcache is shrinked.
>> >>>> + */
>> >>>>  int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
>> >>>>  			     loff_t offset, loff_t len)
>> >>>>  {
>> >>>> @@ -555,6 +585,9 @@ int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
>> >>>>  	pgoff_t pg_start;
>> >>>>  	pgoff_t pg_end;
>> >>>>  
>> >>>> +	if (nodeid == FUSE_INVAL_ALL_INODES)
>> >>>> +		return fuse_reverse_inval_all(fc);
>> >>>> +
>> >>>>  	inode = fuse_ilookup(fc, nodeid, NULL);
>> >>>>  	if (!inode)
>> >>>>  		return -ENOENT;
>> >>>> diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
>> >>>> index 5e0eb41d967e..e5852b63f99f 100644
>> >>>> --- a/include/uapi/linux/fuse.h
>> >>>> +++ b/include/uapi/linux/fuse.h
>> >>>> @@ -669,6 +669,9 @@ enum fuse_notify_code {
>> >>>>  	FUSE_NOTIFY_CODE_MAX,
>> >>>>  };
>> >>>>  
>> >>>> +/* The nodeid to request to invalidate all inodes */
>> >>>> +#define FUSE_INVAL_ALL_INODES 0
>> >>>> +
>> >>>>  /* The read buffer is required to be at least 8k, but may be much larger */
>> >>>>  #define FUSE_MIN_READ_BUFFER 8192
>> >>>>  
>> >>>
>> >>>
>> >>> I think this version might end up in 
>> >>>
>> >>> static void fuse_evict_inode(struct inode *inode)
>> >>> {
>> >>> 	struct fuse_inode *fi = get_fuse_inode(inode);
>> >>>
>> >>> 	/* Will write inode on close/munmap and in all other dirtiers */
>> >>> 	WARN_ON(inode->i_state & I_DIRTY_INODE);
>> >>>
>> >>>
>> >>> if the fuse connection has writeback cache enabled.
>> >>>
>> >>>
>> >>> Without having it tested, reproducer would probably be to run
>> >>> something like passthrough_hp (without --direct-io), opening
>> >>> and writing to a file and then sending FUSE_INVAL_ALL_INODES.
>> >> 
>> >> Thanks, Bernd.  So far I couldn't trigger this warning.  But I just found
>> >> that there's a stupid bug in the code: a missing iput() after doing the
>> >> fuse_ilookup().
>> >> 
>> >> I'll spend some more time trying to understand how (or if) the warning you
>> >> mentioned can triggered before sending a new revision.
>> >> 
>> >
>> > Maybe I'm wrong, but it calls 
>> >
>> >    invalidate_inodes()
>> >       dispose_list()
>> >         evict(inode)
>> >            fuse_evict_inode()
>> >
>> > and if at the same time something writes to inode page cache, the
>> > warning would be triggered? 
>> > There are some conditions in evict, like inode_wait_for_writeback()
>> > that might protect us, but what is if it waited and then just
>> > in the right time the another write comes and dirties the inode
>> > again?
>> 
>> Right, I have looked into that too but my understanding is that this can
>> not happen because, before doing that wait, the code does:
>> 
>> 	inode_sb_list_del(inode);
>> 
>> and the inode state will include I_FREEING.
>> 
>> Thus, before writing to it again, the inode will need to get added back to
>> the sb list.  Also, reading the comments on evict(), if something writes
>> into the inode at that point that's likely a bug.  But this is just my
>> understanding, and I may be missing something.
>
> Yes. invalidate_inodes() checks i_count == 0 and sets I_FREEING. Once
> I_FREEING is set nobody can acquire inode reference until the inode is
> fully destroyed. So nobody should be writing to the inode or anything like
> that.

Awesome, it's good to have that confirmed.  Thank you, Jan!

Cheers,
-- 
Luís

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

* Re: [PATCH v5 1/2] vfs: export invalidate_inodes()
  2025-02-18 11:59   ` Jan Kara
@ 2025-02-18 13:35     ` Luis Henriques
  0 siblings, 0 replies; 11+ messages in thread
From: Luis Henriques @ 2025-02-18 13:35 UTC (permalink / raw)
  To: Jan Kara
  Cc: Miklos Szeredi, Bernd Schubert, Dave Chinner, Alexander Viro,
	Christian Brauner, Matt Harvey, linux-fsdevel, linux-kernel

On Tue, Feb 18 2025, Jan Kara wrote:

> On Sun 16-02-25 16:50:07, Luis Henriques wrote:
>> Signed-off-by: Luis Henriques <luis@igalia.com>
>
> Please use evict_inodes(). It is already exported and does exactly the same
> these days. We should really merge the patch deleting invalidate_inodes()
> :)

Thank you for the suggestion, Jan.  Yeah that makes sense, of course.

However, since it's still not clear what's the future of this patchset
will be, I'll hold on re-sending it for now, but I'll definitely replace
invalidate_inodes() in a future revision.

Cheers,
-- 
Luís


>
> 									Honza
>
>> ---
>>  fs/inode.c         | 1 +
>>  fs/internal.h      | 1 -
>>  include/linux/fs.h | 1 +
>>  3 files changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/fs/inode.c b/fs/inode.c
>> index 5587aabdaa5e..88387ecb2c34 100644
>> --- a/fs/inode.c
>> +++ b/fs/inode.c
>> @@ -939,6 +939,7 @@ void invalidate_inodes(struct super_block *sb)
>>  
>>  	dispose_list(&dispose);
>>  }
>> +EXPORT_SYMBOL(invalidate_inodes);
>>  
>>  /*
>>   * Isolate the inode from the LRU in preparation for freeing it.
>> diff --git a/fs/internal.h b/fs/internal.h
>> index e7f02ae1e098..7cb515cede3f 100644
>> --- a/fs/internal.h
>> +++ b/fs/internal.h
>> @@ -207,7 +207,6 @@ bool in_group_or_capable(struct mnt_idmap *idmap,
>>   * fs-writeback.c
>>   */
>>  extern long get_nr_dirty_inodes(void);
>> -void invalidate_inodes(struct super_block *sb);
>>  
>>  /*
>>   * dcache.c
>> diff --git a/include/linux/fs.h b/include/linux/fs.h
>> index 2c3b2f8a621f..ff016885646e 100644
>> --- a/include/linux/fs.h
>> +++ b/include/linux/fs.h
>> @@ -3270,6 +3270,7 @@ extern void discard_new_inode(struct inode *);
>>  extern unsigned int get_next_ino(void);
>>  extern void evict_inodes(struct super_block *sb);
>>  void dump_mapping(const struct address_space *);
>> +extern void invalidate_inodes(struct super_block *sb);
>>  
>>  /*
>>   * Userspace may rely on the inode number being non-zero. For example, glibc
> -- 
> Jan Kara <jack@suse.com>
> SUSE Labs, CR


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

end of thread, other threads:[~2025-02-18 13:35 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-16 16:50 [PATCH v5 0/2] fuse: allow notify_inval for all inodes Luis Henriques
2025-02-16 16:50 ` [PATCH v5 1/2] vfs: export invalidate_inodes() Luis Henriques
2025-02-18 11:59   ` Jan Kara
2025-02-18 13:35     ` Luis Henriques
2025-02-16 16:50 ` [PATCH v5 2/2] fuse: add new function to invalidate cache for all inodes Luis Henriques
2025-02-17  0:40   ` Bernd Schubert
2025-02-17 10:07     ` Luis Henriques
2025-02-17 10:29       ` Bernd Schubert
2025-02-17 11:47         ` Luis Henriques
2025-02-18 11:57           ` Jan Kara
2025-02-18 13:28             ` Luis Henriques

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).