From 32ffb79f18cbaebcbe6bba51599ca234f44675cc Mon Sep 17 00:00:00 2001 From: Brian Foster Date: Wed, 13 Jun 2012 12:08:38 -0400 Subject: fuse/md-cache: add support for the 'fopen-keep-cache' mount option fopen-keep-cache disables unconditional page-cache invalidations on file open in fuse (via FOPEN_KEEP_CACHE) and replaces that behavior with detection of remote changes and explicit invalidations from mount/fuse. This option improves local caching through the page cache and native client. This change defines a new 'invalidate' translator callback to identify when an inode's cache mapping has been determined to be invalid. md-cache implements the policy to detect and invoke inode invalidations. fuse-bridge and io-cache implement invalidate handlers to invalidate the respective caches (page cache in the case of fuse). BUG: 833564 Change-Id: I99818da5777eaf06276c1c0b194669f5bab92d48 Signed-off-by: Brian Foster Reviewed-on: http://review.gluster.com/3584 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- glusterfsd/src/glusterfsd.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'glusterfsd/src/glusterfsd.c') diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 0ab8fcd4c..76f019481 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -168,6 +168,8 @@ static struct argp_option gf_options[] = { "Brick name to be registered with Gluster portmapper" }, {"brick-port", ARGP_BRICK_PORT_KEY, "BRICK-PORT", OPTION_HIDDEN, "Brick Port to be registered with Gluster portmapper" }, + {"fopen-keep-cache", ARGP_FOPEN_KEEP_CACHE_KEY, 0, 0, + "Do not purge the cache on file open"}, {0, 0, 0, 0, "Fuse options:"}, {"direct-io-mode", ARGP_DIRECT_IO_MODE_KEY, "BOOL", OPTION_ARG_OPTIONAL, @@ -368,6 +370,17 @@ create_fuse_mount (glusterfs_ctx_t *ctx) } } + if (cmd_args->fopen_keep_cache) { + ret = dict_set_static_ptr(master->options, "fopen-keep-cache", + "on"); + if (ret < 0) { + gf_log("glusterfsd", GF_LOG_ERROR, + "failed to set dict value for key " + "fopen-keep-cache"); + goto err; + } + } + switch (cmd_args->fuse_direct_io_mode) { case GF_OPTION_DISABLE: /* disable */ ret = dict_set_static_ptr (master->options, ZR_DIRECT_IO_OPT, @@ -814,7 +827,11 @@ parse_opts (int key, char *arg, struct argp_state *state) ctx = glusterfs_ctx_get (); ctx->mem_accounting = 1; break; - } + + case ARGP_FOPEN_KEEP_CACHE_KEY: + cmd_args->fopen_keep_cache = 1; + break; + } return 0; } -- cgit