From: Yan, Zheng Date: Sun, 14 Feb 2016 09:27:26 +0000 (+0800) Subject: mds: deny access to file with pool_ns layout if feature is missing X-Git-Tag: v10.1.0~241^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=72ff3421b8c3654eb318b0749c854e01b6c37803;p=ceph.git mds: deny access to file with pool_ns layout if feature is missing Signed-off-by: Yan, Zheng --- diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index c0f82ca60e23..e79d5c381e76 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -2902,8 +2902,9 @@ int CInode::get_xlocker_mask(client_t client) const (linklock.gcaps_xlocker_mask(client) << linklock.get_cap_shift()); } -int CInode::get_caps_allowed_for_client(client_t client) const +int CInode::get_caps_allowed_for_client(Session *session, inode_t *file_i) const { + client_t client = session->info.inst.name.num(); int allowed; if (client == get_loner()) { // as the loner, we get the loner_caps AND any xlocker_caps for things we have xlocked @@ -2913,9 +2914,14 @@ int CInode::get_caps_allowed_for_client(client_t client) const } else { allowed = get_caps_allowed_by_type(CAP_ANY); } - if (inode.inline_data.version != CEPH_INLINE_NONE && - !mdcache->mds->get_session(client)->connection->has_feature(CEPH_FEATURE_MDS_INLINE_DATA)) - allowed &= ~(CEPH_CAP_FILE_RD | CEPH_CAP_FILE_WR); + + if (!is_dir()) { + if ((file_i->inline_data.version != CEPH_INLINE_NONE && + !session->connection->has_feature(CEPH_FEATURE_MDS_INLINE_DATA)) || + (!file_i->layout.pool_ns.empty() && + !session->connection->has_feature(CEPH_FEATURE_FS_FILE_LAYOUT_V2))) + allowed &= ~(CEPH_CAP_FILE_RD | CEPH_CAP_FILE_WR); + } return allowed; } @@ -3198,7 +3204,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session, */ ecap.caps = valid ? get_caps_allowed_by_type(CAP_ANY) : CEPH_STAT_CAP_INODE; if (last == CEPH_NOSNAP || is_any_caps()) - ecap.caps = ecap.caps & get_caps_allowed_for_client(client); + ecap.caps = ecap.caps & get_caps_allowed_for_client(session, file_i); ecap.seq = 0; ecap.mseq = 0; ecap.realm = 0; @@ -3216,7 +3222,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session, if (!no_caps && valid && cap) { int likes = get_caps_liked(); - int allowed = get_caps_allowed_for_client(client); + int allowed = get_caps_allowed_for_client(session, file_i); int issue = (cap->wanted() | likes) & allowed; cap->issue_norevoke(issue); issue = cap->pending(); diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 851e7e71510f..a393b4cbf90a 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -955,7 +955,7 @@ public: int get_caps_allowed_by_type(int type) const; int get_caps_careful() const; int get_xlocker_mask(client_t client) const; - int get_caps_allowed_for_client(client_t client) const; + int get_caps_allowed_for_client(Session *s, inode_t *file_i) const; // caps issued, wanted int get_caps_issued(int *ploner = 0, int *pother = 0, int *pxlocker = 0,