]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: only update change_attr and btime when client sets appropriate feature flags
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)
The kernel client lags the userland code a bit, and feature support for
addr2 is not quite ready. Still, we want to allow the client to set the
new flags field in a cap request before then so it can get better fsync
performance.

When we go to update the cap fields, grab the features from the peer,
and verify that the appropriate flags are set before we apply updates
to the btime and change_attr.

Also, just have the function return early if dirty is 0, since it's
a no-op in that case, and turn the comment above the function into
an assertion.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/mds/Locker.cc

index 285eebdd3c88ba5a7b9426cd8b5b699f30b40920..3eff5ebd3e663801c3ab931a259d1eed96a194b6 100644 (file)
@@ -2994,19 +2994,23 @@ void Locker::_do_snap_update(CInode *in, snapid_t snap, int dirty, snapid_t foll
                                                                 ack));
 }
 
-/**
- * m might be NULL, so don't dereference it unless dirty != 0.
- */
 void Locker::_update_cap_fields(CInode *in, int dirty, MClientCaps *m, inode_t *pi)
 {
+  if (dirty == 0)
+    return;
 
-  if (dirty && m->get_ctime() > pi->ctime) {
+  /* m must be valid if there are dirty caps */
+  assert(m);
+  uint64_t features = m->get_connection()->get_features();
+
+  if (m->get_ctime() > pi->ctime) {
     dout(7) << "  ctime " << pi->ctime << " -> " << m->get_ctime()
            << " for " << *in << dendl;
     pi->ctime = m->get_ctime();
   }
 
-  if (dirty && m->get_change_attr() > pi->change_attr) {
+  if ((features & CEPH_FEATURE_FS_CHANGE_ATTR) &&
+      m->get_change_attr() > pi->change_attr) {
     dout(7) << "  change_attr " << pi->change_attr << " -> " << m->get_change_attr()
            << " for " << *in << dendl;
     pi->change_attr = m->get_change_attr();
@@ -3073,14 +3077,13 @@ void Locker::_update_cap_fields(CInode *in, int dirty, MClientCaps *m, inode_t *
              << " for " << *in << dendl;
       pi->mode = m->head.mode;
     }
-    if (m->get_btime() != pi->btime) {
+    if ((features & CEPH_FEATURE_FS_BTIME) && m->get_btime() != pi->btime) {
       dout(7) << "  btime " << oct << pi->btime
              << " -> " << m->get_btime() << dec
              << " for " << *in << dendl;
       pi->btime = m->get_btime();
     }
   }
-
 }
 
 /*