Received: by 10.223.164.202 with SMTP id h10csp2909945wrb; Sun, 12 Nov 2017 22:03:35 -0800 (PST) X-Google-Smtp-Source: AGs4zMbQvvv75dIasIGT/Ere9PjFnyCR9+ODH/LFy08IWDPX7SI9HLiri34K/C+AOordyZFfnKmx X-Received: by 10.159.255.70 with SMTP id u6mr7970209pls.41.1510553015081; Sun, 12 Nov 2017 22:03:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510553015; cv=none; d=google.com; s=arc-20160816; b=eRrjYEgj4hTBVjB+bmJk4hB1bNXOuwFCQaP5F+s/bd6zGtF5YZNk8sLgely4iPqtf8 OyJjoWOY84rTdYgWy24QdIsILBBJPsqo707ZrrOoIacRxJmcSBxAYnfOtc7Ad7OhgZSq 2XdWyd8csKPNRO6lDZZV5ItGXxMfbWEOGH1oLN5N15fjClM1HKIq/p1/lmABHS+ewoTT wNcXxAKBTDnwIGY30LJA1BZp/F+wPC97oh91U2CZz3nUweMPgA9DluVlBg1fTScVvqV9 LT7+I5USMSpiKqdadU5F5+N6c8R2Xhz249jxZKOy3MguZqN/Zs2XYB2v17OACWt3vm6d qmag== 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:reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Xdd0v7XXHamI/GxjzTnJCCLaG0a2X9tl5hJbO6uCJoE=; b=vWdVSG/58ee2CYa7VmCTmjAD1oTEPnIFTmbXMx+WW9ZGmTKvoKh07tbH6myRI/SwNn ymQwCqfkIeGw5c0vQIG9HTBD1tDaYhK8rgxQ654W+tKCWraHMcfRHthPlfoJZRTOXcaw 2ayQNGkyLK0n2ZM1aXM0uhanmfz0sOFb07ztVf5hKLSu+v4PPpz9QQEpInwcGi0Mz3cb 3ix857AkxVSN3aKAHkYpsuofOmrvon23c5Pvca91rrkjSm7aQmWXgviqKbkEaA6wS30u IDc6sc6KQkmkCn5hSBYyjumYX8mFn2E1XasJ8EIn1wAsFXblEkE4sR/gGLkzdg5dj7gv ThZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rOBlnamm; 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 k71si13324257pgc.376.2017.11.12.22.03.22; Sun, 12 Nov 2017 22:03:35 -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=rOBlnamm; 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 S1751891AbdKMGCp (ORCPT + 88 others); Mon, 13 Nov 2017 01:02:45 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:53247 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751308AbdKMGCn (ORCPT ); Mon, 13 Nov 2017 01:02:43 -0500 Received: by mail-wm0-f49.google.com with SMTP id t139so12698494wmt.1; Sun, 12 Nov 2017 22:02:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:reply-to:from:date:message-id:subject:to:cc :content-transfer-encoding; bh=Xdd0v7XXHamI/GxjzTnJCCLaG0a2X9tl5hJbO6uCJoE=; b=rOBlnammfT/pXp7GAQdJ96e3e31i5m4/v89M2daFY87v63CwlOMuSfLJvjOJfrzKWu N5Sf5+YaZ37oA5aqp/gCFLLaaUMfb1IEhlyLpiRPTkcB6hDj/LC/be/HMfo8dpYMConS bsB9Jg0ztswavv8dePc/EU+JIca1/Jqaq+5rFcHp6Zpe6XdRGCIAvnaVz/DFF1EYCnTC w7QJ6bo6+zKv4yc1CXQbNMG3OnLwti5IzMcZrTdWhc+scKv+6iNxbkqTRewR5VMsFlx/ ML5/mfJgxgQkDfO9HFKfQTJLmNHoT8w6MSj3YfNHppvRZCgrRBZfCbat0s5pUTyyyDTr bOdQ== 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:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=Xdd0v7XXHamI/GxjzTnJCCLaG0a2X9tl5hJbO6uCJoE=; b=h6li9qLYVu7Rt//VF2ibdlXZ6OisrcbjNtO8COetlshjJz0MmhoxQRUm8euhpvbICz Y1Z/YiPmNIpTlq4S8RhSatQjfH8IRO/+ygURCQ1iS7pLIqYdvR57VIvA1z6sVZYmUEso 0mjzS8mlPS76rbw/ufgGXEWR6cooXULpS4PPhble4xlQOcUwEhdISm4pLdXXn0Ir2GOo 32poLRMjOACX96T+Hr+YVkkombFQkOfdA7Cv3n9XUh4Sh/+QkU6peYS0A86AwcW5Ofz3 SVeIKlJUOA1AFVkk6j77RPT+E//Ry7Ia3d6ISxfTW/bOsk9YygpHU/KRRjUsoVvmz63r zpiQ== X-Gm-Message-State: AJaThX7kCXEgAXeR7WiIZwGk4c/xIYBYXsFu+uk9o+rFolw/7T6OP/0o qRs1dZwKoX9vN3iOiAEtrOEhX3GiyxGLVHfBd98= X-Received: by 10.80.241.143 with SMTP id x15mr8104975edl.119.1510552961509; Sun, 12 Nov 2017 22:02:41 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.245.52 with HTTP; Sun, 12 Nov 2017 22:02:21 -0800 (PST) Reply-To: mtk.manpages@gmail.com From: "Michael Kerrisk (man-pages)" Date: Mon, 13 Nov 2017 07:02:21 +0100 Message-ID: Subject: Improving documentation of parent-ID field in /proc/PID/mountinfo To: Ram Pai Cc: lkml , linux-man , Alexander Eder , Miklos Szeredi , Michael Kerrisk , "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 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=3Dcon= tinue (1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11) (1) mount ID: unique identifier of the mount (may be reused after umount) (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=3Dorder 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. 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 root mount point, the ID shown here is a hidden mount ID associated with the mount namespace. That ID is dis=E2= =80=90 tinct from any of the IDs shown in field (1) of the records shown in the mountinfo file, and does not appear in field (1) in the mountinfo file in any other mount namespace. (In the initial mount namespace, this hidden ID has the value 0.) ]] With best regards, Michael --=20 Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ From 1584611194422097918@xxx Mon Nov 20 18:36:37 +0000 2017 X-GM-THRID: 1584611194422097918 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread