Quota Hash Abstraction 2.4.22-pre6 second part
Subsystems (4)
Hi All!
Here goes the second patch which should complete the Quota Hash Abstraction (at least regarding super_block and sb references)
added the locking and included the trivial fix.
attached a interdiff between 0.04 and 0.05 as well as the new 0.05 patch (for 2.4.22-pre6).
enjoy,
Herbert
fs/dquot.c +22 -12
@@ -68,6 +68,7 @@#include <linux/init.h> #include <linux/module.h> #include <linux/proc_fs.h> +#include <linux/quotaops.h> #include <asm/uaccess.h>
@@ -392,8 +393,12 @@INIT_LIST_HEAD (hash->dqh_hash + i);sema_init (&hash->dqh_dquot.dqio_sem,1 );sema_init (&hash->dqh_dquot.dqoff_sem,1 ); + hash->dqh_qop = &dquot_operations; + hash->dqh_qcop = &vfs_quotactl_ops; } +lock_kernel ();list_add (&hash->dqh_list, &dqhash_list); +unlock_kernel ();// printk ("new dqhash %p\n", hash); return hash; }
@@ -403,7 +408,9 @@int cnt;// printk ("destroy dqhash %p\n", hash); +lock_kernel ();list_del (&hash->dqh_list); +unlock_kernel ();for (cnt =0 ; cnt <MAXQUOTAS ; cnt++)invalidate_dquots (hash, cnt);kfree (hash);
@@ -454,7 +461,7 @@if (dquot->dq_flags &DQ_LOCKED )wait_on_dquot (dquot);if (dquot_dirty (dquot)) - sb->dq_op->sync_dquot (dquot); + hash->dqh_qop->sync_dquot (dquot);dqput (dquot); goto restart; }
@@ -478,10 +485,11 @@spin_lock (&sb_lock);list_for_each (head, &super_blocks) { struct super_block *sb = list_entry(head, struct super_block, s_list); +struct dqhash *dqh = sb->s_dqh;for (cnt =0 , dirty =0 ; cnt <MAXQUOTAS ; cnt++) -if ((type == cnt || type ==-1 ) &&sb_has_quota_enabled (sb, cnt) - &&sb_dqopt (sb)->info[cnt].dqi_flags &DQF_ANY_DQUOT_DIRTY ) +if ((type == cnt || type ==-1 ) &&dqh_has_quota_enabled (dqh, cnt) + &&dqh_dqopt (dqh)->info[cnt].dqi_flags &DQF_ANY_DQUOT_DIRTY ) dirty =1 ;if (!dirty)continue ;
@@ -501,12 +509,14 @@void sync_dquots_dev (kdev_t dev,int type) {struct super_block *sb; +struct dqhash *dqh;if (dev) {if ((sb =get_super (dev))) {lock_kernel (); -if (sb->s_qcop->quota_sync) - sb->s_qcop->quota_sync (sb->s_dqh, type); + dqh = sb->s_dqh; +if (dqh && dqh->dqh_qcop->quota_sync) + dqh->dqh_qcop->quota_sync (dqh, type);unlock_kernel ();drop_super (sb); }
@@ -514,19 +524,20 @@else {while ((sb =get_super_to_sync (type))) {lock_kernel (); -if (sb->s_qcop->quota_sync) - sb->s_qcop->quota_sync (sb->s_dqh, type); + dqh = sb->s_dqh; +if (dqh && dqh->dqh_qcop->quota_sync) + dqh->dqh_qcop->quota_sync (dqh, type);unlock_kernel ();drop_super (sb); } } } -void sync_dquots_sb (struct super_block *sb,int type) +void sync_dquots_dqh (struct dqhash *hash,int type) {lock_kernel (); -if (sb->s_qcop->quota_sync) - sb->s_qcop->quota_sync (sb->s_dqh, type); +if (hash->dqh_qcop->quota_sync) + hash->dqh_qcop->quota_sync (hash, type);unlock_kernel (); }
@@ -751,7 +762,7 @@struct vfsmount *mnt =mntget (filp->f_vfsmnt);struct dentry *dentry =dget (filp->f_dentry);file_list_unlock (); - sb->dq_op->initialize (inode, type); + hash->dqh_qop->initialize (inode, type);dput (dentry);mntput (mnt);/* As we may have blocked we had better restart... */
@@ -1356,7 +1367,6 @@ dqopt->ops[cnt] =NULL ; }up (&dqopt->dqoff_sem); -out:unlock_kernel ();return 0 ; }
fs/inode.c +4 -4
@@ -95,6 +95,7 @@struct address_space *const mapping = &inode->i_data; inode->i_sb = sb; + inode->i_dqh = sb->s_dqh;/* this is the default */ inode->i_dev = sb->s_dev; inode->i_blkbits = sb->s_blocksize_bits; inode->i_flags =0 ;
@@ -1212,8 +1213,7 @@struct super_block *sb = hash->dqh_sb;LIST_HEAD (tofree_head); -/* fix this later!!, we need dq_op here? */ -if (sb && !sb->dq_op) +if (hash->dqh_qop)return ;/* nothing to do */ /* We have to be protected against other CPUs */ lock_kernel ();/* This lock is for quota code */
@@ -1221,12 +1221,12 @@list_for_each (act_head, &inode_in_use) { inode = list_entry(act_head, struct inode, i_list); -if (inode->i_sb == sb &&IS_QUOTAINIT (inode)) +if (inode->i_dqh == hash &&IS_QUOTAINIT (inode))remove_inode_dquot_ref (inode, type, &tofree_head); }list_for_each (act_head, &inode_unused) { inode = list_entry(act_head, struct inode, i_list); -if (inode->i_sb == sb &&IS_QUOTAINIT (inode)) +if (inode->i_dqh == hash &&IS_QUOTAINIT (inode))remove_inode_dquot_ref (inode, type, &tofree_head); }list_for_each (act_head, &sb->s_dirty) {
fs/quota.c +63 -71
393 lines not on this page · raw message
fs/super.c +0 -2
@@ -280,8 +280,6 @@sema_init (&s->s_nfsd_free_path_sem,1 ); s->s_maxbytes =MAX_NON_LFS ; s->s_op = &empty_sops; - s->dq_op = sb_dquot_ops; - s->s_qcop = sb_quotactl_ops;/* quick hack to make dqhash id unique, sufficient for now */ s->s_dqh =new_dqhash ((unsigned int )s); s->s_dqh->dqh_sb = s;
include/linux/fs.h +1 -2
@@ -468,6 +468,7 @@struct file_lock *i_flock;struct address_space *i_mapping;struct address_space i_data; +struct dqhash *i_dqh;struct dquot *i_dquot[MAXQUOTAS ];/* These three should probably be a union */ struct list_head i_devices;
@@ -743,8 +744,6 @@unsigned long long s_maxbytes;/* Max file size */ struct file_system_type *s_type;struct super_operations *s_op; -struct dquot_operations *dq_op; -struct quotactl_ops *s_qcop;unsigned long s_flags;unsigned long s_magic;struct dentry *s_root;
include/linux/quota.h +6 -10
@@ -182,8 +182,6 @@#define info_any_dirty (info) ((info)->dqi_flags & DQF_INFO_DIRTY ||\ (info)->dqi_flags & DQF_ANY_DQUOT_DIRTY) -#define sb_dqopt (sb) (dqh_dqopt((sb)->s_dqh)) -#define dqh_dqopt (dqh) (&(dqh)->dqh_dquot)struct dqstats {
@@ -265,10 +263,10 @@int (*set_info)(struct dqhash *,int ,struct if_dqinfo *);int (*get_dqblk)(struct dqhash *,int ,qid_t ,struct if_dqblk *);int (*set_dqblk)(struct dqhash *,int ,qid_t ,struct if_dqblk *); -int (*get_xstate)(struct super_block *,struct fs_quota_stat *); -int (*set_xstate)(struct super_block *,unsigned int ,int ); -int (*get_xquota)(struct super_block *,int ,qid_t ,struct fs_disk_quota *); -int (*set_xquota)(struct super_block *,int ,qid_t ,struct fs_disk_quota *); +int (*get_xstate)(struct dqhash *,struct fs_quota_stat *); +int (*set_xstate)(struct dqhash *,unsigned int ,int ); +int (*get_xquota)(struct dqhash *,int ,qid_t ,struct fs_disk_quota *); +int (*set_xquota)(struct dqhash *,int ,qid_t ,struct fs_disk_quota *); };struct quota_format_type {
@@ -304,10 +302,6 @@return 0 ; } -#define sb_any_quota_enabled (sb) (is_enabled(sb_dqopt(sb), USRQUOTA) | is_enabled(sb_dqopt(sb), GRPQUOTA)) - -#define sb_has_quota_enabled (sb, type) (is_enabled(sb_dqopt(sb), type)) -#define dqh_any_quota_enabled (hash) (is_enabled(dqh_dqopt(hash), USRQUOTA) \ | is_enabled(dqh_dqopt(hash), GRPQUOTA))
@@ -321,6 +315,8 @@unsigned int dqh_id;/* ID for hash */ struct quota_info dqh_dquot;/* Diskquota specific options */ struct list_head dqh_list;/* List of all quota hashes */ +struct dquot_operations *dqh_qop; +struct quotactl_ops *dqh_qcop;struct super_block *dqh_sb;/* super block if applicable */ struct list_head dqh_hash[NR_DQHASH ]; };
include/linux/quotaops.h +23 -32
141 lines not on this page · raw message
only in patch2:
unchanged:
drivers/char/sysrq.c +1 -1
@@ -160,7 +160,7 @@ file->f_mode &= ~2 ; }file_list_unlock (); -DQUOT_OFF (sb); +DQUOT_OFF (sb->s_dqh);fsync_dev (sb->s_dev); flags =MS_RDONLY ;if (sb->s_op && sb->s_op->remount_fs) {
only in patch2:
unchanged:
fs/buffer.c +1 -1
@@ -336,7 +336,7 @@lock_kernel ();sync_inodes_sb (sb); -DQUOT_SYNC_SB (sb); +DQUOT_SYNC_DQH (sb->s_dqh);lock_super (sb);if (sb->s_dirt && sb->s_op && sb->s_op->write_super) sb->s_op->write_super (sb);
only in patch2:
unchanged:
fs/ext3/super.c +2 -2
@@ -1131,7 +1131,7 @@* set up enough so that it can read an inode */ sb->s_op = &ext3_sops; - sb->dq_op = &ext3_qops; + sb->s_dqh->dqh_qop = &ext3_qops;INIT_LIST_HEAD (&sbi->s_orphan);/* unlinked but open files */ sb->s_root =0 ;
@@ -1783,7 +1783,7 @@ {int nblocks, ret;handle_t *handle; -struct quota_info *dqops =sb_dqopt (dquot->dq_sb); +struct quota_info *dqops =dqh_dqopt (dquot->dq_dqh);struct inode *qinode;switch (dqops->info[dquot->dq_type].dqi_format->qf_fmt_id) {
only in patch2:
unchanged:
fs/namespace.c +1 -1
@@ -337,7 +337,7 @@/* last instance - try to be smart */ spin_unlock (&dcache_lock);lock_kernel (); -DQUOT_OFF (sb); +DQUOT_OFF (sb->s_dqh);acct_auto_close (sb->s_dev);unlock_kernel ();spin_lock (&dcache_lock);
only in patch2:
unchanged:
fs/udf/super.c +1 -1
@@ -1435,7 +1435,7 @@/* Fill in the rest of the superblock */ sb->s_op = &udf_sb_ops; - sb->dq_op =NULL ; + sb->s_dqh->dqh_qop =NULL ; sb->s_dirt =0 ; sb->s_magic =UDF_SUPER_MAGIC ;
only in patch2:
unchanged:
fs/ufs/super.c +1 -1
@@ -744,7 +744,7 @@ sb->s_blocksize =fs32_to_cpu (sb, usb1->fs_fsize); sb->s_blocksize_bits =fs32_to_cpu (sb, usb1->fs_fshift); sb->s_op = &ufs_super_ops; - sb->dq_op =NULL ;/***/ + sb->s_dqh->dqh_qop =NULL ;/***/ sb->s_magic =fs32_to_cpu (sb, usb3->fs_magic); uspi->s_sblkno =fs32_to_cpu (sb, usb1->fs_sblkno);
drivers/char/sysrq.c +1 -1
@@ -160,7 +160,7 @@ file->f_mode &= ~2 ; }file_list_unlock (); -DQUOT_OFF (sb); +DQUOT_OFF (sb->s_dqh);fsync_dev (sb->s_dev); flags =MS_RDONLY ;if (sb->s_op && sb->s_op->remount_fs) {
fs/buffer.c +1 -1
@@ -336,7 +336,7 @@lock_kernel ();sync_inodes_sb (sb); -DQUOT_SYNC_SB (sb); +DQUOT_SYNC_DQH (sb->s_dqh);lock_super (sb);if (sb->s_dirt && sb->s_op && sb->s_op->write_super) sb->s_op->write_super (sb);
fs/dquot.c +150 -82
587 lines not on this page · raw message
fs/ext3/super.c +2 -2
@@ -1131,7 +1131,7 @@* set up enough so that it can read an inode */ sb->s_op = &ext3_sops; - sb->dq_op = &ext3_qops; + sb->s_dqh->dqh_qop = &ext3_qops;INIT_LIST_HEAD (&sbi->s_orphan);/* unlinked but open files */ sb->s_root =0 ;
@@ -1783,7 +1783,7 @@ {int nblocks, ret;handle_t *handle; -struct quota_info *dqops =sb_dqopt (dquot->dq_sb); +struct quota_info *dqops =dqh_dqopt (dquot->dq_dqh);struct inode *qinode;switch (dqops->info[dquot->dq_type].dqi_format->qf_fmt_id) {
fs/inode.c +6 -4
@@ -95,6 +95,7 @@struct address_space *const mapping = &inode->i_data; inode->i_sb = sb; + inode->i_dqh = sb->s_dqh;/* this is the default */ inode->i_dev = sb->s_dev; inode->i_blkbits = sb->s_blocksize_bits; inode->i_flags =0 ;
@@ -1205,13 +1206,14 @@void put_dquot_list (struct list_head *);int remove_inode_dquot_ref (struct inode *,short ,struct list_head *); -void remove_dquot_ref (struct super_block *sb,short type) +void remove_dquot_ref (struct dqhash *hash,short type) {struct inode *inode;struct list_head *act_head; +struct super_block *sb = hash->dqh_sb;LIST_HEAD (tofree_head); -if (!sb->dq_op) +if (hash->dqh_qop)return ;/* nothing to do */ /* We have to be protected against other CPUs */ lock_kernel ();/* This lock is for quota code */
@@ -1219,12 +1221,12 @@list_for_each (act_head, &inode_in_use) { inode = list_entry(act_head, struct inode, i_list); -if (inode->i_sb == sb &&IS_QUOTAINIT (inode)) +if (inode->i_dqh == hash &&IS_QUOTAINIT (inode))remove_inode_dquot_ref (inode, type, &tofree_head); }list_for_each (act_head, &inode_unused) { inode = list_entry(act_head, struct inode, i_list); -if (inode->i_sb == sb &&IS_QUOTAINIT (inode)) +if (inode->i_dqh == hash &&IS_QUOTAINIT (inode))remove_inode_dquot_ref (inode, type, &tofree_head); }list_for_each (act_head, &sb->s_dirty) {
fs/namespace.c +1 -1
@@ -337,7 +337,7 @@/* last instance - try to be smart */ spin_unlock (&dcache_lock);lock_kernel (); -DQUOT_OFF (sb); +DQUOT_OFF (sb->s_dqh);acct_auto_close (sb->s_dev);unlock_kernel ();spin_lock (&dcache_lock);
fs/quota.c +63 -59
375 lines not on this page · raw message
fs/quota_v1.c +11 -11
@@ -42,7 +42,7 @@loff_t offset;struct v1_disk_dqblk dqblk; - filp =sb_dqopt (dquot->dq_sb)->files[type]; + filp =dqh_dqopt (dquot->dq_dqh)->files[type];if (filp == (struct file *)NULL )return -EINVAL ;
@@ -71,7 +71,7 @@ssize_t ret;struct v1_disk_dqblk dqblk; - filp =sb_dqopt (dquot->dq_sb)->files[type]; + filp =dqh_dqopt (dquot->dq_dqh)->files[type]; offset =v1_dqoff (dquot->dq_id); fs =get_fs ();set_fs (KERNEL_DS );
@@ -83,8 +83,8 @@v1_mem2disk_dqblk (&dqblk, &dquot->dq_dqb); dquot->dq_flags &= ~DQ_MOD ;if (dquot->dq_id ==0 ) { - dqblk.dqb_btime =sb_dqopt (dquot->dq_sb)->info[type].dqi_bgrace; - dqblk.dqb_itime =sb_dqopt (dquot->dq_sb)->info[type].dqi_igrace; + dqblk.dqb_btime =dqh_dqopt (dquot->dq_dqh)->info[type].dqi_bgrace; + dqblk.dqb_itime =dqh_dqopt (dquot->dq_dqh)->info[type].dqi_igrace; } ret =0 ;if (filp)
@@ -117,9 +117,9 @@__u32 dqh_version;/* File version */ }; -static int v1_check_quota_file (struct super_block *sb,int type) +static int v1_check_quota_file (struct dqhash *hash,int type) { -struct file *f =sb_dqopt (sb)->files[type]; +struct file *f =dqh_dqopt (hash)->files[type];struct inode *inode = f->f_dentry->d_inode;ulong blocks;size_t off;
@@ -144,13 +144,13 @@return 1 ;/* Probably not new format */ if (le32_to_cpu (dqhead.dqh_magic) != quota_magics[type])return 1 ;/* Definitely not new format */ -printk (KERN_INFO "VFS: %s: Refusing to turn on old quota format on given file. It probably contains newer quota format.\n" ,kdevname (sb->s_dev)); +printk (KERN_INFO "VFS: %s: Refusing to turn on old quota format on given file. It probably contains newer quota format.\n" ,kdevname (hash->dqh_sb->s_dev));return 0 ;/* Seems like a new format file -> refuse it */ } -static int v1_read_file_info (struct super_block *sb,int type) +static int v1_read_file_info (struct dqhash *hash,int type) { -struct quota_info *dqopt =sb_dqopt (sb); +struct quota_info *dqopt =dqh_dqopt (hash);mm_segment_t fs;loff_t offset;struct file *filp = dqopt->files[type];
@@ -175,9 +175,9 @@return ret; } -static int v1_write_file_info (struct super_block *sb,int type) +static int v1_write_file_info (struct dqhash *hash,int type) { -struct quota_info *dqopt =sb_dqopt (sb); +struct quota_info *dqopt =dqh_dqopt (hash);mm_segment_t fs;struct file *filp = dqopt->files[type];struct v1_disk_dqblk dqblk;
fs/quota_v2.c +21 -21
118 lines not on this page · raw message
fs/super.c +4 -4
@@ -278,12 +278,11 @@atomic_set (&s->s_active,1 );sema_init (&s->s_vfs_rename_sem,1 );sema_init (&s->s_nfsd_free_path_sem,1 ); -sema_init (&s->s_dquot.dqio_sem,1 ); -sema_init (&s->s_dquot.dqoff_sem,1 ); s->s_maxbytes =MAX_NON_LFS ; s->s_op = &empty_sops; - s->dq_op = sb_dquot_ops; - s->s_qcop = sb_quotactl_ops; +/* quick hack to make dqhash id unique, sufficient for now */ + s->s_dqh =new_dqhash ((unsigned int )s); + s->s_dqh->dqh_sb = s; }return s; }
@@ -296,6 +295,7 @@*/ static inline void destroy_super (struct super_block *s) { +destroy_dqhash (s->s_dqh);kfree (s); }
fs/udf/super.c +1 -1
@@ -1435,7 +1435,7 @@/* Fill in the rest of the superblock */ sb->s_op = &udf_sb_ops; - sb->dq_op =NULL ; + sb->s_dqh->dqh_qop =NULL ; sb->s_dirt =0 ; sb->s_magic =UDF_SUPER_MAGIC ;
fs/ufs/super.c +1 -1
@@ -744,7 +744,7 @@ sb->s_blocksize =fs32_to_cpu (sb, usb1->fs_fsize); sb->s_blocksize_bits =fs32_to_cpu (sb, usb1->fs_fshift); sb->s_op = &ufs_super_ops; - sb->dq_op =NULL ;/***/ + sb->s_dqh->dqh_qop =NULL ;/***/ sb->s_magic =fs32_to_cpu (sb, usb3->fs_magic); uspi->s_sblkno =fs32_to_cpu (sb, usb1->fs_sblkno);
include/linux/fs.h +2 -3
@@ -468,6 +468,7 @@struct file_lock *i_flock;struct address_space *i_mapping;struct address_space i_data; +struct dqhash *i_dqh;struct dquot *i_dquot[MAXQUOTAS ];/* These three should probably be a union */ struct list_head i_devices;
@@ -743,8 +744,6 @@unsigned long long s_maxbytes;/* Max file size */ struct file_system_type *s_type;struct super_operations *s_op; -struct dquot_operations *dq_op; -struct quotactl_ops *s_qcop;unsigned long s_flags;unsigned long s_magic;struct dentry *s_root;
@@ -759,7 +758,7 @@struct block_device *s_bdev;struct list_head s_instances; -struct quota_info s_dquot;/* Diskquota specific options */ +struct dqhash *s_dqh;/* Diskquota hash */ union {struct minix_sb_info minix_sb;
include/linux/mount.h +1 -0
@@ -29,6 +29,7 @@int mnt_flags;char *mnt_devname;/* Name of device e.g. /dev/dsk/hda1 */ struct list_head mnt_list; +struct dqhash *mnt_dqh;/* Diskquota hash for mount */ };static inline struct vfsmount *mntget (struct vfsmount *mnt)
include/linux/quota.h +42 -26
110 lines not on this page · raw message
include/linux/quotaops.h +23 -28
137 lines not on this page · raw message