public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH, RFC] more reserved blocks fixups
@ 2010-01-27 23:14 Eric Sandeen
  2010-01-28  1:58 ` Dave Chinner
  2010-02-05 22:59 ` PATCH V2] " Eric Sandeen
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Sandeen @ 2010-01-27 23:14 UTC (permalink / raw)
  To: xfs mailing list

This mangles the reserved blocks counts a little more.

1) add a helper function for the default reserved count
2) add helper functions to save/restore counts on ro/rw
3) save/restore reserved blocks on freeze/thaw
4) disallow changing reserved count while readonly

for 2) - maybe better names (save_and_clear?)
for 4) - maybe allow, but change the _ro field instead?

(TBH not tested yet but wondered if this seems sane)

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
---

diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index 5bb523d..5f06150 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -1430,6 +1430,9 @@ xfs_file_ioctl(
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 
+		if (mp->m_flags & XFS_MOUNT_RDONLY)
+			return -XFS_ERROR(EROFS);
+
 		if (copy_from_user(&inout, arg, sizeof(inout)))
 			return -XFS_ERROR(EFAULT);
 
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 7b15ed0..5f50372 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -1237,6 +1237,29 @@ xfs_fs_statfs(
 	return 0;
 }
 
+STATIC void
+xfs_save_resvblks(struct xfs_mount *mp)
+{
+	__uint64_t resblks = 0;
+
+	mp->m_resblks_ro = mp->m_resblks;
+	xfs_reserve_blocks(mp, &resblks, NULL);
+}
+
+STATIC void
+xfs_restore_resvblks(struct xfs_mount *mp)
+{
+	__uint64_t resblks;
+
+	if (mp->m_resblks_ro) {
+		resblks = mp->m_resblks_ro;
+		mp->m_resblks_ro = 0;
+	} else
+		resblks = xfs_default_resblks(mp);
+
+	xfs_reserve_blocks(mp, &resblks, NULL);
+}
+
 STATIC int
 xfs_fs_remount(
 	struct super_block	*sb,
@@ -1299,8 +1322,6 @@ xfs_fs_remount(
 
 	/* ro -> rw */
 	if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
-		__uint64_t resblks;
-
 		mp->m_flags &= ~XFS_MOUNT_RDONLY;
 		if (mp->m_flags & XFS_MOUNT_BARRIER)
 			xfs_mountfs_check_barriers(mp);
@@ -1323,15 +1344,7 @@ xfs_fs_remount(
 		 * Fill out the reserve pool if it is empty. Use the stashed
 		 * value if it is non-zero, otherwise go with the default.
 		 */
-		if (mp->m_resblks_ro) {
-			resblks = mp->m_resblks_ro;
-			mp->m_resblks_ro = 0;
-		} else {
-			resblks = mp->m_sb.sb_dblocks;
-			do_div(resblks, 20);
-			resblks = min_t(__uint64_t, resblks, 1024);
-		}
-		xfs_reserve_blocks(mp, &resblks, NULL);
+		xfs_restore_resvblks(mp);
 	}
 
 	/* rw -> ro */
@@ -1344,11 +1357,9 @@ xfs_fs_remount(
 		 * so that if we get remounted rw, we can return it to the same
 		 * size.
 		 */
-		__uint64_t resblks = 0;
 
 		xfs_quiesce_data(mp);
-		mp->m_resblks_ro = mp->m_resblks;
-		xfs_reserve_blocks(mp, &resblks, NULL);
+		xfs_save_resvblks(mp);
 		xfs_quiesce_attr(mp);
 		mp->m_flags |= XFS_MOUNT_RDONLY;
 	}
@@ -1367,11 +1378,22 @@ xfs_fs_freeze(
 {
 	struct xfs_mount	*mp = XFS_M(sb);
 
+	xfs_save_resvblks(mp);
 	xfs_quiesce_attr(mp);
 	return -xfs_fs_log_dummy(mp);
 }
 
 STATIC int
+xfs_fs_unfreeze(
+	struct super_block	*sb)
+{
+	struct xfs_mount	*mp = XFS_M(sb);
+
+	xfs_restore_resvblks(mp);
+	return 0;
+}
+
+STATIC int
 xfs_fs_show_options(
 	struct seq_file		*m,
 	struct vfsmount		*mnt)
@@ -1595,6 +1617,7 @@ static const struct super_operations xfs_super_operations = {
 	.put_super		= xfs_fs_put_super,
 	.sync_fs		= xfs_fs_sync_fs,
 	.freeze_fs		= xfs_fs_freeze,
+	.unfreeze_fs		= xfs_fs_unfreeze,
 	.statfs			= xfs_fs_statfs,
 	.remount_fs		= xfs_fs_remount,
 	.show_options		= xfs_fs_show_options,
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 8b6c9e8..0d1fbc1 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1006,6 +1006,22 @@ xfs_mount_reset_sbqflags(
 	return xfs_trans_commit(tp, 0);
 }
 
+__uint64_t
+xfs_default_resblks(xfs_mount_t *mp)
+{
+	__uint64_t resblks;
+
+	/*
+	 * We default to 5% or 1024 fsbs of space reserved, whichever is smaller.
+	 * This may drive us straight to ENOSPC on mount, but that implies
+	 * we were already there on the last unmount. Warn if this occurs.
+	 */
+	resblks = mp->m_sb.sb_dblocks;
+	do_div(resblks, 20);
+	resblks = min_t(__uint64_t, resblks, 1024);
+	return resblks;
+}
+
 /*
  * This function does the following on an initial mount of a file system:
  *	- reads the superblock from disk and init the mount struct
@@ -1316,18 +1332,14 @@ xfs_mountfs(
 	 * when at ENOSPC. This is needed for operations like create with
 	 * attr, unwritten extent conversion at ENOSPC, etc. Data allocations
 	 * are not allowed to use this reserved space.
-	 *
-	 * We default to 5% or 1024 fsbs of space reserved, whichever is smaller.
-	 * This may drive us straight to ENOSPC on mount, but that implies
-	 * we were already there on the last unmount. Warn if this occurs.
 	 */
-	resblks = mp->m_sb.sb_dblocks;
-	do_div(resblks, 20);
-	resblks = min_t(__uint64_t, resblks, 1024);
-	error = xfs_reserve_blocks(mp, &resblks, NULL);
-	if (error)
-		cmn_err(CE_WARN, "XFS: Unable to allocate reserve blocks. "
-				"Continuing without a reserve pool.");
+	if (!(mp->m_flags & XFS_MOUNT_RDONLY)) {
+		resblks = xfs_default_resblks(mp);
+		error = xfs_reserve_blocks(mp, &resblks, NULL);
+		if (error)
+			cmn_err(CE_WARN, "XFS: Unable to allocate reserve "
+				"blocks. Continuing without a reserve pool.");
+	}
 
 	return 0;
 
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 1205844..4ab7f40 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -414,6 +414,7 @@ typedef struct xfs_mod_sb {
 } xfs_mod_sb_t;
 
 extern int	xfs_log_sbcount(xfs_mount_t *, uint);
+extern __uint64_t xfs_default_resblks(xfs_mount_t *mp);
 extern int	xfs_mountfs(xfs_mount_t *mp);
 
 extern void	xfs_unmountfs(xfs_mount_t *);

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH, RFC] more reserved blocks fixups
  2010-01-27 23:14 [PATCH, RFC] more reserved blocks fixups Eric Sandeen
@ 2010-01-28  1:58 ` Dave Chinner
  2010-02-04 16:18   ` Christoph Hellwig
  2010-02-05 22:59 ` PATCH V2] " Eric Sandeen
  1 sibling, 1 reply; 5+ messages in thread
From: Dave Chinner @ 2010-01-28  1:58 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs mailing list

On Wed, Jan 27, 2010 at 05:14:54PM -0600, Eric Sandeen wrote:
> This mangles the reserved blocks counts a little more.
> 
> 1) add a helper function for the default reserved count
> 2) add helper functions to save/restore counts on ro/rw
> 3) save/restore reserved blocks on freeze/thaw
> 4) disallow changing reserved count while readonly
> 
> for 2) - maybe better names (save_and_clear?)
> for 4) - maybe allow, but change the _ro field instead?
> 
> (TBH not tested yet but wondered if this seems sane)

I was wondering if the save/restore could be encapsualted entirely
within xfs_quiesce_attr(). i.e. save before the superblock write,
restore directly after. That removes the need for a variable in
the xfs_mount structure, and catches both remount,ro and freeze.

What do you think?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH, RFC] more reserved blocks fixups
  2010-01-28  1:58 ` Dave Chinner
@ 2010-02-04 16:18   ` Christoph Hellwig
  0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2010-02-04 16:18 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Eric Sandeen, xfs mailing list

On Thu, Jan 28, 2010 at 12:58:17PM +1100, Dave Chinner wrote:
> On Wed, Jan 27, 2010 at 05:14:54PM -0600, Eric Sandeen wrote:
> > This mangles the reserved blocks counts a little more.
> > 
> > 1) add a helper function for the default reserved count
> > 2) add helper functions to save/restore counts on ro/rw
> > 3) save/restore reserved blocks on freeze/thaw
> > 4) disallow changing reserved count while readonly
> > 
> > for 2) - maybe better names (save_and_clear?)
> > for 4) - maybe allow, but change the _ro field instead?
> > 
> > (TBH not tested yet but wondered if this seems sane)
> 
> I was wondering if the save/restore could be encapsualted entirely
> within xfs_quiesce_attr(). i.e. save before the superblock write,
> restore directly after. That removes the need for a variable in
> the xfs_mount structure, and catches both remount,ro and freeze.

Seems like a bit fragile.  But I think we want Eric's version
over yours for a start - we should have a clean filesystem not
only after remount,ro but also for a frozen filesystem.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 5+ messages in thread

* PATCH V2] more reserved blocks fixups
  2010-01-27 23:14 [PATCH, RFC] more reserved blocks fixups Eric Sandeen
  2010-01-28  1:58 ` Dave Chinner
@ 2010-02-05 22:59 ` Eric Sandeen
  2010-02-06  1:41   ` Alex Elder
  1 sibling, 1 reply; 5+ messages in thread
From: Eric Sandeen @ 2010-02-05 22:59 UTC (permalink / raw)
  To: xfs mailing list

This mangles the reserved blocks counts a little more.

1) add a helper function for the default reserved count
2) add helper functions to save/restore counts on ro/rw
3) save/restore reserved blocks on freeze/thaw
4) disallow changing reserved count while readonly

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
---

V2: changed field name to match Dave's changes

diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index a034cf6..883929b 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -1431,6 +1431,9 @@ xfs_file_ioctl(
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 
+		if (mp->m_flags & XFS_MOUNT_RDONLY)
+			return -XFS_ERROR(EROFS);
+
 		if (copy_from_user(&inout, arg, sizeof(inout)))
 			return -XFS_ERROR(EFAULT);
 
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 8884f26..97c0f5a 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -1257,6 +1257,29 @@ xfs_fs_statfs(
 	return 0;
 }
 
+STATIC void
+xfs_save_resvblks(struct xfs_mount *mp)
+{
+	__uint64_t resblks = 0;
+
+	mp->m_resblks_save = mp->m_resblks;
+	xfs_reserve_blocks(mp, &resblks, NULL);
+}
+
+STATIC void
+xfs_restore_resvblks(struct xfs_mount *mp)
+{
+	__uint64_t resblks;
+
+	if (mp->m_resblks_save) {
+		resblks = mp->m_resblks_save;
+		mp->m_resblks_save = 0;
+	} else
+		resblks = xfs_default_resblks(mp);
+
+	xfs_reserve_blocks(mp, &resblks, NULL);
+}
+
 STATIC int
 xfs_fs_remount(
 	struct super_block	*sb,
@@ -1319,8 +1342,6 @@ xfs_fs_remount(
 
 	/* ro -> rw */
 	if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
-		__uint64_t resblks;
-
 		mp->m_flags &= ~XFS_MOUNT_RDONLY;
 		if (mp->m_flags & XFS_MOUNT_BARRIER)
 			xfs_mountfs_check_barriers(mp);
@@ -1343,15 +1364,7 @@ xfs_fs_remount(
 		 * Fill out the reserve pool if it is empty. Use the stashed
 		 * value if it is non-zero, otherwise go with the default.
 		 */
-		if (mp->m_resblks_save) {
-			resblks = mp->m_resblks_save;
-			mp->m_resblks_save = 0;
-		} else {
-			resblks = mp->m_sb.sb_dblocks;
-			do_div(resblks, 20);
-			resblks = min_t(__uint64_t, resblks, 1024);
-		}
-		xfs_reserve_blocks(mp, &resblks, NULL);
+		xfs_restore_resvblks(mp);
 	}
 
 	/* rw -> ro */
@@ -1364,11 +1377,9 @@ xfs_fs_remount(
 		 * so that if we get remounted rw, we can return it to the same
 		 * size.
 		 */
-		__uint64_t resblks = 0;
 
 		xfs_quiesce_data(mp);
-		mp->m_resblks_save = mp->m_resblks;
-		xfs_reserve_blocks(mp, &resblks, NULL);
+		xfs_save_resvblks(mp);
 		xfs_quiesce_attr(mp);
 		mp->m_flags |= XFS_MOUNT_RDONLY;
 	}
@@ -1387,11 +1398,22 @@ xfs_fs_freeze(
 {
 	struct xfs_mount	*mp = XFS_M(sb);
 
+	xfs_save_resvblks(mp);
 	xfs_quiesce_attr(mp);
 	return -xfs_fs_log_dummy(mp);
 }
 
 STATIC int
+xfs_fs_unfreeze(
+	struct super_block	*sb)
+{
+	struct xfs_mount	*mp = XFS_M(sb);
+
+	xfs_restore_resvblks(mp);
+	return 0;
+}
+
+STATIC int
 xfs_fs_show_options(
 	struct seq_file		*m,
 	struct vfsmount		*mnt)
@@ -1613,6 +1635,7 @@ static const struct super_operations xfs_super_operations = {
 	.put_super		= xfs_fs_put_super,
 	.sync_fs		= xfs_fs_sync_fs,
 	.freeze_fs		= xfs_fs_freeze,
+	.unfreeze_fs		= xfs_fs_unfreeze,
 	.statfs			= xfs_fs_statfs,
 	.remount_fs		= xfs_fs_remount,
 	.show_options		= xfs_fs_show_options,
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index eb403b4..48e1ee7 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1008,6 +1008,22 @@ xfs_mount_reset_sbqflags(
 	return xfs_trans_commit(tp, 0);
 }
 
+__uint64_t
+xfs_default_resblks(xfs_mount_t *mp)
+{
+	__uint64_t resblks;
+
+	/*
+	 * We default to 5% or 1024 fsbs of space reserved, whichever is smaller.
+	 * This may drive us straight to ENOSPC on mount, but that implies
+	 * we were already there on the last unmount. Warn if this occurs.
+	 */
+	resblks = mp->m_sb.sb_dblocks;
+	do_div(resblks, 20);
+	resblks = min_t(__uint64_t, resblks, 1024);
+	return resblks;
+}
+
 /*
  * This function does the following on an initial mount of a file system:
  *	- reads the superblock from disk and init the mount struct
@@ -1318,18 +1334,14 @@ xfs_mountfs(
 	 * when at ENOSPC. This is needed for operations like create with
 	 * attr, unwritten extent conversion at ENOSPC, etc. Data allocations
 	 * are not allowed to use this reserved space.
-	 *
-	 * We default to 5% or 1024 fsbs of space reserved, whichever is smaller.
-	 * This may drive us straight to ENOSPC on mount, but that implies
-	 * we were already there on the last unmount. Warn if this occurs.
 	 */
-	resblks = mp->m_sb.sb_dblocks;
-	do_div(resblks, 20);
-	resblks = min_t(__uint64_t, resblks, 1024);
-	error = xfs_reserve_blocks(mp, &resblks, NULL);
-	if (error)
-		cmn_err(CE_WARN, "XFS: Unable to allocate reserve blocks. "
-				"Continuing without a reserve pool.");
+	if (!(mp->m_flags & XFS_MOUNT_RDONLY)) {
+		resblks = xfs_default_resblks(mp);
+		error = xfs_reserve_blocks(mp, &resblks, NULL);
+		if (error)
+			cmn_err(CE_WARN, "XFS: Unable to allocate reserve "
+				"blocks. Continuing without a reserve pool.");
+	}
 
 	return 0;
 
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 996273d..c8f880d 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -429,6 +429,7 @@ typedef struct xfs_mod_sb {
 } xfs_mod_sb_t;
 
 extern int	xfs_log_sbcount(xfs_mount_t *, uint);
+extern __uint64_t xfs_default_resblks(xfs_mount_t *mp);
 extern int	xfs_mountfs(xfs_mount_t *mp);
 
 extern void	xfs_unmountfs(xfs_mount_t *);

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: PATCH V2] more reserved blocks fixups
  2010-02-05 22:59 ` PATCH V2] " Eric Sandeen
@ 2010-02-06  1:41   ` Alex Elder
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2010-02-06  1:41 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs mailing list

On Fri, 2010-02-05 at 16:59 -0600, Eric Sandeen wrote:
> This mangles the reserved blocks counts a little more.
> 
> 1) add a helper function for the default reserved count
> 2) add helper functions to save/restore counts on ro/rw
> 3) save/restore reserved blocks on freeze/thaw
> 4) disallow changing reserved count while readonly

Looks good.  Thanks for updating it.

> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>

Reviewed-by: Alex Elder <aelder@sgi.com>

> ---
> 
> V2: changed field name to match Dave's changes
> 
> diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
> index a034cf6..883929b 100644
> --- a/fs/xfs/linux-2.6/xfs_ioctl.c
> +++ b/fs/xfs/linux-2.6/xfs_ioctl.c
> @@ -1431,6 +1431,9 @@ xfs_file_ioctl(
>  		if (!capable(CAP_SYS_ADMIN))
>  			return -EPERM;
>  
> +		if (mp->m_flags & XFS_MOUNT_RDONLY)
> +			return -XFS_ERROR(EROFS);
> +
>  		if (copy_from_user(&inout, arg, sizeof(inout)))
>  			return -XFS_ERROR(EFAULT);
>  
> diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
> index 8884f26..97c0f5a 100644
> --- a/fs/xfs/linux-2.6/xfs_super.c
> +++ b/fs/xfs/linux-2.6/xfs_super.c
> @@ -1257,6 +1257,29 @@ xfs_fs_statfs(
>  	return 0;
>  }
>  
> +STATIC void
> +xfs_save_resvblks(struct xfs_mount *mp)
> +{
> +	__uint64_t resblks = 0;
> +
> +	mp->m_resblks_save = mp->m_resblks;
> +	xfs_reserve_blocks(mp, &resblks, NULL);
> +}
> +
> +STATIC void
> +xfs_restore_resvblks(struct xfs_mount *mp)
> +{
> +	__uint64_t resblks;
> +
> +	if (mp->m_resblks_save) {
> +		resblks = mp->m_resblks_save;
> +		mp->m_resblks_save = 0;
> +	} else
> +		resblks = xfs_default_resblks(mp);
> +
> +	xfs_reserve_blocks(mp, &resblks, NULL);
> +}
> +
>  STATIC int
>  xfs_fs_remount(
>  	struct super_block	*sb,
> @@ -1319,8 +1342,6 @@ xfs_fs_remount(
>  
>  	/* ro -> rw */
>  	if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
> -		__uint64_t resblks;
> -
>  		mp->m_flags &= ~XFS_MOUNT_RDONLY;
>  		if (mp->m_flags & XFS_MOUNT_BARRIER)
>  			xfs_mountfs_check_barriers(mp);
> @@ -1343,15 +1364,7 @@ xfs_fs_remount(
>  		 * Fill out the reserve pool if it is empty. Use the stashed
>  		 * value if it is non-zero, otherwise go with the default.
>  		 */
> -		if (mp->m_resblks_save) {
> -			resblks = mp->m_resblks_save;
> -			mp->m_resblks_save = 0;
> -		} else {
> -			resblks = mp->m_sb.sb_dblocks;
> -			do_div(resblks, 20);
> -			resblks = min_t(__uint64_t, resblks, 1024);
> -		}
> -		xfs_reserve_blocks(mp, &resblks, NULL);
> +		xfs_restore_resvblks(mp);
>  	}
>  
>  	/* rw -> ro */
> @@ -1364,11 +1377,9 @@ xfs_fs_remount(
>  		 * so that if we get remounted rw, we can return it to the same
>  		 * size.
>  		 */
> -		__uint64_t resblks = 0;
>  
>  		xfs_quiesce_data(mp);
> -		mp->m_resblks_save = mp->m_resblks;
> -		xfs_reserve_blocks(mp, &resblks, NULL);
> +		xfs_save_resvblks(mp);
>  		xfs_quiesce_attr(mp);
>  		mp->m_flags |= XFS_MOUNT_RDONLY;
>  	}
> @@ -1387,11 +1398,22 @@ xfs_fs_freeze(
>  {
>  	struct xfs_mount	*mp = XFS_M(sb);
>  
> +	xfs_save_resvblks(mp);
>  	xfs_quiesce_attr(mp);
>  	return -xfs_fs_log_dummy(mp);
>  }
>  
>  STATIC int
> +xfs_fs_unfreeze(
> +	struct super_block	*sb)
> +{
> +	struct xfs_mount	*mp = XFS_M(sb);
> +
> +	xfs_restore_resvblks(mp);
> +	return 0;
> +}
> +
> +STATIC int
>  xfs_fs_show_options(
>  	struct seq_file		*m,
>  	struct vfsmount		*mnt)
> @@ -1613,6 +1635,7 @@ static const struct super_operations xfs_super_operations = {
>  	.put_super		= xfs_fs_put_super,
>  	.sync_fs		= xfs_fs_sync_fs,
>  	.freeze_fs		= xfs_fs_freeze,
> +	.unfreeze_fs		= xfs_fs_unfreeze,
>  	.statfs			= xfs_fs_statfs,
>  	.remount_fs		= xfs_fs_remount,
>  	.show_options		= xfs_fs_show_options,
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index eb403b4..48e1ee7 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -1008,6 +1008,22 @@ xfs_mount_reset_sbqflags(
>  	return xfs_trans_commit(tp, 0);
>  }
>  
> +__uint64_t
> +xfs_default_resblks(xfs_mount_t *mp)
> +{
> +	__uint64_t resblks;
> +
> +	/*
> +	 * We default to 5% or 1024 fsbs of space reserved, whichever is smaller.
> +	 * This may drive us straight to ENOSPC on mount, but that implies
> +	 * we were already there on the last unmount. Warn if this occurs.
> +	 */
> +	resblks = mp->m_sb.sb_dblocks;
> +	do_div(resblks, 20);
> +	resblks = min_t(__uint64_t, resblks, 1024);
> +	return resblks;
> +}
> +
>  /*
>   * This function does the following on an initial mount of a file system:
>   *	- reads the superblock from disk and init the mount struct
> @@ -1318,18 +1334,14 @@ xfs_mountfs(
>  	 * when at ENOSPC. This is needed for operations like create with
>  	 * attr, unwritten extent conversion at ENOSPC, etc. Data allocations
>  	 * are not allowed to use this reserved space.
> -	 *
> -	 * We default to 5% or 1024 fsbs of space reserved, whichever is smaller.
> -	 * This may drive us straight to ENOSPC on mount, but that implies
> -	 * we were already there on the last unmount. Warn if this occurs.
>  	 */
> -	resblks = mp->m_sb.sb_dblocks;
> -	do_div(resblks, 20);
> -	resblks = min_t(__uint64_t, resblks, 1024);
> -	error = xfs_reserve_blocks(mp, &resblks, NULL);
> -	if (error)
> -		cmn_err(CE_WARN, "XFS: Unable to allocate reserve blocks. "
> -				"Continuing without a reserve pool.");
> +	if (!(mp->m_flags & XFS_MOUNT_RDONLY)) {
> +		resblks = xfs_default_resblks(mp);
> +		error = xfs_reserve_blocks(mp, &resblks, NULL);
> +		if (error)
> +			cmn_err(CE_WARN, "XFS: Unable to allocate reserve "
> +				"blocks. Continuing without a reserve pool.");
> +	}
>  
>  	return 0;
>  
> diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
> index 996273d..c8f880d 100644
> --- a/fs/xfs/xfs_mount.h
> +++ b/fs/xfs/xfs_mount.h
> @@ -429,6 +429,7 @@ typedef struct xfs_mod_sb {
>  } xfs_mod_sb_t;
>  
>  extern int	xfs_log_sbcount(xfs_mount_t *, uint);
> +extern __uint64_t xfs_default_resblks(xfs_mount_t *mp);
>  extern int	xfs_mountfs(xfs_mount_t *mp);
>  
>  extern void	xfs_unmountfs(xfs_mount_t *);
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs



_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-02-06  1:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-27 23:14 [PATCH, RFC] more reserved blocks fixups Eric Sandeen
2010-01-28  1:58 ` Dave Chinner
2010-02-04 16:18   ` Christoph Hellwig
2010-02-05 22:59 ` PATCH V2] " Eric Sandeen
2010-02-06  1:41   ` Alex Elder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox