mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Jan Kara <jack@suse.cz>
Cc: Josef Bacik <josef@toxicpanda.com>,
	 Miklos Szeredi <miklos@szeredi.hu>,
	Amir Goldstein <amir73il@gmail.com>,
	 Christian Brauner <brauner@kernel.org>,
	 Alexander Viro <viro@zeniv.linux.org.uk>,
	Christoph Hellwig <hch@infradead.org>,
	 Chris Mason <mason@kernel.org>,
	Chengguang Xu <cgxu519@mykernel.net>,
	 linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 4/7] fs: add write_inode_for_sync()
Date: Thu, 19 Nov 2026 19:58:35 +0900	[thread overview]
Message-ID: <875wxt1410.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <2z4x35murtwkmuzosciww63z4hfnnaefitc5qinzazvq4pr7qb@uor7pldovwan>

Jan Kara <jack@suse.cz> writes:

> On Thu 19-11-26 18:47:09, OGAWA Hirofumi wrote:
>> Jan Kara <jack@suse.cz> writes:
>> 
>> > On Wed 18-11-26 17:03:27, Josef Bacik wrote:
>> >> sync_inodes_sb() has the flusher write every dirty inode of a superblock
>> >> with WB_SYNC_ALL and for_sync set.  That writes the pages without waiting
>> >> for them, hands over the timestamps that lazytime has deferred while it
>> >> holds I_SYNC, and calls ->write_inode() in a way that tells the filesystem
>> >> that ->sync_fs() follows, so ext4 does not commit a transaction for every
>> >> inode.
>> >> 
>> >> overlayfs is about to sync some of the inodes of its upper filesystem, and
>> >> none of the exported functions does that for one inode.  write_inode_now()
>> >> and sync_inode_metadata() either do not wait for somebody else who is
>> >> writing the inode and leave deferred timestamps alone, or they wait for the
>> >> pages, clear the error flags of the mapping and make ext4 commit.
>> >> 
>> >> Add a function that writes one inode the way a sync does.
>> >> 
>> >> Nothing calls it yet.
>> >> 
>> >> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
>> >
>> > Looks good. Feel free to add:
>> >
>> > Reviewed-by: Jan Kara <jack@suse.cz>
>> >
>> > Actually Ogawa wanted the very same function for FAT flushing of dirty data
>> > on close so it looks like a generally useful primitive to have. Just the
>> > description of the function is really hard to parse (at least to me as a
>> > non-native speaker). 
>> >
>> >> +/**
>> >> + * write_inode_for_sync - write an inode like a sync of its filesystem does
>> >> + * @inode: inode to write to disk
>> >> + *
>> >> + * This does for one inode what sync_inodes_sb() has the flusher do for every
>> >> + * dirty inode of a superblock.  It writes all dirty pages, the timestamps that
>> >> + * lazytime has deferred and the inode.  It waits for somebody else who is
>> >> + * writing the inode, but not for the pages it writes, and it does not ask the
>> >> + * filesystem to commit anything.
>> >> + *
>> >> + * This is for a caller that syncs some of the inodes of a filesystem.  It has
>> >> + * to wait for the pages with filemap_fdatawait_keep_errors(), like
>> >> + * wait_sb_inodes() does, and to call sync_fs_and_bdev() in the end.
>> >
>> > I'd write:
>> > This writes out inode like e.g. sync(2) would do it. On high level that
>> > means we make sure anything dirty is submitted to the storage but we don't
>> > wait for any completion. In particular, it means we wait if there's
>> > somebody else submitting writeback for the inode (I_SYNC state set), we
>> > make sure all dirty pages are submitted for writeback waiting for locks,
>> > and we treat the inode as dirty if it has dirty timestamps. However we
>> > don't wait for any IO to complete and we don't persist other inode-related
>> > metadata through ->sync_inode_metadata(). If the caller wants data
>> > persistency guarantee, it has to wait for IO completion (e.g. using
>> > filemap_fdatawait_keep_errors()) and also persist common filesystem
>> > metadata using sync_fs_and_bdev().
>> 
>> Looks good (except the name of function though). What I want is, not
>> emulate sync, it is flushing dirty stuff. Now both are same usage
>> though, may not be same by future changes.
>
> The intention behind both users is "reliably submit everything for IO but
> don't wait for IO completion". So I think they overlap not only in the
> implementation and there's good chance they won't diverge...

Possible. However, current implementation is unclear name and boolean
.for_sync. Not combination of clear flags, so it is also possible to
introduce unintended code for flush via sync changes.

Well, anyway, what I wanted is make it clear for future developers.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

  reply	other threads:[~2026-11-19 10:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 17:03 [PATCH v7 0/7] ovl: only sync what was written through the overlay Josef Bacik
2026-11-18 17:03 ` [PATCH v7 1/7] ovl: expand fsync mount options Josef Bacik
2026-11-18 17:03 ` [PATCH v7 2/7] ovl: no fsync=relaxed without data integrity Josef Bacik
2026-11-18 18:00   ` Amir Goldstein
2026-11-18 17:03 ` [PATCH v7 3/7] fs: add sync_fs_and_bdev() Josef Bacik
2026-11-19  8:55   ` Jan Kara
2026-11-18 17:03 ` [PATCH v7 4/7] fs: add write_inode_for_sync() Josef Bacik
2026-11-19  9:14   ` Jan Kara
2026-11-19  9:47     ` OGAWA Hirofumi
2026-11-19  9:59       ` Jan Kara
2026-11-19 10:58         ` OGAWA Hirofumi [this message]
2026-11-18 17:03 ` [PATCH v7 5/7] ovl: add a set of the inodes that a sync has to write Josef Bacik
2026-11-18 17:03 ` [PATCH v7 6/7] ovl: track an inode when it is modified Josef Bacik
2026-11-18 17:03 ` [PATCH v7 7/7] ovl: implement containerized syncfs for overlayfs Josef Bacik
2026-11-18 18:09   ` Amir Goldstein
2026-11-18 18:14 ` [PATCH v7 0/7] ovl: only sync what was written through the overlay Amir Goldstein

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=875wxt1410.fsf@mail.parknet.co.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=cgxu519@mykernel.net \
    --cc=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=josef@toxicpanda.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=mason@kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®