From: Jan Kara <jack@suse.cz>
To: Christoph Hellwig <hch@lst.de>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Eric Van Hensbergen <ericvh@kernel.org>,
Latchesar Ionkov <lucho@ionkov.net>,
Dominique Martinet <asmadeus@codewreck.org>,
Christian Schoenebeck <linux_oss@crudebyte.com>,
Chris Mason <clm@fb.com>, David Sterba <dsterba@suse.com>,
Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
Joseph Qi <joseph.qi@linux.alibaba.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
Josef Bacik <josef@toxicpanda.com>, Jan Kara <jack@suse.cz>,
linux-block@vger.kernel.org, v9fs@lists.linux.dev,
linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org,
linux-fsdevel@vger.kernel.org,
jfs-discussion@lists.sourceforge.net,
ocfs2-devel@lists.linux.dev, linux-xfs@vger.kernel.org,
linux-mm@kvack.org, David Hildenbrand <david@redhat.com>,
Damien Le Moal <dlemoal@kernel.org>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: Re: [PATCH 06/10] mm,btrfs: add a filemap_flush_nr helper
Date: Fri, 24 Oct 2025 14:09:23 +0200 [thread overview]
Message-ID: <myxuxundkuabvgmym5ayqycxjgzjgcxn35ncuxpmdxgwjc7ht4@utx2jecj6wpq> (raw)
In-Reply-To: <20251024080431.324236-7-hch@lst.de>
On Fri 24-10-25 10:04:17, Christoph Hellwig wrote:
> Abstract out the btrfs-specific behavior of kicking off I/O on a number
> of pages on an address_space into a well-defined helper.
>
> Note: there is no kerneldoc comment for the new function because it is
> not part of the public API.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: David Hildenbrand <david@redhat.com>
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/btrfs/inode.c | 13 ++-----------
> include/linux/pagemap.h | 1 +
> mm/filemap.c | 22 ++++++++++++++++++++++
> 3 files changed, 25 insertions(+), 11 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index b97d6c1f7772..d12b8116adde 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -8752,19 +8752,10 @@ static int start_delalloc_inodes(struct btrfs_root *root, long *nr_to_write,
> btrfs_queue_work(root->fs_info->flush_workers,
> &work->work);
> } else {
> - struct writeback_control wbc = {
> - .nr_to_write = *nr_to_write,
> - .sync_mode = WB_SYNC_NONE,
> - .range_start = 0,
> - .range_end = LLONG_MAX,
> - };
> -
> - ret = filemap_fdatawrite_wbc(tmp_inode->i_mapping,
> - &wbc);
> + ret = filemap_flush_nr(tmp_inode->i_mapping,
> + nr_to_write);
> btrfs_add_delayed_iput(inode);
>
> - if (*nr_to_write != LONG_MAX)
> - *nr_to_write = wbc.nr_to_write;
> if (ret || *nr_to_write <= 0)
> goto out;
> }
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index 09b581c1d878..cebdf160d3dd 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -38,6 +38,7 @@ int filemap_invalidate_pages(struct address_space *mapping,
> int write_inode_now(struct inode *, int sync);
> int filemap_fdatawrite(struct address_space *);
> int filemap_flush(struct address_space *);
> +int filemap_flush_nr(struct address_space *mapping, long *nr_to_write);
> int filemap_fdatawait_keep_errors(struct address_space *mapping);
> int filemap_fdatawait_range(struct address_space *, loff_t lstart, loff_t lend);
> int filemap_fdatawait_range_keep_errors(struct address_space *mapping,
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 99d6919af60d..e344b79a012d 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -474,6 +474,28 @@ int filemap_flush(struct address_space *mapping)
> }
> EXPORT_SYMBOL(filemap_flush);
>
> +/*
> + * Start writeback on @nr_to_write pages from @mapping. No one but the existing
> + * btrfs caller should be using this. Talk to linux-mm if you think adding a
> + * new caller is a good idea.
> + */
> +int filemap_flush_nr(struct address_space *mapping, long *nr_to_write)
> +{
> + struct writeback_control wbc = {
> + .nr_to_write = *nr_to_write,
> + .sync_mode = WB_SYNC_NONE,
> + .range_start = 0,
> + .range_end = LLONG_MAX,
> + };
> + int ret;
> +
> + ret = filemap_fdatawrite_wbc(mapping, &wbc);
> + if (!ret)
> + *nr_to_write = wbc.nr_to_write;
> + return ret;
> +}
> +EXPORT_SYMBOL_FOR_MODULES(filemap_flush_nr, "btrfs");
> +
> /**
> * filemap_range_has_page - check if a page exists in range.
> * @mapping: address space within which to check
> --
> 2.47.3
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2025-10-24 12:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-24 8:04 filemap_* writeback interface cleanups v2 Christoph Hellwig
2025-10-24 8:04 ` [PATCH 01/10] mm: don't opencode filemap_fdatawrite_range in filemap_invalidate_inode Christoph Hellwig
2025-10-24 8:04 ` [PATCH 02/10] 9p: don't opencode filemap_fdatawrite_range in v9fs_mmap_vm_close Christoph Hellwig
2025-10-24 8:04 ` [PATCH 03/10] ocfs2: don't opencode filemap_fdatawrite_range in ocfs2_journal_submit_inode_data_buffers Christoph Hellwig
2025-10-24 8:04 ` [PATCH 04/10] btrfs: use the local tmp_inode variable in start_delalloc_inodes Christoph Hellwig
2025-10-24 8:04 ` [PATCH 05/10] btrfs: push struct writeback_control into start_delalloc_inodes Christoph Hellwig
2025-10-30 18:21 ` David Sterba
2025-10-24 8:04 ` [PATCH 06/10] mm,btrfs: add a filemap_flush_nr helper Christoph Hellwig
2025-10-24 12:09 ` Jan Kara [this message]
2025-10-24 8:04 ` [PATCH 07/10] mm: remove __filemap_fdatawrite Christoph Hellwig
2025-10-24 12:11 ` Jan Kara
2025-10-24 8:04 ` [PATCH 08/10] mm: remove filemap_fdatawrite_wbc Christoph Hellwig
2025-10-24 8:04 ` [PATCH 09/10] mm: remove __filemap_fdatawrite_range Christoph Hellwig
2025-10-24 8:04 ` [PATCH 10/10] mm: rename filemap_fdatawrite_range_kick to filemap_flush_range Christoph Hellwig
2025-10-24 12:13 ` Jan Kara
2025-10-29 14:53 ` filemap_* writeback interface cleanups v2 Christian Brauner
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=myxuxundkuabvgmym5ayqycxjgzjgcxn35ncuxpmdxgwjc7ht4@utx2jecj6wpq \
--to=jack@suse.cz \
--cc=asmadeus@codewreck.org \
--cc=brauner@kernel.org \
--cc=clm@fb.com \
--cc=david@redhat.com \
--cc=dlemoal@kernel.org \
--cc=dsterba@suse.com \
--cc=ericvh@kernel.org \
--cc=hch@lst.de \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=jlbec@evilplan.org \
--cc=johannes.thumshirn@wdc.com \
--cc=josef@toxicpanda.com \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=linux_oss@crudebyte.com \
--cc=lucho@ionkov.net \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@lists.linux.dev \
--cc=v9fs@lists.linux.dev \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox