Thread (8 messages) 8 messages, 2 authors, 2021-11-11

Re: [PATCH] ext4: remove unnecessary ext4_inode_datasync_dirty in read path

From: Zhongwei Cai <hidden>
Date: 2021-11-04 09:30:20

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?

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?

Best,

Zhongwei.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help