Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

convert ramfs and tmpfs

Quite a bit is already done by infrastructure changes (simple_link(),
simple_unlink()) - all that is left is replacing d_instantiate() +
pinning dget() (in ->symlink() and ->mknod()) with d_make_persistent(),
and, in case of shmem, using simple_unlink() and simple_link() in
->unlink() and ->link() resp., instead of open-coding those there.
Since d_make_persistent() accepts (and hashes) unhashed ones, shmem
situation gets simpler - we no longer care whether ->lookup() has hashed
the sucker.

With that done, we don't need kill_litter_super() for these filesystems
anymore - by the umount time all remaining dentries will be marked
persistent and kill_litter_super() will boil down to call of
kill_anon_super().

The same goes for devtmpfs and rootfs - they are handled by
ramfs or by shmem, depending upon config.

NB: strictly speaking, both devtmpfs and rootfs ought to use
ramfs_kill_sb() if they end up using ramfs; that's a separate
story and the only impact of "just use kill_{litter,anon}_super()"
is that we fail to free their sb->s_fs_info... on reboot.
That's orthogonal to the changes in this series - kill_litter_super()
is identical to kill_anon_super() for those at this point.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 23135982 e49ce258

+13 -37
+1 -1
drivers/base/devtmpfs.c
··· 70 70 #else 71 71 .init_fs_context = ramfs_init_fs_context, 72 72 #endif 73 - .kill_sb = kill_litter_super, 73 + .kill_sb = kill_anon_super, 74 74 }; 75 75 76 76 /* Simply take a ref on the existing mount */
+3 -5
fs/ramfs/inode.c
··· 110 110 goto out; 111 111 } 112 112 113 - d_instantiate(dentry, inode); 114 - dget(dentry); /* Extra count - pin the dentry in core */ 113 + d_make_persistent(dentry, inode); 115 114 error = 0; 116 115 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); 117 116 } ··· 153 154 154 155 error = page_symlink(inode, symname, l); 155 156 if (!error) { 156 - d_instantiate(dentry, inode); 157 - dget(dentry); 157 + d_make_persistent(dentry, inode); 158 158 inode_set_mtime_to_ts(dir, 159 159 inode_set_ctime_current(dir)); 160 160 } else ··· 311 313 void ramfs_kill_sb(struct super_block *sb) 312 314 { 313 315 kfree(sb->s_fs_info); 314 - kill_litter_super(sb); 316 + kill_anon_super(sb); 315 317 } 316 318 317 319 static struct file_system_type ramfs_fs_type = {
+1 -1
init/do_mounts.c
··· 507 507 struct file_system_type rootfs_fs_type = { 508 508 .name = "rootfs", 509 509 .init_fs_context = rootfs_init_fs_context, 510 - .kill_sb = kill_litter_super, 510 + .kill_sb = kill_anon_super, 511 511 }; 512 512 513 513 void __init init_rootfs(void)
+8 -30
mm/shmem.c
··· 3858 3858 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); 3859 3859 inode_inc_iversion(dir); 3860 3860 3861 - if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) 3862 - d_add(dentry, inode); 3863 - else 3864 - d_instantiate(dentry, inode); 3865 - 3866 - dget(dentry); /* Extra count - pin the dentry in core */ 3861 + d_make_persistent(dentry, inode); 3867 3862 return error; 3868 3863 3869 3864 out_iput: ··· 3919 3924 struct dentry *dentry) 3920 3925 { 3921 3926 struct inode *inode = d_inode(old_dentry); 3922 - int ret = 0; 3927 + int ret; 3923 3928 3924 3929 /* 3925 3930 * No ordinary (disk based) filesystem counts links as inodes; ··· 3931 3936 if (inode->i_nlink) { 3932 3937 ret = shmem_reserve_inode(inode->i_sb, NULL); 3933 3938 if (ret) 3934 - goto out; 3939 + return ret; 3935 3940 } 3936 3941 3937 3942 ret = simple_offset_add(shmem_get_offset_ctx(dir), dentry); 3938 3943 if (ret) { 3939 3944 if (inode->i_nlink) 3940 3945 shmem_free_inode(inode->i_sb, 0); 3941 - goto out; 3946 + return ret; 3942 3947 } 3943 3948 3944 3949 dir->i_size += BOGO_DIRENT_SIZE; 3945 - inode_set_mtime_to_ts(dir, 3946 - inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode))); 3947 3950 inode_inc_iversion(dir); 3948 - inc_nlink(inode); 3949 - ihold(inode); /* New dentry reference */ 3950 - dget(dentry); /* Extra pinning count for the created dentry */ 3951 - if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) 3952 - d_add(dentry, inode); 3953 - else 3954 - d_instantiate(dentry, inode); 3955 - out: 3956 - return ret; 3951 + return simple_link(old_dentry, dir, dentry); 3957 3952 } 3958 3953 3959 3954 static int shmem_unlink(struct inode *dir, struct dentry *dentry) ··· 3956 3971 simple_offset_remove(shmem_get_offset_ctx(dir), dentry); 3957 3972 3958 3973 dir->i_size -= BOGO_DIRENT_SIZE; 3959 - inode_set_mtime_to_ts(dir, 3960 - inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode))); 3961 3974 inode_inc_iversion(dir); 3962 - drop_nlink(inode); 3963 - dput(dentry); /* Undo the count from "create" - does all the work */ 3975 + simple_unlink(dir, dentry); 3964 3976 3965 3977 /* 3966 3978 * For now, VFS can't deal with case-insensitive negative dentries, so ··· 4112 4130 dir->i_size += BOGO_DIRENT_SIZE; 4113 4131 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); 4114 4132 inode_inc_iversion(dir); 4115 - if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) 4116 - d_add(dentry, inode); 4117 - else 4118 - d_instantiate(dentry, inode); 4119 - dget(dentry); 4133 + d_make_persistent(dentry, inode); 4120 4134 return 0; 4121 4135 4122 4136 out_remove_offset: ··· 5312 5334 #ifdef CONFIG_TMPFS 5313 5335 .parameters = shmem_fs_parameters, 5314 5336 #endif 5315 - .kill_sb = kill_litter_super, 5337 + .kill_sb = kill_anon_super, 5316 5338 .fs_flags = FS_USERNS_MOUNT | FS_ALLOW_IDMAP | FS_MGTIME, 5317 5339 }; 5318 5340