Skip to content

Commit 0f0dd62

Browse files
Christoph Hellwigjankara
authored andcommitted
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>
1 parent c79d967 commit 0f0dd62

10 files changed

Lines changed: 85 additions & 90 deletions

File tree

‎fs/ext2/super.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,9 +1250,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
12501250
es->s_mtime = cpu_to_le32(get_seconds());
12511251
spin_unlock(&sbi->s_lock);
12521252

1253-
err = vfs_dq_off(sb, 1);
1254-
if (err < 0 && err != -ENOSYS) {
1255-
err = -EBUSY;
1253+
err = dquot_suspend(sb, -1);
1254+
if (err < 0) {
12561255
spin_lock(&sbi->s_lock);
12571256
goto restore_opts;
12581257
}
@@ -1281,7 +1280,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
12811280

12821281
ext2_write_super(sb);
12831282

1284-
vfs_dq_quota_on_remount(sb);
1283+
dquot_resume(sb, -1);
12851284
}
12861285

12871286
return 0;

‎fs/ext3/super.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,11 +2598,9 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
25982598
}
25992599

26002600
if (*flags & MS_RDONLY) {
2601-
err = vfs_dq_off(sb, 1);
2602-
if (err < 0 && err != -ENOSYS) {
2603-
err = -EBUSY;
2601+
err = dquot_suspend(sb, -1);
2602+
if (err < 0)
26042603
goto restore_opts;
2605-
}
26062604

26072605
/*
26082606
* 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)
26722670
unlock_kernel();
26732671

26742672
if (enable_quota)
2675-
vfs_dq_quota_on_remount(sb);
2673+
dquot_resume(sb, -1);
26762674
return 0;
26772675
restore_opts:
26782676
sb->s_flags = old_sb_flags;

‎fs/ext4/super.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3631,11 +3631,9 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
36313631
}
36323632

36333633
if (*flags & MS_RDONLY) {
3634-
err = vfs_dq_off(sb, 1);
3635-
if (err < 0 && err != -ENOSYS) {
3636-
err = -EBUSY;
3634+
err = dquot_suspend(sb, -1);
3635+
if (err < 0)
36373636
goto restore_opts;
3638-
}
36393637

36403638
/*
36413639
* 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)
37223720
unlock_super(sb);
37233721
unlock_kernel();
37243722
if (enable_quota)
3725-
vfs_dq_quota_on_remount(sb);
3723+
dquot_resume(sb, -1);
37263724
return 0;
37273725

37283726
restore_opts:

‎fs/jfs/super.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,14 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data)
401401
sb->s_flags &= ~MS_RDONLY;
402402

403403
unlock_kernel();
404-
vfs_dq_quota_on_remount(sb);
404+
dquot_resume(sb, -1);
405405
return ret;
406406
}
407407
if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) {
408-
rc = vfs_dq_off(sb, 1);
409-
if (rc < 0 && rc != -ENOSYS) {
408+
rc = dquot_suspend(sb, -1);
409+
if (rc < 0) {
410410
unlock_kernel();
411-
return -EBUSY;
411+
return rc;
412412
}
413413
rc = jfs_umount_rw(sb);
414414
JFS_SBI(sb)->flag = flag;

‎fs/ocfs2/super.c‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -879,18 +879,14 @@ static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend)
879879
if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type]))
880880
continue;
881881
if (unsuspend)
882-
status = vfs_quota_enable(
883-
sb_dqopt(sb)->files[type],
884-
type, QFMT_OCFS2,
885-
DQUOT_SUSPENDED);
882+
status = dquot_resume(sb, type);
886883
else {
887884
struct ocfs2_mem_dqinfo *oinfo;
888885

889886
/* Cancel periodic syncing before suspending */
890887
oinfo = sb_dqinfo(sb, type)->dqi_priv;
891888
cancel_delayed_work_sync(&oinfo->dqi_sync_work);
892-
status = vfs_quota_disable(sb, type,
893-
DQUOT_SUSPENDED);
889+
status = dquot_suspend(sb, type);
894890
}
895891
if (status < 0)
896892
break;
@@ -958,8 +954,8 @@ static void ocfs2_disable_quotas(struct ocfs2_super *osb)
958954
/* Turn off quotas. This will remove all dquot structures from
959955
* memory and so they will be automatically synced to global
960956
* quota files */
961-
vfs_quota_disable(sb, type, DQUOT_USAGE_ENABLED |
962-
DQUOT_LIMITS_ENABLED);
957+
dquot_disable(sb, type, DQUOT_USAGE_ENABLED |
958+
DQUOT_LIMITS_ENABLED);
963959
if (!inode)
964960
continue;
965961
iput(inode);
@@ -989,7 +985,7 @@ static int ocfs2_quota_off(struct super_block *sb, int type, int remount)
989985
if (remount)
990986
return 0; /* Ignore now and handle later in
991987
* ocfs2_remount() */
992-
return vfs_quota_disable(sb, type, DQUOT_LIMITS_ENABLED);
988+
return dquot_disable(sb, type, DQUOT_LIMITS_ENABLED);
993989
}
994990

995991
static const struct quotactl_ops ocfs2_quotactl_ops = {

‎fs/quota/dquot.c‎

Lines changed: 34 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,7 @@ EXPORT_SYMBOL(dquot_file_open);
18651865
/*
18661866
* Turn quota off on a device. type == -1 ==> quotaoff for all types (umount)
18671867
*/
1868-
int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags)
1868+
int dquot_disable(struct super_block *sb, int type, unsigned int flags)
18691869
{
18701870
int cnt, ret = 0;
18711871
struct quota_info *dqopt = sb_dqopt(sb);
@@ -1995,14 +1995,16 @@ int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags)
19951995
}
19961996
return ret;
19971997
}
1998-
EXPORT_SYMBOL(vfs_quota_disable);
1998+
EXPORT_SYMBOL(dquot_disable);
19991999

20002000
int vfs_quota_off(struct super_block *sb, int type, int remount)
20012001
{
2002-
return vfs_quota_disable(sb, type, remount ? DQUOT_SUSPENDED :
2003-
(DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED));
2002+
BUG_ON(remount);
2003+
return dquot_disable(sb, type,
2004+
DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
20042005
}
20052006
EXPORT_SYMBOL(vfs_quota_off);
2007+
20062008
/*
20072009
* Turn quotas on on a device
20082010
*/
@@ -2120,34 +2122,41 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
21202122
}
21212123

21222124
/* Reenable quotas on remount RW */
2123-
static int vfs_quota_on_remount(struct super_block *sb, int type)
2125+
int dquot_resume(struct super_block *sb, int type)
21242126
{
21252127
struct quota_info *dqopt = sb_dqopt(sb);
21262128
struct inode *inode;
2127-
int ret;
2129+
int ret = 0, cnt;
21282130
unsigned int flags;
21292131

2130-
mutex_lock(&dqopt->dqonoff_mutex);
2131-
if (!sb_has_quota_suspended(sb, type)) {
2132+
for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
2133+
if (type != -1 && cnt != type)
2134+
continue;
2135+
2136+
mutex_lock(&dqopt->dqonoff_mutex);
2137+
if (!sb_has_quota_suspended(sb, cnt)) {
2138+
mutex_unlock(&dqopt->dqonoff_mutex);
2139+
continue;
2140+
}
2141+
inode = dqopt->files[cnt];
2142+
dqopt->files[cnt] = NULL;
2143+
spin_lock(&dq_state_lock);
2144+
flags = dqopt->flags & dquot_state_flag(DQUOT_USAGE_ENABLED |
2145+
DQUOT_LIMITS_ENABLED,
2146+
cnt);
2147+
dqopt->flags &= ~dquot_state_flag(DQUOT_STATE_FLAGS, cnt);
2148+
spin_unlock(&dq_state_lock);
21322149
mutex_unlock(&dqopt->dqonoff_mutex);
2133-
return 0;
2134-
}
2135-
inode = dqopt->files[type];
2136-
dqopt->files[type] = NULL;
2137-
spin_lock(&dq_state_lock);
2138-
flags = dqopt->flags & dquot_state_flag(DQUOT_USAGE_ENABLED |
2139-
DQUOT_LIMITS_ENABLED, type);
2140-
dqopt->flags &= ~dquot_state_flag(DQUOT_STATE_FLAGS, type);
2141-
spin_unlock(&dq_state_lock);
2142-
mutex_unlock(&dqopt->dqonoff_mutex);
21432150

2144-
flags = dquot_generic_flag(flags, type);
2145-
ret = vfs_load_quota_inode(inode, type, dqopt->info[type].dqi_fmt_id,
2146-
flags);
2147-
iput(inode);
2151+
flags = dquot_generic_flag(flags, cnt);
2152+
ret = vfs_load_quota_inode(inode, cnt,
2153+
dqopt->info[cnt].dqi_fmt_id, flags);
2154+
iput(inode);
2155+
}
21482156

21492157
return ret;
21502158
}
2159+
EXPORT_SYMBOL(dquot_resume);
21512160

21522161
int vfs_quota_on_path(struct super_block *sb, int type, int format_id,
21532162
struct path *path)
@@ -2172,8 +2181,7 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *name,
21722181
struct path path;
21732182
int error;
21742183

2175-
if (remount)
2176-
return vfs_quota_on_remount(sb, type);
2184+
BUG_ON(remount);
21772185

21782186
error = kern_path(name, LOOKUP_FOLLOW, &path);
21792187
if (!error) {
@@ -2196,8 +2204,8 @@ int vfs_quota_enable(struct inode *inode, int type, int format_id,
21962204
struct quota_info *dqopt = sb_dqopt(sb);
21972205

21982206
/* Just unsuspend quotas? */
2199-
if (flags & DQUOT_SUSPENDED)
2200-
return vfs_quota_on_remount(sb, type);
2207+
BUG_ON(flags & DQUOT_SUSPENDED);
2208+
22012209
if (!flags)
22022210
return 0;
22032211
/* Just updating flags needed? */
@@ -2263,23 +2271,6 @@ int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
22632271
}
22642272
EXPORT_SYMBOL(vfs_quota_on_mount);
22652273

2266-
/* Wrapper to turn on quotas when remounting rw */
2267-
int vfs_dq_quota_on_remount(struct super_block *sb)
2268-
{
2269-
int cnt;
2270-
int ret = 0, err;
2271-
2272-
if (!sb->s_qcop || !sb->s_qcop->quota_on)
2273-
return -ENOSYS;
2274-
for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
2275-
err = sb->s_qcop->quota_on(sb, cnt, 0, NULL, 1);
2276-
if (err < 0 && !ret)
2277-
ret = err;
2278-
}
2279-
return ret;
2280-
}
2281-
EXPORT_SYMBOL(vfs_dq_quota_on_remount);
2282-
22832274
static inline qsize_t qbtos(qsize_t blocks)
22842275
{
22852276
return blocks << QIF_DQBLKSIZE_BITS;

‎fs/reiserfs/super.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,11 +1243,9 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
12431243
/* it is read-only already */
12441244
goto out_ok;
12451245

1246-
err = vfs_dq_off(s, 1);
1247-
if (err < 0 && err != -ENOSYS) {
1248-
err = -EBUSY;
1246+
err = dquot_suspend(s, -1);
1247+
if (err < 0)
12491248
goto out_err;
1250-
}
12511249

12521250
/* try to remount file system with read-only permissions */
12531251
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)
13021300
s->s_dirt = 0;
13031301

13041302
if (!(*mount_flags & MS_RDONLY)) {
1305-
vfs_dq_quota_on_remount(s);
1303+
dquot_resume(s, -1);
13061304
finish_unfinished(s);
13071305
reiserfs_xattr_init(s, *mount_flags);
13081306
}

‎fs/udf/super.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,15 +590,13 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
590590
if (*flags & MS_RDONLY) {
591591
udf_close_lvid(sb);
592592

593-
error = vfs_dq_off(sb, 1);
594-
if (error < 0 && error != -ENOSYS)
595-
error = -EBUSY;
593+
error = dquot_suspend(sb, -1);
596594
} else {
597595
udf_open_lvid(sb);
598596

599597
/* mark the fs r/w for quota activity */
600598
sb->s_flags &= ~MS_RDONLY;
601-
vfs_dq_quota_on_remount(sb);
599+
dquot_resume(sb, -1);
602600
}
603601

604602
out_unlock:

‎fs/ufs/super.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,11 +1291,11 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
12911291
* fs was mouted as rw, remounting ro
12921292
*/
12931293
if (*mount_flags & MS_RDONLY) {
1294-
err = vfs_dq_off(sb, 1);
1295-
if (err < 0 && err != -ENOSYS) {
1294+
err = dquot_suspend(sb, -1);
1295+
if (err < 0) {
12961296
unlock_super(sb);
12971297
unlock_kernel();
1298-
return -EBUSY;
1298+
return err;
12991299
}
13001300

13011301
ufs_put_super_internal(sb);
@@ -1343,7 +1343,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
13431343
unlock_super(sb);
13441344
unlock_kernel();
13451345
if (enable_quota)
1346-
vfs_dq_quota_on_remount(sb);
1346+
dquot_resume(sb, -1);
13471347
return 0;
13481348
}
13491349

‎include/linux/quotaops.h‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ int dquot_alloc_inode(const struct inode *inode);
5050
int dquot_claim_space_nodirty(struct inode *inode, qsize_t number);
5151
void dquot_free_inode(const struct inode *inode);
5252

53+
int dquot_disable(struct super_block *sb, int type, unsigned int flags);
54+
/* Suspend quotas on remount RO */
55+
static inline int dquot_suspend(struct super_block *sb, int type)
56+
{
57+
return dquot_disable(sb, type, DQUOT_SUSPENDED);
58+
}
59+
int dquot_resume(struct super_block *sb, int type);
60+
5361
int dquot_commit(struct dquot *dquot);
5462
int dquot_acquire(struct dquot *dquot);
5563
int dquot_release(struct dquot *dquot);
@@ -67,7 +75,6 @@ int vfs_quota_on_path(struct super_block *sb, int type, int format_id,
6775
int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
6876
int format_id, int type);
6977
int vfs_quota_off(struct super_block *sb, int type, int remount);
70-
int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags);
7178
int vfs_quota_sync(struct super_block *sb, int type, int wait);
7279
int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
7380
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,
7885

7986
int __dquot_transfer(struct inode *inode, struct dquot **transfer_to);
8087
int dquot_transfer(struct inode *inode, struct iattr *iattr);
81-
int vfs_dq_quota_on_remount(struct super_block *sb);
8288

8389
static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
8490
{
@@ -231,11 +237,6 @@ static inline int vfs_dq_off(struct super_block *sb, int remount)
231237
return 0;
232238
}
233239

234-
static inline int vfs_dq_quota_on_remount(struct super_block *sb)
235-
{
236-
return 0;
237-
}
238-
239240
static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
240241
{
241242
return 0;
@@ -262,6 +263,22 @@ static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
262263
return 0;
263264
}
264265

266+
static inline int dquot_disable(struct super_block *sb, int type,
267+
unsigned int flags)
268+
{
269+
return 0;
270+
}
271+
272+
static inline int dquot_suspend(struct super_block *sb, int type)
273+
{
274+
return 0;
275+
}
276+
277+
static inline int dquot_resume(struct super_block *sb, int type)
278+
{
279+
return 0;
280+
}
281+
265282
#define dquot_file_open generic_file_open
266283

267284
#endif /* CONFIG_QUOTA */

0 commit comments

Comments
 (0)