aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2016-11-10 07:42:03 -0500
committerIlya Dryomov <idryomov@gmail.com>2016-12-12 17:54:28 -0500
commit0ff8bfb394124a7ff4f5a4cd3dc9e8dc52dbe5c9 (patch)
treef744edba8e8da8ae257a2aa5c7f4c903096fda62
parent9670079f5f0a52b4ddcc16c407cfe9ff42633e04 (diff)
ceph: define new argument structure for send_cap_msg
When we get to this many arguments, it's hard to work with positional parameters. send_cap_msg is already at 25 arguments, with more needed. Define a new args structure and pass a pointer to it to send_cap_msg. Eventually it might make sense to embed one of these inside ceph_cap_snap instead of tracking individual fields. Signed-off-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Yan, Zheng <zyan@redhat.com>
-rw-r--r--fs/ceph/caps.c225
1 files changed, 126 insertions, 99 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 483baab2b170..2bb183d764ae 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -987,22 +987,27 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release)
987 __cap_delay_cancel(mdsc, ci); 987 __cap_delay_cancel(mdsc, ci);
988} 988}
989 989
990struct cap_msg_args {
991 struct ceph_mds_session *session;
992 u64 ino, cid, follows;
993 u64 flush_tid, oldest_flush_tid, size, max_size;
994 u64 xattr_version;
995 struct ceph_buffer *xattr_buf;
996 struct timespec atime, mtime, ctime;
997 int op, caps, wanted, dirty;
998 u32 seq, issue_seq, mseq, time_warp_seq;
999 kuid_t uid;
1000 kgid_t gid;
1001 umode_t mode;
1002 bool inline_data;
1003};
1004
990/* 1005/*
991 * Build and send a cap message to the given MDS. 1006 * Build and send a cap message to the given MDS.
992 * 1007 *
993 * Caller should be holding s_mutex. 1008 * Caller should be holding s_mutex.
994 */ 1009 */
995static int send_cap_msg(struct ceph_mds_session *session, 1010static int send_cap_msg(struct cap_msg_args *arg)
996 u64 ino, u64 cid, int op,
997 int caps, int wanted, int dirty,
998 u32 seq, u64 flush_tid, u64 oldest_flush_tid,
999 u32 issue_seq, u32 mseq, u64 size, u64 max_size,
1000 struct timespec *mtime, struct timespec *atime,
1001 struct timespec *ctime, u32 time_warp_seq,
1002 kuid_t uid, kgid_t gid, umode_t mode,
1003 u64 xattr_version,
1004 struct ceph_buffer *xattrs_buf,
1005 u64 follows, bool inline_data)
1006{ 1011{
1007 struct ceph_mds_caps *fc; 1012 struct ceph_mds_caps *fc;
1008 struct ceph_msg *msg; 1013 struct ceph_msg *msg;
@@ -1011,12 +1016,13 @@ static int send_cap_msg(struct ceph_mds_session *session,
1011 1016
1012 dout("send_cap_msg %s %llx %llx caps %s wanted %s dirty %s" 1017 dout("send_cap_msg %s %llx %llx caps %s wanted %s dirty %s"
1013 " seq %u/%u tid %llu/%llu mseq %u follows %lld size %llu/%llu" 1018 " seq %u/%u tid %llu/%llu mseq %u follows %lld size %llu/%llu"
1014 " xattr_ver %llu xattr_len %d\n", ceph_cap_op_name(op), 1019 " xattr_ver %llu xattr_len %d\n", ceph_cap_op_name(arg->op),
1015 cid, ino, ceph_cap_string(caps), ceph_cap_string(wanted), 1020 arg->cid, arg->ino, ceph_cap_string(arg->caps),
1016 ceph_cap_string(dirty), 1021 ceph_cap_string(arg->wanted), ceph_cap_string(arg->dirty),
1017 seq, issue_seq, flush_tid, oldest_flush_tid, 1022 arg->seq, arg->issue_seq, arg->flush_tid, arg->oldest_flush_tid,
1018 mseq, follows, size, max_size, 1023 arg->mseq, arg->follows, arg->size, arg->max_size,
1019 xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0); 1024 arg->xattr_version,
1025 arg->xattr_buf ? (int)arg->xattr_buf->vec.iov_len : 0);
1020 1026
1021 /* flock buffer size + inline version + inline data size + 1027 /* flock buffer size + inline version + inline data size +
1022 * osd_epoch_barrier + oldest_flush_tid */ 1028 * osd_epoch_barrier + oldest_flush_tid */
@@ -1027,56 +1033,53 @@ static int send_cap_msg(struct ceph_mds_session *session,
1027 return -ENOMEM; 1033 return -ENOMEM;
1028 1034
1029 msg->hdr.version = cpu_to_le16(6); 1035 msg->hdr.version = cpu_to_le16(6);
1030 msg->hdr.tid = cpu_to_le64(flush_tid); 1036 msg->hdr.tid = cpu_to_le64(arg->flush_tid);
1031 1037
1032 fc = msg->front.iov_base; 1038 fc = msg->front.iov_base;
1033 memset(fc, 0, sizeof(*fc)); 1039 memset(fc, 0, sizeof(*fc));
1034 1040
1035 fc->cap_id = cpu_to_le64(cid); 1041 fc->cap_id = cpu_to_le64(arg->cid);
1036 fc->op = cpu_to_le32(op); 1042 fc->op = cpu_to_le32(arg->op);
1037 fc->seq = cpu_to_le32(seq); 1043 fc->seq = cpu_to_le32(arg->seq);
1038 fc->issue_seq = cpu_to_le32(issue_seq); 1044 fc->issue_seq = cpu_to_le32(arg->issue_seq);
1039 fc->migrate_seq = cpu_to_le32(mseq); 1045 fc->migrate_seq = cpu_to_le32(arg->mseq);
1040 fc->caps = cpu_to_le32(caps); 1046 fc->caps = cpu_to_le32(arg->caps);
1041 fc->wanted = cpu_to_le32(wanted); 1047 fc->wanted = cpu_to_le32(arg->wanted);
1042 fc->dirty = cpu_to_le32(dirty); 1048 fc->dirty = cpu_to_le32(arg->dirty);
1043 fc->ino = cpu_to_le64(ino); 1049 fc->ino = cpu_to_le64(arg->ino);
1044 fc->snap_follows = cpu_to_le64(follows); 1050 fc->snap_follows = cpu_to_le64(arg->follows);
1045 1051
1046 fc->size = cpu_to_le64(size); 1052 fc->size = cpu_to_le64(arg->size);
1047 fc->max_size = cpu_to_le64(max_size); 1053 fc->max_size = cpu_to_le64(arg->max_size);
1048 if (mtime) 1054 ceph_encode_timespec(&fc->mtime, &arg->mtime);
1049 ceph_encode_timespec(&fc->mtime, mtime); 1055 ceph_encode_timespec(&fc->atime, &arg->atime);
1050 if (atime) 1056 ceph_encode_timespec(&fc->ctime, &arg->ctime);
1051 ceph_encode_timespec(&fc->atime, atime); 1057 fc->time_warp_seq = cpu_to_le32(arg->time_warp_seq);
1052 if (ctime) 1058
1053 ceph_encode_timespec(&fc->ctime, ctime); 1059 fc->uid = cpu_to_le32(from_kuid(&init_user_ns, arg->uid));
1054 fc->time_warp_seq = cpu_to_le32(time_warp_seq); 1060 fc->gid = cpu_to_le32(from_kgid(&init_user_ns, arg->gid));
1055 1061 fc->mode = cpu_to_le32(arg->mode);
1056 fc->uid = cpu_to_le32(from_kuid(&init_user_ns, uid)); 1062
1057 fc->gid = cpu_to_le32(from_kgid(&init_user_ns, gid)); 1063 fc->xattr_version = cpu_to_le64(arg->xattr_version);
1058 fc->mode = cpu_to_le32(mode); 1064 if (arg->xattr_buf) {
1059 1065 msg->middle = ceph_buffer_get(arg->xattr_buf);
1060 fc->xattr_version = cpu_to_le64(xattr_version); 1066 fc->xattr_len = cpu_to_le32(arg->xattr_buf->vec.iov_len);
1061 if (xattrs_buf) { 1067 msg->hdr.middle_len = cpu_to_le32(arg->xattr_buf->vec.iov_len);
1062 msg->middle = ceph_buffer_get(xattrs_buf);
1063 fc->xattr_len = cpu_to_le32(xattrs_buf->vec.iov_len);
1064 msg->hdr.middle_len = cpu_to_le32(xattrs_buf->vec.iov_len);
1065 } 1068 }
1066 1069
1067 p = fc + 1; 1070 p = fc + 1;
1068 /* flock buffer size */ 1071 /* flock buffer size */
1069 ceph_encode_32(&p, 0); 1072 ceph_encode_32(&p, 0);
1070 /* inline version */ 1073 /* inline version */
1071 ceph_encode_64(&p, inline_data ? 0 : CEPH_INLINE_NONE); 1074 ceph_encode_64(&p, arg->inline_data ? 0 : CEPH_INLINE_NONE);
1072 /* inline data size */ 1075 /* inline data size */
1073 ceph_encode_32(&p, 0); 1076 ceph_encode_32(&p, 0);
1074 /* osd_epoch_barrier */ 1077 /* osd_epoch_barrier */
1075 ceph_encode_32(&p, 0); 1078 ceph_encode_32(&p, 0);
1076 /* oldest_flush_tid */ 1079 /* oldest_flush_tid */
1077 ceph_encode_64(&p, oldest_flush_tid); 1080 ceph_encode_64(&p, arg->oldest_flush_tid);
1078 1081
1079 ceph_con_send(&session->s_con, msg); 1082 ceph_con_send(&arg->session->s_con, msg);
1080 return 0; 1083 return 0;
1081} 1084}
1082 1085
@@ -1121,21 +1124,11 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,
1121{ 1124{
1122 struct ceph_inode_info *ci = cap->ci; 1125 struct ceph_inode_info *ci = cap->ci;
1123 struct inode *inode = &ci->vfs_inode; 1126 struct inode *inode = &ci->vfs_inode;
1124 u64 cap_id = cap->cap_id; 1127 struct cap_msg_args arg;
1125 int held, revoking, dropping, keep; 1128 int held, revoking, dropping;
1126 u64 follows, size, max_size;
1127 u32 seq, issue_seq, mseq, time_warp_seq;
1128 struct timespec mtime, atime, ctime;
1129 int wake = 0; 1129 int wake = 0;
1130 umode_t mode;
1131 kuid_t uid;
1132 kgid_t gid;
1133 struct ceph_mds_session *session;
1134 u64 xattr_version = 0;
1135 struct ceph_buffer *xattr_blob = NULL;
1136 int delayed = 0; 1130 int delayed = 0;
1137 int ret; 1131 int ret;
1138 bool inline_data;
1139 1132
1140 held = cap->issued | cap->implemented; 1133 held = cap->issued | cap->implemented;
1141 revoking = cap->implemented & ~cap->issued; 1134 revoking = cap->implemented & ~cap->issued;
@@ -1148,7 +1141,7 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,
1148 ceph_cap_string(revoking)); 1141 ceph_cap_string(revoking));
1149 BUG_ON((retain & CEPH_CAP_PIN) == 0); 1142 BUG_ON((retain & CEPH_CAP_PIN) == 0);
1150 1143
1151 session = cap->session; 1144 arg.session = cap->session;
1152 1145
1153 /* don't release wanted unless we've waited a bit. */ 1146 /* don't release wanted unless we've waited a bit. */
1154 if ((ci->i_ceph_flags & CEPH_I_NODELAY) == 0 && 1147 if ((ci->i_ceph_flags & CEPH_I_NODELAY) == 0 &&
@@ -1177,40 +1170,48 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,
1177 cap->implemented &= cap->issued | used; 1170 cap->implemented &= cap->issued | used;
1178 cap->mds_wanted = want; 1171 cap->mds_wanted = want;
1179 1172
1180 follows = flushing ? ci->i_head_snapc->seq : 0; 1173 arg.ino = ceph_vino(inode).ino;
1181 1174 arg.cid = cap->cap_id;
1182 keep = cap->implemented; 1175 arg.follows = flushing ? ci->i_head_snapc->seq : 0;
1183 seq = cap->seq; 1176 arg.flush_tid = flush_tid;
1184 issue_seq = cap->issue_seq; 1177 arg.oldest_flush_tid = oldest_flush_tid;
1185 mseq = cap->mseq; 1178
1186 size = inode->i_size; 1179 arg.size = inode->i_size;
1187 ci->i_reported_size = size; 1180 ci->i_reported_size = arg.size;
1188 max_size = ci->i_wanted_max_size; 1181 arg.max_size = ci->i_wanted_max_size;
1189 ci->i_requested_max_size = max_size; 1182 ci->i_requested_max_size = arg.max_size;
1190 mtime = inode->i_mtime;
1191 atime = inode->i_atime;
1192 ctime = inode->i_ctime;
1193 time_warp_seq = ci->i_time_warp_seq;
1194 uid = inode->i_uid;
1195 gid = inode->i_gid;
1196 mode = inode->i_mode;
1197 1183
1198 if (flushing & CEPH_CAP_XATTR_EXCL) { 1184 if (flushing & CEPH_CAP_XATTR_EXCL) {
1199 __ceph_build_xattrs_blob(ci); 1185 __ceph_build_xattrs_blob(ci);
1200 xattr_blob = ci->i_xattrs.blob; 1186 arg.xattr_version = ci->i_xattrs.version;
1201 xattr_version = ci->i_xattrs.version; 1187 arg.xattr_buf = ci->i_xattrs.blob;
1188 } else {
1189 arg.xattr_buf = NULL;
1202 } 1190 }
1203 1191
1204 inline_data = ci->i_inline_version != CEPH_INLINE_NONE; 1192 arg.mtime = inode->i_mtime;
1193 arg.atime = inode->i_atime;
1194 arg.ctime = inode->i_ctime;
1195
1196 arg.op = op;
1197 arg.caps = cap->implemented;
1198 arg.wanted = want;
1199 arg.dirty = flushing;
1200
1201 arg.seq = cap->seq;
1202 arg.issue_seq = cap->issue_seq;
1203 arg.mseq = cap->mseq;
1204 arg.time_warp_seq = ci->i_time_warp_seq;
1205
1206 arg.uid = inode->i_uid;
1207 arg.gid = inode->i_gid;
1208 arg.mode = inode->i_mode;
1209
1210 arg.inline_data = ci->i_inline_version != CEPH_INLINE_NONE;
1205 1211
1206 spin_unlock(&ci->i_ceph_lock); 1212 spin_unlock(&ci->i_ceph_lock);
1207 1213
1208 ret = send_cap_msg(session, ceph_vino(inode).ino, cap_id, 1214 ret = send_cap_msg(&arg);
1209 op, keep, want, flushing, seq,
1210 flush_tid, oldest_flush_tid, issue_seq, mseq,
1211 size, max_size, &mtime, &atime, &ctime, time_warp_seq,
1212 uid, gid, mode, xattr_version, xattr_blob,
1213 follows, inline_data);
1214 if (ret < 0) { 1215 if (ret < 0) {
1215 dout("error sending cap msg, must requeue %p\n", inode); 1216 dout("error sending cap msg, must requeue %p\n", inode);
1216 delayed = 1; 1217 delayed = 1;
@@ -1227,15 +1228,41 @@ static inline int __send_flush_snap(struct inode *inode,
1227 struct ceph_cap_snap *capsnap, 1228 struct ceph_cap_snap *capsnap,
1228 u32 mseq, u64 oldest_flush_tid) 1229 u32 mseq, u64 oldest_flush_tid)
1229{ 1230{
1230 return send_cap_msg(session, ceph_vino(inode).ino, 0, 1231 struct cap_msg_args arg;
1231 CEPH_CAP_OP_FLUSHSNAP, capsnap->issued, 0, 1232
1232 capsnap->dirty, 0, capsnap->cap_flush.tid, 1233 arg.session = session;
1233 oldest_flush_tid, 0, mseq, capsnap->size, 0, 1234 arg.ino = ceph_vino(inode).ino;
1234 &capsnap->mtime, &capsnap->atime, 1235 arg.cid = 0;
1235 &capsnap->ctime, capsnap->time_warp_seq, 1236 arg.follows = capsnap->follows;
1236 capsnap->uid, capsnap->gid, capsnap->mode, 1237 arg.flush_tid = capsnap->cap_flush.tid;
1237 capsnap->xattr_version, capsnap->xattr_blob, 1238 arg.oldest_flush_tid = oldest_flush_tid;
1238 capsnap->follows, capsnap->inline_data); 1239
1240 arg.size = capsnap->size;
1241 arg.max_size = 0;
1242 arg.xattr_version = capsnap->xattr_version;
1243 arg.xattr_buf = capsnap->xattr_blob;
1244
1245 arg.atime = capsnap->atime;
1246 arg.mtime = capsnap->mtime;
1247 arg.ctime = capsnap->ctime;
1248
1249 arg.op = CEPH_CAP_OP_FLUSHSNAP;
1250 arg.caps = capsnap->issued;
1251 arg.wanted = 0;
1252 arg.dirty = capsnap->dirty;
1253
1254 arg.seq = 0;
1255 arg.issue_seq = 0;
1256 arg.mseq = mseq;
1257 arg.time_warp_seq = capsnap->time_warp_seq;
1258
1259 arg.uid = capsnap->uid;
1260 arg.gid = capsnap->gid;
1261 arg.mode = capsnap->mode;
1262
1263 arg.inline_data = capsnap->inline_data;
1264
1265 return send_cap_msg(&arg);
1239} 1266}
1240 1267
1241/* 1268/*