linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: jack@suse.cz
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH 1/6] dquot: move remount handling into the filesystem
Date: Wed, 12 May 2010 15:44:09 -0400	[thread overview]
Message-ID: <20100512194453.440456468@bombadil.infradead.org> (raw)
In-Reply-To: 20100512194408.620390318@bombadil.infradead.org

[-- Attachment #1: quota-move-remount --]
[-- Type: text/plain, Size: 8582 bytes --]

Currently do_remount_sb calls into the dquot code to tell it about going
from rw to ro and ro to rw.  Move this code into the filesystem to
not depend on the dquot code in the VFS - note ocfs2 already ignores
these calls and handles remount by itself.  This gets rif of overloading
the quotactl calls and allows to unify the VFS and XFS codepathes in
that area later.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/fs/ext2/super.c
===================================================================
--- linux-2.6.orig/fs/ext2/super.c	2010-05-10 22:42:00.615256048 +0200
+++ linux-2.6/fs/ext2/super.c	2010-05-10 22:42:19.030253953 +0200
@@ -1191,6 +1191,7 @@ static int ext2_remount (struct super_bl
 	unsigned long old_mount_opt = sbi->s_mount_opt;
 	struct ext2_mount_options old_opts;
 	unsigned long old_sb_flags;
+	int enable_quota = 0;
 	int err;
 
 	spin_lock(&sbi->s_lock);
@@ -1241,6 +1242,7 @@ static int ext2_remount (struct super_bl
 			spin_unlock(&sbi->s_lock);
 			return 0;
 		}
+
 		/*
 		 * OK, we are remounting a valid rw partition rdonly, so set
 		 * the rdonly flag and then mark the partition as valid again.
@@ -1248,6 +1250,14 @@ static int ext2_remount (struct super_bl
 		es->s_state = cpu_to_le16(sbi->s_mount_state);
 		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;
+			spin_lock(&sbi->s_lock);
+			goto restore_opts;
+		}
+
 		ext2_sync_super(sb, es, 1);
 	} else {
 		__le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,
@@ -1269,8 +1279,13 @@ static int ext2_remount (struct super_bl
 		if (!ext2_setup_super (sb, es, 0))
 			sb->s_flags &= ~MS_RDONLY;
 		spin_unlock(&sbi->s_lock);
+
 		ext2_write_super(sb);
+		enable_quota = 1;
 	}
+
+	if (enable_quota)
+		vfs_dq_quota_on_remount(sb);
 	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:42:00.634006642 +0200
+++ linux-2.6/fs/ext3/super.c	2010-05-10 22:42:19.032253115 +0200
@@ -2551,6 +2551,7 @@ static int ext3_remount (struct super_bl
 	ext3_fsblk_t n_blocks_count = 0;
 	unsigned long old_sb_flags;
 	struct ext3_mount_options old_opts;
+	int enable_quota = 0;
 	int err;
 #ifdef CONFIG_QUOTA
 	int i;
@@ -2597,6 +2598,12 @@ static int ext3_remount (struct super_bl
 		}
 
 		if (*flags & MS_RDONLY) {
+			err = vfs_dq_off(sb, 1);
+			if (err < 0 && err != -ENOSYS) {
+				err = -EBUSY;
+				goto restore_opts;
+			}
+
 			/*
 			 * First of all, the unconditional stuff we have to do
 			 * to disable replay of the journal when we next remount
@@ -2651,6 +2658,7 @@ static int ext3_remount (struct super_bl
 				goto restore_opts;
 			if (!ext3_setup_super (sb, es, 0))
 				sb->s_flags &= ~MS_RDONLY;
+			enable_quota = 1;
 		}
 	}
 #ifdef CONFIG_QUOTA
@@ -2662,6 +2670,9 @@ static int ext3_remount (struct super_bl
 #endif
 	unlock_super(sb);
 	unlock_kernel();
+
+	if (enable_quota)
+		vfs_dq_quota_on_remount(sb);
 	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:42:00.655004337 +0200
+++ linux-2.6/fs/ext4/super.c	2010-05-10 22:42:19.034275045 +0200
@@ -3574,6 +3574,7 @@ static int ext4_remount(struct super_blo
 	ext4_fsblk_t n_blocks_count = 0;
 	unsigned long old_sb_flags;
 	struct ext4_mount_options old_opts;
+	int enable_quota = 0;
 	ext4_group_t g;
 	unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO;
 	int err;
@@ -3630,6 +3631,12 @@ static int ext4_remount(struct super_blo
 		}
 
 		if (*flags & MS_RDONLY) {
+			err = vfs_dq_off(sb, 1);
+			if (err < 0 && err != -ENOSYS) {
+				err = -EBUSY;
+				goto restore_opts;
+			}
+
 			/*
 			 * First of all, the unconditional stuff we have to do
 			 * to disable replay of the journal when we next remount
@@ -3698,6 +3705,7 @@ static int ext4_remount(struct super_blo
 				goto restore_opts;
 			if (!ext4_setup_super(sb, es, 0))
 				sb->s_flags &= ~MS_RDONLY;
+			enable_quota = 1;
 		}
 	}
 	ext4_setup_system_zone(sb);
@@ -3713,6 +3721,8 @@ static int ext4_remount(struct super_blo
 #endif
 	unlock_super(sb);
 	unlock_kernel();
+	if (enable_quota)
+		vfs_dq_quota_on_remount(sb);
 	return 0;
 
 restore_opts:
Index: linux-2.6/fs/jfs/super.c
===================================================================
--- linux-2.6.orig/fs/jfs/super.c	2010-05-10 22:42:00.662003848 +0200
+++ linux-2.6/fs/jfs/super.c	2010-05-10 22:42:19.039314715 +0200
@@ -397,9 +397,15 @@ 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);
 		return ret;
 	}
 	if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) {
+		rc = vfs_dq_off(sb, 1);
+		if (rc < 0 && rc != -ENOSYS) {
+			unlock_kernel();
+			return -EBUSY;
+		}
 		rc = jfs_umount_rw(sb);
 		JFS_SBI(sb)->flag = flag;
 		unlock_kernel();
Index: linux-2.6/fs/reiserfs/super.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/super.c	2010-05-10 22:42:00.673004267 +0200
+++ linux-2.6/fs/reiserfs/super.c	2010-05-10 22:42:19.046255559 +0200
@@ -1242,6 +1242,13 @@ static int reiserfs_remount(struct super
 		if (s->s_flags & MS_RDONLY)
 			/* it is read-only already */
 			goto out_ok;
+
+		err = vfs_dq_off(s, 1);
+		if (err < 0 && err != -ENOSYS) {
+			err = -EBUSY;
+			goto out_err;
+		}
+
 		/* try to remount file system with read-only permissions */
 		if (sb_umount_state(rs) == REISERFS_VALID_FS
 		    || REISERFS_SB(s)->s_mount_state != REISERFS_VALID_FS) {
@@ -1297,6 +1304,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);
 	}
 
 out_ok:
Index: linux-2.6/fs/ufs/super.c
===================================================================
--- linux-2.6.orig/fs/ufs/super.c	2010-05-10 22:42:00.681003778 +0200
+++ linux-2.6/fs/ufs/super.c	2010-05-10 22:42:19.051260518 +0200
@@ -1248,7 +1248,9 @@ static int ufs_remount (struct super_blo
 	struct ufs_super_block_first * usb1;
 	struct ufs_super_block_third * usb3;
 	unsigned new_mount_opt, ufstype;
+	int enable_quota = 0;
 	unsigned flags;
+	int err;
 
 	lock_kernel();
 	lock_super(sb);
@@ -1289,6 +1291,13 @@ 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) {
+			unlock_super(sb);
+			unlock_kernel();
+			return -EBUSY;
+		}
+
 		ufs_put_super_internal(sb);
 		usb1->fs_time = cpu_to_fs32(sb, get_seconds());
 		if ((flags & UFS_ST_MASK) == UFS_ST_SUN
@@ -1327,11 +1336,14 @@ static int ufs_remount (struct super_blo
 			return -EPERM;
 		}
 		sb->s_flags &= ~MS_RDONLY;
+		enable_quota = 1;
 #endif
 	}
 	UFS_SB(sb)->s_mount_opt = new_mount_opt;
 	unlock_super(sb);
 	unlock_kernel();
+	if (enable_quota)
+		vfs_dq_quota_on_remount(sb);
 	return 0;
 }
 
Index: linux-2.6/fs/super.c
===================================================================
--- linux-2.6.orig/fs/super.c	2010-05-10 22:42:00.690004267 +0200
+++ linux-2.6/fs/super.c	2010-05-10 22:42:32.808005454 +0200
@@ -569,7 +569,7 @@ out:
 int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
 {
 	int retval;
-	int remount_rw, remount_ro;
+	int remount_ro;
 
 	if (sb->s_frozen != SB_UNFROZEN)
 		return -EBUSY;
@@ -585,7 +585,6 @@ int do_remount_sb(struct super_block *sb
 	sync_filesystem(sb);
 
 	remount_ro = (flags & MS_RDONLY) && !(sb->s_flags & MS_RDONLY);
-	remount_rw = !(flags & MS_RDONLY) && (sb->s_flags & MS_RDONLY);
 
 	/* If we are remounting RDONLY and current sb is read/write,
 	   make sure there are no rw files opened */
@@ -594,9 +593,6 @@ int do_remount_sb(struct super_block *sb
 			mark_files_ro(sb);
 		else if (!fs_may_remount_ro(sb))
 			return -EBUSY;
-		retval = vfs_dq_off(sb, 1);
-		if (retval < 0 && retval != -ENOSYS)
-			return -EBUSY;
 	}
 
 	if (sb->s_op->remount_fs) {
@@ -605,8 +601,7 @@ int do_remount_sb(struct super_block *sb
 			return retval;
 	}
 	sb->s_flags = (sb->s_flags & ~MS_RMT_MASK) | (flags & MS_RMT_MASK);
-	if (remount_rw)
-		vfs_dq_quota_on_remount(sb);
+
 	/*
 	 * Some filesystems modify their metadata via some other path than the
 	 * bdev buffer cache (eg. use a private mapping, or directories in


  reply	other threads:[~2010-05-12 19:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-12 19:44 [PATCH 0/6] more quota cleanups Christoph Hellwig
2010-05-12 19:44 ` Christoph Hellwig [this message]
2010-05-17 22:34   ` [PATCH 1/6] dquot: move remount handling into the filesystem Jan Kara
2010-05-19 10:55     ` Christoph Hellwig
2010-05-19 13:47       ` Jan Kara
2010-05-12 19:44 ` [PATCH 2/6] quota: kill the vfs_dq_off and vfs_dq_quota_on_remount wrappers Christoph Hellwig
2010-05-17 22:46   ` Jan Kara
2010-05-12 19:44 ` [PATCH 3/6] dquot: move unmount handling into the filesystem Christoph Hellwig
2010-05-17 22:58   ` Jan Kara
2010-05-19 11:03     ` Christoph Hellwig
2010-05-12 19:44 ` [PATCH 4/6] quota: drop remount argument to ->quota_on and ->quota_off Christoph Hellwig
2010-05-17 23:00   ` Jan Kara
2010-05-12 19:44 ` [PATCH 5/6] quota: explicitly set ->dq_op and ->s_qcop Christoph Hellwig
2010-05-17 23:06   ` Jan Kara
2010-05-19 11:07     ` Christoph Hellwig
2010-05-12 19:44 ` [PATCH 6/6] quota: rename default quotactl methods to dqout_ Christoph Hellwig
2010-05-17 23:09   ` Jan Kara
2010-05-19 11:07     ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2010-05-19 11:16 [PATCH 0/6] more quota cleanups V2 Christoph Hellwig
2010-05-19 11:16 ` [PATCH 1/6] dquot: move remount handling into the filesystem Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100512194453.440456468@bombadil.infradead.org \
    --to=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).