Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1430906 > unrolled thread

[PATCH 1/2] vfs: Add hooks for filesystem-specific prune_icache_sb

Started byBob Peterson <rpeterso@redhat.com>
First post2016-06-24 22:00 +0200
Last post2016-06-28 03:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/2] vfs: Add hooks for filesystem-specific prune_icache_sb Bob Peterson <rpeterso@redhat.com> - 2016-06-24 22:00 +0200
    Re: [PATCH 1/2] vfs: Add hooks for filesystem-specific  prune_icache_sb Dave Chinner <david@fromorbit.com> - 2016-06-28 03:20 +0200

#1430906 — [PATCH 1/2] vfs: Add hooks for filesystem-specific prune_icache_sb

FromBob Peterson <rpeterso@redhat.com>
Date2016-06-24 22:00 +0200
Subject[PATCH 1/2] vfs: Add hooks for filesystem-specific prune_icache_sb
Message-ID<rNFqG-447-3@gated-at.bofh.it>
This patch adds filesystem-specific callbacks for shrinking the
inode cache, prune_icache_sb. This is provided for filesystems in
which the default VFS prune_icache_sb needs to be delayed due to
filesystem locking requirements not met by vfs.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
 Documentation/filesystems/vfs.txt | 15 +++++++++++++++
 fs/inode.c                        |  1 +
 fs/super.c                        |  5 ++++-
 include/linux/fs.h                |  3 +++
 4 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index c61a223..7cb4c5c 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -230,6 +230,7 @@ struct super_operations {
         ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t);
 	int (*nr_cached_objects)(struct super_block *);
 	void (*free_cached_objects)(struct super_block *, int);
+	long (*prune_icache_sb)(struct super_block *, struct shrink_control *);
 };
 
 All methods are called without any locks being held, unless otherwise
@@ -319,6 +320,20 @@ or bottom half).
 	implementations will cause holdoff problems due to large scan batch
 	sizes.
 
+  prune_icache_sb: called by the sb cache shrinking function for the file
+	filesystem to reduce the number of inodes from slab. This is done to
+	accomodate file systems that may not be able to immediately remove
+	inodes from cache, but must queue them to be removed ASAP.
+
+	This can happen in GFS2, for example, where evicting an inode
+	may require an inter-node lock (glock) which makes a call into DLM
+	(distributed lock manager), which may block for any number of reasons.
+	For example, it may block because a customer node needs to be fenced,
+	so the lock cannot be granted until the fencing is complete.
+	The fencing, in turn, may be blocked for other reasons, such as
+	memory allocations that caused the shrinker to be called in the first
+	place. Optional. If not set, the default vfs prune_icache_sb is called.
+
 Whoever sets up the inode is responsible for filling in the "i_op" field. This
 is a pointer to a "struct inode_operations" which describes the methods that
 can be performed on individual inodes.
diff --git a/fs/inode.c b/fs/inode.c
index 4ccbc21..82c10f3 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -771,6 +771,7 @@ long prune_icache_sb(struct super_block *sb, struct shrink_control *sc)
 	dispose_list(&freeable);
 	return freed;
 }
+EXPORT_SYMBOL(prune_icache_sb);
 
 static void __wait_on_freeing_inode(struct inode *inode);
 /*
diff --git a/fs/super.c b/fs/super.c
index d78b984..8087903 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -98,7 +98,10 @@ static unsigned long super_cache_scan(struct shrinker *shrink,
 	sc->nr_to_scan = dentries + 1;
 	freed = prune_dcache_sb(sb, sc);
 	sc->nr_to_scan = inodes + 1;
-	freed += prune_icache_sb(sb, sc);
+	if (sb->s_op->prune_icache_sb)
+		freed += sb->s_op->prune_icache_sb(sb, sc);
+	else
+		freed += prune_icache_sb(sb, sc);
 
 	if (fs_objects) {
 		sc->nr_to_scan = fs_objects + 1;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5f61431..96e6ae2 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1797,6 +1797,8 @@ struct super_operations {
 				  struct shrink_control *);
 	long (*free_cached_objects)(struct super_block *,
 				    struct shrink_control *);
+	long (*prune_icache_sb)(struct super_block *sb,
+				struct shrink_control *sc);
 };
 
 /*
@@ -2714,6 +2716,7 @@ extern void lockdep_annotate_inode_mutex_key(struct inode *inode);
 static inline void lockdep_annotate_inode_mutex_key(struct inode *inode) { };
 #endif
 extern void unlock_new_inode(struct inode *);
+extern long prune_icache_sb(struct super_block *sb, struct shrink_control *sc);
 extern unsigned int get_next_ino(void);
 
 extern void __iget(struct inode * inode);
-- 
2.5.5

[toc] | [next] | [standalone]


#1432380 — Re: [PATCH 1/2] vfs: Add hooks for filesystem-specific prune_icache_sb

FromDave Chinner <david@fromorbit.com>
Date2016-06-28 03:20 +0200
SubjectRe: [PATCH 1/2] vfs: Add hooks for filesystem-specific prune_icache_sb
Message-ID<rOPQZ-8fN-5@gated-at.bofh.it>
In reply to#1430906
On Fri, Jun 24, 2016 at 02:50:10PM -0500, Bob Peterson wrote:
> This patch adds filesystem-specific callbacks for shrinking the
> inode cache, prune_icache_sb. This is provided for filesystems in
> which the default VFS prune_icache_sb needs to be delayed due to
> filesystem locking requirements not met by vfs.
> 
> Signed-off-by: Bob Peterson <rpeterso@redhat.com>
> ---
>  Documentation/filesystems/vfs.txt | 15 +++++++++++++++
>  fs/inode.c                        |  1 +
>  fs/super.c                        |  5 ++++-
>  include/linux/fs.h                |  3 +++
>  4 files changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
> index c61a223..7cb4c5c 100644
> --- a/Documentation/filesystems/vfs.txt
> +++ b/Documentation/filesystems/vfs.txt
> @@ -230,6 +230,7 @@ struct super_operations {
>          ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t);
>  	int (*nr_cached_objects)(struct super_block *);
>  	void (*free_cached_objects)(struct super_block *, int);
> +	long (*prune_icache_sb)(struct super_block *, struct shrink_control *);
>  };

IIRC, I originally proposed this before adding the
nr_cached_objects/free_cached_objects interface because it allowed
filesystems direct control over inode reclaim. I don't recall the
reasons for it being rejected now - I think the main one was that
the inode life cycle was owned by the VFS, not the filesystem, and
that it woul dbe too easy for people to implement their own
shrinkers and get it all wrong and hence screw over the entire
system....

>  All methods are called without any locks being held, unless otherwise
> @@ -319,6 +320,20 @@ or bottom half).
>  	implementations will cause holdoff problems due to large scan batch
>  	sizes.
>  
> +  prune_icache_sb: called by the sb cache shrinking function for the file
> +	filesystem to reduce the number of inodes from slab. This is done to
> +	accomodate file systems that may not be able to immediately remove
> +	inodes from cache, but must queue them to be removed ASAP.
> +
> +	This can happen in GFS2, for example, where evicting an inode
> +	may require an inter-node lock (glock) which makes a call into DLM
> +	(distributed lock manager), which may block for any number of reasons.
> +	For example, it may block because a customer node needs to be fenced,
> +	so the lock cannot be granted until the fencing is complete.
> +	The fencing, in turn, may be blocked for other reasons, such as
> +	memory allocations that caused the shrinker to be called in the first
> +	place. Optional. If not set, the default vfs prune_icache_sb is called.

So why don't you simply do what XFS does? i.e. when ->evict/destroy is
called on an inode, you clean up the VFS portion of the inode but do
not destroy/free it - you simply queue it to an internal list and
then do the cleanup/freeing in your own time?

i.e. why do you need a special callout just to defer freeing to
another thread when we already have hooks than enable you to do
this?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web