[PATCH 3/3] vfs: convert sb->s_inodes iteration to super_iter_inodes()

Jan Kara jack at suse.cz
Mon Nov 9 10:31:41 UTC 2026


On Thu 15-10-26 17:38:54, Huang Shijie wrote:
> Convert all the remaining superblock inode iterators to use
> super_iter_inodes(). These are mostly straight forward conversions
> for the iterations that use referenced inodes:
>  - sync_bdevs
>  - drop_pagecache_sb
>  - gfs2_kill_sb
>  - add_dquot_ref
>  - hook_sb_delete

...
 
> Signed-off-by: Huang Shijie <huangsj at hygon.cn>
> diff --git a/block/bdev.c b/block/bdev.c
> index 18b4423b4e61..b263b566056f 100644
> --- a/block/bdev.c
> +++ b/block/bdev.c
> @@ -1340,56 +1340,36 @@ void bdev_mark_dead(struct block_device *bdev, bool surprise)
>   */
>  EXPORT_SYMBOL_GPL(bdev_mark_dead);
>  
> -void sync_bdevs(bool wait)
> +static int sync_bdev_fn(struct inode *inode, void *data)
>  {
> -	struct inode *inode, *old_inode = NULL;
> +	struct block_device *bdev;
> +	bool wait = *(bool *)data;
>  
> -	spin_lock(&blockdev_superblock->s_inode_list_lock);
> -	list_for_each_entry(inode, &blockdev_superblock->s_inodes, i_sb_list) {
> -		struct address_space *mapping = inode->i_mapping;
> -		struct block_device *bdev;
> +	if (inode->i_mapping->nrpages == 0)

Seeing these various checks iterators are doing before actually paying the
cost of grabbing (and dropping) the inode reference, I'd add a
->elegible(inode) function to the iterator which will get called under
i_lock after other checks pass and can decide inode is not worth bothering
with and put the checks there. If it is NULL, the behavior would be as
currently.

								Honza
-- 
Jan Kara <jack at suse.com>
SUSE Labs, CR



More information about the Linux-security-module-archive mailing list