]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: wire up the CHECK_CAPS_SYNCHRONOUS flag
authorJeff Layton <jlayton@redhat.com>
Wed, 9 Nov 2016 14:36:07 +0000 (09:36 -0500)
committerJeff Layton <jlayton@redhat.com>
Fri, 11 Nov 2016 11:28:50 +0000 (06:28 -0500)
Ensure that the client will request an immediate journal flush from the
MDS when we'll end up waiting on the flush response. This patch should
fix the fsync codepath, but we may need something similar for syncfs.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/client/Client.cc
src/client/Client.h

index 97de9faafabab13e171bd264f4e7ab62b7452411..31522b934b2665ae91f46cf8bb7d775f64c0e4e0 100644 (file)
@@ -3417,7 +3417,7 @@ void Client::check_caps(Inode *in, unsigned flags)
       if (in->cap_snaps.size())
        flush_snaps(in, true);
       if (in->flushing_caps)
-       flush_caps(in, session);
+       flush_caps(in, session, flags & CHECK_CAPS_SYNCHRONOUS);
     }
 
     int flushing;
@@ -3429,8 +3429,8 @@ void Client::check_caps(Inode *in, unsigned flags)
       flush_tid = 0;
     }
 
-    send_cap(in, session, cap, false, cap_used, wanted, retain, flushing,
-            flush_tid);
+    send_cap(in, session, cap, flags & CHECK_CAPS_SYNCHRONOUS, cap_used, wanted,
+            retain, flushing, flush_tid);
   }
 }
 
@@ -4133,7 +4133,7 @@ void Client::flush_caps()
   }
 }
 
-void Client::flush_caps(Inode *in, MetaSession *session)
+void Client::flush_caps(Inode *in, MetaSession *session, bool sync)
 {
   ldout(cct, 10) << "flush_caps " << in << " mds." << session->mds_num << dendl;
   Cap *cap = in->auth_cap;
@@ -4142,7 +4142,14 @@ void Client::flush_caps(Inode *in, MetaSession *session)
   for (map<ceph_tid_t,int>::iterator p = in->flushing_cap_tids.begin();
        p != in->flushing_cap_tids.end();
        ++p) {
-    send_cap(in, session, cap, false, (get_caps_used(in) | in->caps_dirty()),
+    bool req_sync = false;
+
+    /* If this is a synchronous request, then flush the journal on last one */
+    if (sync && (p->first == in->flushing_cap_tids.rbegin()->first))
+      req_sync = true;
+
+    send_cap(in, session, cap, req_sync,
+            (get_caps_used(in) | in->caps_dirty()),
             in->caps_wanted(), (cap->issued | cap->implemented),
             p->second, p->first);
   }
@@ -9047,7 +9054,7 @@ int Client::_fsync(Inode *in, bool syncdataonly)
   }
   
   if (!syncdataonly && in->dirty_caps) {
-    check_caps(in, CHECK_CAPS_NODELAY);
+    check_caps(in, CHECK_CAPS_NODELAY|CHECK_CAPS_SYNCHRONOUS);
     if (in->flushing_caps)
       flush_tid = last_flush_tid;
   } else ldout(cct, 10) << "no metadata needs to commit" << dendl;
index f9fceb9853b4219796d4fbbf173d2346e99b7341..155385d192f23d3618098fbcff8c45e51466ce8a 100644 (file)
@@ -628,7 +628,7 @@ protected:
   int mark_caps_flushing(Inode *in, ceph_tid_t *ptid);
   void adjust_session_flushing_caps(Inode *in, MetaSession *old_s, MetaSession *new_s);
   void flush_caps();
-  void flush_caps(Inode *in, MetaSession *session);
+  void flush_caps(Inode *in, MetaSession *session, bool sync=false);
   void kick_flushing_caps(MetaSession *session);
   void early_kick_flushing_caps(MetaSession *session);
   void kick_maxsize_requests(MetaSession *session);
@@ -654,6 +654,7 @@ protected:
 
   /* Flags for check_caps() */
 #define CHECK_CAPS_NODELAY     (0x1)
+#define CHECK_CAPS_SYNCHRONOUS (0x2)
 
   void check_caps(Inode *in, unsigned flags);
   void get_cap_ref(Inode *in, int cap);