From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ram Pai Subject: mount behavior question. Date: Thu, 28 Jul 2005 00:35:07 -0700 Message-ID: <1122536107.4715.45.camel@localhost> References: <20050725224417.501066000@localhost> <20050725225907.007405000@localhost> <1122500344.5037.171.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 e34.co.us.ibm.com ([32.97.110.132]:41872 "EHLO e34.co.us.ibm.com") by vger.kernel.org with ESMTP id S261320AbVG1HfU (ORCPT ); Thu, 28 Jul 2005 03:35:20 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e34.co.us.ibm.com (8.12.10/8.12.9) with ESMTP id j6S7Z9RX268860 for ; Thu, 28 Jul 2005 03:35:10 -0400 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay04.boulder.ibm.com (8.12.10/NCO/VERS6.7) with ESMTP id j6S7ZDE9192088 for ; Thu, 28 Jul 2005 01:35:13 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11/8.13.3) with ESMTP id j6S7Z8bV027606 for ; Thu, 28 Jul 2005 01:35:09 -0600 To: Miklos Szeredi In-Reply-To: <1122500344.5037.171.camel@localhost> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Summary of the question: Should the topmost mount be visible, or should the most recent mount be visible? consider the following command sequence (1) cd /mnt (2) mount --bind /usr /mnt (3) mount --bind /bin /mnt (4) mount --bind /var . after step 1, the pwd of the process is pointing to root mount and directory mnt. lets call the root mount as 'A' after step 2, a new mount is laid on top of 'A' at the mountpoint mnt lets call this mount 'B' after step 3, a new mount is laid on top of 'B' at the mountpoint mnt which corresponds to the root dentry of 'B'. lets call this new overlaid mount as 'C'. At this point the visible content of /mnt is the content of C. however at step 4, a new mount is laid on top of 'A' at the same mountpoint mnt, as that of 'B'. Lets call the new mount 'D'. At this point, the visible content of /mnt is that of D and not that of C But should'nt it be C? Why is that the contents of 'D' made visible? Is there any particular reason for this behavior? Note: 'D' is mounted on the bottommost mount, and hence should be obscured by the top level mounts. To make it simpler, imagine you are viewing a 3 storied transparent building from the top. If you place an apple in 1st floor and nothing is placed on any other floors, the apple will be visible from the top. Now if you place a 'orange' in the 2nd floor the apple should get obscured by the orange and the 'orange' should start being visible. And later if you place a 'mango' on 3rd floor, the mango should obscure both the apple and orange. but at this point if you place another apple on top of the first apple in the 1st floor, it cannot be visible, because the 'orange' and the 'mango' block its line of sight. And hence the 'mango' should still continue to be visible. right? If the apple starts becoming visible from the top, won't it defy law of visibility? :) Back to the mount example: Currently the behavior is the most recent mount is visible and not the topmost mount. Not many will run into this question currently, because the sequence of steps have to orchestrated well to get into this scenario. But with shared subtrees it is pretty easy to mount something at a lower level mount because of propogations. And in this case the behavior becomes totally confusing if the rule is 'expose the most-recent-mount and not the topmost-mount'. 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? On analysis it turns out the culprit is the current rule which says 'expose the most-recent-mount and not the topmost mount' RP