All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: ceph-devel@vger.kernel.org
Cc: pdonnell@redhat.com, idryomov@gmail.com
Subject: [PATCH] ceph: fix the inline data handling
Date: Mon, 22 Feb 2021 09:23:32 -0500	[thread overview]
Message-ID: <20210222142332.256981-1-jlayton@kernel.org> (raw)

Patrick saw some testcase failures with inlined data enabled. While it
is true that the data is uninlined before write_begin is called, the
i_inline_version is not updated until much later, after the write is
complete, when the caps are dirtied.

Fix the code to allow for write_begin on the first page of a
still-inlined inode, as long as the page is still Uptodate.

Reported-by: Patrick Donnelly <pdonnell@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/addr.c | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

This is a fix for the netfs conversion. If this tests out OK, I'll plan
to fold this fix into the write_begin conversion.

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 7b0980980ac0..f7c3247616d9 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1234,29 +1234,30 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping,
 	pgoff_t index = pos >> PAGE_SHIFT;
 	int r;
 
+	/*
+	 * Uninlining should have already been done and everything updated, EXCEPT
+	 * for inline_version sent to the MDS.
+	 */
 	if (ci->i_inline_version != CEPH_INLINE_NONE) {
-		/*
-		 * In principle, we should never get here, as the inode should have been uninlined
-		 * before we're allowed to write to the page (in write_iter or page_mkwrite).
-		 */
-		WARN_ONCE(1, "ceph: write_begin called on still-inlined inode!\n");
+		page = grab_cache_page_write_begin(mapping, index, flags);
+		if (!page)
+			return -ENOMEM;
 
 		/*
-		 * Uptodate inline data should have been added
-		 * into page cache while getting Fcr caps.
+		 * The inline_version on a new inode is set to 1. If that's the
+		 * case, then the page is brand new and isn't yet Uptodate.
 		 */
-		if (index == 0) {
-			r = -EINVAL;
+		r = 0;
+		if (index == 0 && ci->i_inline_version != 1) {
+			if (!PageUptodate(page)) {
+				WARN_ONCE(1, "ceph: write_begin called on still-inlined inode (inline_version %llu)!\n",
+					  ci->i_inline_version);
+				r = -EINVAL;
+			}
 			goto out;
 		}
-
-		page = grab_cache_page_write_begin(mapping, index, flags);
-		if (!page)
-			return -ENOMEM;
-
 		zero_user_segment(page, 0, PAGE_SIZE);
 		SetPageUptodate(page);
-		r = 0;
 		goto out;
 	}
 
@@ -1442,9 +1443,6 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf)
 	return ret;
 }
 
-/*
- * Reuse write_begin here for simplicity.
- */
 static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf)
 {
 	struct vm_area_struct *vma = vmf->vma;
-- 
2.29.2


                 reply	other threads:[~2021-02-22 14:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210222142332.256981-1-jlayton@kernel.org \
    --to=jlayton@kernel.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=pdonnell@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.