Skip to content

Commit e20d258

Browse files
ukernelidryomov
authored andcommitted
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 <[email protected]>
1 parent 28127bd commit e20d258

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

fs/ceph/caps.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -975,10 +975,12 @@ static int send_cap_msg(struct ceph_mds_session *session,
975975
kuid_t uid, kgid_t gid, umode_t mode,
976976
u64 xattr_version,
977977
struct ceph_buffer *xattrs_buf,
978-
u64 follows)
978+
u64 follows, bool inline_data)
979979
{
980980
struct ceph_mds_caps *fc;
981981
struct ceph_msg *msg;
982+
void *p;
983+
size_t extra_len;
982984

983985
dout("send_cap_msg %s %llx %llx caps %s wanted %s dirty %s"
984986
" seq %u/%u mseq %u follows %lld size %llu/%llu"
@@ -988,7 +990,10 @@ static int send_cap_msg(struct ceph_mds_session *session,
988990
seq, issue_seq, mseq, follows, size, max_size,
989991
xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0);
990992

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);
992997
if (!msg)
993998
return -ENOMEM;
994999

@@ -1020,6 +1025,14 @@ static int send_cap_msg(struct ceph_mds_session *session,
10201025
fc->gid = cpu_to_le32(from_kgid(&init_user_ns, gid));
10211026
fc->mode = cpu_to_le32(mode);
10221027

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+
10231036
fc->xattr_version = cpu_to_le64(xattr_version);
10241037
if (xattrs_buf) {
10251038
msg->middle = ceph_buffer_get(xattrs_buf);
@@ -1126,6 +1139,7 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,
11261139
u64 flush_tid = 0;
11271140
int i;
11281141
int ret;
1142+
bool inline_data;
11291143

11301144
held = cap->issued | cap->implemented;
11311145
revoking = cap->implemented & ~cap->issued;
@@ -1209,13 +1223,15 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,
12091223
xattr_version = ci->i_xattrs.version;
12101224
}
12111225

1226+
inline_data = ci->i_inline_version != CEPH_INLINE_NONE;
1227+
12121228
spin_unlock(&ci->i_ceph_lock);
12131229

12141230
ret = send_cap_msg(session, ceph_vino(inode).ino, cap_id,
12151231
op, keep, want, flushing, seq, flush_tid, issue_seq, mseq,
12161232
size, max_size, &mtime, &atime, time_warp_seq,
12171233
uid, gid, mode, xattr_version, xattr_blob,
1218-
follows);
1234+
follows, inline_data);
12191235
if (ret < 0) {
12201236
dout("error sending cap msg, must requeue %p\n", inode);
12211237
delayed = 1;
@@ -1336,7 +1352,7 @@ void __ceph_flush_snaps(struct ceph_inode_info *ci,
13361352
capsnap->time_warp_seq,
13371353
capsnap->uid, capsnap->gid, capsnap->mode,
13381354
capsnap->xattr_version, capsnap->xattr_blob,
1339-
capsnap->follows);
1355+
capsnap->follows, capsnap->inline_data);
13401356

13411357
next_follows = capsnap->follows + 1;
13421358
ceph_put_cap_snap(capsnap);

fs/ceph/snap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,8 @@ void ceph_queue_cap_snap(struct ceph_inode_info *ci)
516516
capsnap->xattr_version = 0;
517517
}
518518

519+
capsnap->inline_data = ci->i_inline_version != CEPH_INLINE_NONE;
520+
519521
/* dirty page count moved from _head to this cap_snap;
520522
all subsequent writes page dirties occur _after_ this
521523
snapshot. */

fs/ceph/super.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ struct ceph_cap_snap {
161161
u64 time_warp_seq;
162162
int writing; /* a sync write is still in progress */
163163
int dirty_pages; /* dirty pages awaiting writeback */
164+
bool inline_data;
164165
};
165166

166167
static inline void ceph_put_cap_snap(struct ceph_cap_snap *capsnap)

0 commit comments

Comments
 (0)