[PATCH 2/6] quota: kill the vfs_dq_off and vfs_dq_quota_on_remount wrappers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

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-19 10:47:34.592253960 +0200
+++ linux-2.6/fs/quota/dquot.c	2010-05-19 12:54:25.311005741 +0200
@@ -1865,7 +1865,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);
@@ -1995,14 +1995,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
  */
@@ -2119,35 +2121,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)
@@ -2172,8 +2187,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) {
@@ -2196,8 +2210,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? */
@@ -2263,23 +2277,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-19 12:53:30.000000000 +0200
+++ linux-2.6/fs/ext2/super.c	2010-05-19 12:54:52.992255707 +0200
@@ -1250,9 +1250,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;
 		}
@@ -1281,7 +1280,7 @@ static int ext2_remount (struct super_bl
 
 		ext2_write_super(sb);
 
-		vfs_dq_quota_on_remount(sb);
+		dquot_resume(sb, -1);
 	}
 
 	return 0;
Index: linux-2.6/fs/ext3/super.c
===================================================================
--- linux-2.6.orig/fs/ext3/super.c	2010-05-19 12:43:25.000000000 +0200
+++ linux-2.6/fs/ext3/super.c	2010-05-19 12:54:25.315004205 +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-19 12:43:25.000000000 +0200
+++ linux-2.6/fs/ext4/super.c	2010-05-19 12:54:25.319004274 +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-19 12:50:17.000000000 +0200
+++ linux-2.6/fs/jfs/super.c	2010-05-19 12:54:25.321004135 +0200
@@ -401,14 +401,14 @@ static int jfs_remount(struct super_bloc
 		sb->s_flags &= ~MS_RDONLY;
 
 		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-19 10:47:34.000000000 +0200
+++ linux-2.6/fs/ocfs2/super.c	2010-05-19 12:54:25.326024459 +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;
 	}
@@ -946,8 +942,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);
@@ -977,7 +973,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-19 12:43:25.000000000 +0200
+++ linux-2.6/fs/reiserfs/super.c	2010-05-19 12:54:25.329035703 +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-19 12:43:25.000000000 +0200
+++ linux-2.6/fs/ufs/super.c	2010-05-19 12:54:25.336004274 +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-19 10:47:34.629253262 +0200
+++ linux-2.6/include/linux/quotaops.h	2010-05-19 12:54:25.341003855 +0200
@@ -50,6 +50,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);
@@ -67,7 +71,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);
@@ -78,7 +81,6 @@ int vfs_set_dqblk(struct super_block *sb
 
 int __dquot_transfer(struct inode *inode, struct dquot **transfer_to);
 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)
 {
@@ -231,11 +233,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;
@@ -262,6 +259,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 */
Index: linux-2.6/fs/udf/super.c
===================================================================
--- linux-2.6.orig/fs/udf/super.c	2010-05-19 12:55:38.596254309 +0200
+++ linux-2.6/fs/udf/super.c	2010-05-19 12:56:29.316255985 +0200
@@ -590,15 +590,13 @@ static int udf_remount_fs(struct super_b
 	if (*flags & MS_RDONLY) {
 		udf_close_lvid(sb);
 
-		error = vfs_dq_off(sb, 1);
-		if (error < 0 && error != -ENOSYS)
-			error = -EBUSY;
+		error = dquot_suspend(sb, -1);
 	} else {
 		udf_open_lvid(sb);
 
 		/* mark the fs r/w for quota activity */
 		sb->s_flags &= ~MS_RDONLY;
-		vfs_dq_quota_on_remount(sb);
+		dquot_resume(sb, -1);
 	}
 
 out_unlock:

--
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

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux