All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 03/13] xfs: refactor the v4 group/project inode pointer switch
Date: Mon, 31 Dec 2018 18:22:45 -0800	[thread overview]
Message-ID: <154630936571.21716.17710862173783712576.stgit@magnolia> (raw)
In-Reply-To: <154630934595.21716.17416691804044507782.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

Refactor the group and project quota inode pointer switcheroo that
happens only on v4 filesystems into a separate function prior to
enhancing the xfs_qm_qino_alloc function.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_qm.c |   79 +++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 50 insertions(+), 29 deletions(-)


diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 58be2ef90351..b5f2853a5009 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -742,6 +742,53 @@ xfs_qm_destroy_quotainfo(
 	mp->m_quotainfo = NULL;
 }
 
+/*
+ * Switch the group and project quota in-core inode pointers if needed.
+ *
+ * On v4 superblocks that don't have separate pquotino, we share an inode
+ * between gquota and pquota. If the on-disk superblock has GQUOTA and the
+ * filesystem is now mounted with PQUOTA, just use sb_gquotino for sb_pquotino
+ * and vice-versa.
+ */
+STATIC int
+xfs_qm_qino_switch(
+	struct xfs_mount	*mp,
+	struct xfs_inode	**ip,
+	unsigned int		flags,
+	bool			*need_alloc)
+{
+	xfs_ino_t		ino = NULLFSINO;
+	int			error;
+
+	if (xfs_sb_version_has_pquotino(&mp->m_sb) ||
+	    !(flags & (XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA)))
+		return 0;
+
+	if ((flags & XFS_QMOPT_PQUOTA) &&
+	    (mp->m_sb.sb_gquotino != NULLFSINO)) {
+		ino = mp->m_sb.sb_gquotino;
+		if (mp->m_sb.sb_pquotino != NULLFSINO)
+			return -EFSCORRUPTED;
+	} else if ((flags & XFS_QMOPT_GQUOTA) &&
+		   (mp->m_sb.sb_pquotino != NULLFSINO)) {
+		ino = mp->m_sb.sb_pquotino;
+		if (mp->m_sb.sb_gquotino != NULLFSINO)
+			return -EFSCORRUPTED;
+	}
+
+	if (ino == NULLFSINO)
+		return 0;
+
+	error = xfs_iget(mp, NULL, ino, 0, 0, ip);
+	if (error)
+		return error;
+
+	mp->m_sb.sb_gquotino = NULLFSINO;
+	mp->m_sb.sb_pquotino = NULLFSINO;
+	*need_alloc = false;
+	return 0;
+}
+
 /*
  * Create an inode and return with a reference already taken, but unlocked
  * This is how we create quota inodes
@@ -762,35 +809,9 @@ xfs_qm_qino_alloc(
 	bool		need_alloc = true;
 
 	*ip = NULL;
-	/*
-	 * With superblock that doesn't have separate pquotino, we
-	 * share an inode between gquota and pquota. If the on-disk
-	 * superblock has GQUOTA and the filesystem is now mounted
-	 * with PQUOTA, just use sb_gquotino for sb_pquotino and
-	 * vice-versa.
-	 */
-	if (!xfs_sb_version_has_pquotino(&mp->m_sb) &&
-			(flags & (XFS_QMOPT_PQUOTA|XFS_QMOPT_GQUOTA))) {
-		xfs_ino_t ino = NULLFSINO;
-
-		if ((flags & XFS_QMOPT_PQUOTA) &&
-			     (mp->m_sb.sb_gquotino != NULLFSINO)) {
-			ino = mp->m_sb.sb_gquotino;
-			ASSERT(mp->m_sb.sb_pquotino == NULLFSINO);
-		} else if ((flags & XFS_QMOPT_GQUOTA) &&
-			     (mp->m_sb.sb_pquotino != NULLFSINO)) {
-			ino = mp->m_sb.sb_pquotino;
-			ASSERT(mp->m_sb.sb_gquotino == NULLFSINO);
-		}
-		if (ino != NULLFSINO) {
-			error = xfs_iget(mp, NULL, ino, 0, 0, ip);
-			if (error)
-				return error;
-			mp->m_sb.sb_gquotino = NULLFSINO;
-			mp->m_sb.sb_pquotino = NULLFSINO;
-			need_alloc = false;
-		}
-	}
+	error = xfs_qm_qino_switch(mp, ip, flags, &need_alloc);
+	if (error)
+		return error;
 
 	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_create,
 			XFS_QM_QINOCREATE_SPACE_RES(mp), 0, 0, &tp);

  parent reply	other threads:[~2019-01-01  2:22 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-01  2:22 [PATCH 00/13] xfs: metadata inode directories Darrick J. Wong
2019-01-01  2:22 ` [PATCH 01/13] xfs: create imeta abstractions to get and set metadata inodes Darrick J. Wong
2019-01-01  2:22 ` [PATCH 02/13] xfs: create transaction reservations for metadata inode operations Darrick J. Wong
2019-01-01  2:22 ` Darrick J. Wong [this message]
2019-01-01  2:22 ` [PATCH 04/13] xfs: convert all users to xfs_imeta_log Darrick J. Wong
2019-01-01  2:22 ` [PATCH 05/13] xfs: iget for metadata inodes Darrick J. Wong
2019-01-01  2:23 ` [PATCH 06/13] xfs: define the on-disk format for the metadir feature Darrick J. Wong
2019-01-01  2:23 ` [PATCH 07/13] xfs: load metadata inode directory at mount time Darrick J. Wong
2019-01-01  2:23 ` [PATCH 08/13] xfs: convert metadata inode lookup keys to use paths Darrick J. Wong
2019-01-01  2:23 ` [PATCH 09/13] xfs: enforce metadata inode flag Darrick J. Wong
2019-01-01  2:23 ` [PATCH 10/13] xfs: read and write metadata inode directory Darrick J. Wong
2019-01-01  2:23 ` [PATCH 11/13] xfs: ensure metadata directory paths exist before creating files Darrick J. Wong
2019-01-01  2:23 ` [PATCH 12/13] xfs: disable the agi rotor for metadata inodes Darrick J. Wong
2019-01-01  2:23 ` [PATCH 13/13] xfs: enable metadata inode directory feature Darrick J. Wong
2019-01-01  9:29 ` [PATCH 00/13] xfs: metadata inode directories Amir Goldstein
2019-01-17 14:26 ` Christoph Hellwig
2019-01-17 23:36   ` Darrick J. Wong
2019-01-17 23:50     ` Darrick J. Wong
2020-01-01  1:14 [PATCH v2 " Darrick J. Wong
2020-01-01  1:15 ` [PATCH 03/13] xfs: refactor the v4 group/project inode pointer switch Darrick J. Wong

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=154630936571.21716.17710862173783712576.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.