Skip to contentSkip to conversation

ceph: set osdmap epoch for setxattr.

PATCH In review [email protected] 2 participants 2 messages Dec 9, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: set osdmap epoch for setxattr.

From: Xiubo Li <[email protected]>

When setting the file/dir layout, it may need data pool info. So in mds server, it needs to check the osdmap. At present, if mds doesn't find the data pool specified, it will try to get the latest osdmap. Now if pass the osd epoch for setxattr, the mds server can only check this epoch of osdmap.

URL: https://tracker.ceph.com/issues/48504

---
 fs/ceph/mds_client.c         | 2 +-
 fs/ceph/xattr.c              | 3 +++
 include/linux/ceph/ceph_fs.h | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)
fs/ceph/mds_client.c +1 -1
index 4fab37d858ce..9b5e3975b3ad 100644
@@ -2533,7 +2533,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
 		goto out_free2;
 	}
 
-	msg->hdr.version = cpu_to_le16(2);
+	msg->hdr.version = cpu_to_le16(3);
 	msg->hdr.tid = cpu_to_le64(req->r_tid);
 
 	head = msg->front.iov_base;
fs/ceph/xattr.c +3 -0
index e89750a1f039..a8597cae0ed7 100644
@@ -995,6 +995,7 @@ static int ceph_sync_setxattr(struct inode *inode, const char *name,
 	struct ceph_inode_info *ci = ceph_inode(inode);
 	struct ceph_mds_request *req;
 	struct ceph_mds_client *mdsc = fsc->mdsc;
+	struct ceph_osd_client *osdc = &fsc->client->osdc;
 	struct ceph_pagelist *pagelist = NULL;
 	int op = CEPH_MDS_OP_SETXATTR;
 	int err;
@@ -1033,6 +1034,8 @@ static int ceph_sync_setxattr(struct inode *inode, const char *name,
 
 	if (op == CEPH_MDS_OP_SETXATTR) {
 		req->r_args.setxattr.flags = cpu_to_le32(flags);
+		req->r_args.setxattr.osdmap_epoch =
+			cpu_to_le32(osdc->osdmap->epoch);
 		req->r_pagelist = pagelist;
 		pagelist = NULL;
 	}
include/linux/ceph/ceph_fs.h +1 -0
index 455e9b9e2adf..c0f1b921ec69 100644
@@ -424,6 +424,7 @@ union ceph_mds_request_args {
 	} __attribute__ ((packed)) open;
 	struct {
 		__le32 flags;
+		__le32 osdmap_epoch; /* used for setting file/dir layouts */
 	} __attribute__ ((packed)) setxattr;
 	struct {
 		struct ceph_file_layout_legacy layout;
Signature · 1 line
2.27.0
#1 lore raw
Quoted 58 lines · On Wed, 2020-12-09 at 10:52 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

When setting the file/dir layout, it may need data pool info. So in mds server, it needs to check the osdmap. At present, if mds doesn't find the data pool specified, it will try to get the latest osdmap. Now if pass the osd epoch for setxattr, the mds server can only check this epoch of osdmap.

URL: https://tracker.ceph.com/issues/48504

---

 fs/ceph/mds_client.c         | 2 +-
 fs/ceph/xattr.c              | 3 +++
 include/linux/ceph/ceph_fs.h | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)
fs/ceph/mds_client.c +0 -0
index 4fab37d858ce..9b5e3975b3ad 100644
@@ -2533,7 +2533,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
  		goto out_free2;
  	}

fs/ceph/mds_client.c +1 -1
-	msg->hdr.version = cpu_to_le16(2);
+	msg->hdr.version = cpu_to_le16(3);

  msg->hdr.tid = cpu_to_le64(req->r_tid);

  head = msg->front.iov_base;

fs/ceph/xattr.c +1 -0
index e89750a1f039..a8597cae0ed7 100644
@@ -995,6 +995,7 @@ static int ceph_sync_setxattr(struct inode *inode, const char *name,
  	struct ceph_inode_info *ci = ceph_inode(inode);
  	struct ceph_mds_request *req;
  	struct ceph_mds_client *mdsc = fsc->mdsc;
+	struct ceph_osd_client *osdc = &fsc->client->osdc;
  	struct ceph_pagelist *pagelist = NULL;
  	int op = CEPH_MDS_OP_SETXATTR;
  	int err;
@@ -1033,6 +1034,8 @@ static int ceph_sync_setxattr(struct inode *inode, const char *name,

  if (op == CEPH_MDS_OP_SETXATTR) { req->r_args.setxattr.flags = cpu_to_le32(flags);

fs/ceph/xattr.c +2 -0
+		req->r_args.setxattr.osdmap_epoch =
+			cpu_to_le32(osdc->osdmap->epoch);

  req->r_pagelist = pagelist;
  pagelist = NULL;
  }

include/linux/ceph/ceph_fs.h +0 -0
index 455e9b9e2adf..c0f1b921ec69 100644

include/linux/ceph/ceph_fs.h union ceph_mds_request_args { · line 430

Quoted 7 lines
include/linux/ceph/ceph_fs.h +1 -0
@@ -424,6 +424,7 @@ union ceph_mds_request_args {
  	} __attribute__ ((packed)) open;
  	struct {
  		__le32 flags;
+		__le32 osdmap_epoch; /* used for setting file/dir layouts */
  	} __attribute__ ((packed)) setxattr;
  	struct {
  		struct ceph_file_layout_legacy layout;

Thanks, Xiubo. Merged.

Signature · 1 line
Jeff Layton <[email protected]>