linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Miklos Szeredi <mszeredi@redhat.com>
Cc: linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ovl: make private mounts longterm
Date: Fri, 22 May 2020 17:08:15 +0100	[thread overview]
Message-ID: <20200522160815.GT23230@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20200522085723.29007-1-mszeredi@redhat.com>

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?

  reply	other threads:[~2020-05-22 16:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22  8:57 [PATCH] ovl: make private mounts longterm Miklos Szeredi
2020-05-22 16:08 ` Al Viro [this message]
2020-05-22 16:32   ` Miklos Szeredi
2020-05-22 17:02     ` Amir Goldstein
2020-05-22 18:53       ` Miklos Szeredi
2020-05-22 19:56         ` Al Viro
2020-05-23  4:07           ` Miklos Szeredi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200522160815.GT23230@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=mszeredi@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).