From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Hansen Subject: [RFC][PATCH 00/27] Read-only bind mounts Date: Wed, 07 Jun 2006 17:10:13 -0700 Message-ID: <20060608001013.0D041507@localhost.localdomain> Cc: herbert@13thfloor.at, viro@ftp.linux.org.uk, hch@infradead.org, trond.myklebust@fys.uio.no, Dave Hansen Return-path: Received: from e2.ny.us.ibm.com ([32.97.182.142]:12687 "EHLO e2.ny.us.ibm.com") by vger.kernel.org with ESMTP id S932474AbWFHAK2 (ORCPT ); Wed, 7 Jun 2006 20:10:28 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e2.ny.us.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k580AMc4003925 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 7 Jun 2006 20:10:22 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay04.pok.ibm.com (8.13.6/NCO/VER7.0) with ESMTP id k580AIs5129042 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 7 Jun 2006 20:10:22 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k580AHkL004673 for ; Wed, 7 Jun 2006 20:10:18 -0400 To: linux-fsdevel@vger.kernel.org Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org The following series implements read-only bind mounts. This set does not take the previously tried approach of pushing down the vfsmount structure deeply into call paths, such that it might be checked in functions like permission(), may_create() and may_open(). Instead, it does checks near the entry points in the kernel, bumping a reference count in the vfsmount structure and effetively holding a kind of a lock on the vfsmount. This approach will come in handy in the future, allowing transitions from rw to ro mounts while guaranteeing that no writers are currently active. I apologize for so many small patches, but breaking them up like this really did help me find bugs. A rollup is here: http://sr71.net/~dave/patches/ro-bind-mounts-06-07-2006.patch This series passes a test I got from Herbert Poetzl, checking to see that these r/o bind mounts have the same properties as regular r/o device mounts for a number of syscalls. http://vserver.13thfloor.at/Experimental/BME/fstest-0.03.tar.bz2 Here is the script I used to generate and compare the output from that test: #!/bin/sh { umount ro-bind-mount ro-mount; rm -rf ro-mount-source ro-bind-mount-source ro-mount ro-bind-mount; dd if=/dev/zero of=ro-mount-source count=10000; mkfs.ext3 -F ro-mount-source; mkdir ro-mount ro-bind-mount; mkdir ro-bind-mount-source } > /dev/null 2>&1 mount --bind -o ro ro-bind-mount-source ro-bind-mount mount -t ext3 -o loop,ro ro-mount-source ro-mount function fstest_and_diff { ARG1="$1" shift ARG2="$1" ./fstest -d "$ARG1" > "$ARG1".log; ./fstest -d "$ARG2" > "$ARG2".log; diff -ru "$ARG1".log "$ARG2".log } fstest_and_diff ro-mount ro-bind-mount umount ro-bind-mount ro-mount Signed-off-by: Dave Hansen