From: Jeff Layton Date: Wed, 9 Nov 2016 14:36:07 +0000 (-0500) Subject: mds: only update change_attr and btime when client sets appropriate feature flags X-Git-Tag: v11.1.0~333^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cdd2220abb471d866d4c57acde6f7aa34986f611;p=ceph.git mds: only update change_attr and btime when client sets appropriate feature flags 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 --- diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 285eebdd3c88..3eff5ebd3e66 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -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(); } } - } /*