Re: [RFC PATCH 0/3] create simple libfs directory iterator and make efivarfs use it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 18, 2025 at 03:41:08PM -0400, James Bottomley wrote:
> [Note this is built on top of the previous patch to populate path.mnt]
> 
> This turned out to be much simpler than I feared.  The first patch
> breaks out the core of the current dcache_readdir() into an internal
> function with a callback (there should be no functional change).  The
> second adds a new API, simple_iterate_call(), which loops over the
> dentries in the next level and executes a callback for each one and
> the third which removes all the efivarfs superblock and mnt crud and
> replaces it with this simple callback interface.  I think the
> diffstats of the third patch demonstrate how much nicer it is for us:

I suspect that you are making it too generic for its own good.

dcache_readdir() needs to cope with the situation when there are
fuckloads of opened-and-unliked files in there.  That's why we
play those games with cursors under if (need_resched()) there.
That's not the case for efivarfs.  There you really want just
"grab a reference to the next positive, drop the reference we
were given" and that's it.

IOW, find_next_child() instead of scan_positives().  Export that
and it becomes just a simple loop -
	child = NULL;
	while ((child = find_next_child(parent, child)) != NULL) {
		struct inode *inode = d_inode(child);
		struct efivar_entry *entry = efivar_entry(inode);

		err = efivar_entry_size(entry, &size);

		inode_lock(inode);
		i_size_write(inode, err ? 0 : size + sizeof(__u32));
		inode_unlock(inode);

		if (err)
			simple_recursive_removal(child, NULL);
	}
and that's it.  No callbacks, no cursors, no iterators - just an
export of helper already there.




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux