diff options
author | Yan, Zheng <zyan@redhat.com> | 2014-11-14 09:39:13 -0500 |
---|---|---|
committer | Ilya Dryomov <idryomov@redhat.com> | 2014-12-17 12:09:53 -0500 |
commit | e20d258d73a8d565b729b6fc0290e060daabd8b8 (patch) | |
tree | da7986234d3e3254571b615dfe87673dfe0c6fbf | |
parent | 28127bdd2f843e996f24b51a70a0592c7ec5c763 (diff) |
ceph: flush inline version
After converting inline data to normal data, client need to flush
the new i_inline_version (CEPH_INLINE_NONE) to MDS. This commit makes
cap messages (sent to MDS) contain inline_version and inline_data.
Client always converts inline data to normal data before data write,
so the inline data length part is always zero.
Signed-off-by: Yan, Zheng <zyan@redhat.com>
-rw-r--r-- | fs/ceph/caps.c | 24 | ||||
-rw-r--r-- | fs/ceph/snap.c | 2 | ||||
-rw-r--r-- | fs/ceph/super.h | 1 |
3 files changed, 23 insertions, 4 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 795afe304871..b93c631c6c87 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c | |||
@@ -975,10 +975,12 @@ static int send_cap_msg(struct ceph_mds_session *session, | |||
975 | kuid_t uid, kgid_t gid, umode_t mode, | 975 | kuid_t uid, kgid_t gid, umode_t mode, |
976 | u64 xattr_version, | 976 | u64 xattr_version, |
977 | struct ceph_buffer *xattrs_buf, | 977 | struct ceph_buffer *xattrs_buf, |
978 | u64 follows) | 978 | u64 follows, bool inline_data) |
979 | { | 979 | { |
980 | struct ceph_mds_caps *fc; | 980 | struct ceph_mds_caps *fc; |
981 | struct ceph_msg *msg; | 981 | struct ceph_msg *msg; |
982 | void *p; | ||
983 | size_t extra_len; | ||
982 | 984 | ||
983 | dout("send_cap_msg %s %llx %llx caps %s wanted %s dirty %s" | 985 | dout("send_cap_msg %s %llx %llx caps %s wanted %s dirty %s" |
984 | " seq %u/%u mseq %u follows %lld size %llu/%llu" | 986 | " seq %u/%u mseq %u follows %lld size %llu/%llu" |
@@ -988,7 +990,10 @@ static int send_cap_msg(struct ceph_mds_session *session, | |||
988 | seq, issue_seq, mseq, follows, size, max_size, | 990 | seq, issue_seq, mseq, follows, size, max_size, |
989 | xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0); | 991 | xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0); |
990 | 992 | ||
991 | msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPS, sizeof(*fc), GFP_NOFS, false); | 993 | /* flock buffer size + inline version + inline data size */ |
994 | extra_len = 4 + 8 + 4; | ||
995 | msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPS, sizeof(*fc) + extra_len, | ||
996 | GFP_NOFS, false); | ||
992 | if (!msg) | 997 | if (!msg) |
993 | return -ENOMEM; | 998 | return -ENOMEM; |
994 | 999 | ||
@@ -1020,6 +1025,14 @@ static int send_cap_msg(struct ceph_mds_session *session, | |||
1020 | fc->gid = cpu_to_le32(from_kgid(&init_user_ns, gid)); | 1025 | fc->gid = cpu_to_le32(from_kgid(&init_user_ns, gid)); |
1021 | fc->mode = cpu_to_le32(mode); | 1026 | fc->mode = cpu_to_le32(mode); |
1022 | 1027 | ||
1028 | p = fc + 1; | ||
1029 | /* flock buffer size */ | ||
1030 | ceph_encode_32(&p, 0); | ||
1031 | /* inline version */ | ||
1032 | ceph_encode_64(&p, inline_data ? 0 : CEPH_INLINE_NONE); | ||
1033 | /* inline data size */ | ||
1034 | ceph_encode_32(&p, 0); | ||
1035 | |||
1023 | fc->xattr_version = cpu_to_le64(xattr_version); | 1036 | fc->xattr_version = cpu_to_le64(xattr_version); |
1024 | if (xattrs_buf) { | 1037 | if (xattrs_buf) { |
1025 | msg->middle = ceph_buffer_get(xattrs_buf); | 1038 | msg->middle = ceph_buffer_get(xattrs_buf); |
@@ -1126,6 +1139,7 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap, | |||
1126 | u64 flush_tid = 0; | 1139 | u64 flush_tid = 0; |
1127 | int i; | 1140 | int i; |
1128 | int ret; | 1141 | int ret; |
1142 | bool inline_data; | ||
1129 | 1143 | ||
1130 | held = cap->issued | cap->implemented; | 1144 | held = cap->issued | cap->implemented; |
1131 | revoking = cap->implemented & ~cap->issued; | 1145 | revoking = cap->implemented & ~cap->issued; |
@@ -1209,13 +1223,15 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap, | |||
1209 | xattr_version = ci->i_xattrs.version; | 1223 | xattr_version = ci->i_xattrs.version; |
1210 | } | 1224 | } |
1211 | 1225 | ||
1226 | inline_data = ci->i_inline_version != CEPH_INLINE_NONE; | ||
1227 | |||
1212 | spin_unlock(&ci->i_ceph_lock); | 1228 | spin_unlock(&ci->i_ceph_lock); |
1213 | 1229 | ||
1214 | ret = send_cap_msg(session, ceph_vino(inode).ino, cap_id, | 1230 | ret = send_cap_msg(session, ceph_vino(inode).ino, cap_id, |
1215 | op, keep, want, flushing, seq, flush_tid, issue_seq, mseq, | 1231 | op, keep, want, flushing, seq, flush_tid, issue_seq, mseq, |
1216 | size, max_size, &mtime, &atime, time_warp_seq, | 1232 | size, max_size, &mtime, &atime, time_warp_seq, |
1217 | uid, gid, mode, xattr_version, xattr_blob, | 1233 | uid, gid, mode, xattr_version, xattr_blob, |
1218 | follows); | 1234 | follows, inline_data); |
1219 | if (ret < 0) { | 1235 | if (ret < 0) { |
1220 | dout("error sending cap msg, must requeue %p\n", inode); | 1236 | dout("error sending cap msg, must requeue %p\n", inode); |
1221 | delayed = 1; | 1237 | delayed = 1; |
@@ -1336,7 +1352,7 @@ retry: | |||
1336 | capsnap->time_warp_seq, | 1352 | capsnap->time_warp_seq, |
1337 | capsnap->uid, capsnap->gid, capsnap->mode, | 1353 | capsnap->uid, capsnap->gid, capsnap->mode, |
1338 | capsnap->xattr_version, capsnap->xattr_blob, | 1354 | capsnap->xattr_version, capsnap->xattr_blob, |
1339 | capsnap->follows); | 1355 | capsnap->follows, capsnap->inline_data); |
1340 | 1356 | ||
1341 | next_follows = capsnap->follows + 1; | 1357 | next_follows = capsnap->follows + 1; |
1342 | ceph_put_cap_snap(capsnap); | 1358 | ceph_put_cap_snap(capsnap); |
diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c index f64576e72b79..ce35fbd4ba5d 100644 --- a/fs/ceph/snap.c +++ b/fs/ceph/snap.c | |||
@@ -516,6 +516,8 @@ void ceph_queue_cap_snap(struct ceph_inode_info *ci) | |||
516 | capsnap->xattr_version = 0; | 516 | capsnap->xattr_version = 0; |
517 | } | 517 | } |
518 | 518 | ||
519 | capsnap->inline_data = ci->i_inline_version != CEPH_INLINE_NONE; | ||
520 | |||
519 | /* dirty page count moved from _head to this cap_snap; | 521 | /* dirty page count moved from _head to this cap_snap; |
520 | all subsequent writes page dirties occur _after_ this | 522 | all subsequent writes page dirties occur _after_ this |
521 | snapshot. */ | 523 | snapshot. */ |
diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 8197a3cf750b..e1aa32d0759d 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h | |||
@@ -161,6 +161,7 @@ struct ceph_cap_snap { | |||
161 | u64 time_warp_seq; | 161 | u64 time_warp_seq; |
162 | int writing; /* a sync write is still in progress */ | 162 | int writing; /* a sync write is still in progress */ |
163 | int dirty_pages; /* dirty pages awaiting writeback */ | 163 | int dirty_pages; /* dirty pages awaiting writeback */ |
164 | bool inline_data; | ||
164 | }; | 165 | }; |
165 | 166 | ||
166 | static inline void ceph_put_cap_snap(struct ceph_cap_snap *capsnap) | 167 | static inline void ceph_put_cap_snap(struct ceph_cap_snap *capsnap) |