Skip to content

Commit b8e6906

Browse files
Sage WeilYan, Zheng
authored andcommitted
ceph: include time stamp in every MDS request
We recently modified the client/MDS protocol to include a timestamp in the client request. This allows ctime updates to follow the client's clock in most cases, which avoids subtle problems when clocks are out of sync and timestamps are updated sometimes by the MDS clock (for most requests) and sometimes by the client clock (for cap writeback). Signed-off-by: Sage Weil <sage@inktank.com>
1 parent ffe312c commit b8e6906

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎fs/ceph/mds_client.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,8 @@ ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode)
15581558
init_completion(&req->r_safe_completion);
15591559
INIT_LIST_HEAD(&req->r_unsafe_item);
15601560

1561+
req->r_stamp = CURRENT_TIME;
1562+
15611563
req->r_op = op;
15621564
req->r_direct_mode = mode;
15631565
return req;
@@ -1783,7 +1785,8 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
17831785
}
17841786

17851787
len = sizeof(*head) +
1786-
pathlen1 + pathlen2 + 2*(1 + sizeof(u32) + sizeof(u64));
1788+
pathlen1 + pathlen2 + 2*(1 + sizeof(u32) + sizeof(u64)) +
1789+
sizeof(struct timespec);
17871790

17881791
/* calculate (max) length for cap releases */
17891792
len += sizeof(struct ceph_mds_request_release) *
@@ -1800,6 +1803,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
18001803
goto out_free2;
18011804
}
18021805

1806+
msg->hdr.version = 2;
18031807
msg->hdr.tid = cpu_to_le64(req->r_tid);
18041808

18051809
head = msg->front.iov_base;
@@ -1836,6 +1840,9 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
18361840
mds, req->r_old_inode_drop, req->r_old_inode_unless, 0);
18371841
head->num_releases = cpu_to_le16(releases);
18381842

1843+
/* time stamp */
1844+
ceph_encode_copy(&p, &req->r_stamp, sizeof(req->r_stamp));
1845+
18391846
BUG_ON(p > end);
18401847
msg->front.iov_len = p - msg->front.iov_base;
18411848
msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);

‎fs/ceph/mds_client.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ struct ceph_mds_request {
194194
int r_fmode; /* file mode, if expecting cap */
195195
kuid_t r_uid;
196196
kgid_t r_gid;
197+
struct timespec r_stamp;
197198

198199
/* for choosing which mds to send this request to */
199200
int r_direct_mode;

0 commit comments

Comments
 (0)