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

Huang Shijie huangsj at hygon.cn
Tue Nov 10 06:29:26 UTC 2026


在 Mon, Nov 09, 2026 at 11:31:41AM +0100,Jan Kara 写道:
> > +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.
Okay.
I will add the ->eligible() function to the iterator in next version.

Thanks
Huang Shijie




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