diff options
author | Sage Weil <sage@inktank.com> | 2014-05-21 20:41:08 -0400 |
---|---|---|
committer | Yan, Zheng <zheng.z.yan@intel.com> | 2014-06-05 21:30:00 -0400 |
commit | b8e69066d8afa8d2670dc697252ff0e5907aafad (patch) | |
tree | fd4969aaae0ba9e39ec7395768ed4b5b67c42b9a /fs/ceph | |
parent | ffe312cf31c7d8616096616d469eb5f6bb8905c0 (diff) |
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>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/mds_client.c | 9 | ||||
-rw-r--r-- | fs/ceph/mds_client.h | 1 |
2 files changed, 9 insertions, 1 deletions
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 2b4d093d0563..7b195107efb2 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -1558,6 +1558,8 @@ ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode) | |||
1558 | init_completion(&req->r_safe_completion); | 1558 | init_completion(&req->r_safe_completion); |
1559 | INIT_LIST_HEAD(&req->r_unsafe_item); | 1559 | INIT_LIST_HEAD(&req->r_unsafe_item); |
1560 | 1560 | ||
1561 | req->r_stamp = CURRENT_TIME; | ||
1562 | |||
1561 | req->r_op = op; | 1563 | req->r_op = op; |
1562 | req->r_direct_mode = mode; | 1564 | req->r_direct_mode = mode; |
1563 | return req; | 1565 | return req; |
@@ -1783,7 +1785,8 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc, | |||
1783 | } | 1785 | } |
1784 | 1786 | ||
1785 | len = sizeof(*head) + | 1787 | 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); | ||
1787 | 1790 | ||
1788 | /* calculate (max) length for cap releases */ | 1791 | /* calculate (max) length for cap releases */ |
1789 | len += sizeof(struct ceph_mds_request_release) * | 1792 | len += sizeof(struct ceph_mds_request_release) * |
@@ -1800,6 +1803,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc, | |||
1800 | goto out_free2; | 1803 | goto out_free2; |
1801 | } | 1804 | } |
1802 | 1805 | ||
1806 | msg->hdr.version = 2; | ||
1803 | msg->hdr.tid = cpu_to_le64(req->r_tid); | 1807 | msg->hdr.tid = cpu_to_le64(req->r_tid); |
1804 | 1808 | ||
1805 | head = msg->front.iov_base; | 1809 | head = msg->front.iov_base; |
@@ -1836,6 +1840,9 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc, | |||
1836 | mds, req->r_old_inode_drop, req->r_old_inode_unless, 0); | 1840 | mds, req->r_old_inode_drop, req->r_old_inode_unless, 0); |
1837 | head->num_releases = cpu_to_le16(releases); | 1841 | head->num_releases = cpu_to_le16(releases); |
1838 | 1842 | ||
1843 | /* time stamp */ | ||
1844 | ceph_encode_copy(&p, &req->r_stamp, sizeof(req->r_stamp)); | ||
1845 | |||
1839 | BUG_ON(p > end); | 1846 | BUG_ON(p > end); |
1840 | msg->front.iov_len = p - msg->front.iov_base; | 1847 | msg->front.iov_len = p - msg->front.iov_base; |
1841 | msg->hdr.front_len = cpu_to_le32(msg->front.iov_len); | 1848 | msg->hdr.front_len = cpu_to_le32(msg->front.iov_len); |
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index e90cfccf93bd..e00737cf523c 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h | |||
@@ -194,6 +194,7 @@ struct ceph_mds_request { | |||
194 | int r_fmode; /* file mode, if expecting cap */ | 194 | int r_fmode; /* file mode, if expecting cap */ |
195 | kuid_t r_uid; | 195 | kuid_t r_uid; |
196 | kgid_t r_gid; | 196 | kgid_t r_gid; |
197 | struct timespec r_stamp; | ||
197 | 198 | ||
198 | /* for choosing which mds to send this request to */ | 199 | /* for choosing which mds to send this request to */ |
199 | int r_direct_mode; | 200 | int r_direct_mode; |