Skip to content

Mount writer count API (read-only bind mounts prep)

Dave Hansen linux-fsdevel lkml 1 version New

Get series with b4
b4 am 20070712001710.654CD9ED@kernel

Versions newest first

  1. v1 Latest23 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/23rearrange may_open() to be r/o friendlyfs/namei.c+9 -50 replies
2/23create cleanup helper svc_msnfs()fs/nfsd/vfs.c+11 -40 replies
3/23filesystem helpers for custom 'struct file'sfs/configfs/dir.c fs/file_table.c fs/hugetlbfs/inode.c +5 more+78 -490 replies
4/23r/o bind mounts: stub functionsfs/namespace.c include/linux/mount.h+49 -00 replies
5/23elevate write count open()'d filesfs/file_table.c fs/namei.c ipc/mqueue.c+27 -50 replies
6/23r/o bind mounts: elevate write count for some ioctlsfs/ext2/ioctl.c fs/ext3/ioctl.c fs/ext4/ioctl.c +8 more+272 -1560 replies
7/23elevate writer count for chown and friendsfs/open.c+30 -90 replies
8/23make access() use mnt checkfs/open.c+11 -20 replies
9/23elevate mnt writers for callers of vfs_mkdir()fs/namei.c fs/nfsd/nfs4recover.c+9 -00 replies
10/23elevate write count during entire ncp_ioctl()fs/ncpfs/ioctl.c+54 -10 replies
11/23elevate write count for link and symlink callsfs/namei.c+10 -00 replies
12/23elevate mount count for extended attributesfs/nfsd/nfs4proc.c fs/xattr.c+20 -30 replies
13/23elevate write count for file_update_time()fs/inode.c+12 -10 replies
14/23mount_is_safe(): add commentfs/namespace.c+4 -00 replies
15/23unix_find_other() elevate write count for touch_atime()net/unix/af_unix.c+12 -40 replies
16/23elevate write count over calls to vfs_rename()fs/namei.c fs/nfsd/vfs.c+15 -40 replies
17/23nfs: check mnt instead of superblock directlyfs/nfs/dir.c fs/nfsd/vfs.c+4 -30 replies
18/23elevate writer count for do_sys_truncate()fs/open.c+9 -70 replies
19/23elevate write count for do_utimes()fs/utimes.c+9 -60 replies
20/23elevate write count for do_sys_utime() and touch_atime()fs/inode.c+12 -80 replies
21/23sys_mknodat(): elevate write count for vfs_mknod/create()fs/namei.c fs/nfsd/vfs.c net/unix/af_unix.c+29 -110 replies
22/23elevate mnt writers for vfs_unlink() callersfs/namei.c ipc/mqueue.c+8 -10 replies
23/23do_rmdir(): elevate write countfs/namei.c+5 -00 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/23] Mount writer count API (read-only bind mounts prep)

The most contentious part of the r/o bind mount patches is actually implementing the count tracking. It has NUMA and SMP implications, and is going to need to have a whole discussion on that one patch.

These patches, on the other hand, simply introduce a new
API: mnt_want_write() and mnt_drop_write(). They do not functionally change the kernel, just alter the way in which we check filesystems for our ability to write to them.

These functions should be used in place of IS_RDONLY(inode) as they explicitly spell out when a mount is expected to _stay_ r/w instead of simply checking at a single point in time.

It should take a very small number (like 3) of small patches to actually implement read-only bind mounts on top of this new API.

These apply to current -git (as of July 11th, 2007).

---

Why do we need r/o 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.

This has a number of uses. It allows chroots to have parts of filesystems writable. It will be useful for containers in the future because users may have root inside a container, but should not be allowed to write to somefilesystems. This also replaces patches that vserver has had out of the tree for several years.

It allows security enhancement by making sure that parts of your filesystem read-only (such as when you don't trust your FTP server), when you don't want to have entire new filesystems mounted, or when you want atime selectively updated. I've been using the following script to test that the feature is working as desired. It takes a directory and makes a regular bind and a r/o bind mount of it. It then performs some normal filesystem operations on the three directories, including ones that are expected to fail, like creating a file on the r/o mount.