[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1466797811-5873-2-git-send-email-rpeterso@redhat.com>
Date: Fri, 24 Jun 2016 14:50:10 -0500
From: Bob Peterson <rpeterso@...hat.com>
To: cluster-devel@...hat.com, <linux-fsdevel@...r.kernel.org>,
Dave Chinner <dchinner@...hat.com>
Cc: linux-kernel@...r.kernel.org, Al Viro <viro@...iv.linux.org.uk>
Subject: [PATCH 1/2] vfs: Add hooks for filesystem-specific prune_icache_sb
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@...hat.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
Powered by blists - more mailing lists