Re: [PATCH] ovl: make private mounts longterm

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

 



On Fri, May 22, 2020 at 10:57:23AM +0200, Miklos Szeredi wrote:
> Overlayfs is using clone_private_mount() to create internal mounts for
> underlying layers.  These are used for operations requiring a path, such as
> dentry_open().
> 
> Since these private mounts are not in any namespace they are treated as
> short term, "detached" mounts and mntput() involves taking the global
> mount_lock, which can result in serious cacheline pingpong.
> 
> Make these private mounts longterm instead, which trade the penalty on
> mntput() for a slightly longer shutdown time due to an added RCU grace
> period when putting these mounts.
> 
> Introduce a new helper kern_unmount_many() that can take care of multiple
> longterm mounts with a single RCU grace period.

Umm...

1) Documentation/filesystems/porting - something along the lines
of "clone_private_mount() returns a longterm mount now, so the proper
destructor of its result is kern_unmount()"

2) the name kern_unmount_many() has an unfortunate clash with
fput_many(), with arguments that look similar and mean something
entirely different.  How about kern_unmount_array()?

3)
> -	mntput(ofs->upper_mnt);
> -	for (i = 1; i < ofs->numlayer; i++) {
> -		iput(ofs->layers[i].trap);
> -		mntput(ofs->layers[i].mnt);
> +
> +	if (!ofs->layers) {
> +		/* Deal with partial setup */
> +		kern_unmount(ofs->upper_mnt);
> +	} else {
> +		/* Hack!  Reuse ofs->layers as a mounts array */
> +		struct vfsmount **mounts = (struct vfsmount **) ofs->layers;
> +
> +		for (i = 0; i < ofs->numlayer; i++) {
> +			iput(ofs->layers[i].trap);
> +			mounts[i] = ofs->layers[i].mnt;
> +		}
> +		kern_unmount_many(mounts, ofs->numlayer);
> +		kfree(ofs->layers);

That's _way_ too subtle.  AFAICS, you rely upon ->upper_mnt == ->layers[0].mnt,
->layers[0].trap == NULL, without even mentioning that.  And the hack you do
mention...  Yecchhh...  How many layers are possible, again?



[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux