Commit 48490776 authored by Xiubo Li's avatar Xiubo Li Committed by Ilya Dryomov
Browse files

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: default avatarXiubo Li <xiubli@redhat.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 00061645
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -313,8 +313,7 @@ static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq)
	int err = 0;
	u64 len = subreq->len;

	if (ci->i_inline_version != CEPH_INLINE_NONE &&
	    ceph_netfs_issue_op_inline(subreq))
	if (ceph_has_inline_data(ci) && ceph_netfs_issue_op_inline(subreq))
		return;

	req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, vino, subreq->start, &len,
@@ -1439,7 +1438,7 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf)
	     inode, off, ceph_cap_string(got));

	if ((got & (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO)) ||
	    ci->i_inline_version == CEPH_INLINE_NONE) {
	    !ceph_has_inline_data(ci)) {
		CEPH_DEFINE_RW_CONTEXT(rw_ctx, got);
		ceph_add_rw_context(fi, &rw_ctx);
		ret = filemap_fault(vmf);
+1 −1
Original line number Diff line number Diff line
@@ -3005,7 +3005,7 @@ int ceph_get_caps(struct file *filp, int need, int want, loff_t endoff, int *got
		}

		if (S_ISREG(ci->netfs.inode.i_mode) &&
		    ci->i_inline_version != CEPH_INLINE_NONE &&
		    ceph_has_inline_data(ci) &&
		    (_got & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) &&
		    i_size_read(inode) > 0) {
			struct page *page =
+2 −3
Original line number Diff line number Diff line
@@ -241,8 +241,7 @@ static int ceph_init_file_info(struct inode *inode, struct file *file,
	INIT_LIST_HEAD(&fi->rw_contexts);
	fi->filp_gen = READ_ONCE(ceph_inode_to_client(inode)->filp_gen);

	if ((file->f_mode & FMODE_WRITE) &&
	    ci->i_inline_version != CEPH_INLINE_NONE) {
	if ((file->f_mode & FMODE_WRITE) && ceph_has_inline_data(ci)) {
		ret = ceph_uninline_data(file);
		if (ret < 0)
			goto error;
@@ -1650,7 +1649,7 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
		     inode, ceph_vinop(inode), iocb->ki_pos, (unsigned)len,
		     ceph_cap_string(got));

		if (ci->i_inline_version == CEPH_INLINE_NONE) {
		if (!ceph_has_inline_data(ci)) {
			if (!retry_op && (iocb->ki_flags & IOCB_DIRECT)) {
				ret = ceph_direct_read_write(iocb, to,
							     NULL, NULL);
+3 −2
Original line number Diff line number Diff line
@@ -1049,7 +1049,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
	    iinfo->inline_version >= ci->i_inline_version) {
		int cache_caps = CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO;
		ci->i_inline_version = iinfo->inline_version;
		if (ci->i_inline_version != CEPH_INLINE_NONE &&
		if (ceph_has_inline_data(ci) &&
		    (locked_page || (info_caps & cache_caps)))
			fill_inline = true;
	}
@@ -2327,7 +2327,8 @@ int __ceph_do_getattr(struct inode *inode, struct page *locked_page,
		if (inline_version == 0) {
			/* the reply is supposed to contain inline data */
			err = -EINVAL;
		} else if (inline_version == CEPH_INLINE_NONE) {
		} else if (inline_version == CEPH_INLINE_NONE ||
			   inline_version == 1) {
			err = -ENODATA;
		} else {
			err = req->r_reply_info.targeti.inline_len;
+8 −0
Original line number Diff line number Diff line
@@ -1231,6 +1231,14 @@ extern int ceph_pool_perm_check(struct inode *inode, int need);
extern void ceph_pool_perm_destroy(struct ceph_mds_client* mdsc);
int ceph_purge_inode_cap(struct inode *inode, struct ceph_cap *cap, bool *invalidate);

static inline bool ceph_has_inline_data(struct ceph_inode_info *ci)
{
	if (ci->i_inline_version == CEPH_INLINE_NONE ||
	    ci->i_inline_version == 1) /* initial version, no data */
		return false;
	return true;
}

/* file.c */
extern const struct file_operations ceph_file_fops;