From: xiubli@redhat.com
To: ceph-devel@vger.kernel.org
Cc: Xiubo Li <xiubli@redhat.com>
Subject: [PATCH] ceph: fall back to use old method to get xattr
Date: Wed, 27 Jul 2022 13:56:37 +0800 [thread overview]
Message-ID: <20220727055637.11949-1-xiubli@redhat.com> (raw)
From: Xiubo Li <xiubli@redhat.com>
If the peer MDS doesn't support getvxattr op then just fall back to
use old getattr method to get it. Or for the old MDSs they will crash
when receive an unknown op.
URL: https://tracker.ceph.com/issues/56529
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
fs/ceph/mds_client.c | 10 ++++++++++
fs/ceph/mds_client.h | 4 +++-
fs/ceph/xattr.c | 9 ++++++---
3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 598012ddc401..bfe6d6393eba 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -3255,6 +3255,16 @@ static void __do_request(struct ceph_mds_client *mdsc,
dout("do_request mds%d session %p state %s\n", mds, session,
ceph_session_state_name(session->s_state));
+
+ /*
+ * The old ceph will crash the MDSs when see unknown OPs
+ */
+ if (req->r_op == CEPH_MDS_OP_GETVXATTR &&
+ !test_bit(CEPHFS_FEATURE_OP_GETVXATTR, &session->s_features)) {
+ err = -EOPNOTSUPP;
+ goto out_session;
+ }
+
if (session->s_state != CEPH_MDS_SESSION_OPEN &&
session->s_state != CEPH_MDS_SESSION_HUNG) {
/*
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
index e15ee2858fef..0e03efab872a 100644
--- a/fs/ceph/mds_client.h
+++ b/fs/ceph/mds_client.h
@@ -31,8 +31,9 @@ enum ceph_feature_type {
CEPHFS_FEATURE_METRIC_COLLECT,
CEPHFS_FEATURE_ALTERNATE_NAME,
CEPHFS_FEATURE_NOTIFY_SESSION_STATE,
+ CEPHFS_FEATURE_OP_GETVXATTR,
- CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_NOTIFY_SESSION_STATE,
+ CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_OP_GETVXATTR,
};
#define CEPHFS_FEATURES_CLIENT_SUPPORTED { \
@@ -45,6 +46,7 @@ enum ceph_feature_type {
CEPHFS_FEATURE_METRIC_COLLECT, \
CEPHFS_FEATURE_ALTERNATE_NAME, \
CEPHFS_FEATURE_NOTIFY_SESSION_STATE, \
+ CEPHFS_FEATURE_OP_GETVXATTR, \
}
/*
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index b10d459c2326..8f8db621772a 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -984,9 +984,12 @@ ssize_t __ceph_getxattr(struct inode *inode, const char *name, void *value,
return err;
} else {
err = ceph_do_getvxattr(inode, name, value, size);
- /* this would happen with a new client and old server combo */
+ /*
+ * This would happen with a new client and old server combo,
+ * then fall back to use old method to get it
+ */
if (err == -EOPNOTSUPP)
- err = -ENODATA;
+ goto handle_non_vxattrs;
return err;
}
handle_non_vxattrs:
@@ -996,7 +999,7 @@ ssize_t __ceph_getxattr(struct inode *inode, const char *name, void *value,
dout("getxattr %p name '%s' ver=%lld index_ver=%lld\n", inode, name,
ci->i_xattrs.version, ci->i_xattrs.index_version);
- if (ci->i_xattrs.version == 0 ||
+ if (ci->i_xattrs.version == 0 || err == -EOPNOTSUPP ||
!((req_mask & CEPH_CAP_XATTR_SHARED) ||
__ceph_caps_issued_mask_metric(ci, CEPH_CAP_XATTR_SHARED, 1))) {
spin_unlock(&ci->i_ceph_lock);
--
2.36.0.rc1
next reply other threads:[~2022-07-27 6:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-27 5:56 xiubli [this message]
2022-07-27 9:05 ` [PATCH] ceph: fall back to use old method to get xattr Luís Henriques
2022-07-27 9:41 ` Xiubo Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220727055637.11949-1-xiubli@redhat.com \
--to=xiubli@redhat.com \
--cc=ceph-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.