On Wed 12-05-10 15:44:10, Christoph Hellwig wrote: > Instead of having wrappers in the VFS namespace export the dquot_suspend > and dquot_resume helpers directly. Also rename vfs_quota_disable to > dquot_disable while we're at it. This patch looks good. Honza > > Signed-off-by: Christoph Hellwig <hch@xxxxxx> > > Index: linux-2.6/fs/quota/dquot.c > =================================================================== > --- linux-2.6.orig/fs/quota/dquot.c 2010-05-10 22:28:55.358254512 +0200 > +++ linux-2.6/fs/quota/dquot.c 2010-05-10 22:28:59.739003639 +0200 > @@ -1875,7 +1875,7 @@ EXPORT_SYMBOL(dquot_file_open); > /* > * Turn quota off on a device. type == -1 ==> quotaoff for all types (umount) > */ > -int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags) > +int dquot_disable(struct super_block *sb, int type, unsigned int flags) > { > int cnt, ret = 0; > struct quota_info *dqopt = sb_dqopt(sb); > @@ -2005,14 +2005,16 @@ put_inodes: > } > return ret; > } > -EXPORT_SYMBOL(vfs_quota_disable); > +EXPORT_SYMBOL(dquot_disable); > > int vfs_quota_off(struct super_block *sb, int type, int remount) > { > - return vfs_quota_disable(sb, type, remount ? DQUOT_SUSPENDED : > - (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED)); > + BUG_ON(remount); > + return dquot_disable(sb, type, > + DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); > } > EXPORT_SYMBOL(vfs_quota_off); > + > /* > * Turn quotas on on a device > */ > @@ -2129,35 +2131,48 @@ out_fmt: > return error; > } > > +/* Suspend quotas on remount RO */ > +int dquot_suspend(struct super_block *sb, int type) > +{ > + return dquot_disable(sb, type, DQUOT_SUSPENDED); > +} > + > /* Reenable quotas on remount RW */ > -static int vfs_quota_on_remount(struct super_block *sb, int type) > +int dquot_resume(struct super_block *sb, int type) > { > struct quota_info *dqopt = sb_dqopt(sb); > struct inode *inode; > - int ret; > + int ret = 0, cnt; > unsigned int flags; > > - mutex_lock(&dqopt->dqonoff_mutex); > - if (!sb_has_quota_suspended(sb, type)) { > + for (cnt = 0; cnt < MAXQUOTAS; cnt++) { > + if (type != -1 && cnt != type) > + continue; > + > + mutex_lock(&dqopt->dqonoff_mutex); > + if (!sb_has_quota_suspended(sb, cnt)) { > + mutex_unlock(&dqopt->dqonoff_mutex); > + continue; > + } > + inode = dqopt->files[cnt]; > + dqopt->files[cnt] = NULL; > + spin_lock(&dq_state_lock); > + flags = dqopt->flags & dquot_state_flag(DQUOT_USAGE_ENABLED | > + DQUOT_LIMITS_ENABLED, > + cnt); > + dqopt->flags &= ~dquot_state_flag(DQUOT_STATE_FLAGS, cnt); > + spin_unlock(&dq_state_lock); > mutex_unlock(&dqopt->dqonoff_mutex); > - return 0; > - } > - inode = dqopt->files[type]; > - dqopt->files[type] = NULL; > - spin_lock(&dq_state_lock); > - flags = dqopt->flags & dquot_state_flag(DQUOT_USAGE_ENABLED | > - DQUOT_LIMITS_ENABLED, type); > - dqopt->flags &= ~dquot_state_flag(DQUOT_STATE_FLAGS, type); > - spin_unlock(&dq_state_lock); > - mutex_unlock(&dqopt->dqonoff_mutex); > > - flags = dquot_generic_flag(flags, type); > - ret = vfs_load_quota_inode(inode, type, dqopt->info[type].dqi_fmt_id, > - flags); > - iput(inode); > + flags = dquot_generic_flag(flags, cnt); > + ret = vfs_load_quota_inode(inode, cnt, > + dqopt->info[cnt].dqi_fmt_id, flags); > + iput(inode); > + } > > return ret; > } > +EXPORT_SYMBOL(dquot_resume); > > int vfs_quota_on_path(struct super_block *sb, int type, int format_id, > struct path *path) > @@ -2182,8 +2197,7 @@ int vfs_quota_on(struct super_block *sb, > struct path path; > int error; > > - if (remount) > - return vfs_quota_on_remount(sb, type); > + BUG_ON(remount); > > error = kern_path(name, LOOKUP_FOLLOW, &path); > if (!error) { > @@ -2206,8 +2220,8 @@ int vfs_quota_enable(struct inode *inode > struct quota_info *dqopt = sb_dqopt(sb); > > /* Just unsuspend quotas? */ > - if (flags & DQUOT_SUSPENDED) > - return vfs_quota_on_remount(sb, type); > + BUG_ON(flags & DQUOT_SUSPENDED); > + > if (!flags) > return 0; > /* Just updating flags needed? */ > @@ -2273,23 +2287,6 @@ out: > } > EXPORT_SYMBOL(vfs_quota_on_mount); > > -/* Wrapper to turn on quotas when remounting rw */ > -int vfs_dq_quota_on_remount(struct super_block *sb) > -{ > - int cnt; > - int ret = 0, err; > - > - if (!sb->s_qcop || !sb->s_qcop->quota_on) > - return -ENOSYS; > - for (cnt = 0; cnt < MAXQUOTAS; cnt++) { > - err = sb->s_qcop->quota_on(sb, cnt, 0, NULL, 1); > - if (err < 0 && !ret) > - ret = err; > - } > - return ret; > -} > -EXPORT_SYMBOL(vfs_dq_quota_on_remount); > - > static inline qsize_t qbtos(qsize_t blocks) > { > return blocks << QIF_DQBLKSIZE_BITS; > Index: linux-2.6/fs/ext2/super.c > =================================================================== > --- linux-2.6.orig/fs/ext2/super.c 2010-05-10 22:28:59.310003709 +0200 > +++ linux-2.6/fs/ext2/super.c 2010-05-10 22:28:59.740003429 +0200 > @@ -1251,9 +1251,8 @@ static int ext2_remount (struct super_bl > es->s_mtime = cpu_to_le32(get_seconds()); > spin_unlock(&sbi->s_lock); > > - err = vfs_dq_off(sb, 1); > - if (err < 0 && err != -ENOSYS) { > - err = -EBUSY; > + err = dquot_suspend(sb, -1); > + if (err < 0) { > spin_lock(&sbi->s_lock); > goto restore_opts; > } > @@ -1285,7 +1284,7 @@ static int ext2_remount (struct super_bl > } > > if (enable_quota) > - vfs_dq_quota_on_remount(sb); > + dquot_resume(sb, -1); > return 0; > restore_opts: > sbi->s_mount_opt = old_opts.s_mount_opt; > Index: linux-2.6/fs/ext3/super.c > =================================================================== > --- linux-2.6.orig/fs/ext3/super.c 2010-05-10 22:28:59.311004407 +0200 > +++ linux-2.6/fs/ext3/super.c 2010-05-10 22:28:59.741003918 +0200 > @@ -2598,11 +2598,9 @@ static int ext3_remount (struct super_bl > } > > if (*flags & MS_RDONLY) { > - err = vfs_dq_off(sb, 1); > - if (err < 0 && err != -ENOSYS) { > - err = -EBUSY; > + err = dquot_suspend(sb, -1); > + if (err < 0) > goto restore_opts; > - } > > /* > * First of all, the unconditional stuff we have to do > @@ -2672,7 +2670,7 @@ static int ext3_remount (struct super_bl > unlock_kernel(); > > if (enable_quota) > - vfs_dq_quota_on_remount(sb); > + dquot_resume(sb, -1); > return 0; > restore_opts: > sb->s_flags = old_sb_flags; > Index: linux-2.6/fs/ext4/super.c > =================================================================== > --- linux-2.6.orig/fs/ext4/super.c 2010-05-10 22:28:59.314004267 +0200 > +++ linux-2.6/fs/ext4/super.c 2010-05-10 22:28:59.744003778 +0200 > @@ -3631,11 +3631,9 @@ static int ext4_remount(struct super_blo > } > > if (*flags & MS_RDONLY) { > - err = vfs_dq_off(sb, 1); > - if (err < 0 && err != -ENOSYS) { > - err = -EBUSY; > + err = dquot_suspend(sb, -1); > + if (err < 0) > goto restore_opts; > - } > > /* > * First of all, the unconditional stuff we have to do > @@ -3722,7 +3720,7 @@ static int ext4_remount(struct super_blo > unlock_super(sb); > unlock_kernel(); > if (enable_quota) > - vfs_dq_quota_on_remount(sb); > + dquot_resume(sb, -1); > return 0; > > restore_opts: > Index: linux-2.6/fs/jfs/super.c > =================================================================== > --- linux-2.6.orig/fs/jfs/super.c 2010-05-10 22:28:59.318023753 +0200 > +++ linux-2.6/fs/jfs/super.c 2010-05-10 22:28:59.746023753 +0200 > @@ -397,14 +397,14 @@ static int jfs_remount(struct super_bloc > JFS_SBI(sb)->flag = flag; > ret = jfs_mount_rw(sb, 1); > unlock_kernel(); > - vfs_dq_quota_on_remount(sb); > + dquot_resume(sb, -1); > return ret; > } > if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) { > - rc = vfs_dq_off(sb, 1); > - if (rc < 0 && rc != -ENOSYS) { > + rc = dquot_suspend(sb, -1); > + if (rc < 0) { > unlock_kernel(); > - return -EBUSY; > + return rc; > } > rc = jfs_umount_rw(sb); > JFS_SBI(sb)->flag = flag; > Index: linux-2.6/fs/ocfs2/super.c > =================================================================== > --- linux-2.6.orig/fs/ocfs2/super.c 2010-05-10 22:28:55.414004477 +0200 > +++ linux-2.6/fs/ocfs2/super.c 2010-05-10 22:31:09.147254093 +0200 > @@ -873,13 +873,9 @@ static int ocfs2_susp_quotas(struct ocfs > if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type])) > continue; > if (unsuspend) > - status = vfs_quota_enable( > - sb_dqopt(sb)->files[type], > - type, QFMT_OCFS2, > - DQUOT_SUSPENDED); > + status = dquot_resume(sb, type); > else > - status = vfs_quota_disable(sb, type, > - DQUOT_SUSPENDED); > + status = dquot_suspend(sb, type); > if (status < 0) > break; > } > @@ -942,8 +938,8 @@ static void ocfs2_disable_quotas(struct > /* Turn off quotas. This will remove all dquot structures from > * memory and so they will be automatically synced to global > * quota files */ > - vfs_quota_disable(sb, type, DQUOT_USAGE_ENABLED | > - DQUOT_LIMITS_ENABLED); > + dquot_disable(sb, type, DQUOT_USAGE_ENABLED | > + DQUOT_LIMITS_ENABLED); > if (!inode) > continue; > iput(inode); > @@ -973,7 +969,7 @@ static int ocfs2_quota_off(struct super_ > if (remount) > return 0; /* Ignore now and handle later in > * ocfs2_remount() */ > - return vfs_quota_disable(sb, type, DQUOT_LIMITS_ENABLED); > + return dquot_disable(sb, type, DQUOT_LIMITS_ENABLED); > } > > static const struct quotactl_ops ocfs2_quotactl_ops = { > Index: linux-2.6/fs/reiserfs/super.c > =================================================================== > --- linux-2.6.orig/fs/reiserfs/super.c 2010-05-10 22:28:59.324003918 +0200 > +++ linux-2.6/fs/reiserfs/super.c 2010-05-10 22:28:59.755004128 +0200 > @@ -1243,11 +1243,9 @@ static int reiserfs_remount(struct super > /* it is read-only already */ > goto out_ok; > > - err = vfs_dq_off(s, 1); > - if (err < 0 && err != -ENOSYS) { > - err = -EBUSY; > + err = dquot_suspend(s, -1); > + if (err < 0) > goto out_err; > - } > > /* try to remount file system with read-only permissions */ > if (sb_umount_state(rs) == REISERFS_VALID_FS > @@ -1304,7 +1302,7 @@ static int reiserfs_remount(struct super > if (!(*mount_flags & MS_RDONLY)) { > finish_unfinished(s); > reiserfs_xattr_init(s, *mount_flags); > - vfs_dq_quota_on_remount(s); > + dquot_resume(s, -1); > } > > out_ok: > Index: linux-2.6/fs/ufs/super.c > =================================================================== > --- linux-2.6.orig/fs/ufs/super.c 2010-05-10 22:28:59.330004128 +0200 > +++ linux-2.6/fs/ufs/super.c 2010-05-10 22:28:59.760004128 +0200 > @@ -1291,11 +1291,11 @@ static int ufs_remount (struct super_blo > * fs was mouted as rw, remounting ro > */ > if (*mount_flags & MS_RDONLY) { > - err = vfs_dq_off(sb, 1); > - if (err < 0 && err != -ENOSYS) { > + err = dquot_suspend(sb, -1); > + if (err < 0) { > unlock_super(sb); > unlock_kernel(); > - return -EBUSY; > + return err; > } > > ufs_put_super_internal(sb); > @@ -1343,7 +1343,7 @@ static int ufs_remount (struct super_blo > unlock_super(sb); > unlock_kernel(); > if (enable_quota) > - vfs_dq_quota_on_remount(sb); > + dquot_resume(sb, -1); > return 0; > } > > Index: linux-2.6/include/linux/quotaops.h > =================================================================== > --- linux-2.6.orig/include/linux/quotaops.h 2010-05-10 22:28:55.455254232 +0200 > +++ linux-2.6/include/linux/quotaops.h 2010-05-10 22:34:24.134024452 +0200 > @@ -42,6 +42,10 @@ int dquot_alloc_inode(const struct inode > int dquot_claim_space_nodirty(struct inode *inode, qsize_t number); > void dquot_free_inode(const struct inode *inode); > > +int dquot_disable(struct super_block *sb, int type, unsigned int flags); > +int dquot_suspend(struct super_block *sb, int type); > +int dquot_resume(struct super_block *sb, int type); > + > int dquot_commit(struct dquot *dquot); > int dquot_acquire(struct dquot *dquot); > int dquot_release(struct dquot *dquot); > @@ -59,7 +63,6 @@ int vfs_quota_on_path(struct super_block > int vfs_quota_on_mount(struct super_block *sb, char *qf_name, > int format_id, int type); > int vfs_quota_off(struct super_block *sb, int type, int remount); > -int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags); > int vfs_quota_sync(struct super_block *sb, int type, int wait); > int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); > int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); > @@ -69,7 +72,6 @@ int vfs_set_dqblk(struct super_block *sb > struct fs_disk_quota *di); > > int dquot_transfer(struct inode *inode, struct iattr *iattr); > -int vfs_dq_quota_on_remount(struct super_block *sb); > > static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) > { > @@ -222,11 +224,6 @@ static inline int vfs_dq_off(struct supe > return 0; > } > > -static inline int vfs_dq_quota_on_remount(struct super_block *sb) > -{ > - return 0; > -} > - > static inline int dquot_transfer(struct inode *inode, struct iattr *iattr) > { > return 0; > @@ -253,6 +250,22 @@ static inline int dquot_claim_space_nodi > return 0; > } > > +static inline int dquot_disable(struct super_block *sb, int type, > + unsigned int flags) > +{ > + return 0; > +} > + > +static inline int dquot_suspend(struct super_block *sb, int type) > +{ > + return 0; > +} > + > +static inline int dquot_resume(struct super_block *sb, int type) > +{ > + return 0; > +} > + > #define dquot_file_open generic_file_open > > #endif /* CONFIG_QUOTA */ > -- Jan Kara <jack@xxxxxxx> SUSE Labs, CR -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html