Re: [RFC][PATCH 1/4] fs: create simple_remove() helper

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

 



On Wed 15-05-19 01:18:58, Amir Goldstein wrote:
> There is a common pattern among pseudo filesystems for removing a dentry
> from code paths that are NOT coming from vfs_{unlink,rmdir}, using a
> combination of simple_{unlink,rmdir} and d_delete().
> 
> Create an helper to perform this common operation.  This helper is going
> to be used as a place holder for the new fsnotify_remove() hook.
> 
> Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>

Looks like a good idea. One comment below:

> +/*
> + * Unlike simple_unlink/rmdir, this helper is NOT called from vfs_unlink/rmdir.
> + * Caller must guaranty that d_parent and d_name are stable.
> + */
> +int simple_remove(struct inode *dir, struct dentry *dentry)
> +{
> +	int ret;
> +
> +	dget(dentry);
> +	if (d_is_dir(dentry))
> +		ret = simple_rmdir(dir, dentry);
> +	else
> +		ret = simple_unlink(dir, dentry);
> +
> +	if (!ret)
> +		d_delete(dentry);
> +	dput(dentry);

This dget() - dput() pair looks fishy. After some research I understand why
it's needed but I think it deserves a comment like:

	/*
	 * 'simple_' operations get dentry reference on create/mkdir and drop
	 * it on unlink/rmdir. So we have to get dentry reference here to
	 * protect d_delete() from accessing freed dentry.
	 */

								Honza

-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux