From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ram Pai Subject: Re: mount behavior question. Date: Thu, 28 Jul 2005 08:02:19 -0700 Message-ID: <1122562938.4715.71.camel@localhost> References: <20050725224417.501066000@localhost> <20050725225907.007405000@localhost> <1122500344.5037.171.camel@localhost> <1122536107.4715.45.camel@localhost> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: Andrew Morton , viro@parcelfarce.linux.theplanet.co.uk, Avantika Mathur , mike@waychison.com, janak@us.ibm.com, linux-fsdevel@vger.kernel.org Return-path: Received: from e5.ny.us.ibm.com ([32.97.182.145]:57783 "EHLO e5.ny.us.ibm.com") by vger.kernel.org with ESMTP id S261541AbVG1PCX (ORCPT ); Thu, 28 Jul 2005 11:02:23 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e5.ny.us.ibm.com (8.12.11/8.12.11) with ESMTP id j6SF2M3m025372 for ; Thu, 28 Jul 2005 11:02:22 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay02.pok.ibm.com (8.12.10/NCO/VERS6.7) with ESMTP id j6SF2MEk250620 for ; Thu, 28 Jul 2005 11:02:22 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.12.11/8.13.3) with ESMTP id j6SF2LKK011700 for ; Thu, 28 Jul 2005 11:02:22 -0400 To: Miklos Szeredi In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Thu, 2005-07-28 at 04:56, Miklos Szeredi wrote: > > Here is a scenario with shared subtree. Sorry it is complex. > > > > > > mount --bind /mnt /mnt > > mount --make-shared /mnt > > mkdir -p /mnt/p > > mount --bind /usr /mnt/1 > > mount --bind /mnt /mnt/2 > > > > At this stage the mount at /mnt/2 and /mnt belong to the same pnode > > which means mounts under them propogate to each other. > > > > mount --bind /var /mnt/1 > > > > the contents of /var will be visible under /mnt/1 and not under /mnt/2 > > But if mount --bind /var /mnt/2 is executed, the contents of /var is > > visible under /mnt/1 as well as /mnt/2 . Isn't this freaky? > > I don't understand. > > 'mount --bind /var /mnt/1' should propagate to /mnt/2/1, not /mnt/2. yes it should propogate to /mnt/2/1 , thats what I meant when I said under /mnt/2, but yes I was not clear. Hope I have a clearer explanation below. > No? > > 'mount --bind /var/ /mnt/2' should propagate to /mnt. What am I > missing? step 1: mount --bind /mnt /mnt a new mount 'A' is created at /mnt step 2: mount --make-shared /mnt mounts under 'A' are made shared. But in this case there are no other mounts. So only 'A' will be made shared. step 3: mkdir -p /mnt/1 /mnt/2 nothing special here step 4: mount --bind /usr /mnt/1 a new mount 'B' is created at /mnt/1 which is 'shared;. step 5: mount --bind /mnt /mnt/2 a new mount 'C' is created at /mnt/2 and propogation is set between 'A' and 'C'. note: 'C' is made shared. lets say, at this point I try mount --bind /var /mnt/1 this is going to mount 'D' on top of mount 'B'. However there is no other mount to which 'B' propogates to. So that is it. the contents of /var is only visible at /mnt/1 and it propogates no where else. but lets say, we tried mount --bind /var /mnt/2/1 /mnt/2/1 belongs to mount 'C'. And mounts under 'C' propogates to 'A' too. So in this case a new mount 'E' is created at mnt/1/2 i.e on top of 'C' at dentry '2' and due to propogation a new mount 'F' is created at /mnt/1 i.e on top of mount 'A' at dentry '1' But note: /mnt/1 already has a mount 'B' on top of it. The new mount 'F' as per the 'most-current mount rule' obscures 'B' even though the mount is on top of 'A'. As a result the contents of /var are now visible both at /mnt/2/1 and /mnt/1 Ok the net effect is, mount at /mnt/1 is visible only under /mnt/1 but mount at /mnt/2/1 is visible at mount /mnt/2/1 and /mnt/1 This makes it confusing. If the 'top-most mount rule' is applied 'F' though mounted on 'A', will not be visible because it will get obscured by 'B' and the confusion is avoided. So the point I am driving at is, is there any special reason for having 'most-recent mount visible rule' instead of 'top-most mount visible rule'? RP > Miklos