lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <myxuxundkuabvgmym5ayqycxjgzjgcxn35ncuxpmdxgwjc7ht4@utx2jecj6wpq>
Date: Fri, 24 Oct 2025 14:09:23 +0200
From: Jan Kara <jack@...e.cz>
To: Christoph Hellwig <hch@....de>
Cc: "Matthew Wilcox (Oracle)" <willy@...radead.org>, 
	Eric Van Hensbergen <ericvh@...nel.org>, Latchesar Ionkov <lucho@...kov.net>, 
	Dominique Martinet <asmadeus@...ewreck.org>, Christian Schoenebeck <linux_oss@...debyte.com>, 
	Chris Mason <clm@...com>, David Sterba <dsterba@...e.com>, Mark Fasheh <mark@...heh.com>, 
	Joel Becker <jlbec@...lplan.org>, Joseph Qi <joseph.qi@...ux.alibaba.com>, 
	Alexander Viro <viro@...iv.linux.org.uk>, Christian Brauner <brauner@...nel.org>, 
	Josef Bacik <josef@...icpanda.com>, Jan Kara <jack@...e.cz>, linux-block@...r.kernel.org, 
	v9fs@...ts.linux.dev, linux-btrfs@...r.kernel.org, linux-ext4@...r.kernel.org, 
	linux-fsdevel@...r.kernel.org, jfs-discussion@...ts.sourceforge.net, 
	ocfs2-devel@...ts.linux.dev, linux-xfs@...r.kernel.org, linux-mm@...ck.org, 
	David Hildenbrand <david@...hat.com>, Damien Le Moal <dlemoal@...nel.org>, 
	Johannes Thumshirn <johannes.thumshirn@....com>
Subject: Re: [PATCH 06/10] mm,btrfs: add a filemap_flush_nr helper

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@....de>
> Reviewed-by: David Hildenbrand <david@...hat.com>
> Reviewed-by: Damien Le Moal <dlemoal@...nel.org>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@....com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@...e.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@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ