From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751493AbdAPBdp (ORCPT ); Sun, 15 Jan 2017 20:33:45 -0500 Received: from kaemail1.nttcom.co.jp ([132.222.121.19]:45487 "EHLO kaemail1.nttcom.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751173AbdAPBdn (ORCPT ); Sun, 15 Jan 2017 20:33:43 -0500 Subject: Re: Duplicate inode number when mount --bind some directories to same mountpoint. (from Fedora18 to 4.10-rc3) To: Al Viro References: <9795d554-d236-2096-497d-e25622042d41@nttcom.co.jp> <20170112102425.GW1555@ZenIV.linux.org.uk> <20170113032651.GF1555@ZenIV.linux.org.uk> CC: From: Nakajima Akira Message-ID: <90248ac2-0253-36d4-ddd0-b283373634f8@nttcom.co.jp> Date: Mon, 16 Jan 2017 10:33:40 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <20170113032651.GF1555@ZenIV.linux.org.uk> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.133.1.147] X-TM-AS-MML: disable Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 120 116 252:1 /home/b /mnt rw,relatime shared:1 - ext4 /dev/vda1 rw,data=ordered > 121 61 252:1 /home/b /home/a rw,relatime shared:1 - ext4 /dev/vda1 rw,data=ordered Thanks for your polite explanation. I can understand this is correct kernel specification and above Fedora18 and RHEL7.0 is using shared mount as default. I should have done it as follows. # mount --make-private --bind a /mnt # mount --make-private --bind b /mnt # ls -i 100 a 999 b # tali /proc/self/mountinfo 200 59 8:3 /home/a /mnt rw,relatime - ext4 /dev/sda3 rw,stripe=64,data=ordered 205 200 8:3 /home/b /mnt rw,relatime - ext4 /dev/sda3 rw,stripe=64,data=ordered On 2017/01/13 12:26, Al Viro wrote: > On Fri, Jan 13, 2017 at 10:40:08AM +0900, Nakajima Akira wrote: >> On 2017/01/12 19:24, Al Viro wrote: >>> On Thu, Jan 12, 2017 at 06:16:35PM +0900, Nakajima Akira wrote: >>>> Bug: >>>> Duplicate inode number when mount --bind some directories to same >>>> mountpoint. (from Fedora18 to 4.10-rc3) >>>> Fedora17 and earlier works correctly. >>> >>> Explain, please. "Duplicate inode number" between what and what? >> >> Duplicate inode number between mounted directories. >> >> Example) >> # cd /home >> # mkdir a b >> # ls -i >> 100 a 999 b >> # mount --bind a /mnt >> # mount --bind b /mnt >> # ls -i >> 999 a 999 b >> >> Inode number of directory "a" is changed to "b". >> Then we see directory "b" when ls "a". > > 61 0 252:1 / / rw,relatime shared:1 - ext4 /dev/vda1 rw,data=ordered > > Root, marked shared (peer group 1). /home is not a mountpoint, /mnt > wasn't one until your mounts (i.e. both are within the same mount as /). > > Since /home/a is a subtree of a shared mount, any clone of it will, by > default, join the same peer group. Which means that binding it on /mnt > results in > > 116 61 252:1 /home/a /mnt rw,relatime shared:1 - ext4 /dev/vda1 rw,data=ordered > > i.e. ext4[vda1]home/a being mounted on /mnt and marked peer of root mount. > Accordingly, any mount/umount event in either will be duplicated to all > peers (provided that they contain a counterpart of affected mountpoint). > In particular, binding /home/b on /mnt (i.e. on top of ext4[vda1]home/mnt) > propagates to the corresponding points in all peers - including the root > mount, where it corresponds to /home/a. Result: > > 120 116 252:1 /home/b /mnt rw,relatime shared:1 - ext4 /dev/vda1 rw,data=ordered > 121 61 252:1 /home/b /home/a rw,relatime shared:1 - ext4 /dev/vda1 rw,data=ordered > > The same tree (ext4[vda1]home/b) is mounted on root in mount 116 > (i.e. the thing found on /mnt) and on /home/a in mount 61 (i.e. /home/a). > > Since /home/b is on a shared mount, both clones are put in the same peer > group (i.e. the same group 1). > > You asked for it, you've got it... Well, fedora folks did, actually. > I'm none too fond of their default setup (root made shared), but that has > nothing to do with the kernel. Userland (systemd, as far as I can tell) > is setting the things up that way, and it's even documented in fedora > release notes... Kernel mechanisms involved in that had been there for > a long time and they are also documented (man 2 mount, look for MS_SHARED > and related flags in there). > > Take it up with fedora folks...