From: "Pankaj Raghav (Samsung)" <pankaj.raghav@linux.dev>
To: Jan Kara <jack@suse.cz>
Cc: Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org,
Andreas Gruenbacher <agruenba@redhat.com>,
gfs2@lists.linux.dev, Mike Marshall <hubcap@omnibond.com>,
Martin Brandenburg <martin@omnibond.com>,
devel@lists.orangefs.org, Dave Kleikamp <shaggy@kernel.org>,
jfs-discussion@lists.sourceforge.net,
Carlos Maiolino <cem@kernel.org>,
linux-xfs@vger.kernel.org, David Howells <dhowells@redhat.com>,
Marc Dionne <marc.dionne@auristor.com>,
linux-afs@lists.infradead.org,
Miklos Szeredi <miklos@szeredi.hu>,
fuse-devel@lists.linux.dev, linux-block@vger.kernel.org,
Chuck Lever <cel@kernel.org>, Jeff Layton <jlayton@kernel.org>,
linux-nfs@vger.kernel.org, Eric Biggers <ebiggers@kernel.org>,
Jaegeuk Kim <jaegeuk@kernel.org>,
linux-fscrypt@vger.kernel.org
Subject: Re: [PATCH 01/13] bdev: Drop pointless loop from blkdev_flush_mapping()
Date: Fri, 20 Nov 2026 13:51:14 +0100 [thread overview]
Message-ID: <awBAeS9ROaFyOjzB@quentin> (raw)
In-Reply-To: <20261118145941.1063127-14-jack@suse.cz>
On Wed, Nov 18, 2026 at 03:59:35PM +0100, Jan Kara wrote:
> bdev_write_inode() is really odd loop calling write_inode_now(). The
> bdev doesn't have any pages by now and if there are any dirty bits in
> the inode state, they are stale. Just call write_inode_now() once to
> clear them.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
When I looked at the commit that introduced bdev_write_inode()[1], it says
to call write_inode_now() on the final put of the block device. At the
moment, tt looks like we call bdev_write_inode() only when bd_openers is 0.
Looks good,
Reviewed-by: Pankaj Raghav (Samsung) <pankaj.raghav@linux.dev>
--
Pankaj
[1] 564f00f6c03a ("block_dev: only write bdev inode on close")
> ---
> block/bdev.c | 25 ++++++-------------------
> 1 file changed, 6 insertions(+), 19 deletions(-)
>
> diff --git a/block/bdev.c b/block/bdev.c
> index f20f91b3176e..9fa72df4f47a 100644
> --- a/block/bdev.c
> +++ b/block/bdev.c
> @@ -60,24 +60,6 @@ struct block_device *file_bdev(struct file *bdev_file)
> }
> EXPORT_SYMBOL(file_bdev);
>
> -static void bdev_write_inode(struct block_device *bdev)
> -{
> - struct inode *inode = BD_INODE(bdev);
> - int ret;
> -
> - spin_lock(&inode->i_lock);
> - while (inode_state_read(inode) & I_DIRTY) {
> - spin_unlock(&inode->i_lock);
> - ret = write_inode_now(inode, true);
> - if (ret)
> - pr_warn_ratelimited(
> - "VFS: Dirty inode writeback failed for block device %pg (err=%d).\n",
> - bdev, ret);
> - spin_lock(&inode->i_lock);
> - }
> - spin_unlock(&inode->i_lock);
> -}
> -
> /* Kill _all_ buffers and pagecache , dirty or not.. */
> static void kill_bdev(struct block_device *bdev)
> {
> @@ -755,7 +737,12 @@ static void blkdev_flush_mapping(struct block_device *bdev)
> WARN_ON_ONCE(bdev->bd_holders);
> sync_blockdev(bdev);
> kill_bdev(bdev);
> - bdev_write_inode(bdev);
> + /*
> + * All data is written out and evicted but inode can have some stale
> + * I_DIRTY bits set. Call write_inode_now() to get rid of them so that
> + * the inode can be evicted.
> + */
> + write_inode_now(BD_INODE(bdev), 1);
> }
>
> static void blkdev_put_whole(struct block_device *bdev)
> --
> 2.53.0
>
next prev parent reply other threads:[~2026-11-20 12:51 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 14:59 [PATCH v2 0/13] fs: Various I_DIRTY_* state handling fixes Jan Kara
2026-11-18 14:59 ` [PATCH 01/13] bdev: Drop pointless loop from blkdev_flush_mapping() Jan Kara
2026-11-20 12:51 ` Pankaj Raghav (Samsung) [this message]
2026-11-18 14:59 ` [PATCH 02/13] xfs: Drop pointless I_DIRTY_PAGES check in xfs_can_free_cowblocks() Jan Kara
2026-11-20 13:11 ` Pankaj Raghav (Samsung)
2026-11-18 14:59 ` [PATCH 03/13] orangefs: Check PAGECACHE_TAG_DIRTY instead of I_DIRTY_PAGES inode state Jan Kara
2026-11-18 14:59 ` [PATCH 04/13] fs: Provide inode_is_dirty() helper Jan Kara
2026-11-18 14:59 ` [PATCH 05/13] jfs: Use inode_is_dirty() in jfs_fsync() Jan Kara
2026-11-18 14:59 ` [PATCH 06/13] gfs2: Avoid racy dirtiness check in gfs2_fsync() Jan Kara
2026-11-18 23:35 ` Andreas Gruenbacher
2026-11-19 12:05 ` Jan Kara
2026-11-19 12:17 ` Andreas Gruenbacher
2026-11-19 17:23 ` Jan Kara
2026-11-18 14:59 ` [PATCH 07/13] fuse: Use inode_is_dirty() check in fuse_evict_inode() Jan Kara
2026-11-18 14:59 ` [PATCH 08/13] fs: Provide inode_or_folios_dirty() helper Jan Kara
2026-11-19 0:25 ` Andreas Gruenbacher
2026-11-19 11:47 ` Jan Kara
2026-11-18 14:59 ` [PATCH 09/13] gfs2: Fix dirtiness checks in gfs2_write_inode() and evict_linked_inode() Jan Kara
2026-11-19 0:12 ` Andreas Gruenbacher
2026-11-18 14:59 ` [PATCH 10/13] afs: Use inode_or_folios_dirty() in afs_evict_inode() Jan Kara
2026-11-18 14:59 ` [PATCH 11/13] nfsd: Use inode_or_folios_dirty() for dirtiness check in wait_for_concurrent_writes() Jan Kara
2026-11-18 14:59 ` [PATCH 12/13] fscrypt: Use inode_or_folios_dirty() instead of explicit state check Jan Kara
2026-11-18 14:59 ` [PATCH 13/13] fs: Use inode_or_folios_dirty() in __inode_lru_list_add() Jan Kara
2026-11-20 16:28 ` [PATCH v2 0/13] fs: Various I_DIRTY_* state handling fixes Christian Brauner
-- strict thread matches above, loose matches on Subject: below --
2026-11-13 8:47 [PATCH " Jan Kara
2026-11-13 8:47 ` [PATCH 01/13] bdev: Drop pointless loop from blkdev_flush_mapping() Jan Kara
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=awBAeS9ROaFyOjzB@quentin \
--to=pankaj.raghav@linux.dev \
--cc=agruenba@redhat.com \
--cc=brauner@kernel.org \
--cc=cel@kernel.org \
--cc=cem@kernel.org \
--cc=devel@lists.orangefs.org \
--cc=dhowells@redhat.com \
--cc=ebiggers@kernel.org \
--cc=fuse-devel@lists.linux.dev \
--cc=gfs2@lists.linux.dev \
--cc=hubcap@omnibond.com \
--cc=jack@suse.cz \
--cc=jaegeuk@kernel.org \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=jlayton@kernel.org \
--cc=linux-afs@lists.infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=marc.dionne@auristor.com \
--cc=martin@omnibond.com \
--cc=miklos@szeredi.hu \
--cc=shaggy@kernel.org \
/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.