From: Zhang Yi <yi.zhang@huaweicloud.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, hch@infradead.org,
brauner@kernel.org, david@fromorbit.com, jack@suse.cz,
willy@infradead.org, yi.zhang@huawei.com,
chengzhihao1@huawei.com, yukuai3@huawei.com
Subject: Re: [PATCH v2 4/6] iomap: correct the dirty length in page mkwrite
Date: Tue, 13 Aug 2024 10:49:21 +0800 [thread overview]
Message-ID: <0ee2814f-2878-bcff-7baf-703327091805@huaweicloud.com> (raw)
In-Reply-To: <20240812164536.GE6043@frogsfrogsfrogs>
On 2024/8/13 0:45, Darrick J. Wong wrote:
> On Mon, Aug 12, 2024 at 08:11:57PM +0800, Zhang Yi wrote:
>> From: Zhang Yi <yi.zhang@huawei.com>
>>
>> When doing page mkwrite, iomap_folio_mkwrite_iter() dirty the entire
>> folio by folio_mark_dirty() even the map length is shorter than one
>> folio. However, on the filesystem with more than one blocks per folio,
>> we'd better to only set counterpart block's dirty bit according to
>> iomap_length(), so open code folio_mark_dirty() and pass the correct
>> length.
>>
>> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
>> ---
>> fs/iomap/buffered-io.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
>> index 79031b7517e5..ac762de9a27f 100644
>> --- a/fs/iomap/buffered-io.c
>> +++ b/fs/iomap/buffered-io.c
>> @@ -1492,7 +1492,10 @@ static loff_t iomap_folio_mkwrite_iter(struct iomap_iter *iter,
>> block_commit_write(&folio->page, 0, length);
>> } else {
>> WARN_ON_ONCE(!folio_test_uptodate(folio));
>> - folio_mark_dirty(folio);
>> +
>> + ifs_alloc(iter->inode, folio, 0);
>> + iomap_set_range_dirty(folio, 0, length);
>> + filemap_dirty_folio(iter->inode->i_mapping, folio);
>
> Is it correct to be doing a lot more work by changing folio_mark_dirty
> to filemap_dirty_folio? Now pagefaults call __mark_inode_dirty which
> they did not before. Also, the folio itself must be marked dirty if any
> of the ifs bitmap is marked dirty, so I don't understand the change
> here.
>
This change is just open code iomap_dirty_folio() and correct the length
that passing to iomap_set_range_dirty().
bool iomap_dirty_folio(struct address_space *mapping, struct folio *folio)
{
struct inode *inode = mapping->host;
size_t len = folio_size(folio);
...
ifs_alloc(inode, folio, 0);
iomap_set_range_dirty(folio, 0, len);
return filemap_dirty_folio(mapping, folio);
}
Before this change, the code also call filemap_dirty_folio() (though
folio_mark_dirty()->iomap_dirty_folio()->filemap_dirty_folio()), so it call
__mark_inode_dirty() too. After this change, filemap_dirty_folio()->
folio_test_set_dirty() will mark the folio dirty. Hence there is no
difference between the two points you mentioned. Am I missing something?
Thanks,
Yi.
>
>> }
>>
>> return length;
>> --
>> 2.39.2
>>
>>
next prev parent reply other threads:[~2024-08-13 2:49 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-12 12:11 [PATCH v2 0/6] iomap: some minor non-critical fixes and improvements when block size < folio size Zhang Yi
2024-08-12 12:11 ` [PATCH v2 1/6] iomap: correct the range of a partial dirty clear Zhang Yi
2024-08-12 16:33 ` Darrick J. Wong
2024-08-13 2:14 ` Zhang Yi
2024-08-14 1:53 ` Dave Chinner
2024-08-12 12:11 ` [PATCH v2 2/6] iomap: support invalidating partial folios Zhang Yi
2024-08-12 16:55 ` Darrick J. Wong
2024-08-12 12:11 ` [PATCH v2 3/6] iomap: advance the ifs allocation if we have more than one blocks per folio Zhang Yi
2024-08-12 12:47 ` yangerkun
2024-08-13 2:21 ` Zhang Yi
2024-08-14 5:32 ` Christoph Hellwig
2024-08-14 7:08 ` Zhang Yi
2024-08-15 6:00 ` Christoph Hellwig
2024-08-16 1:44 ` Zhang Yi
2024-08-17 4:27 ` Zhang Yi
2024-08-17 4:42 ` Matthew Wilcox
2024-08-17 6:16 ` Zhang Yi
2024-08-12 12:11 ` [PATCH v2 4/6] iomap: correct the dirty length in page mkwrite Zhang Yi
2024-08-12 16:45 ` Darrick J. Wong
2024-08-13 2:49 ` Zhang Yi [this message]
2024-08-14 5:36 ` Christoph Hellwig
2024-08-14 7:49 ` Zhang Yi
2024-08-15 5:59 ` Christoph Hellwig
2024-08-16 2:19 ` Zhang Yi
2024-08-17 4:45 ` Matthew Wilcox
2024-08-17 6:43 ` Zhang Yi
2024-08-12 12:11 ` [PATCH v2 5/6] iomap: don't mark blocks uptodate after partial zeroing Zhang Yi
2024-08-12 16:49 ` Darrick J. Wong
2024-08-13 3:01 ` Zhang Yi
2024-08-14 5:39 ` Christoph Hellwig
2024-08-17 4:48 ` Matthew Wilcox
2024-08-17 7:16 ` Zhang Yi
2024-08-12 12:11 ` [PATCH v2 6/6] iomap: reduce unnecessary state_lock when setting ifs uptodate and dirty bits Zhang Yi
2024-08-12 16:54 ` Darrick J. Wong
2024-08-12 17:00 ` Matthew Wilcox
2024-08-13 8:15 ` Zhang Yi
2024-08-14 1:49 ` [PATCH v2 0/6] iomap: some minor non-critical fixes and improvements when block size < folio size Dave Chinner
2024-08-14 2:14 ` Zhang Yi
2024-08-14 2:47 ` Dave Chinner
2024-08-14 3:57 ` Zhang Yi
2024-08-14 5:16 ` Dave Chinner
2024-08-14 6:32 ` Zhang Yi
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=0ee2814f-2878-bcff-7baf-703327091805@huaweicloud.com \
--to=yi.zhang@huaweicloud.com \
--cc=brauner@kernel.org \
--cc=chengzhihao1@huawei.com \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=willy@infradead.org \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).