quota: kill the vfs_dq_off and vfs_dq_quota_on_remount wrappers

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.

[Jan Kara: Moved dquot_suspend to quotaops.h and made it inline]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
Christoph Hellwig 2010-05-19 07:16:41 -04:00 committed by Jan Kara
parent c79d967de3
commit 0f0dd62fdd
10 changed files with 86 additions and 91 deletions

View File

@ -1250,9 +1250,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
es->s_mtime = cpu_to_le32(get_seconds()); es->s_mtime = cpu_to_le32(get_seconds());
spin_unlock(&sbi->s_lock); spin_unlock(&sbi->s_lock);
err = vfs_dq_off(sb, 1); err = dquot_suspend(sb, -1);
if (err < 0 && err != -ENOSYS) { if (err < 0) {
err = -EBUSY;
spin_lock(&sbi->s_lock); spin_lock(&sbi->s_lock);
goto restore_opts; goto restore_opts;
} }
@ -1281,7 +1280,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
ext2_write_super(sb); ext2_write_super(sb);
vfs_dq_quota_on_remount(sb); dquot_resume(sb, -1);
} }
return 0; return 0;

View File

@ -2598,11 +2598,9 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
} }
if (*flags & MS_RDONLY) { if (*flags & MS_RDONLY) {
err = vfs_dq_off(sb, 1); err = dquot_suspend(sb, -1);
if (err < 0 && err != -ENOSYS) { if (err < 0)
err = -EBUSY;
goto restore_opts; goto restore_opts;
}
/* /*
* First of all, the unconditional stuff we have to do * First of all, the unconditional stuff we have to do
@ -2672,7 +2670,7 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
unlock_kernel(); unlock_kernel();
if (enable_quota) if (enable_quota)
vfs_dq_quota_on_remount(sb); dquot_resume(sb, -1);
return 0; return 0;
restore_opts: restore_opts:
sb->s_flags = old_sb_flags; sb->s_flags = old_sb_flags;

View File

@ -3631,11 +3631,9 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
} }
if (*flags & MS_RDONLY) { if (*flags & MS_RDONLY) {
err = vfs_dq_off(sb, 1); err = dquot_suspend(sb, -1);
if (err < 0 && err != -ENOSYS) { if (err < 0)
err = -EBUSY;
goto restore_opts; goto restore_opts;
}
/* /*
* First of all, the unconditional stuff we have to do * First of all, the unconditional stuff we have to do
@ -3722,7 +3720,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
unlock_super(sb); unlock_super(sb);
unlock_kernel(); unlock_kernel();
if (enable_quota) if (enable_quota)
vfs_dq_quota_on_remount(sb); dquot_resume(sb, -1);
return 0; return 0;
restore_opts: restore_opts:

View File

@ -401,14 +401,14 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data)
sb->s_flags &= ~MS_RDONLY; sb->s_flags &= ~MS_RDONLY;
unlock_kernel(); unlock_kernel();
vfs_dq_quota_on_remount(sb); dquot_resume(sb, -1);
return ret; return ret;
} }
if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) { if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) {
rc = vfs_dq_off(sb, 1); rc = dquot_suspend(sb, -1);
if (rc < 0 && rc != -ENOSYS) { if (rc < 0) {
unlock_kernel(); unlock_kernel();
return -EBUSY; return rc;
} }
rc = jfs_umount_rw(sb); rc = jfs_umount_rw(sb);
JFS_SBI(sb)->flag = flag; JFS_SBI(sb)->flag = flag;

View File

@ -879,18 +879,14 @@ static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend)
if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type])) if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type]))
continue; continue;
if (unsuspend) if (unsuspend)
status = vfs_quota_enable( status = dquot_resume(sb, type);
sb_dqopt(sb)->files[type],
type, QFMT_OCFS2,
DQUOT_SUSPENDED);
else { else {
struct ocfs2_mem_dqinfo *oinfo; struct ocfs2_mem_dqinfo *oinfo;
/* Cancel periodic syncing before suspending */ /* Cancel periodic syncing before suspending */
oinfo = sb_dqinfo(sb, type)->dqi_priv; oinfo = sb_dqinfo(sb, type)->dqi_priv;
cancel_delayed_work_sync(&oinfo->dqi_sync_work); cancel_delayed_work_sync(&oinfo->dqi_sync_work);
status = vfs_quota_disable(sb, type, status = dquot_suspend(sb, type);
DQUOT_SUSPENDED);
} }
if (status < 0) if (status < 0)
break; break;
@ -958,8 +954,8 @@ static void ocfs2_disable_quotas(struct ocfs2_super *osb)
/* Turn off quotas. This will remove all dquot structures from /* Turn off quotas. This will remove all dquot structures from
* memory and so they will be automatically synced to global * memory and so they will be automatically synced to global
* quota files */ * quota files */
vfs_quota_disable(sb, type, DQUOT_USAGE_ENABLED | dquot_disable(sb, type, DQUOT_USAGE_ENABLED |
DQUOT_LIMITS_ENABLED); DQUOT_LIMITS_ENABLED);
if (!inode) if (!inode)
continue; continue;
iput(inode); iput(inode);
@ -989,7 +985,7 @@ static int ocfs2_quota_off(struct super_block *sb, int type, int remount)
if (remount) if (remount)
return 0; /* Ignore now and handle later in return 0; /* Ignore now and handle later in
* ocfs2_remount() */ * 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 = { static const struct quotactl_ops ocfs2_quotactl_ops = {

View File

@ -1865,7 +1865,7 @@ EXPORT_SYMBOL(dquot_file_open);
/* /*
* Turn quota off on a device. type == -1 ==> quotaoff for all types (umount) * 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; int cnt, ret = 0;
struct quota_info *dqopt = sb_dqopt(sb); struct quota_info *dqopt = sb_dqopt(sb);
@ -1995,14 +1995,16 @@ put_inodes:
} }
return ret; return ret;
} }
EXPORT_SYMBOL(vfs_quota_disable); EXPORT_SYMBOL(dquot_disable);
int vfs_quota_off(struct super_block *sb, int type, int remount) int vfs_quota_off(struct super_block *sb, int type, int remount)
{ {
return vfs_quota_disable(sb, type, remount ? DQUOT_SUSPENDED : BUG_ON(remount);
(DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED)); return dquot_disable(sb, type,
DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
} }
EXPORT_SYMBOL(vfs_quota_off); EXPORT_SYMBOL(vfs_quota_off);
/* /*
* Turn quotas on on a device * Turn quotas on on a device
*/ */
@ -2120,34 +2122,41 @@ out_fmt:
} }
/* Reenable quotas on remount RW */ /* 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 quota_info *dqopt = sb_dqopt(sb);
struct inode *inode; struct inode *inode;
int ret; int ret = 0, cnt;
unsigned int flags; unsigned int flags;
mutex_lock(&dqopt->dqonoff_mutex); for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
if (!sb_has_quota_suspended(sb, type)) { if (type != -1 && cnt != type)
mutex_unlock(&dqopt->dqonoff_mutex); continue;
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); mutex_lock(&dqopt->dqonoff_mutex);
ret = vfs_load_quota_inode(inode, type, dqopt->info[type].dqi_fmt_id, if (!sb_has_quota_suspended(sb, cnt)) {
flags); mutex_unlock(&dqopt->dqonoff_mutex);
iput(inode); 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);
flags = dquot_generic_flag(flags, cnt);
ret = vfs_load_quota_inode(inode, cnt,
dqopt->info[cnt].dqi_fmt_id, flags);
iput(inode);
}
return ret; return ret;
} }
EXPORT_SYMBOL(dquot_resume);
int vfs_quota_on_path(struct super_block *sb, int type, int format_id, int vfs_quota_on_path(struct super_block *sb, int type, int format_id,
struct path *path) struct path *path)
@ -2172,8 +2181,7 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *name,
struct path path; struct path path;
int error; int error;
if (remount) BUG_ON(remount);
return vfs_quota_on_remount(sb, type);
error = kern_path(name, LOOKUP_FOLLOW, &path); error = kern_path(name, LOOKUP_FOLLOW, &path);
if (!error) { if (!error) {
@ -2196,8 +2204,8 @@ int vfs_quota_enable(struct inode *inode, int type, int format_id,
struct quota_info *dqopt = sb_dqopt(sb); struct quota_info *dqopt = sb_dqopt(sb);
/* Just unsuspend quotas? */ /* Just unsuspend quotas? */
if (flags & DQUOT_SUSPENDED) BUG_ON(flags & DQUOT_SUSPENDED);
return vfs_quota_on_remount(sb, type);
if (!flags) if (!flags)
return 0; return 0;
/* Just updating flags needed? */ /* Just updating flags needed? */
@ -2263,23 +2271,6 @@ out:
} }
EXPORT_SYMBOL(vfs_quota_on_mount); 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) static inline qsize_t qbtos(qsize_t blocks)
{ {
return blocks << QIF_DQBLKSIZE_BITS; return blocks << QIF_DQBLKSIZE_BITS;

View File

@ -1243,11 +1243,9 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
/* it is read-only already */ /* it is read-only already */
goto out_ok; goto out_ok;
err = vfs_dq_off(s, 1); err = dquot_suspend(s, -1);
if (err < 0 && err != -ENOSYS) { if (err < 0)
err = -EBUSY;
goto out_err; goto out_err;
}
/* try to remount file system with read-only permissions */ /* try to remount file system with read-only permissions */
if (sb_umount_state(rs) == REISERFS_VALID_FS if (sb_umount_state(rs) == REISERFS_VALID_FS
@ -1302,7 +1300,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
s->s_dirt = 0; s->s_dirt = 0;
if (!(*mount_flags & MS_RDONLY)) { if (!(*mount_flags & MS_RDONLY)) {
vfs_dq_quota_on_remount(s); dquot_resume(s, -1);
finish_unfinished(s); finish_unfinished(s);
reiserfs_xattr_init(s, *mount_flags); reiserfs_xattr_init(s, *mount_flags);
} }

View File

@ -590,15 +590,13 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
if (*flags & MS_RDONLY) { if (*flags & MS_RDONLY) {
udf_close_lvid(sb); udf_close_lvid(sb);
error = vfs_dq_off(sb, 1); error = dquot_suspend(sb, -1);
if (error < 0 && error != -ENOSYS)
error = -EBUSY;
} else { } else {
udf_open_lvid(sb); udf_open_lvid(sb);
/* mark the fs r/w for quota activity */ /* mark the fs r/w for quota activity */
sb->s_flags &= ~MS_RDONLY; sb->s_flags &= ~MS_RDONLY;
vfs_dq_quota_on_remount(sb); dquot_resume(sb, -1);
} }
out_unlock: out_unlock:

View File

@ -1291,11 +1291,11 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
* fs was mouted as rw, remounting ro * fs was mouted as rw, remounting ro
*/ */
if (*mount_flags & MS_RDONLY) { if (*mount_flags & MS_RDONLY) {
err = vfs_dq_off(sb, 1); err = dquot_suspend(sb, -1);
if (err < 0 && err != -ENOSYS) { if (err < 0) {
unlock_super(sb); unlock_super(sb);
unlock_kernel(); unlock_kernel();
return -EBUSY; return err;
} }
ufs_put_super_internal(sb); ufs_put_super_internal(sb);
@ -1343,7 +1343,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
unlock_super(sb); unlock_super(sb);
unlock_kernel(); unlock_kernel();
if (enable_quota) if (enable_quota)
vfs_dq_quota_on_remount(sb); dquot_resume(sb, -1);
return 0; return 0;
} }

View File

@ -50,6 +50,14 @@ int dquot_alloc_inode(const struct inode *inode);
int dquot_claim_space_nodirty(struct inode *inode, qsize_t number); int dquot_claim_space_nodirty(struct inode *inode, qsize_t number);
void dquot_free_inode(const struct inode *inode); void dquot_free_inode(const struct inode *inode);
int dquot_disable(struct super_block *sb, int type, unsigned int flags);
/* Suspend quotas on remount RO */
static inline int dquot_suspend(struct super_block *sb, int type)
{
return dquot_disable(sb, type, DQUOT_SUSPENDED);
}
int dquot_resume(struct super_block *sb, int type);
int dquot_commit(struct dquot *dquot); int dquot_commit(struct dquot *dquot);
int dquot_acquire(struct dquot *dquot); int dquot_acquire(struct dquot *dquot);
int dquot_release(struct dquot *dquot); int dquot_release(struct dquot *dquot);
@ -67,7 +75,6 @@ int vfs_quota_on_path(struct super_block *sb, int type, int format_id,
int vfs_quota_on_mount(struct super_block *sb, char *qf_name, int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
int format_id, int type); int format_id, int type);
int vfs_quota_off(struct super_block *sb, int type, int remount); 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_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_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); int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
@ -78,7 +85,6 @@ int vfs_set_dqblk(struct super_block *sb, int type, qid_t id,
int __dquot_transfer(struct inode *inode, struct dquot **transfer_to); int __dquot_transfer(struct inode *inode, struct dquot **transfer_to);
int dquot_transfer(struct inode *inode, struct iattr *iattr); 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) static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
{ {
@ -231,11 +237,6 @@ static inline int vfs_dq_off(struct super_block *sb, int remount)
return 0; 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) static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
{ {
return 0; return 0;
@ -262,6 +263,22 @@ static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
return 0; 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 #define dquot_file_open generic_file_open
#endif /* CONFIG_QUOTA */ #endif /* CONFIG_QUOTA */