Skip to content

RFC Read-only bind mounts

Dave Hansen linux-fsdevel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest27 patches 27 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/27Add vfsmount writer countfs/namespace.c include/linux/mount.h+15 -01 reply
2/27vfs_rmdir: change if() into gotofs/namei.c+5 -41 reply
3/27do_rmdir(): elevate write countfs/namei.c+5 -02 replies
4/27elevate mnt writers for vfs_unlink() callersfs/namei.c ipc/mqueue.c+8 -10 replies
5/27elevate mnt writers for nfsd caller of vfs_mkdir()fs/nfsd/nfs4recover.c+4 -00 replies
6/27elevate write count during entire ncp_ioctl()fs/ncpfs/ioctl.c+53 -12 replies
7/27sys_mkdirat(): collapse if()fs/namei.c+19 -193 replies
8/27sys_mkdirat(): one more gotofs/namei.c+8 -61 reply
9/27elevate mnt writers for sys_mkdirat() call of vfs_mkdir()fs/namei.c+5 -00 replies
10/27sys_symlinkat() collapse if()sfs/namei.c+17 -160 replies
11/27sys_symlinkat() collapse one more if ()fs/namei.c+6 -41 reply
12/27sys_symlinkat() elevate write count around vfs_symlink()fs/namei.c+5 -00 replies
13/27sys_linkat(): elevate write count around vfs_link()fs/namei.c+10 -40 replies
14/27tricky: elevate write count files are open()edfs/file_table.c fs/namei.c ipc/mqueue.c+33 -43 replies
15/27elevate writer count for do_sys_truncate()fs/open.c+11 -50 replies
16/27elevate write count for do_sys_utime()fs/open.c+11 -50 replies
17/27elevate write count for do_utimes()fs/open.c+9 -40 replies
18/27sys_faccessat(): collapse if()fs/open.c+10 -81 reply
19/27sys_faccessat() elevate writer countfs/open.c+14 -22 replies
20/27unix_find_other() elevate write count for touch_atime()net/unix/af_unix.c+12 -41 reply
21/27mount_is_safe(): add commentfs/namespace.c+4 -00 replies
22/27sys_mknodat(): elevate write count for vfs_mknod/create()fs/namei.c fs/nfsd/vfs.c net/unix/af_unix.c+39 -172 replies
23/27elevate write count over calls to vfs_rename()fs/namei.c fs/nfsd/vfs.c+37 -155 replies
24/27elevate mount count for extended attributesfs/nfsd/nfs4proc.c fs/xattr.c+20 -10 replies
25/27/proc/mounts: prep for flags from sb or mntfs/namespace.c+24 -221 reply
26/27/proc/mounts: treat ro/rw like the restfs/namespace.c+2 -11 reply
27/27create and pass read-only mnt flag into do_loopback()fs/file.c fs/inode.c fs/namespace.c +2 more+14 -30 replies

Reviews trailers per patch

3 of 27 patches have a Reviewed-by or Acked-by.

PatchHerbert Poetzl
1/27
2/27A-b
3/27
4/27
5/27
6/27
7/27
8/27A-b
9/27
10/27
11/27A-b
12/27
13/27
14/27
15/27
16/27
17/27
18/27
19/27
20/27
21/27
22/27
23/27
24/27
25/27
26/27
27/27

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [RFC][PATCH 00/27] Read-only bind mounts

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