All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luis Henriques <lhenriques@suse.de>
To: Daniel Dawson <danielcdawson@gmail.com>
Cc: Theodore Ts'o <tytso@mit.edu>,
	 Andreas Dilger <adilger.kernel@dilger.ca>,
	 linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [inline_data] ext4: Stale flags before sync when convert to non-inline
Date: Wed, 24 Jan 2024 17:13:18 +0000	[thread overview]
Message-ID: <87jznyr6xd.fsf@suse.de> (raw)
In-Reply-To: <358aaf68-0618-41e6-9adf-04e211eb690e@gmail.com> (Daniel Dawson's message of "Mon, 22 Jan 2024 21:56:28 -0800")

Daniel Dawson <danielcdawson@gmail.com> writes:

> On 11/28/23 10:15 PM, Daniel Dawson wrote:
>> When a file is converted from inline to non-inline, it has stale flags until
>> sync.
>
>> Why is this a problem? Because some code will fail under such a condition, for
>> example, lseek(..., SEEK_HOLE) will result in ENOENT.
>
>
> Just tested. Still happening on 6.8-rc1.

FWIW, I've been looking into a similar issue related with inline-data and
delayed allocation.  It may however be quite different because it seems to
add small block sizes into the mix:

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

Unfortunately, I'm still trying to find my way around all this code and I
can't say I fully understand the whole flow using the reproducer provided
in that bugzilla.

Bellow, I'm inlining a patch that started as debug patch that I've used to
try to understand what was going on.  It seems to workaround that bug, but
I know it's not a real fix -- I don't yet understand what's going on.

Regarding your specific usecase, I can reproduce it and, unfortunately, I
don't thing Ted's suggestion will fix it as I don't even see
ext4_iomap_begin_report() being executed at all.  Anyway, just my 2
cents... let's see if I can come up with something.

Cheers,
-- 
Luís

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index d5bd1e3a5d36..d0c3d6fd48de 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -528,7 +528,19 @@ 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));
+		struct buffer_head *bh, *head;
+		size_t start = 0;
+
+		head = folio_buffers(folio);
+		if (head) {
+			bh = head;
+			do {
+				if (!buffer_uptodate(bh))
+					break;
+				start += inode->i_sb->s_blocksize;
+			} while ((bh = bh->b_this_page) != head);
+		}
+		folio_zero_segment(folio, start, folio_size(folio));
 		folio_mark_uptodate(folio);
 	}

  reply	other threads:[~2024-01-24 17:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29  6:15 [inline_data] ext4: Stale flags before sync when convert to non-inline Daniel Dawson
2023-11-29 20:05 ` Daniel Dawson
2023-11-30  4:06 ` Theodore Ts'o
2023-12-28  9:29   ` Daniel Dawson
2024-01-23  5:56 ` Daniel Dawson
2024-01-24 17:13   ` Luis Henriques [this message]
2024-01-28 12:06     ` Daniel Dawson
2024-01-29 11:17       ` Luis Henriques

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=87jznyr6xd.fsf@suse.de \
    --to=lhenriques@suse.de \
    --cc=adilger.kernel@dilger.ca \
    --cc=danielcdawson@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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.