From: Greg Farnum Date: Tue, 10 Feb 2015 19:11:06 +0000 (-0800) Subject: Client: check for failures on system() invocation X-Git-Tag: v0.93~1^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cd95b297d728e063bf95007436f550576fc1979f;p=ceph.git Client: check for failures on system() invocation Fixes: #10710 Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index ef11bdb9b4b5..a3a0ce702b6b 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3443,7 +3443,16 @@ private: public: C_Client_Remount(Client *c) : client(c) {} void finish(int r) { - client->remount_cb(client->callback_handle); + assert (r == 0); + r = client->remount_cb(client->callback_handle); + if (r != 0) { + client_t whoami = client->get_nodeid(); + lderr(client->cct) << "tried to remount (to trim kernel dentries) and got error " + << r << dendl; + if (client->cct->_conf->client_die_on_failed_remount) { + assert(0 == "failed to remount for kernel dentry trimming"); + } + } } }; diff --git a/src/client/Client.h b/src/client/Client.h index 0d4bb2cf9f5f..d00a4ca909bd 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -136,7 +136,7 @@ typedef void (*client_ino_callback_t)(void *handle, vinodeno_t ino, int64_t off, typedef void (*client_dentry_callback_t)(void *handle, vinodeno_t dirino, vinodeno_t ino, string& name); -typedef void (*client_remount_callback_t)(void *handle); +typedef int (*client_remount_callback_t)(void *handle); typedef int (*client_getgroups_callback_t)(void *handle, uid_t uid, gid_t **sgids); typedef void(*client_switch_interrupt_callback_t)(void *req, void *data); diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index 50a9d4879f46..f9c380c9cb4f 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -757,14 +757,19 @@ static void dentry_invalidate_cb(void *handle, vinodeno_t dirino, #endif } -static void remount_cb(void *handle) +static int remount_cb(void *handle) { // used for trimming kernel dcache. when remounting a file system, linux kernel // trims all unused dentries in the file system char cmd[1024]; CephFuse::Handle *cfuse = (CephFuse::Handle *)handle; snprintf(cmd, sizeof(cmd), "mount -i -o remount %s", cfuse->mountpoint); - system(cmd); + int r = system(cmd); + if (r != 0 && r != -1) { + r = WEXITSTATUS(r); + } + + return r; } static void do_init(void *data, fuse_conn_info *bar) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 00a23b6b661f..38416ae1691e 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -326,6 +326,7 @@ OPTION(fuse_big_writes, OPT_BOOL, true) OPTION(fuse_atomic_o_trunc, OPT_BOOL, true) OPTION(fuse_debug, OPT_BOOL, false) OPTION(fuse_multithreaded, OPT_BOOL, true) +OPTION(client_die_on_failed_remount, OPT_BOOL, true) OPTION(crush_location, OPT_STR, "") // whitespace-separated list of key=value pairs describing crush location