Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp994376rdh; Fri, 27 Oct 2023 01:18:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgiF1J0xPSoUlY7K2xwFmkiycqfxZ9spoXy7Y2f9Nw02umpSNJXeiYNv+W6uKwIVSlhsfb X-Received: by 2002:a5b:d08:0:b0:d9a:c41c:133a with SMTP id y8-20020a5b0d08000000b00d9ac41c133amr1697057ybp.38.1698394721508; Fri, 27 Oct 2023 01:18:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698394721; cv=none; d=google.com; s=arc-20160816; b=mb42D7Wk/S5wWJ08k4Yc6bKbQTI3+GkltAjp0p8Tj8wiymMFPpIk5BkkHdz67IqkCH GOv5kPvHYRgtgDrmKAMeiRs6TNT7xixfw7pgXMM0x5ih7G6Lksx3D92xtf6xrOVL18N/ F+6kpOEkadwQCNrM+ER4vWcnBJnpRBhkR8xOIPGTMpn8G8vbPCCd0jBj6lwN08Af14df MT396dmX3qgb55sKLpzy0TA1iHAOuJ6diKecs4GaheIBGvmFoB7DuIqPBZI04AMRq3tw OozOrol3fOVlrLuS1t0aZ0YbHskPExMOWNppt2RbYHixa4NaXkF8HwpMqysJBu3bQzig Hvtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=+ouDL3Q+P4kOF4DRXdbPPiLhvDYpBpA3cyTxKCKn6rY=; fh=ZfhrTBYYt4DlsjERYpWO+3OQYJpvdBA4xBBOyLsMixk=; b=bU3qIGg8qMBG3e++qErsysBDmEZlQHcbEg7Dn04QY1oxp39IcJjwhvMJ9afH6Hxv2g mMtVs/TLJ6squX4pfvK8wM3hQ66N908myhQNHBo04S1C5C+7kpBIwgvNhGPEwYJLBfWv 1WJ+65OO1VjaN391FOta0aSSM3SlPP64NukiQPjlXDnuD3+wdBGSsGKJBjomu9L7guwp c6AUA1NrTLItfBbGldQt/6nT5S7+vQQXgqUNfCs1TM66f4yoE6zV9yXwF6MmWROu2E9U xS19a8ayh/kQTcL+ko8/KKF74q+Pr5qySvQKM9z0KjBl5CePzRUk1dQT+MeDKsQeE+4U GOVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hZNl3TqQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id n70-20020a254049000000b00d9a38f71864si1498282yba.159.2023.10.27.01.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 01:18:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hZNl3TqQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id F0535816F0B7; Fri, 27 Oct 2023 01:18:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235069AbjJ0ISc (ORCPT + 99 others); Fri, 27 Oct 2023 04:18:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbjJ0ISb (ORCPT ); Fri, 27 Oct 2023 04:18:31 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77E891A5 for ; Fri, 27 Oct 2023 01:17:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698394664; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+ouDL3Q+P4kOF4DRXdbPPiLhvDYpBpA3cyTxKCKn6rY=; b=hZNl3TqQHTQtFEvoEygh85cEyyhCRQOKJu674qlJhT2b8RSvefBN2URwZF9c69wyuuOMek 7KaLMZCI/1vFfu/uIKxgdGXpzSipF+J3e7VzHzh1JwXCMyDjyyi5negjB5Nd3bBviAuvlL Q6EWIMPJZ/5Jx+l7j1aHV36g1ImS+bE= Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-482-pifx8qjuOAOR_4ZkfBS8DQ-1; Fri, 27 Oct 2023 04:17:33 -0400 X-MC-Unique: pifx8qjuOAOR_4ZkfBS8DQ-1 Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-6b496e1e53bso1715823b3a.0 for ; Fri, 27 Oct 2023 01:17:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698394652; x=1698999452; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+ouDL3Q+P4kOF4DRXdbPPiLhvDYpBpA3cyTxKCKn6rY=; b=SmprjnihuHHBVQeYuyn874rYRAxR20tZi1De3WUsiPhdJbYZbqjBWNc0Wrch+IHv1S GZyM0M4wi6+faa6uBUbJegXg/542zrz/kqD9ll3oMsUFDJK8OOooyrIFDZk1ffxz3Lyd D8f88c/ausmW8NDsq+4h2DA8Dooy4+Ix3LlcC95MYfzEUT4B/L4ur1W102+82B7kvwTv hILqLVOkszU+JlH37JRGtma6MJYt2WiNe1RpbQjIt4ZpJlzjgNg0OU07uIUwPAYoze3Q 0Vdzu/aJILMAYOPkaaVjasBKNTNU80MOCnD9MSBXBT/3KLhxKLp6KZVWHzzMUFJZlwOR 2tTw== X-Gm-Message-State: AOJu0YyHY84vEGFIGlWKftLvYTRVCJxubr+M5+bI1Pq7R+XEnc7KhJwC HM7TjDxdan19x/xRx4hO3afzS/njW3Uf6aOqg3oiyEZdNJvNXOu6ckPGJ1IzD/vPbcWQs1douyw eSIqtlsw5jdMK0/BnjcnixqUoAR8tqWIA0hXQYT8d X-Received: by 2002:a05:6a21:33a4:b0:14c:c393:692 with SMTP id yy36-20020a056a2133a400b0014cc3930692mr2704227pzb.7.1698394651759; Fri, 27 Oct 2023 01:17:31 -0700 (PDT) X-Received: by 2002:a05:6a21:33a4:b0:14c:c393:692 with SMTP id yy36-20020a056a2133a400b0014cc3930692mr2704213pzb.7.1698394651459; Fri, 27 Oct 2023 01:17:31 -0700 (PDT) MIME-Version: 1.0 References: <20231025140205.3586473-1-mszeredi@redhat.com> <20231025140205.3586473-3-mszeredi@redhat.com> In-Reply-To: From: Miklos Szeredi Date: Fri, 27 Oct 2023 10:17:20 +0200 Message-ID: Subject: Re: [PATCH v4 2/6] mounts: keep list of mounts in an rbtree To: Ian Kent Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-man@vger.kernel.org, linux-security-module@vger.kernel.org, Karel Zak , David Howells , Linus Torvalds , Al Viro , Christian Brauner , Amir Goldstein , Matthew House , Florian Weimer , Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 27 Oct 2023 01:18:39 -0700 (PDT) On Fri, Oct 27, 2023 at 5:12=E2=80=AFAM Ian Kent wrote: > > On 25/10/23 22:02, Miklos Szeredi wrote: > > The mnt.mnt_list is still used to set up the mount tree and for > > propagation, but not after the mount has been added to a namespace. He= nce > > mnt_list can live in union with rb_node. Use MNT_ONRB mount flag to > > validate that the mount is on the correct list. > > Is that accurate, propagation occurs at mount and also at umount. When propagating a mount, the new mount's mnt_list is used as a head for the new propagated mounts. These are then moved to the rb tree by commit_tree(). When umounting there's a "to umount" list called tmp_list in umount_tree(), this list is used to collect direct umounts and then propagated umounts. The direct umounts are added in umount_tree(), the propagated ones umount_one(). Note: umount_tree() can be called on a not yet finished mount, in that case the mounts are still on mnt_list, so umount_tree() needs to deal with both. > IDG how the change to umount_one() works, it looks like umount_list() > > uses mnt_list. It looks like propagate_umount() is also using mnt_list. > > > Am I missing something obvious? So when a mount is part of a namespace (either anonymous or not) it is on the rb tree, when not then it can temporarily be on mnt_list. MNT_ONRB flag is used to validate that the mount is on the list that we expect it to be on, but also to detect the case of the mount setup being aborted. We could handle the second case differently, since we should be able to tell when we are removing the mount from a namespace and when we are aborting a mount, but this was the least invasive way to do this. Thanks, Miklos