Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp415407ybr; Fri, 22 May 2020 09:35:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUn+TVBkl87WNumJYS5wVSsx1E2jOdxIi3Sl3Xn4Y//1qwt4FgPq00Sxx0CiWIa2DHaW+G X-Received: by 2002:a17:907:9d5:: with SMTP id bx21mr8682004ejc.504.1590165306973; Fri, 22 May 2020 09:35:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590165306; cv=none; d=google.com; s=arc-20160816; b=kqhGJN0e7CjwRYC51DtfDZ220zpnFjdDRQ0uqVEUApQ6b1Kj66mUhl+loTn/ydpb/z gOiL57KAQTMn8IRWXEwTK1uX4pl2bjHvw2DXqRRVj+tPtyrNG4sn+N52nz9sKKCcG5Mn +FMRw4WSdx5ZugtN0VggYcanDetPKAbujxbiYt/ltKaJRlxH6COzeda65QPzrFMrpf64 RMaNl1cu5o1Z98n7GKHwqbEQLbmGgZaYyqG/N7rh7QFMzAldQEO5Js4RK0MA4cUtMo26 Wael1Z/C2Lj00Zug+gpkgEtCPok5UaQK4hQ9znOD/dVeEBPHCIuncA66qDD/YhuAcNKc 4a8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=L4sy0ib9KEdvEVMUccLs1iu3r+olJXF2ra9ooHBixRc=; b=nCq7tY+4nBO4sjwOdluoF1k+i0A1cxeTi3hDTXdRIqi9ouFVfeuFO02v7kxMBoAKjl 9/0a0+lShlG/OGeCx93HR4rY5UT1vBbVQRlmpQhZfGIZBjcU2zdPzQg+Xmgz5EclAqGl m50nRs1ov6a/bQRJVAc6y1tsmbyhH/HHcN9OLH0nq7jD04N9ooFic6NPgAVT0gXU7qnZ bD672QHpUNK/xuIMHF8BMX+l6JwtLMrFb+aCJ7kCHtPXtVDtChcXiSkGWYZup6TVAcFV AFZM380hhso9uIHQUGNFunius1QeO2G4hd+qt1ljQPbiHFnZrLqAP375ZRe+3X+U5V0J pRcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jIclSPKA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si5269995edt.406.2020.05.22.09.34.43; Fri, 22 May 2020 09:35:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jIclSPKA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730510AbgEVQdP (ORCPT + 99 others); Fri, 22 May 2020 12:33:15 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:56137 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730031AbgEVQdO (ORCPT ); Fri, 22 May 2020 12:33:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590165192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=L4sy0ib9KEdvEVMUccLs1iu3r+olJXF2ra9ooHBixRc=; b=jIclSPKARplo1dy+Jy0Vm9JVduZEagBLKBOdPqJ1CgyAoj6kdGRpuatse7fE36Fspg6xdQ OeGdO9rMqbdwv33pKOY0ewE+iEC2IOfs761xqzboF8krJ7/5YQ51a3uHnVGYJDBv4kCIj9 h24Oaxv7O/Xj89BG+fNIB2mQKXmYWtY= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-43-3Sqif6oIMgGLubVHjzNiNg-1; Fri, 22 May 2020 12:33:11 -0400 X-MC-Unique: 3Sqif6oIMgGLubVHjzNiNg-1 Received: by mail-qt1-f197.google.com with SMTP id e44so12325204qta.9 for ; Fri, 22 May 2020 09:33:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=L4sy0ib9KEdvEVMUccLs1iu3r+olJXF2ra9ooHBixRc=; b=APr/kq7iq8KRLr851YC9rH9Iq4b31k3+gtUTIWYjbXpSIJLId9vWkGIC/0+X3YEbKR xOqQ3pE3ouLIj/9M16Gffx1VE9Va+b9YvjEj396i0LyLUf1fZRbogO2I4IsVnMydfqiN YPpQb9R3orrQ1jdaDd2UXifh5Lts9mE+9Y7t+5ApW+/hxBL3dDEarUEQwokhx5B1hJ9p gYaMNKWt5nEPBuorZfwjasf+oipz+yo9XLFQD16mafsZXxorSeO4jTVVodp4L5Hd4Pxo kejZY/u+PbdLkrCngAg91063RNpFrSXFj9N+gnWexcCE/aOHir8RYpZDZ8qxoYjZ6l9x 86tA== X-Gm-Message-State: AOAM530OO6busnu1Tl1JWJEKnq5QVGDhiaje7Yt2TGHNXxFwaUm+Gy6v /tDeb3NMtEAx2GlTdxzXOl/eycZDq1oef55XdY7UL/XGmN2zrHJlhw7KgKCRIfZqQMJ69fMb0iE uKDLZSCawC37+zaXtjV937hlEY0suKghkMq8HfCD+ X-Received: by 2002:a37:8187:: with SMTP id c129mr15675239qkd.211.1590165190418; Fri, 22 May 2020 09:33:10 -0700 (PDT) X-Received: by 2002:a37:8187:: with SMTP id c129mr15675212qkd.211.1590165190105; Fri, 22 May 2020 09:33:10 -0700 (PDT) MIME-Version: 1.0 References: <20200522085723.29007-1-mszeredi@redhat.com> <20200522160815.GT23230@ZenIV.linux.org.uk> In-Reply-To: <20200522160815.GT23230@ZenIV.linux.org.uk> From: Miklos Szeredi Date: Fri, 22 May 2020 18:32:59 +0200 Message-ID: Subject: Re: [PATCH] ovl: make private mounts longterm To: Al Viro Cc: overlayfs , linux-fsdevel , lkml Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 22, 2020 at 6:08 PM Al Viro wrote: > > 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? 500, mounts array would fit inside a page and a page can be allocated with __GFP_NOFAIL. But why bother? It's not all that bad, is it? Thanks, Miklos