From: Dave Chinner <david@fromorbit.com>
To: Zhongwei Cai <sunrise_l@sjtu.edu.cn>
Cc: tytso@mit.edu, adilger.kernel@dilger.ca,
linux-ext4@vger.kernel.org, mingkaidong@gmail.com
Subject: Re: [PATCH] ext4: remove unnecessary ext4_inode_datasync_dirty in read path
Date: Fri, 5 Nov 2021 10:22:26 +1100 [thread overview]
Message-ID: <20211104232226.GD418105@dread.disaster.area> (raw)
In-Reply-To: <ffb199dc-f7ae-ba03-db57-bf7acc3d0636@sjtu.edu.cn>
On Thu, Nov 04, 2021 at 05:29:59PM +0800, Zhongwei Cai wrote:
> On 11/3/21 8:28 AM, Dave Chinner wrote:
> > IOWs, we expect the IOMAP_F_DIRTY flag to be set on all types of
> > iomap mapping calls if the inode is dirty, not just IOMAP_WRITE
> > calls.
>
> Thanks for correction!
>
> > /*
> > * Flags reported by the file system from iomap_begin:
> > *
> > * IOMAP_F_NEW indicates that the blocks have been newly allocated
> > * and need zeroing for areas that no data is copied to.
> > *
> > * IOMAP_F_DIRTY indicates the inode has uncommitted metadata needed
> > * to access written data and requires fdatasync to commit them to
> > * persistent storage. This needs to take into account metadata
> > * changes that *may* be made at IO completion, such as file size
> > * updates from direct IO.
> > *
> > * IOMAP_F_SHARED indicates that the blocks are shared, and will
> > * need to be unshared as part a write.
> > *
> > * IOMAP_F_MERGED indicates that the iomap contains the merge of
> > * multiple block mappings.
> > *
> > * IOMAP_F_BUFFER_HEAD indicates that the file system requires the
> > * use of buffer heads for this mapping.
> > */
>
> According to the comments in include/linux/iomap.h, it seems other
> flags in the iomap indicates the iomap-related status, but the
> IOMAP_F_DIRTY flag only indicates the status of the inode. So can
> I_DIRTY_INODE or I_DIRTY_PAGES flags in the inode replace it?
No. Some filesystems don't track inode metadata dirty status using
the VFS inode; instead they track it more efficiently in internal
inode and/or journal based structures. Hence the only way to get
"inode needs journal flush for data stability" information to
generic IO code is to have a specific per-IO mapping flag for it.
> And for ext4 at least we can do
>
> /*
> * Writes that span EOF might trigger an I/O size update on completion,
> * so consider them to be dirty for the purpose of O_DSYNC, even if
> * there is no other metadata changes being made or are pending.
> */
> if (ext4_inode_datasync_dirty(inode) ||
> - offset + length > i_size_read(inode))
> + ((flags & IOMAP_WRITE) && offset + length > i_size_read(inode)))
> iomap->flags |= IOMAP_F_DIRTY;
>
> , since only writes that span EOF might trigger an update. How
> do you feel about it?
ext4 can do what it likes here, but given that the problem that was
being addressed was avoiding lock contention in
ext4_inode_datasync_dirty(), this appears to be a completely
unnecessary change as it doesn't address the problem being reported.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2021-11-04 23:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-02 2:42 [PATCH] ext4: remove unnecessary ext4_inode_datasync_dirty in read path Zhongwei Cai
2021-11-03 0:28 ` Dave Chinner
2021-11-04 9:29 ` Zhongwei Cai
2021-11-04 23:22 ` Dave Chinner [this message]
2021-11-05 5:28 ` Zhongwei Cai
2021-11-09 4:50 ` Dave Chinner
2021-11-10 8:07 ` Zhongwei Cai
2021-11-11 3:12 ` Dave Chinner
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=20211104232226.GD418105@dread.disaster.area \
--to=david@fromorbit.com \
--cc=adilger.kernel@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=mingkaidong@gmail.com \
--cc=sunrise_l@sjtu.edu.cn \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox