Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp952142imm; Thu, 31 May 2018 12:20:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKZIhLtnbQsR4NWrvObr9QpQWYKZ9EbYIwlszPcqzNeIu0KjF+WCwtxCdObvrlXHTXQuBhK X-Received: by 2002:a62:e50d:: with SMTP id n13-v6mr7927674pff.125.1527794440974; Thu, 31 May 2018 12:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527794440; cv=none; d=google.com; s=arc-20160816; b=Fv6SlTIyKK6B6GP1h0bIcv2E0iVJhD9kbXfBZMPNl9r95s3ZlLh5Zzt/u0xB4C2ekK DOG3OYt85VF1ykPxmr4FewJiS1ams67bMcdSKTeWkmLyO0eP3x7BJHWu73wl4BNBOSTk 7n5mz8I/9W0pQHGXUA7VUI+tjQMN5HngQBymBUmJs4wQAnfX1UXUom9fDSxq1kfn8xXA jQAVNbD19mhWfcK3FWQ7mK+tj4q8nW8LOOnZQCNcEATM9vrqjLgZVRk8YlARUYHJqjY6 E1lntjP3DMFP6D8RmM5HA4cQjs6eE8S249kaLueQFfokPgH90a59Atca02I8eUhvy5uZ GAkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=3vcvXXGe+IKBZ5l3aldg0i3yp7gwwhYvO/wwq4UGMxg=; b=SDCjpfDWTHM47tiWrFwUbW7LDoqCjS2uNKSXkCLGpClu4B3IhfHIJOvdrPGMEX9bZO JnRuz0yw1K+g/hWkx2aooXUJHKp1GClAY4Cc/DUkhIbVkt0fGAalkVsstNxEt3aKWVVe lWFK0/wH7phbVO2dEQbq6n4bQiHVjj8EmHKa2wyudcOa/0cuugWbiVQDX3zBxhvya1xm YCAqUCYRQXgW50E/926qjWgA9cNGLGnNoROrTnag2o23uCIU4seflP/QrQmhPcN1Gb9k IwkYGVIoLXMV4KyaNXT4gEYhmw5Xj5/phSCDiWov0hCiX8yhhQ+Tf7C2f1W/f89KBItq WYtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h66-v6si14518337pgc.53.2018.05.31.12.20.24; Thu, 31 May 2018 12:20:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754102AbeEaTT6 (ORCPT + 99 others); Thu, 31 May 2018 15:19:58 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:48472 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754030AbeEaTT5 (ORCPT ); Thu, 31 May 2018 15:19:57 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fOT75-0005G7-KF; Thu, 31 May 2018 19:19:55 +0000 Date: Thu, 31 May 2018 20:19:55 +0100 From: Al Viro To: David Howells Cc: linux-fsdevel@vger.kernel.org, linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 20/32] vfs: Make close() unmount the attached mount if so flagged [ver #8] Message-ID: <20180531191955.GG30522@ZenIV.linux.org.uk> References: <152720672288.9073.9868393448836301272.stgit@warthog.procyon.org.uk> <152720685405.9073.17445116582570028610.stgit@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <152720685405.9073.17445116582570028610.stgit@warthog.procyon.org.uk> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 25, 2018 at 01:07:34AM +0100, David Howells wrote: > + if (unlikely(file->f_mode & FMODE_NEED_UNMOUNT)) > + __detach_mounts(dentry); > + This is completely wrong. First of all, you want to dissolve the mount tree on file->f_path.mount, not every tree rooted at dentry equal to file->f_path.dentry. This is easily done - it would be a simple call of drop_collected_mounts(mnt) if not for one detail. You want it to happen only if the sucker isn't attached anywhere by that point. IOW, namespace_lock(); lock_mount_hash(); if (!real_mount(mnt)->mnt_ns) umount_tree(real_mount(mnt), UMOUNT_SYNC); unlock_mount_hash(); namespace_unlock(); and that's it. You don't need that magical mystery turd in move_mount() later in the series and all the infrastructure you grow for it. FWIW, I would've suggested this void drop_collected_mounts(struct vfsmount *mnt) { namespace_lock(); lock_mount_hash(); + if (!real_mount(mnt)->mnt_ns) + umount_tree(real_mount(mnt), UMOUNT_SYNC); - umount_tree(real_mount(mnt), UMOUNT_SYNC); unlock_mount_hash(); namespace_unlock(); } and in __fput() if (unlikely(file->f_mode & FMODE_NEED_UNMOUNT)) drop_collected_mounts(mnt); All there is to it, AFAICS...