Unbork fs.h + per-fs supers
Subsystems (7)
Adding VFS support for per-fs superblock size was dead simple compared to doing the inodes because superblocks are few enough that no slab cache is needed, and also because of cleanup Al had already done.
I've gotten brave enough to run this on my own machine (which I'm doing right now) so I'd be pleased if some folks would be equally brave and give this a workout. If it works well, everything is in place to start moving the per-fs includes out of fs.h, so the sooner it gets tested, the better.
Besides providing the VFS mechanism, this patch enables per-fs superblocks and inodes for Ext2. I did not remove the get_empty_inode function in this patch - that properly belongs in a separate patch.
To apply:
cd /your/source/tree
cat this/patch | patch -p0
--
Daniel
drivers/block/rd.c renamed from 2.4.17.clean/drivers/block/rd.c +2 -2
@@ -673,7 +673,7 @@#endif ram_device =MKDEV (MAJOR_NR , unit); -if ((inode =get_empty_inode ()) ==NULL ) +if ((inode =get_empty_inode (NULL )) ==NULL )return ;memset (&infile,0 ,sizeof (infile));memset (&in_dentry,0 ,sizeof (in_dentry));
@@ -683,7 +683,7 @@ infile.f_op = &def_blk_fops;init_special_inode (inode,S_IFBLK |S_IRUSR ,kdev_t_to_nr (device)); -if ((out_inode =get_empty_inode ()) ==NULL ) +if ((out_inode =get_empty_inode (NULL )) ==NULL ) goto free_inode;memset (&outfile,0 ,sizeof (outfile));memset (&out_dentry,0 ,sizeof (out_dentry));
fs/ext2/super.c renamed from 2.4.17.clean/fs/ext2/super.c +11 -4
@@ -806,16 +806,23 @@return 0 ; } -static DECLARE_FSTYPE_DEV(ext2_fs_type, "ext2", ext2_read_super); - +static struct file_system_type ext2_fs = { + owner:THIS_MODULE , + fs_flags:FS_REQUIRES_DEV , + name:"ext2" , + read_super: ext2_read_super, + super_size:sizeof (struct ext2_sb_info ), + inode_size:sizeof (struct ext2_inode_info ) +}; +static int __init init_ext2_fs (void ) { -return register_filesystem (&ext2_fs_type); +return register_filesystem (&ext2_fs); } static void __exit exit_ext2_fs(void) { -unregister_filesystem (&ext2_fs_type); +unregister_filesystem (&ext2_fs); }EXPORT_NO_SYMBOLS ;
fs/inode.c renamed from 2.4.17.clean/fs/inode.c +48 -22
157 lines not on this page · raw message
fs/super.c renamed from 2.4.17.clean/fs/super.c +35 -26
119 lines not on this page · raw message
include/linux/fs.h renamed from 2.4.17.clean/include/linux/fs.h +14 -6
@@ -691,6 +691,9 @@#include <linux/cramfs_fs_sb.h> #include <linux/jffs2_fs_sb.h> +extern struct file_system_type *file_systems; +extern rwlock_t file_systems_lock; +extern struct list_head super_blocks;extern spinlock_t sb_lock;
@@ -951,10 +954,14 @@int fs_flags;struct super_block *(*read_super) (struct super_block *,void *,int );struct module *owner; -struct file_system_type * next; +struct file_system_type *next;struct list_head fs_supers; +unsigned super_size, inode_size; +struct kmem_cache_s *inode_cache; }; +/* Backward compatible declarations, remove when all updated */ +#define DECLARE_FSTYPE (var,type,read,flags) \ struct file_system_type var = { \ name: type, \
@@ -1328,20 +1335,21 @@ }extern void clear_inode (struct inode *); -extern struct inode *get_empty_inode (void ); +extern struct inode *get_empty_inode (struct super_block *sb); -static inline struct inode *new_inode (struct super_block *sb) +static inline struct inode *new_inode (struct super_block *sb) { -struct inode *inode =get_empty_inode (); +struct inode *inode =get_empty_inode (sb);if (inode) { - inode->i_sb = sb; inode->i_dev = sb->s_dev; inode->i_blkbits = sb->s_blocksize_bits; }return inode; } -extern void remove_suid (struct inode *inode); +extern int create_inode_cache (struct file_system_type *fs); +extern int destroy_inode_cache (struct file_system_type *fs); +extern void remove_suid (struct inode *inode);extern void insert_inode_hash (struct inode *);extern void remove_inode_hash (struct inode *);extern struct file *get_empty_filp (void );
include/linux/slab.h renamed from 2.4.17.clean/include/linux/slab.h +1 -0
@@ -57,6 +57,7 @@extern int kmem_cache_shrink (kmem_cache_t *);extern void *kmem_cache_alloc (kmem_cache_t *,int );extern void kmem_cache_free (kmem_cache_t *,void *); +extern void kmem_cache_clear (kmem_cache_t *,void *);extern void *kmalloc (size_t ,int );extern void kfree (const void *);
mm/slab.c renamed from 2.4.17.clean/mm/slab.c +10 -0
@@ -1078,6 +1078,16 @@ slabp->free =0 ; } +void kmem_cache_clear (kmem_cache_t *cachep,void *objp) +{ +unsigned size = cachep->objsize; +#if DEBUG +if (cachep->flags &SLAB_RED_ZONE ) + size -=BYTES_PER_WORD *2 ; +#endif +memset (objp,0 , size); +} +/* * Grow (by 1) the number of slabs within a cache. This is called by * kmem_cache_alloc() when there are no active objs left in a cache.
net/socket.c renamed from 2.4.17.clean/net/socket.c +1 -2
@@ -438,11 +438,10 @@struct inode * inode;struct socket * sock; - inode =get_empty_inode (); + inode =get_empty_inode (sock_mnt->mnt_sb);if (!inode)return NULL ; - inode->i_sb = sock_mnt->mnt_sb; sock =socki_lookup (inode); inode->i_mode =S_IFSOCK |S_IRWXUGO ;
Quoted 3 lines · Daniel Phillips
Adding VFS support for per-fs superblock size was dead simple compared to doing the inodes because superblocks are few enough that no slab cache is needed, and also because of cleanup Al had already done.
*Stop*.
First of all, exporting size of superblock is wrong, since the entire ->read_super() mechanism is going to be replaced with ->get_super(type, ...) (get_sb_...() becoming commonly used instances of the method). Moreover, freeing superblock is very likely to become a method (for quite a few reasons).
Please, don't turn fs type into a bloody mess. It's bad enough as it is; at least don't add the stuff that will go away anyway.
Quoted 8 lines · Alexander Viro
Quoted 3 lines · Daniel Phillips
Adding VFS support for per-fs superblock size was dead simple compared to doing the inodes because superblocks are few enough that no slab cache is needed, and also because of cleanup Al had already done.
*Stop*.
Quoted 8 lines
First of all, exporting size of superblock is wrong, since the entire ->read_super() mechanism is going to be replaced with ->get_super(type, ...) (get_sb_...() becoming commonly used instances of the method). Moreover, freeing superblock is very likely to become a method (for quite a few reasons).
Please, don't turn fs type into a bloody mess. It's bad enough as it is; at least don't add the stuff that will go away anyway.
How would you suggest it be done?
--
Daniel
Re: [CFT] Unbork fs.h + per-fs supers -> dontuse
In reply to Daniel PhillipsDon't use the above patch please, there's a stupid oversight - it seems super_block has a couple of fields *after* the fs-private union, and the new code doesn't take that into account. The plan is:
a) get some sleep
b) then fix it
--
Daniel
Re: [CFT] Unbork fs.h + per-fs supers (fixed)
In reply to Daniel PhillipsQuoted 3 lines · Daniel Phillips
Don't use the above patch please, there's a stupid oversight - it seems
super_blockhas a couple of fields *after* the fs-private union, and the new code doesn't take that into account.
Yes, that was it all right. This was fixed by moving the two 'don't use' inode fields before the union. (The variable-sized component of such structs always has to come last.) I also cleaned up the formatting of my additions along the lines discussed in the recent 'janitorial' thread.
Doing 'less /proc/slabinfo' shows the ext2 inode cache objects, at 416 bytes, are now 64 bytes smaller than they used to be. More space could be saved by relaxing the slab cache alignment for these objects from 64 bytes (686 cacheline) to 4 or 8 bytes. Has anybody checked to see if hardware cacheline alignment for inodes is really a win?
This patch now appears stable enough for testing - I'm running it on my server at the moment.
To Apply:
cd /your/2.4.17/tree
cat this/patch | patch -p0
--
Daniel
drivers/block/rd.c renamed from 2.4.17.clean/drivers/block/rd.c +2 -2
@@ -673,7 +673,7 @@#endif ram_device =MKDEV (MAJOR_NR , unit); -if ((inode =get_empty_inode ()) ==NULL ) +if ((inode =get_empty_inode (NULL )) ==NULL )return ;memset (&infile,0 ,sizeof (infile));memset (&in_dentry,0 ,sizeof (in_dentry));
@@ -683,7 +683,7 @@ infile.f_op = &def_blk_fops;init_special_inode (inode,S_IFBLK |S_IRUSR ,kdev_t_to_nr (device)); -if ((out_inode =get_empty_inode ()) ==NULL ) +if ((out_inode =get_empty_inode (NULL )) ==NULL ) goto free_inode;memset (&outfile,0 ,sizeof (outfile));memset (&out_dentry,0 ,sizeof (out_dentry));
fs/ext2/super.c renamed from 2.4.17.clean/fs/ext2/super.c +11 -4
@@ -806,16 +806,23 @@return 0 ; } -static DECLARE_FSTYPE_DEV(ext2_fs_type, "ext2", ext2_read_super); - +static struct file_system_type ext2_fs = { + owner:THIS_MODULE , + fs_flags:FS_REQUIRES_DEV , + name:"ext2" , + read_super: ext2_read_super, + super_size:sizeof (struct ext2_sb_info ), + inode_size:sizeof (struct ext2_inode_info ) +}; +static int __init init_ext2_fs (void ) { -return register_filesystem (&ext2_fs_type); +return register_filesystem (&ext2_fs); } static void __exit exit_ext2_fs(void) { -unregister_filesystem (&ext2_fs_type); +unregister_filesystem (&ext2_fs); }EXPORT_NO_SYMBOLS ;
fs/inode.c renamed from 2.4.17.clean/fs/inode.c +48 -22
157 lines not on this page · raw message
fs/super.c renamed from 2.4.17.clean/fs/super.c +35 -26
119 lines not on this page · raw message
include/linux/fs.h renamed from 2.4.17.clean/include/linux/fs.h +29 -20
91 lines not on this page · raw message
include/linux/slab.h renamed from 2.4.17.clean/include/linux/slab.h +1 -0
@@ -57,6 +57,7 @@extern int kmem_cache_shrink (kmem_cache_t *);extern void *kmem_cache_alloc (kmem_cache_t *,int );extern void kmem_cache_free (kmem_cache_t *,void *); +extern void kmem_cache_clear (kmem_cache_t *,void *);extern void *kmalloc (size_t ,int );extern void kfree (const void *);
mm/slab.c renamed from 2.4.17.clean/mm/slab.c +10 -0
@@ -1078,6 +1078,16 @@ slabp->free =0 ; } +void kmem_cache_clear (kmem_cache_t *cachep,void *objp) +{ +unsigned size = cachep->objsize; +#if DEBUG +if (cachep->flags &SLAB_RED_ZONE ) + size -=BYTES_PER_WORD *2 ; +#endif +memset (objp,0 , size); +} +/* * Grow (by 1) the number of slabs within a cache. This is called by * kmem_cache_alloc() when there are no active objs left in a cache.
net/socket.c renamed from 2.4.17.clean/net/socket.c +1 -2
@@ -438,11 +438,10 @@struct inode * inode;struct socket * sock; - inode =get_empty_inode (); + inode =get_empty_inode (sock_mnt->mnt_sb);if (!inode)return NULL ; - inode->i_sb = sock_mnt->mnt_sb; sock =socki_lookup (inode); inode->i_mode =S_IFSOCK |S_IRWXUGO ;