Skip to content

RFC vfs: 'views' for filesystems with more than one root

Mark Fasheh linux-btrfs linux-fsdevel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest76 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/76vfs: Introduce struct fs_viewfs/inode.c fs/super.c include/linux/fs.h+22 -20 replies
2/76arch: Use inode_sb() helper instead of inode->i_sbarch/arc/kernel/troubleshoot.c arch/powerpc/platforms/cell/spufs/inode.c arch/s390/hypfs/inode.c+6 -60 replies
3/76drivers: Use inode_sb() helper instead of inode->i_sbdrivers/block/loop.c drivers/infiniband/hw/qib/qib_fs.c drivers/md/md-bitmap.c +14 more+76 -710 replies
4/76fs: Use inode_sb() helper instead of inode->i_sbfs/aio.c fs/attr.c fs/binfmt_misc.c +18 more+125 -1190 replies
5/76include: Use inode_sb() helper instead of inode->i_sbinclude/linux/backing-dev.h include/linux/cleancache.h include/linux/fs.h +12 more+134 -1310 replies
6/76ipc: Use inode_sb() helper instead of inode->i_sbipc/mqueue.c+2 -20 replies
7/76kernel: Use inode_sb() helper instead of inode->i_sbkernel/audit.c kernel/audit_fsnotify.c kernel/audit_watch.c +4 more+16 -150 replies
8/76mm: Use inode_sb() helper instead of inode->i_sbmm/cleancache.c mm/filemap.c mm/hugetlb.c +3 more+30 -290 replies
9/76net: Use inode_sb() helper instead of inode->i_sbnet/sunrpc/auth_gss/auth_gss.c net/sunrpc/rpc_pipe.c+4 -40 replies
10/76security: Use inode_sb() helper instead of inode->i_sbsecurity/apparmor/apparmorfs.c security/commoncap.c security/inode.c +7 more+43 -420 replies
11/76fs/9p: Use inode_sb() helper instead of inode->i_sbfs/9p/acl.c fs/9p/v9fs.h fs/9p/vfs_inode.c +1 more+14 -130 replies
12/76fs/adfs: Use inode_sb() helper instead of inode->i_sbfs/adfs/dir.c fs/adfs/inode.c+7 -70 replies
13/76fs/affs: Use inode_sb() helper instead of inode->i_sbfs/affs/amigaffs.c fs/affs/bitmap.c fs/affs/dir.c +4 more+37 -370 replies
14/76fs/afs: Use inode_sb() helper instead of inode->i_sbfs/afs/callback.c fs/afs/dir.c fs/afs/file.c +1 more+8 -80 replies
15/76fs/autofs4: Use inode_sb() helper instead of inode->i_sbfs/autofs4/dev-ioctl.c fs/autofs4/root.c+11 -110 replies
16/76fs/befs: Use inode_sb() helper instead of inode->i_sbfs/befs/linuxvfs.c+6 -60 replies
17/76fs/bfs: Use inode_sb() helper instead of inode->i_sbfs/bfs/dir.c fs/bfs/file.c fs/bfs/inode.c+23 -200 replies
18/76fs/btrfs: Use inode_sb() helper instead of inode->i_sbfs/btrfs/compression.c fs/btrfs/ctree.h fs/btrfs/delayed-inode.c +12 more+169 -1680 replies
19/76fs/ceph: Use inode_sb() helper instead of inode->i_sbfs/ceph/addr.c fs/ceph/caps.c fs/ceph/dir.c +8 more+48 -480 replies
20/76fs/cifs: Use inode_sb() helper instead of inode->i_sbfs/cifs/cifsacl.c fs/cifs/cifsfs.c fs/cifs/cifsglob.h +10 more+80 -720 replies
21/76fs/coda: Use inode_sb() helper instead of inode->i_sbfs/coda/dir.c fs/coda/file.c fs/coda/inode.c +2 more+22 -200 replies
22/76fs/configfs: Use inode_sb() helper instead of inode->i_sbfs/configfs/inode.c+3 -30 replies
23/76fs/cramfs: Use inode_sb() helper instead of inode->i_sbfs/cramfs/inode.c+10 -90 replies
24/76fs/crypto: Use inode_sb() helper instead of inode->i_sbfs/crypto/bio.c fs/crypto/crypto.c fs/crypto/fname.c +2 more+19 -190 replies
25/76fs/ecryptfs: Use inode_sb() helper instead of inode->i_sbfs/ecryptfs/crypto.c fs/ecryptfs/file.c fs/ecryptfs/inode.c+11 -140 replies
26/76fs/efivarfs: Use inode_sb() helper instead of inode->i_sbfs/efivarfs/inode.c+1 -10 replies
27/76fs/efs: Use inode_sb() helper instead of inode->i_sbfs/efs/dir.c fs/efs/file.c fs/efs/inode.c +2 more+9 -90 replies
28/76fs/exofs: Use inode_sb() helper instead of inode->i_sbfs/exofs/dir.c fs/exofs/inode.c fs/exofs/namei.c+11 -110 replies
29/76fs/exportfs: Use inode_sb() helper instead of inode->i_sbfs/exportfs/expfs.c+1 -10 replies
30/76fs/ext2: Use inode_sb() helper instead of inode->i_sbfs/ext2/balloc.c fs/ext2/dir.c fs/ext2/file.c +6 more+115 -1120 replies
31/76fs/ext4: Use inode_sb() helper instead of inode->i_sbfs/ext4/acl.c fs/ext4/balloc.c fs/ext4/block_validity.c +26 more+591 -5640 replies
32/76fs/f2fs: Use inode_sb() helper instead of inode->i_sbfs/f2fs/data.c fs/f2fs/f2fs.h fs/f2fs/file.c +7 more+48 -451 reply
33/76fs/fat: Use inode_sb() helper instead of inode->i_sbfs/fat/cache.c fs/fat/dir.c fs/fat/fat.h +7 more+74 -740 replies
34/76fs/freevxfs: Use inode_sb() helper instead of inode->i_sbfs/freevxfs/vxfs_bmap.c fs/freevxfs/vxfs_inode.c fs/freevxfs/vxfs_lookup.c +1 more+15 -150 replies
35/76fs/fuse: Use inode_sb() helper instead of inode->i_sbfs/fuse/dir.c fs/fuse/file.c fs/fuse/fuse_i.h +1 more+15 -130 replies
36/76fs/gfs2: Use inode_sb() helper instead of inode->i_sbfs/gfs2/aops.c fs/gfs2/bmap.c fs/gfs2/dir.c +6 more+22 -190 replies
37/76fs/hfs: Use inode_sb() helper instead of inode->i_sbfs/hfs/attr.c fs/hfs/catalog.c fs/hfs/dir.c +2 more+34 -330 replies
38/76fs/hfsplus: Use inode_sb() helper instead of inode->i_sbfs/hfsplus/attributes.c fs/hfsplus/bnode.c fs/hfsplus/catalog.c +6 more+69 -650 replies
39/76fs/hostfs: Use inode_sb() helper instead of inode->i_sbfs/hostfs/hostfs_kern.c+3 -30 replies
40/76fs/hpfs: Use inode_sb() helper instead of inode->i_sbfs/hpfs/dir.c fs/hpfs/dnode.c fs/hpfs/ea.c +4 more+287 -2250 replies
41/76fs/hugetlbfs: Use inode_sb() helper instead of inode->i_sbfs/hugetlbfs/inode.c+3 -30 replies
42/76fs/isofs: Use inode_sb() helper instead of inode->i_sbfs/isofs/dir.c fs/isofs/export.c fs/isofs/inode.c +3 more+35 -320 replies
43/76fs/jbd2: Use inode_sb() helper instead of inode->i_sbfs/jbd2/journal.c+11 -70 replies
44/76fs/jffs2: Use inode_sb() helper instead of inode->i_sbfs/jffs2/dir.c fs/jffs2/file.c fs/jffs2/fs.c +1 more+19 -190 replies
45/76fs/jfs: Use inode_sb() helper instead of inode->i_sbfs/jfs/acl.c fs/jfs/file.c fs/jfs/inode.c +16 more+222 -2120 replies
46/76fs/kernfs: Use inode_sb() helper instead of inode->i_sbfs/kernfs/dir.c fs/kernfs/inode.c+3 -30 replies
47/76fs/lockd: Use inode_sb() helper instead of inode->i_sbfs/lockd/svclock.c fs/lockd/svcsubs.c+6 -60 replies
48/76fs/minix: Use inode_sb() helper instead of inode->i_sbfs/minix/bitmap.c fs/minix/dir.c fs/minix/inode.c +5 more+37 -350 replies
49/76fs/nfsd: Use inode_sb() helper instead of inode->i_sbfs/nfsd/blocklayout.c fs/nfsd/export.c fs/nfsd/nfs4recover.c +3 more+16 -150 replies
50/76fs/nfs: Use inode_sb() helper instead of inode->i_sbfs/nfs/blocklayout/rpc_pipefs.c fs/nfs/callback_proc.c fs/nfs/dir.c +15 more+84 -840 replies
51/76fs/nilfs2: Use inode_sb() helper instead of inode->i_sbfs/nilfs2/alloc.c fs/nilfs2/bmap.c fs/nilfs2/btnode.c +16 more+154 -1530 replies
52/76fs/notify: Use inode_sb() helper instead of inode->i_sbfs/notify/fdinfo.c+3 -20 replies
53/76fs/ntfs: Use inode_sb() helper instead of inode->i_sbfs/ntfs/aops.c fs/ntfs/bitmap.c fs/ntfs/dir.c +5 more+214 -1390 replies
54/76fs/ocfs2: Use inode_sb() helper instead of inode->i_sbfs/ocfs2/acl.c fs/ocfs2/alloc.c fs/ocfs2/aops.c +27 more+620 -5780 replies
55/76fs/omfs: Use inode_sb() helper instead of inode->i_sbfs/omfs/dir.c fs/omfs/file.c fs/omfs/inode.c+41 -390 replies
56/76fs/openpromfs: Use inode_sb() helper instead of inode->i_sbfs/openpromfs/inode.c+1 -10 replies
57/76fs/orangefs: Use inode_sb() helper instead of inode->i_sbfs/orangefs/file.c fs/orangefs/namei.c fs/orangefs/orangefs-kernel.h+13 -90 replies
58/76fs/overlayfs: Use inode_sb() helper instead of inode->i_sbfs/overlayfs/export.c fs/overlayfs/inode.c fs/overlayfs/super.c+5 -50 replies
59/76fs/proc: Use inode_sb() helper instead of inode->i_sbfs/proc/array.c fs/proc/base.c fs/proc/fd.c +8 more+24 -220 replies
60/76fs/qnx4: Use inode_sb() helper instead of inode->i_sbfs/qnx4/dir.c fs/qnx4/inode.c fs/qnx4/namei.c+5 -50 replies
61/76fs/qnx6: Use inode_sb() helper instead of inode->i_sbfs/qnx6/dir.c fs/qnx6/inode.c fs/qnx6/namei.c+7 -70 replies
62/76fs/quota: Use inode_sb() helper instead of inode->i_sbfs/quota/dquot.c+15 -150 replies
63/76fs/ramfs: Use inode_sb() helper instead of inode->i_sbfs/ramfs/inode.c+2 -20 replies
64/76fs/read: Use inode_sb() helper instead of inode->i_sbfs/read_write.c+6 -50 replies
65/76fs/reiserfs: Use inode_sb() helper instead of inode->i_sbfs/reiserfs/bitmap.c fs/reiserfs/dir.c fs/reiserfs/file.c +13 more+397 -3860 replies
66/76fs/romfs: Use inode_sb() helper instead of inode->i_sbfs/romfs/mmap-nommu.c fs/romfs/super.c+15 -130 replies
67/76fs/squashfs: Use inode_sb() helper instead of inode->i_sbfs/squashfs/dir.c fs/squashfs/export.c fs/squashfs/file.c +6 more+61 -510 replies
68/76fs/sysv: Use inode_sb() helper instead of inode->i_sbfs/sysv/dir.c fs/sysv/ialloc.c fs/sysv/inode.c +2 more+30 -290 replies
69/76fs/ubifs: Use inode_sb() helper instead of inode->i_sbfs/ubifs/crypto.c fs/ubifs/dir.c fs/ubifs/file.c +3 more+47 -470 replies
70/76fs/udf: Use inode_sb() helper instead of inode->i_sbfs/udf/dir.c fs/udf/directory.c fs/udf/file.c +8 more+199 -1890 replies
71/76fs/ufs: Use inode_sb() helper instead of inode->i_sbfs/ufs/balloc.c fs/ufs/dir.c fs/ufs/ialloc.c +2 more+53 -510 replies
72/76fs/xfs: Use inode_sb() helper instead of inode->i_sbfs/xfs/xfs_acl.c fs/xfs/xfs_aops.c fs/xfs/xfs_export.c +5 more+50 -500 replies
73/76vfs: Move s_dev to to struct fs_viewinclude/linux/fs.h+6 -10 replies
74/76fs: Use fs_view device from struct inode.arch/arc/kernel/troubleshoot.c drivers/staging/lustre/lustre/llite/dir.c drivers/staging/lustre/lustre/llite/file.c +29 more+209 -2090 replies
75/76fs: Use fs view device from struct super_blockdrivers/mtd/mtdsuper.c drivers/staging/lustre/lustre/llite/llite_lib.c fs/autofs4/autofs_i.h +34 more+162 -1570 replies
76/76btrfs: Use fs_view in roots, point inodes to itfs/btrfs/ctree.h fs/btrfs/disk-io.c fs/btrfs/disk-io.h +2 more+15 -150 replies

Reviews trailers per patch

1 of 76 patches has a Reviewed-by or Acked-by.

PatchChao Yu
1/76
2/76
3/76
4/76
5/76
6/76
7/76
8/76
9/76
10/76
11/76
12/76
13/76
14/76
15/76
16/76
17/76
18/76
19/76
20/76
21/76
22/76
23/76
24/76
25/76
26/76
27/76
28/76
29/76
30/76
31/76
32/76R-b
33/76
34/76
35/76
36/76
37/76
38/76
39/76
40/76
41/76
42/76
43/76
44/76
45/76
46/76
47/76
48/76
49/76
50/76
51/76
52/76
53/76
54/76
55/76
56/76
57/76
58/76
59/76
60/76
61/76
62/76
63/76
64/76
65/76
66/76
67/76
68/76
69/76
70/76
71/76
72/76
73/76
74/76
75/76
76/76

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 0/76] vfs: 'views' for filesystems with more than one root

Hi,

The VFS's super_block covers a variety of filesystem functionality. In particular we have a single structure representing both I/O and namespace domains.

There are requirements to de-couple this functionality. For example, filesystems with more than one root (such as btrfs subvolumes) can have multiple inode namespaces. This starts to confuse userspace when it notices multiple inodes with the same inode/device tuple on a filesystem.

In addition, it's currently impossible for a filesystem subvolume to have a different security context from it's parent. If we could allow for subvolumes to optionally specify their own security context, we could use them as containers directly instead of having to go through an overlay.

I ran into this particular problem with respect to Btrfs some years ago and sent out a very naive set of patches which were (rightfully) not incorporated:

https://marc.info/?l=linux-btrfs&m=130074451403261&w=2
https://marc.info/?l=linux-btrfs&m=130532890824992&w=2

During the discussion, one question did come up - why can't filesystems like Btrfs use a superblock per subvolume? There's a couple of problems with that:

- It's common for a single Btrfs filesystem to have thousands of subvolumes. So keeping a superblock for each subvol in memory would get prohibively expensive - imagine having 8000 copies of struct super_block for a file system just because we wanted some separation of say, s_dev.

- Writeback would also have to walk all of these superblocks - again not very good for system performance.

- Anyone wanting to lock down I/O on a filesystem would have to freeze all the superblocks. This goes for most things related to I/O really
- we simply can't afford to have the kernel walking thousands of superblocks to sync a single fs.

It's far more efficient then to pull those fields we need for a subvolume namespace into their own structure.

The following patches attempt to fix this issue by introducing a structure, fs_view, which can be used to represent a 'view' into a filesystem. We can migrate super_block fields to this structure one at a time. Struct super_block gets a default view embedded into it. Inodes get a new field, i_view, which can be dereferenced to get the view that an inode belgongs to. By default, we point i_view to the view on struct super_block. That way existing filesystems don't have to do anything different.

The patches are careful not to grow the size of struct inode.

For the first patch series, we migrate s_dev over from struct super_block to struct fs_view. This fixes a long standing bug in how the kernel reports inode devices to userspace.

The series follows an order:

- We first introduce the fs_view structure and embed it into struct super_block. As discussed, struct inode gets a pointer to the fs_view, i_view. The only member on fs_view at this point is a super_block * so that we can replace i_sb. A helper function is provided to get to the super_block from a struct inode.

- Convert the kernel to using our helper function to get to i_sb. This is done on in a per-filesystem patch. The other parts of the kernel referencing i_sb get their changes batched up in logical groupings.

- Move s_dev from struct super_block to struct fs_view.

- Convert the kernel from inode->i_sb->s_dev to the device from our fs_view. In the end, these lines will look like inode_view(inode)->v_dev.

- Add an fs_view struct to each Btrfs root, point inodes to that view when we initialize them.

The patches are available via git and are based off Linux v4.16. There's two branches, with identical code.

- With the inode_sb() changeover patch broken out (as is sent here):

https://github.com/markfasheh/linux fs_view-broken-out

- With the inode_sb() changeover patch in one big change:

https://github.com/markfasheh/linux fs_view

Comments are appreciated.

Thanks,
--Mark