client: quit on failed remount during dentry invalidate test 21162/head
authorPatrick Donnelly <pdonnell@redhat.com>
Tue, 28 Nov 2017 23:01:32 +0000 (15:01 -0800)
committerNathan Cutler <ncutler@suse.com>
Mon, 16 Apr 2018 07:20:10 +0000 (09:20 +0200)
Fixes: http://tracker.ceph.com/issues/22269
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit 5b2b1d14468c290c56ee6c95ea557c99464e0098)

Conflicts:
PendingReleaseNotes - put the release note under 10.2.11
src/ceph_fuse.cc - changed order of client_try_dentry_invalidate and
    can_invalidate_dentries assignments to match master, and use jewel
            form of g_conf for accessing config option values
src/client/Client.cc - code being replaced by _do_remount() calls is
    different in jewel, and use jewel convention for accessing config
            option values
src/common/legacy_config_opts.h - file does not exist in jewel
src/common/options.cc - file does not exit in jewel; made the changes
            manually in src/common/config_opts.h

PendingReleaseNotes
src/ceph_fuse.cc
src/client/Client.cc
src/client/Client.h
src/common/config_opts.h

index d134ac86ad2b2a23ee1bd37c6f569014eada75cb..383ea6c1bd6a50c7b81c154324b388e2624c762c 100644 (file)
@@ -22,3 +22,9 @@
   delete workload, it can lead to high latency when leveldb's
   single-threaded compaction cannot keep up. rocksdb supports multiple
   threads for compaction, which avoids this problem.
+
+* The CephFS client now catches failures to clear dentries during startup
+  and refuses to start as consistency and untrimmable cache issues may
+  develop. The new option client_die_on_failed_dentry_invalidate (default:
+  true) may be turned off to allow the client to proceed (dangerous!).
+
index d2baa9606f21e931bc4ed2a63e55c01955ad1c15..3b6890b7b2ef6e396a8b8548365f4791babced63 100644 (file)
@@ -153,10 +153,12 @@ int main(int argc, const char **argv, const char *envp[]) {
 #if defined(__linux__)
        int ver = get_linux_version();
        assert(ver != 0);
-       bool can_invalidate_dentries = g_conf->client_try_dentry_invalidate &&
-                                      ver < KERNEL_VERSION(3, 18, 0);
+        bool client_try_dentry_invalidate = g_conf->client_try_dentry_invalidate;
+       bool can_invalidate_dentries = 
+          client_try_dentry_invalidate && ver < KERNEL_VERSION(3, 18, 0);
        int tr = client->test_dentry_handling(can_invalidate_dentries);
-       if (tr != 0) {
+        bool client_die_on_failed_dentry_invalidate = g_conf->client_die_on_failed_dentry_invalidate;
+       if (tr != 0 && client_die_on_failed_dentry_invalidate) {
          cerr << "ceph-fuse[" << getpid()
               << "]: fuse failed dentry invalidate/remount test with error "
               << cpp_strerror(tr) << ", stopping" << std::endl;
index 9680e6c3561dc20d6469b974e23a31c553f686ec..09503f9315eec2b0eb9a0c5d581af34ad382f867 100644 (file)
@@ -247,7 +247,6 @@ Client::Client(Messenger *m, MonClient *mc)
     getgroups_cb(NULL),
     umask_cb(NULL),
     can_invalidate_dentries(false),
-    require_remount(false),
     async_ino_invalidator(m->cct),
     async_dentry_invalidator(m->cct),
     interrupt_finisher(m->cct),
@@ -3944,6 +3943,32 @@ void Client::remove_session_caps(MetaSession *s)
   sync_cond.Signal();
 }
 
+int Client::_do_remount(void)
+{
+  errno = 0;
+  int r = remount_cb(callback_handle);
+  if (r != 0) {
+    int e = errno;
+    client_t whoami = get_nodeid();
+    if (r == -1) {
+      lderr(cct) <<
+          "failed to remount (to trim kernel dentries): "
+          "errno = " << e << " (" << strerror(e) << ")" << dendl;
+    } else {
+      lderr(cct) <<
+          "failed to remount (to trim kernel dentries): "
+          "return code = " << r << dendl;
+    }
+    bool should_abort = cct->_conf->client_die_on_failed_remount ||
+        cct->_conf->client_die_on_failed_dentry_invalidate;
+    if (should_abort && !unmounting) {
+      lderr(cct) << "failed to remount for kernel dentry trimming; quitting!" << dendl;
+      ceph_abort();
+    }
+  }
+  return r;
+}
+
 class C_Client_Remount : public Context  {
 private:
   Client *client;
@@ -3951,15 +3976,7 @@ public:
   explicit C_Client_Remount(Client *c) : client(c) {}
   void finish(int r) {
     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->require_remount && !client->unmounting) {
-       assert(0 == "failed to remount for kernel dentry trimming");
-      }
-    }
+    client->_do_remount();
   }
 };
 
@@ -9347,21 +9364,19 @@ int Client::test_dentry_handling(bool can_invalidate)
   if (can_invalidate_dentries) {
     assert(dentry_invalidate_cb);
     ldout(cct, 1) << "using dentry_invalidate_cb" << dendl;
+    r = 0;
   } else if (remount_cb) {
     ldout(cct, 1) << "using remount_cb" << dendl;
-    int s = remount_cb(callback_handle);
-    if (s) {
-      lderr(cct) << "Failed to invoke remount, needed to ensure kernel dcache consistency"
-                << dendl;
-    }
-    if (cct->_conf->client_die_on_failed_remount) {
-      require_remount = true;
-      r = s;
+    r = _do_remount();
+  }
+  if (r) {
+    bool should_abort = cct->_conf->client_die_on_failed_dentry_invalidate;
+    if (should_abort) {
+      lderr(cct) << "no method to invalidate kernel dentry cache; quitting!" << dendl;
+      ceph_abort();
+    } else {
+      lderr(cct) << "no method to invalidate kernel dentry cache; expect issues!" << dendl;
     }
-  } else {
-    lderr(cct) << "no method to invalidate kernel dentry cache; expect issues!" << dendl;
-    if (cct->_conf->client_die_on_failed_remount)
-      assert(0);
   }
   return r;
 }
index f569b9e488529ea60e3f1c3d3d92fa91f3d5af66..f81698da15aafe87099c350c273eb10914bdd220 100644 (file)
@@ -284,7 +284,6 @@ class Client : public Dispatcher, public md_config_obs_t {
   client_getgroups_callback_t getgroups_cb;
   client_umask_callback_t umask_cb;
   bool can_invalidate_dentries;
-  bool require_remount;
 
   Finisher async_ino_invalidator;
   Finisher async_dentry_invalidator;
@@ -740,6 +739,8 @@ private:
   int _release_fh(Fh *fh);
   void _put_fh(Fh *fh);
 
+  int _do_remount(void);
+  friend class C_Client_Remount;
 
   struct C_Readahead : public Context {
     Client *client;
index ee4fd2976e13ac8c30aaa824fd735492a0d615de..8b1268a30018ef6d3e179dda801b5b57d01ce060 100644 (file)
@@ -415,7 +415,8 @@ OPTION(fuse_require_active_mds, OPT_BOOL, true) // if ceph_fuse requires active
 OPTION(fuse_syncfs_on_mksnap, OPT_BOOL, true)
 
 OPTION(client_try_dentry_invalidate, OPT_BOOL, false) // 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)
+OPTION(client_die_on_failed_remount, OPT_BOOL, false)
+OPTION(client_die_on_failed_dentry_invalidate, OPT_BOOL, true)
 OPTION(client_check_pool_perm, OPT_BOOL, true)
 OPTION(client_use_faked_inos, OPT_BOOL, false)
 OPTION(client_mds_namespace, OPT_INT, -1)