Skip to content

Mount writer count and read-only bind mounts (v3)

Dave Hansen lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest20 patches 17 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/20prepare for write access checks: collapse if()fs/namei.c fs/open.c+64 -510 replies
2/20r/o bind mount prepwork: move open_namei()'s vfs_create()fs/namei.c+20 -100 replies
3/20Add vfsmount writer countfs/namespace.c include/linux/mount.h+50 -00 replies
4/20elevate mnt writers for callers of vfs_mkdir()fs/namei.c fs/nfsd/nfs4recover.c+9 -00 replies
5/20elevate write count during entire ncp_ioctl()fs/ncpfs/ioctl.c+54 -10 replies
6/20sys_symlinkat() elevate write count around vfs_symlink()fs/namei.c+5 -00 replies
7/20elevate mount count for extended attributesfs/nfsd/nfs4proc.c fs/xattr.c+20 -10 replies
8/20sys_linkat(): elevate write count around vfs_link()fs/namei.c+5 -00 replies
9/20mount_is_safe(): add commentfs/namespace.c+4 -00 replies
10/20unix_find_other() elevate write count for touch_atime()net/unix/af_unix.c+12 -40 replies
11/20elevate write count over calls to vfs_rename()fs/namei.c fs/nfsd/vfs.c+24 -50 replies
12/20tricky: elevate write count files are open()edfs/file_table.c fs/namei.c ipc/mqueue.c+25 -50 replies
13/20elevate writer count for do_sys_truncate()fs/open.c+11 -50 replies
14/20elevate write count for do_utimes()fs/open.c+9 -40 replies
15/20elevate write count for do_sys_utime() and touch_atime()fs/inode.c fs/open.c+18 -70 replies
16/20sys_mknodat(): elevate write count for vfs_mknod/create()fs/namei.c fs/nfsd/vfs.c net/unix/af_unix.c+20 -00 replies
17/20elevate mnt writers for vfs_unlink() callersfs/namei.c ipc/mqueue.c+8 -10 replies
18/20do_rmdir(): elevate write countfs/namei.c+5 -00 replies
19/20elevate writer count for custom 'struct file'fs/hugetlbfs/inode.c mm/shmem.c mm/tiny-shmem.c +1 more+9 -02 replies
20/20honor r/w changes at do_remount() timefs/namespace.c fs/open.c include/linux/mount.h+45 -37 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/20] Mount writer count and read-only bind mounts (v3)

I think these are ready for -mm. They've gone through a few revisions and a week or two of normal burn-in testing.

---

The following series implements read-only bind mounts. This feature allows a read-only view into a read-write filesystem. In the process of doing that, it also provides infrastructure for keeping track of the number of writers to any given mount. New in this version is that if that number is non-zero, remounts from r/w to r/o are not allowed.

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. I've also eliminated the use of the MNT_RDONLY flag. It was redundant since we have the reference count.

This set also makes no attempt to keep the return codes for these r/o bind mounts the same as for a real r/o filesystem or device. It would require significantly more code and be quite a bit more invasive. Unless there is a very strong reason to do so, I believe it isn't worth the trouble.

One note: the previous patches all worked this way:

	mount --bind -o ro /source /dest

These patches have changed that behavior. It now requires two steps:

	mount --bind /source /dest
	mount -o remount,ro  /dest

Since the last revision, the locking in faccessat() and mnt_is_readonly() has been changed to fix a race which might have caused a false-negative mount-is-readonly return when faccessat() is called while another two processes are racing to make a mount readonly.