diff options
author | Brian Behlendorf <[email protected]> | 2011-12-22 12:20:43 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2012-01-11 11:46:02 -0800 |
commit | ab26409db753bb087842ab6f1af943f3386c764f (patch) | |
tree | 7baa51b121ef9a866371bd750b9949688f0c29e8 /include/sys | |
parent | 8eaa020b46e80b09cc5f924b90809e219ce08e75 (diff) |
Linux 3.1 compat, super_block->s_shrink
The Linux 3.1 kernel has introduced the concept of per-filesystem
shrinkers which are directly assoicated with a super block. Prior
to this change there was one shared global shrinker.
The zfs code relied on being able to call the global shrinker when
the arc_meta_limit was exceeded. This would cause the VFS to drop
references on a fraction of the dentries in the dcache. The ARC
could then safely reclaim the memory used by these entries and
honor the arc_meta_limit. Unfortunately, when per-filesystem
shrinkers were added the old interfaces were made unavailable.
This change adds support to use the new per-filesystem shrinker
interface so we can continue to honor the arc_meta_limit. The
major benefit of the new interface is that we can now target
only the zfs filesystem for dentry and inode pruning. Thus we
can minimize any impact on the caching of other filesystems.
In the context of making this change several other important
issues related to managing the ARC were addressed, they include:
* The dnlc_reduce_cache() function which was called by the ARC
to drop dentries for the Posix layer was replaced with a generic
zfs_prune_t callback. The ZPL layer now registers a callback to
drop these dentries removing a layering violation which dates
back to the Solaris code. This callback can also be used by
other ARC consumers such as Lustre.
arc_add_prune_callback()
arc_remove_prune_callback()
* The arc_reduce_dnlc_percent module option has been changed to
arc_meta_prune for clarity. The dnlc functions are specific to
Solaris's VFS and have already been largely eliminated already.
The replacement tunable now represents the number of bytes the
prune callback will request when invoked.
* Less aggressively invoke the prune callback. We used to call
this whenever we exceeded the arc_meta_limit however that's not
strictly correct since it results in over zeleous reclaim of
dentries and inodes. It is now only called once the arc_meta_limit
is exceeded and every effort has been made to evict other data from
the ARC cache.
* More promptly manage exceeding the arc_meta_limit. When reading
meta data in to the cache if a buffer was unable to be recycled
notify the arc_reclaim thread to invoke the required prune.
* Added arcstat_prune kstat which is incremented when the ARC
is forced to request that a consumer prune its cache. Remember
this will only occur when the ARC has no other choice. If it
can evict buffers safely without invoking the prune callback
it will.
* This change is also expected to resolve the unexpect collapses
of the ARC cache. This would occur because when exceeded just the
arc_meta_limit reclaim presure would be excerted on the arc_c
value via arc_shrink(). This effectively shrunk the entire cache
when really we just needed to reclaim meta data.
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #466
Closes #292
Diffstat (limited to 'include/sys')
-rw-r--r-- | include/sys/Makefile.in | 1 | ||||
-rw-r--r-- | include/sys/arc.h | 15 | ||||
-rw-r--r-- | include/sys/fm/Makefile.in | 1 | ||||
-rw-r--r-- | include/sys/fm/fs/Makefile.in | 1 | ||||
-rw-r--r-- | include/sys/fs/Makefile.in | 1 | ||||
-rw-r--r-- | include/sys/zfs_vfsops.h | 5 | ||||
-rw-r--r-- | include/sys/zpl.h | 2 |
7 files changed, 25 insertions, 1 deletions
diff --git a/include/sys/Makefile.in b/include/sys/Makefile.in index b17649b02..012ffe9f7 100644 --- a/include/sys/Makefile.in +++ b/include/sys/Makefile.in @@ -71,6 +71,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ $(top_srcdir)/config/kernel-security-inode-init.m4 \ $(top_srcdir)/config/kernel-set-nlink.m4 \ + $(top_srcdir)/config/kernel-shrink.m4 \ $(top_srcdir)/config/kernel-truncate-setsize.m4 \ $(top_srcdir)/config/kernel-xattr-handler.m4 \ $(top_srcdir)/config/kernel.m4 \ diff --git a/include/sys/arc.h b/include/sys/arc.h index 8f189c62d..dd9b128bc 100644 --- a/include/sys/arc.h +++ b/include/sys/arc.h @@ -34,16 +34,27 @@ extern "C" { #include <sys/zio.h> #include <sys/dmu.h> #include <sys/spa.h> +#include <sys/refcount.h> typedef struct arc_buf_hdr arc_buf_hdr_t; typedef struct arc_buf arc_buf_t; +typedef struct arc_prune arc_prune_t; typedef void arc_done_func_t(zio_t *zio, arc_buf_t *buf, void *private); +typedef void arc_prune_func_t(int64_t bytes, void *private); typedef int arc_evict_func_t(void *private); /* generic arc_done_func_t's which you can use */ arc_done_func_t arc_bcopy_func; arc_done_func_t arc_getbuf_func; +/* generic arc_prune_func_t wrapper for callbacks */ +struct arc_prune { + arc_prune_func_t *p_pfunc; + void *p_private; + list_node_t p_node; + refcount_t p_refcnt; +}; + struct arc_buf { arc_buf_hdr_t *b_hdr; arc_buf_t *b_next; @@ -113,9 +124,13 @@ zio_t *arc_write(zio_t *pio, spa_t *spa, uint64_t txg, arc_done_func_t *ready, arc_done_func_t *done, void *private, int priority, int zio_flags, const zbookmark_t *zb); +arc_prune_t *arc_add_prune_callback(arc_prune_func_t *func, void *private); +void arc_remove_prune_callback(arc_prune_t *p); + void arc_set_callback(arc_buf_t *buf, arc_evict_func_t *func, void *private); int arc_buf_evict(arc_buf_t *buf); +void arc_adjust_meta(int64_t adjustment, boolean_t may_prune); void arc_flush(spa_t *spa); void arc_tempreserve_clear(uint64_t reserve); int arc_tempreserve_space(uint64_t reserve, uint64_t txg); diff --git a/include/sys/fm/Makefile.in b/include/sys/fm/Makefile.in index e3fd84cfd..932e5e732 100644 --- a/include/sys/fm/Makefile.in +++ b/include/sys/fm/Makefile.in @@ -71,6 +71,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ $(top_srcdir)/config/kernel-security-inode-init.m4 \ $(top_srcdir)/config/kernel-set-nlink.m4 \ + $(top_srcdir)/config/kernel-shrink.m4 \ $(top_srcdir)/config/kernel-truncate-setsize.m4 \ $(top_srcdir)/config/kernel-xattr-handler.m4 \ $(top_srcdir)/config/kernel.m4 \ diff --git a/include/sys/fm/fs/Makefile.in b/include/sys/fm/fs/Makefile.in index 40952616b..bbcb1c258 100644 --- a/include/sys/fm/fs/Makefile.in +++ b/include/sys/fm/fs/Makefile.in @@ -71,6 +71,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ $(top_srcdir)/config/kernel-security-inode-init.m4 \ $(top_srcdir)/config/kernel-set-nlink.m4 \ + $(top_srcdir)/config/kernel-shrink.m4 \ $(top_srcdir)/config/kernel-truncate-setsize.m4 \ $(top_srcdir)/config/kernel-xattr-handler.m4 \ $(top_srcdir)/config/kernel.m4 \ diff --git a/include/sys/fs/Makefile.in b/include/sys/fs/Makefile.in index db73ab862..da86a6fbc 100644 --- a/include/sys/fs/Makefile.in +++ b/include/sys/fs/Makefile.in @@ -71,6 +71,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ $(top_srcdir)/config/kernel-security-inode-init.m4 \ $(top_srcdir)/config/kernel-set-nlink.m4 \ + $(top_srcdir)/config/kernel-shrink.m4 \ $(top_srcdir)/config/kernel-truncate-setsize.m4 \ $(top_srcdir)/config/kernel-xattr-handler.m4 \ $(top_srcdir)/config/kernel.m4 \ diff --git a/include/sys/zfs_vfsops.h b/include/sys/zfs_vfsops.h index 6d4d713ce..b7badeed8 100644 --- a/include/sys/zfs_vfsops.h +++ b/include/sys/zfs_vfsops.h @@ -67,7 +67,8 @@ typedef struct zfs_sb { boolean_t z_unmounted; /* unmounted */ rrwlock_t z_teardown_lock; krwlock_t z_teardown_inactive_lock; - list_t z_all_znodes; /* all vnodes in the fs */ + list_t z_all_znodes; /* all znodes in the fs */ + uint64_t z_nr_znodes; /* number of znodes in the fs */ kmutex_t z_znodes_lock; /* lock for z_all_znodes */ struct inode *z_ctldir; /* .zfs directory inode */ boolean_t z_show_ctldir; /* expose .zfs in the root dir */ @@ -185,6 +186,8 @@ extern int zfs_get_zplprop(objset_t *os, zfs_prop_t prop, extern int zfs_sb_create(const char *name, zfs_sb_t **zsbp); extern int zfs_sb_setup(zfs_sb_t *zsb, boolean_t mounting); extern void zfs_sb_free(zfs_sb_t *zsb); +extern int zfs_sb_prune(struct super_block *sb, unsigned long nr_to_scan, + int *objects); extern int zfs_sb_teardown(zfs_sb_t *zsb, boolean_t unmounting); extern int zfs_check_global_label(const char *dsname, const char *hexsl); extern boolean_t zfs_is_readonly(zfs_sb_t *zsb); diff --git a/include/sys/zpl.h b/include/sys/zpl.h index 0aacce8bd..2195ec9a3 100644 --- a/include/sys/zpl.h +++ b/include/sys/zpl.h @@ -48,6 +48,8 @@ extern const struct file_operations zpl_file_operations; extern const struct file_operations zpl_dir_file_operations; /* zpl_super.c */ +extern void zpl_prune_sbs(int64_t bytes_to_scan, void *private); + typedef struct zpl_mount_data { const char *z_osname; /* Dataset name */ void *z_data; /* Mount options string */ |