From: Yan, Zheng Date: Mon, 15 Feb 2016 07:29:28 +0000 (+0800) Subject: client: flush kernel pagecache before creating snapshot X-Git-Tag: v10.1.0~174^2^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=bd611ab1898307271b168d455ee0e5b434f7aca0;p=ceph.git client: flush kernel pagecache before creating snapshot Fixes: #10436 Signed-off-by: Yan, Zheng --- diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index 793cc4d1ab990..edbd1d6bd92e1 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -328,11 +328,33 @@ static void fuse_ll_mkdir(fuse_req_t req, fuse_ino_t parent, const char *name, { CephFuse::Handle *cfuse = fuse_ll_req_prepare(req); const struct fuse_ctx *ctx = fuse_req_ctx(req); - Inode *i2, *i1 = cfuse->iget(parent); + Inode *i2, *i1; struct fuse_entry_param fe; memset(&fe, 0, sizeof(fe)); +#ifdef HAVE_SYS_SYNCFS + if (cfuse->fino_snap(parent) == CEPH_SNAPDIR && + cfuse->client->cct->_conf->fuse_multithreaded && + cfuse->client->cct->_conf->fuse_syncfs_on_mksnap) { + int err = 0; + int fd = ::open(cfuse->mountpoint, O_RDONLY | O_DIRECTORY); + if (fd < 0) { + err = -errno; + } else { + int r = ::syncfs(fd); + if (r < 0) + err = -errno; + ::close(fd); + } + if (err) { + fuse_reply_err(req, err); + return; + } + } +#endif + + i1 = cfuse->iget(parent); int r = cfuse->client->ll_mkdir(i1, name, mode, &fe.attr, &i2, ctx->uid, ctx->gid); if (r == 0) { diff --git a/src/common/config_opts.h b/src/common/config_opts.h index a0ae4955ebc7c..f0a4512466587 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -399,6 +399,7 @@ OPTION(fuse_atomic_o_trunc, OPT_BOOL, true) OPTION(fuse_debug, OPT_BOOL, false) OPTION(fuse_multithreaded, OPT_BOOL, true) OPTION(fuse_require_active_mds, OPT_BOOL, true) // if ceph_fuse requires active mds server +OPTION(fuse_syncfs_on_mksnap, OPT_BOOL, true) OPTION(client_try_dentry_invalidate, OPT_BOOL, true) // the client should try to use dentry invaldation instead of remounting, on kernels it believes that will work for OPTION(client_die_on_failed_remount, OPT_BOOL, true)