Received: by 10.223.164.202 with SMTP id h10csp192539wrb; Mon, 13 Nov 2017 23:10:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMYxARb/kfhb9UOXuMznkzgUSjHdfeaGfQM+o3zwGaCSyn7EGW1mT6FUTNBsENq3fEJ8ZBa3 X-Received: by 10.84.234.129 with SMTP id n1mr10979121plk.298.1510643437850; Mon, 13 Nov 2017 23:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510643437; cv=none; d=google.com; s=arc-20160816; b=Na+nr/pnsQ+g2gk9XGRClf5mZ6MoLASod/NbU0RjuJI61dmGUlNYez6NLcykIzx2nR 4KMj38MlaMtly9S6epKffaqUmvTds02XbUGQiEpBp8EK4XJDE4pzXeY42Ozzr91YJs4B 8e/6WgV9HRGSqxCYDloHWfWG0OANOElXe0cJ5T9EFZmS/RGZOTcljZAYvElQ7tAqk/n5 LLCaqdbJ57YvOq+kUPvlVGQ7YnCzq6JaHQ4YyzFtw1NZBhXGaGixwX2DOGce3q7Op1Ut KzlSUgqECup+P3Rw3+GSeVpGA+25nGDzX4oY4nsOPhWe8sVqMxYywSXyuFzfTRyp+1jX nOsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:reply-to:mime-version :dkim-signature:arc-authentication-results; bh=IODQNyR20d9+gU+/yKZ/Vfd22MRenagpUcKr7Ejysuc=; b=E8giCDUpNIzqcItEOUkvhIK6v8ftNVSZi88LzFrs6RHuaX2t9BeY5MIO5N8wno3UBR oa6WsJS82c3j7lQP3a5eSJmxYfGGUhPKM0kqIOzpseWsQn/qagjxemkOPnT+PERfeYPM VgSyKmiPk6IYDIq4ijWq4vMWcDKGdoxoBX/xsYNaZkSoDHhXngGrkC+CpNs+uGqpML2p ttNZAozI77kS33TSnoINimGD9gYEYzwDT5Phks8XMcubXG/JzNN830zLhEEEbcXCxmpX ayyihfzzQ6+8dXcCJAF4Fzuxtismrrq0tnJIc+Jrt0kB7A7Fx9gqMQeoZsAqskq48v2K ZsEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZBxPVbcV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t19si15084589plo.127.2017.11.13.23.10.26; Mon, 13 Nov 2017 23:10:37 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZBxPVbcV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753323AbdKNHJH (ORCPT + 89 others); Tue, 14 Nov 2017 02:09:07 -0500 Received: from mail-wm0-f52.google.com ([74.125.82.52]:39519 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752905AbdKNHI6 (ORCPT ); Tue, 14 Nov 2017 02:08:58 -0500 Received: by mail-wm0-f52.google.com with SMTP id l8so13660561wmg.4; Mon, 13 Nov 2017 23:08:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=IODQNyR20d9+gU+/yKZ/Vfd22MRenagpUcKr7Ejysuc=; b=ZBxPVbcVGoEns3eQ6bjCh8ZjYxKWDFhM/fEJSx1bAvaCJlwqr+cahV2ZbWEQ0jc9CM GxuY7QxBy+42oLi9q90KhSacsxPLAaq+wizKfOteFjoiaAf57S46Olr3TfujE+cA3NC2 +9A/LuGoxYMJaTpLD41pUoCoLwyMTtdazpauVR/qDKDeA1QLKcrMbbNulL1Dt3GSTLC7 7O1DiA/VxCWxf/ReupzEv/PFrhqxmDMDtKIDmXlqgBPqhTYeBobHXRoJKt9cGInmRMnN blm7/CWUH9bsuCAiZC/ToqvbV+TnrCb7CgtYEMSLHO+tQurdMPaFpbKCChrbfAP7mUl7 Us4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-transfer-encoding; bh=IODQNyR20d9+gU+/yKZ/Vfd22MRenagpUcKr7Ejysuc=; b=t52aukQ+8NqvLxqP354Vype3pKJSGk60trsbHBjbiQVsBg1xpZEN8QFc/I4xlfr2Lk IHwEFei20TCUsXFBmwISxk2QeQRYJybaxfayBZBrUWB73kOps+z6sSwN0grYND9dNreU daAhc2f9ooMWhEu0UaMdDHRJVIMh9ctcRbbiSs64c4hRnOiHC8jz+tPFNicXEoDYBPTD hXB5nSiteqg8ZRa6in4oswTrJEs+KIg6nwx1Rjkomj5Ded8k4zO07XFgXXX71hEFtLfn LqG8GGXNQd26882baT1Nskp6NRsuct/1FMd8MEL8k2MOeWhF9oTjGZwy5r0FwWkMimqZ THgQ== X-Gm-Message-State: AJaThX5MDIFbZ5BXW7+RnpFXImSxS5DpO25mCCZ7AmUkFbYRwa7Oqt0E /B2yrGRiDWiyolKTLnVTyGcpfjerOv5Qgo41mNc= X-Received: by 10.80.150.69 with SMTP id y63mr16215927eda.75.1510643336318; Mon, 13 Nov 2017 23:08:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.245.52 with HTTP; Mon, 13 Nov 2017 23:08:36 -0800 (PST) Reply-To: mtk.manpages@gmail.com In-Reply-To: References: <20171113075537.GG5546@ram.oc3035372033.ibm.com> From: "Michael Kerrisk (man-pages)" Date: Tue, 14 Nov 2017 08:08:36 +0100 Message-ID: Subject: Re: Improving documentation of parent-ID field in /proc/PID/mountinfo To: Miklos Szeredi Cc: Ram Pai , lkml , linux-man , Alexander Eder , "linux-fsdevel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Miklos, Ram Thanks for your comments. A question below. On 13 November 2017 at 09:11, Miklos Szeredi wrote: > On Mon, Nov 13, 2017 at 8:55 AM, Ram Pai wrote: >> On Mon, Nov 13, 2017 at 07:02:21AM +0100, Michael Kerrisk (man-pages) wr= ote: >>> Hello Ram, >>> >>> Long ago (2.6.29) you added the /proc/PID/mountinfo file and >>> associated documentation in Documentation/filesystems/proc.txt. Later, >>> I pasted much of that documentation into the proc(5) manual page. >>> >>> That documentation says of the second field in the file: >>> >>> [[ >>> This file contains lines of the form: >>> >>> 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors= =3Dcontinue >>> (1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11) >>> >>> (1) mount ID: unique identifier of the mount (may be reused after umou= nt) >>> (2) parent ID: ID of parent (or of self for the top of the mount tree) >>> ... >>> ]] >>> >>> The last piece of the description of field (2) doesn't seem to be >>> correct, or is at least rather unclear. I take this to be saying that >>> that for the root mount point, /, field (2) will have the same value >>> as field (1). I never actually looked at this detail closely, but >>> Alexander pointed out that this is obviously not so, as one can >>> immediately verify: >>> >>> $ grep '/ / ' /proc/$$/mountinfo >>> 65 0 8:2 / / rw,relatime shared:1 - ext4 /dev/sda2 rw,seclabel,data=3Do= rder >>> >>> I dug around in the kernel source for a bit. I do not have an exact >>> handle on the details, but I can see roughly what is going on. >>> Internally, there seems to be one ("hidden") mount ID reserved to each >>> mount namespace, and that ID is the parent of the root mount point. >>> >>> Looking through the (4.14) kernel source, mount IDs are allocated by >>> mnt_alloc_id() (in fs/namespace.c), which is in turn called by >>> alloc_vfsmnt() which is in turn called by clone_mnt(). >>> >>> A new mount namespace is created by the kernel function copy_mnt_ns() >>> (in fs/namespace.c, called by create_new_namespaces() in >>> kernel/nsproxy.c). The copy_mnt_ns() function calls copy_tree() (in >>> fs/namespace.c), and copy_tree() calls clone_mnt() in *two* places. >>> The first of these is the call that creates the "hidden" mount ID that >>> becomes the parent of the root mount point. (I verified this by >>> instrumenting the kernel with a few printk() calls to display the >>> IDs.) The second place where copy_tree() calls clone_mnt() is in a >>> loop that replicates each of the mount points (including the root >>> mount point) in the source mount namespace. >> >> We used to report that mount, ones upon a time. Something has changed >> the behavior since then and its not reported any more, thus making it >> hidden. > > The hidden one is the initramfs, I believe. That's the root of the > mount namespace, and the when a namespace is cloned, the tree is > copied from the namespace root. > > It is "hidden" because no process has its root there. Note the > difference between namespace root and process root: the first is the > real root of the mount tree and is unchangeable, the second is > pointing to some place in a mount tree and can be changed (chroot). > > So there's nothing special in this rootfs, it is just hidden because > it's not the root of any task. > > The description of field (2) is correct, it just does not make it > clear what it means by "root". Sorry -- do you mean the old description is correct, or my new description (below)? Cheers, Michael > Thanks, > Miklos > >> >>> >>> With these details in mind, I propose to patch the man page to read as >>> below. Perhaps you have some corrections or improvements to suggest >>> for this text? >>> >>> [[ >>> (2) parent ID: the ID of the parent mount. For the ro= ot >>> mount point, the ID shown here is a hidden mount = ID >>> associated with the mount namespace. That ID is di= s=E2=80=90 >>> tinct from any of the IDs shown in field (1) of t= he >>> records shown in the mountinfo file, and does n= ot >>> appear in field (1) in the mountinfo file in any oth= er >>> mount namespace. (In the initial mount namespac= e, >>> this hidden ID has the value 0.) >> >> It captures the current semantics correctly. >> >> RP >> --=20 Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ From 1583937802308204969@xxx Mon Nov 13 08:13:20 +0000 2017 X-GM-THRID: 1583929638158288060 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread