Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ceph: don't get the inline data for new creating files

If the 'i_inline_version' is 1, that means the file is just new
created and there shouldn't have any inline data in it, we should
skip retrieving the inline data from MDS.

This also could help reduce possiblity of dead lock issue introduce
by the inline data and Fcr caps.

Gradually we will remove the inline feature from kclient after ceph's
scrub too have support to unline the inline data, currently this
could help reduce the teuthology test failures.

This is possiblly could also fix a bug that for some old clients if
they couldn't explictly uninline the inline data when writing, the
inline version will keep as 1 always. We may always reading non-exist
data from inline data.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

authored by

Xiubo Li and committed by
Ilya Dryomov
48490776 00061645

+16 -9
+2 -3
fs/ceph/addr.c
··· 313 313 int err = 0; 314 314 u64 len = subreq->len; 315 315 316 - if (ci->i_inline_version != CEPH_INLINE_NONE && 317 - ceph_netfs_issue_op_inline(subreq)) 316 + if (ceph_has_inline_data(ci) && ceph_netfs_issue_op_inline(subreq)) 318 317 return; 319 318 320 319 req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, vino, subreq->start, &len, ··· 1438 1439 inode, off, ceph_cap_string(got)); 1439 1440 1440 1441 if ((got & (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO)) || 1441 - ci->i_inline_version == CEPH_INLINE_NONE) { 1442 + !ceph_has_inline_data(ci)) { 1442 1443 CEPH_DEFINE_RW_CONTEXT(rw_ctx, got); 1443 1444 ceph_add_rw_context(fi, &rw_ctx); 1444 1445 ret = filemap_fault(vmf);
+1 -1
fs/ceph/caps.c
··· 3005 3005 } 3006 3006 3007 3007 if (S_ISREG(ci->netfs.inode.i_mode) && 3008 - ci->i_inline_version != CEPH_INLINE_NONE && 3008 + ceph_has_inline_data(ci) && 3009 3009 (_got & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) && 3010 3010 i_size_read(inode) > 0) { 3011 3011 struct page *page =
+2 -3
fs/ceph/file.c
··· 241 241 INIT_LIST_HEAD(&fi->rw_contexts); 242 242 fi->filp_gen = READ_ONCE(ceph_inode_to_client(inode)->filp_gen); 243 243 244 - if ((file->f_mode & FMODE_WRITE) && 245 - ci->i_inline_version != CEPH_INLINE_NONE) { 244 + if ((file->f_mode & FMODE_WRITE) && ceph_has_inline_data(ci)) { 246 245 ret = ceph_uninline_data(file); 247 246 if (ret < 0) 248 247 goto error; ··· 1649 1650 inode, ceph_vinop(inode), iocb->ki_pos, (unsigned)len, 1650 1651 ceph_cap_string(got)); 1651 1652 1652 - if (ci->i_inline_version == CEPH_INLINE_NONE) { 1653 + if (!ceph_has_inline_data(ci)) { 1653 1654 if (!retry_op && (iocb->ki_flags & IOCB_DIRECT)) { 1654 1655 ret = ceph_direct_read_write(iocb, to, 1655 1656 NULL, NULL);
+3 -2
fs/ceph/inode.c
··· 1049 1049 iinfo->inline_version >= ci->i_inline_version) { 1050 1050 int cache_caps = CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO; 1051 1051 ci->i_inline_version = iinfo->inline_version; 1052 - if (ci->i_inline_version != CEPH_INLINE_NONE && 1052 + if (ceph_has_inline_data(ci) && 1053 1053 (locked_page || (info_caps & cache_caps))) 1054 1054 fill_inline = true; 1055 1055 } ··· 2327 2327 if (inline_version == 0) { 2328 2328 /* the reply is supposed to contain inline data */ 2329 2329 err = -EINVAL; 2330 - } else if (inline_version == CEPH_INLINE_NONE) { 2330 + } else if (inline_version == CEPH_INLINE_NONE || 2331 + inline_version == 1) { 2331 2332 err = -ENODATA; 2332 2333 } else { 2333 2334 err = req->r_reply_info.targeti.inline_len;
+8
fs/ceph/super.h
··· 1231 1231 extern void ceph_pool_perm_destroy(struct ceph_mds_client* mdsc); 1232 1232 int ceph_purge_inode_cap(struct inode *inode, struct ceph_cap *cap, bool *invalidate); 1233 1233 1234 + static inline bool ceph_has_inline_data(struct ceph_inode_info *ci) 1235 + { 1236 + if (ci->i_inline_version == CEPH_INLINE_NONE || 1237 + ci->i_inline_version == 1) /* initial version, no data */ 1238 + return false; 1239 + return true; 1240 + } 1241 + 1234 1242 /* file.c */ 1235 1243 extern const struct file_operations ceph_file_fops; 1236 1244