All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luis Henriques <luis.henriques@linux.dev>
To: linux-ext4@vger.kernel.org
Subject: Old inline-data bug with small block sizes
Date: Mon, 07 Oct 2024 10:28:02 +0100	[thread overview]
Message-ID: <87h69oclel.fsf@linux.dev> (raw)

Hi!

I have a local branch where, some time ago, I tried to fix an old
inline_data bug[1].  The reproducer is easy to run, it just requires a
filesystem with a small block size (I've used 1024).

Looking at it again with fresh eyes I believe the bug could be easily
fixed with the patch below.

My understanding is that, when we are doing a ->read_folio() and there's
inlined data, that inlined data has to be in the first page.  However, if
we get a different page (i.e. not the first one), then we are zero'ing it
and marking it up-to-date.  And that doesn't sound right to me.

The patch bellow fixes things by reverting back to do a regular read in
those cases, because it's not inlined data.  Does it make sense?  Or am I
missing something and not seeing the real bug here?

[1] https://bugzilla.kernel.org/show_bug.cgi?id=200681

Cheers,
-- 
Luís

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 3536ca7e4fcc..ec96038dd75f 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -516,7 +516,8 @@ int ext4_readpage_inline(struct inode *inode, struct folio *folio)
 	int ret = 0;
 
 	down_read(&EXT4_I(inode)->xattr_sem);
-	if (!ext4_has_inline_data(inode)) {
+	if (!ext4_has_inline_data(inode) ||
+	    ((folio->index > 0) && !folio_test_uptodate(folio))) {
 		up_read(&EXT4_I(inode)->xattr_sem);
 		return -EAGAIN;
 	}
@@ -527,10 +528,6 @@ int ext4_readpage_inline(struct inode *inode, struct folio *folio)
 	 */
 	if (!folio->index)
 		ret = ext4_read_inline_folio(inode, folio);
-	else if (!folio_test_uptodate(folio)) {
-		folio_zero_segment(folio, 0, folio_size(folio));
-		folio_mark_uptodate(folio);
-	}
 
 	up_read(&EXT4_I(inode)->xattr_sem);
 

                 reply	other threads:[~2024-10-07  9: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=87h69oclel.fsf@linux.dev \
    --to=luis.henriques@linux.dev \
    --cc=linux-ext4@vger.kernel.org \
    /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.