[PATCH 05/15] xfs: Teach inode/space allocator aware of XFS_AG_STATE_ALLOC_DENY

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

 



Teach inode/space allocators aware of the new AG state(XFS_AG_STATE_ALLOC_DENY).

- Don't chose an AG with this state.
- Don't mark pagi_inodeok upon an AG for xfs_set_inode32/64 mount options if the
given AG incore object has this state.


Signed-off-by: Jie Liu <jeff.liu@xxxxxxxxxx>
---
 fs/xfs/xfs_alloc.c  |   15 ++++++++++++++-
 fs/xfs/xfs_ialloc.c |    6 +++++-
 fs/xfs/xfs_super.c  |   10 ++++++++++
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index bd9cc41..d2eb856 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -493,6 +493,7 @@ STATIC int			/* error */
 xfs_alloc_ag_vextent(
 	xfs_alloc_arg_t	*args)	/* argument structure for allocation */
 {
+	xfs_perag_t	*pag = args->pag;
 	int		error=0;
 
 	ASSERT(args->minlen > 0);
@@ -500,6 +501,18 @@ xfs_alloc_ag_vextent(
 	ASSERT(args->minlen <= args->maxlen);
 	ASSERT(args->mod < args->prod);
 	ASSERT(args->alignment > 0);
+
+	/*
+	 * Return NULLAGBLOCK if the a.g. state is set to offline.
+	 * i.e. deny allocation.
+	 * FIXME: how about replacing XFS_AG_STATE_ALLOC_DENY to
+	 * XFS_AG_STATE_OFFLINE? maybe looks a bit more reasonable.
+	 */
+	if (unlikely(pag->pag_state & XFS_AG_STATE_ALLOC_DENY)) {
+		args->agbno = NULLAGBLOCK;
+		return 0;
+	}
+
 	/*
 	 * Branch to correct routine based on the type.
 	 */
@@ -1893,7 +1906,7 @@ xfs_alloc_fix_freelist(
 		/*
 		 * Stop if we run out.  Won't happen if callers are obeying
 		 * the restrictions correctly.  Can happen for free calls
-		 * on a completely full ag.
+		 * on a completely full ag, or an ag is set to offline.
 		 */
 		if (targs.agbno == NULLAGBLOCK) {
 			if (flags & XFS_ALLOC_FLAG_FREEING)
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index 445bf1a..04fbb49 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -488,7 +488,11 @@ xfs_ialloc_ag_select(
 	flags = XFS_ALLOC_FLAG_TRYLOCK;
 	for (;;) {
 		pag = xfs_perag_get(mp, agno);
-		if (!pag->pagi_inodeok) {
+		/*
+		 * Skip the current AG if it's state is set to offline.
+		 */
+		if (!pag->pagi_inodeok ||
+		    unlikely(pag->pag_state & XFS_AG_STATE_ALLOC_DENY)) {
 			xfs_ialloc_next_ag(mp);
 			goto nextag;
 		}
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 26a09bd..e01f64c 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -642,6 +642,11 @@ xfs_set_inode32(struct xfs_mount *mp)
 		}
 
 		pag = xfs_perag_get(mp, index);
+		if (unlikely(pag->pag_state & XFS_AG_STATE_ALLOC_DENY)) {
+			xfs_perag_put(pag);
+			continue;
+		}
+
 		pag->pagi_inodeok = 1;
 		maxagi++;
 		if (index < max_metadata)
@@ -663,6 +668,11 @@ xfs_set_inode64(struct xfs_mount *mp)
 		struct xfs_perag	*pag;
 
 		pag = xfs_perag_get(mp, index);
+		if (unlikely(pag->pag_state & XFS_AG_STATE_ALLOC_DENY)) {
+			xfs_perag_put(pag);
+			continue;
+		}
+
 		pag->pagi_inodeok = 1;
 		pag->pagf_metadata = 0;
 		xfs_perag_put(pag);
-- 
1.7.4.1

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


[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux