From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 095F8811BB for ; Fri, 6 Nov 2026 15:18:05 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A6FGkH9019219; Fri, 6 Nov 2026 18:16:48 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A6FGkH9019219 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1793978210; bh=ZHj8xl881tlTDy6sYYS4Fds/+2uk+j1Ayu0UdYafVEg=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe; b=amGNFMQsuYHT/mRA5tiiaqZF3EDnlM6lYS1RS1gTR0nhNUSHYhoQRcm35QNeDnTr2 qLk+V1FZZiq+FbwTr37hwvSqs8MAM3rBxJtKppOdcg+3NV087YjxmlBQOHU9ytBoRA zjkxf/q1Z46rOieLNskyJiuL6v2nM5ERGXV2aI172sq3hMYvMV0GpUkDNL9qgz2PQO nOKX4dZEaYpJ5nUvIyCDYvCafq5tZvOuufZiZ4+GMKGkA95JK3ECk8RmFcZPUr8Y65 IoxcYyWwYHN60ZZUW7YZYL0oTKhUZcJJHj0oNUC75jlNy9UDMX5umcy9jj+9teIIZY Hq5bjCjb1/uEQ== Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A6FGiRn019215 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Fri, 6 Nov 2026 18:16:44 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A6FGiRn019215 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="PFY/jSEN" Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-48df02b91f9so1101655f8f.1 for ; Fri, 06 Nov 2026 07:16:44 -0800 (PST) X-Gm-Message-State: APuU4Z/CCw6tUDaSV80CriQtlHtFTcK3Rh/9RZQbGWOOp4ukWEZhsw02 bPA/70me43uRlDoIQG4NQqvgSnBpJeASH2CZBfGcpWQx01KNoCjpP2oh7JuB2of1rh+z2TmlwFx 0jg4esC0I95/LaBfWHJJGZ2uAzP53YnYv1JOFJthvsjXDozIXGWqKdw== X-Gm-Gg: AYBFou3nPynph6LpTm48r1tTfj/ZFoXKLR5NOBLYVfMM/Kzy863xtewe7Wo7b7z/hr6 2su3+xfU6/cHUQkaAm0tMEITEZUd60iu4kKk2fNXfoa0F3kbrwsUgKECcgGWoFRmv0a63+iHjHR 7ttj1jwdy4IUA8GO022uqb/ZFPvxDx7FZ2b7X4OybaLbJ5XVTZMh4D7fMnmH3vFH2IFE2aiW5QJ THUZwitYuxBbfce5lWBhaUOMV6Th4ZxkIqKu5ZVVBT9dKI4IPiJnVLHWf+icLE0w/R2JAf2sSAP J1cGTTUgRw== X-Received: by 2002:a05:6000:470e:b0:48f:bf71:2aeb with SMTP id ffacd0b85a97d-49279d520f6mr5927047f8f.23.1793978204526; Fri, 06 Nov 2026 07:16:44 -0800 (PST) X-Received: by 2002:a05:6000:470e:b0:48f:bf71:2aeb with SMTP id ffacd0b85a97d-49279d520f6mr5926986f8f.23.1793978203980; Fri, 06 Nov 2026 07:16:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793978203; cv=none; d=google.com; s=arc-20260327; b=a7ljbFlRRwcWKV/fSR4Urz0Bc1QmhLa1Q5En+vRaTrUih9Gmvf6qrTmgvbTwM7cI7j lVqMQhURZpZFVw6/yKPj0kPv6YYvhM7puA32exe6+nA6bB96JIsdsWO3WKkbx3cYaNIy glkMwjJm4diL84xc05ULMxxenWXU6AqUsuQ7eGM+WuZ2T9tJgl+t955brvTV5FJeHEN2 J9m0mAwiI6zHq5+Es1ajwm+KJIzbvZcUruwYhKsAiI5rs3dhhHEPSQGwJR4/WbzW+Edg 3ruXHUiGtzAcqoczifOc9Pgsrf1Stk0ENClrBcF5dpgx9XzqfHHjKFt+AoEpyODMehKb 4uFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=YjrZt80ov2f6gggRxE8FgdSdq/ygtUZ45y6+CTHKYxY=; fh=/iS1GdBPiyhj1kkY3RAeT0m3lZnMP1vRR7Rvd5RcISs=; b=LiYyqYW+XXtJVjRaYbYpnTDZZqk2VsiGhb3o/L2k2nBm0whegHBxpgmKPthSYyUKVX eLeXCkw/9Xzi7dp42M+xrzlfGlANL3iKkSb2TTUkPbHNBrbhdMmPi6/AuF2HyW6DQ8tM olgtspao65AI50lnLHqgCwLc+8QVF1L4GNNqFxiXWBcBcLUomPvNq+fM9b7GuWrDC/zM DcSVQNwhAbWn5YkTBTqOIAKNb/MPHsk63r/GQOwBa96mXRU7xFQRZ0TCmQJpc/iGEUDV +PxlwHNwNcIddLYoOD5QkJzfiufnv0BSaXkMZWfirBsnHjPahzBBKd9nZ/IVpWnXMgGO hqzw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b="PFY/jSEN"; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:1488:8e51:f958:9448 as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id ffacd0b85a97d-492d7513bfesor502153f8f.7.2026.11.06.07.16.43 for (Google Transport Security); Fri, 06 Nov 2026 07:16:43 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:1488:8e51:f958:9448 as permitted sender) client-ip=2a06:5b06:b600:300:1488:8e51:f958:9448; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b="PFY/jSEN"; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:1488:8e51:f958:9448 as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1793978203; x=1794583003; darn=openvz.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=YjrZt80ov2f6gggRxE8FgdSdq/ygtUZ45y6+CTHKYxY=; b=PFY/jSENNcxtzB6XhmyFOnet3o5qx5OGatwN+JtccizkJqRm3ia5F9fA1hYQd7LYAN qV5gaW+HUh7jiGPVrdY0DfEktHpqf1WVf9so6dQL62NwwphvfeQkASMr72HteNrv7bSc UZ0GEllfhpLxZzbG5nOoJIh6TlLGwmfw5v+SLlqc9PA3JAiRuskM2cYasPtrkQsCKV4M zgtQVJFHSEjZPTKcFNB2whbBr4ACynvvMnGv0gdP6/RPN8bAbkXNaqfpuC15eJWGz3xB 6Fu0y6T4BCbsni4v1AO+uXDDCfOwb7KxtfM3Z78964oyGGBEliOHv0DLN3EZvDWmWSpl 8lDQ== X-Received: by 2002:a05:6000:2385:b0:492:3f98:506e with SMTP id ffacd0b85a97d-4923f9851f0mr8120805f8f.19.1793978203519; Fri, 06 Nov 2026 07:16:43 -0800 (PST) Received: from athena.sw.ru ([2a06:5b06:b600:300:1488:8e51:f958:9448]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-492d6d6392csm4125959f8f.12.2026.11.06.07.16.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2026 07:16:43 -0800 (PST) From: "Denis V. Lunev" To: khorenko@virtuozzo.com Date: Fri, 6 Nov 2026 16:16:41 +0100 Message-ID: <20261106151641.3980601-1-den@openvz.org> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH vz10] ovl: release the upperdir/workdir in-use locks before the umount sync X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org From: Denis V. Lunev The in-use locks on upperdir and workdir are released by ovl_free_fs() from ->put_super(). generic_shutdown_super() calls sync_filesystem() before that, and ovl_sync_fs() syncs the whole upper filesystem, so the locks stay held across a journal commit and a cache flush of the upper fs after the overlay is gone. With index=on a new overlay that uses the same upperdir, or uses it as a lowerdir, fails to mount in that window: overlayfs: upperdir is in-use as upperdir/workdir of another mount, mount with '-o index=off' to override exclusive upperdir protection. Userspace hits this when the last reference is not dropped by umount(2) itself. Docker with the containerd snapshotter mounts a snapshot on a thread with a private mount namespace for docker cp and for buildkit, and the superblock dies when that thread exits, after the reply to the client has gone out. The next request then gets EBUSY. The window grows with the flush latency of the upper fs and is there even if nothing was written through the overlay, as the mount itself dirties the upper. ->kill_sb() is called once s_active drops to zero, with no mount and no open file left. Release the locks there, before generic_shutdown_super() runs. What the dying superblock still does to the upper fs, the sync and dropping its references to upper dentries and inodes, does not touch the contents of upperdir or workdir. ovl_free_fs() still releases the locks for a failed mount, so clear the *_locked flags to keep it from unlocking a second time and dropping the lock of a newer mount. This takes the sync out of the window but does not close it: the final mntput of a dying mount namespace runs from task_work, after the exiting thread may have reported completion. Userspace that needs the directories free should umount(2) before saying the job is done. https://virtuozzo.atlassian.net/browse/VSTOR-153253 Fixes: 2cac0c00a6cd ("ovl: get exclusive ownership on upper/work dirs") Cc: Pavel Tikhomirov Cc: Konstantin Khorenko Feature: fix ms/overlayfs Signed-off-by: Denis V. Lunev --- fs/overlayfs/overlayfs.h | 1 + fs/overlayfs/params.c | 5 +---- fs/overlayfs/super.c | 12 +++++++++++- fs/overlayfs/util.c | 12 ++++++++++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 8577c7884fb9..2331bd55302c 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -528,6 +528,7 @@ int ovl_set_impure(struct dentry *dentry, struct dentry *upperdentry); bool ovl_inuse_trylock(struct dentry *dentry); void ovl_inuse_unlock(struct dentry *dentry); bool ovl_is_inuse(struct dentry *dentry); +void ovl_inuse_unlock_all(struct ovl_fs *ofs); bool ovl_need_index(struct dentry *dentry); int ovl_nlink_start(struct dentry *dentry); void ovl_nlink_end(struct dentry *dentry); diff --git a/fs/overlayfs/params.c b/fs/overlayfs/params.c index 32c58fcfe52f..c102fb0ac481 100644 --- a/fs/overlayfs/params.c +++ b/fs/overlayfs/params.c @@ -735,12 +735,9 @@ void ovl_free_fs(struct ovl_fs *ofs) iput(ofs->workdir_trap); dput(ofs->whiteout); dput(ofs->workdir); - if (ofs->workdir_locked) - ovl_inuse_unlock(ofs->workbasedir); + ovl_inuse_unlock_all(ofs); dput(ofs->workbasedir); path_put(&ofs->workbasepath); - if (ofs->upperdir_locked) - ovl_inuse_unlock(ovl_upper_mnt(ofs)->mnt_root); path_put(&ofs->upperpath); /* Reuse ofs->config.lowerdirs as a vfsmount array before freeing it */ diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index fb47711c8fb9..8153362caad1 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -1502,13 +1502,23 @@ int ovl_fill_super(struct super_block *sb, struct fs_context *fc) return err; } +static void ovl_kill_sb(struct super_block *sb) +{ + struct ovl_fs *ofs = OVL_FS(sb); + + /* Nothing can modify them now, do not hold them across the sync */ + if (ofs) + ovl_inuse_unlock_all(ofs); + kill_anon_super(sb); +} + struct file_system_type ovl_fs_type = { .owner = THIS_MODULE, .name = "overlay", .init_fs_context = ovl_init_fs_context, .parameters = ovl_parameter_spec, .fs_flags = FS_USERNS_MOUNT | FS_VIRTUALIZED, - .kill_sb = kill_anon_super, + .kill_sb = ovl_kill_sb, }; MODULE_ALIAS_FS("overlay"); diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index f95090f0d29c..817563215001 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -1051,6 +1051,18 @@ bool ovl_is_inuse(struct dentry *dentry) return inuse; } +void ovl_inuse_unlock_all(struct ovl_fs *ofs) +{ + if (ofs->workdir_locked) { + ovl_inuse_unlock(ofs->workbasedir); + ofs->workdir_locked = false; + } + if (ofs->upperdir_locked) { + ovl_inuse_unlock(ovl_upper_mnt(ofs)->mnt_root); + ofs->upperdir_locked = false; + } +} + /* * Does this overlay dentry need to be indexed on copy up? */ -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel