[12/11] xfs: refactor quota code in xfs_bmap_btalloc
diff mbox

Message ID 20180125052647.GF9068@magnolia
State New
Headers show

Commit Message

Darrick J. Wong Jan. 25, 2018, 5:26 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Since we now have a dedicated function for dealing with CoW allocation
related quota updates in xfs_bmap_btalloc, we might as well refactor the
data/attr fork quota update into its own function too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_bmap.c |   32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Christoph Hellwig Jan. 26, 2018, 12:17 p.m. UTC | #1
On Wed, Jan 24, 2018 at 09:26:47PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Since we now have a dedicated function for dealing with CoW allocation
> related quota updates in xfs_bmap_btalloc, we might as well refactor the
> data/attr fork quota update into its own function too.

Any good reason not to have this merged with the cow fork side helper?

> +	/*
> +	 * Adjust the disk quota also. This was reserved
> +	 * earlier.
> +	 */

Please use the full available line length for comments.

> +	xfs_trans_mod_dquot_byino(ap->tp, ap->ip,
> +		ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : XFS_TRANS_DQ_BCOUNT,
> +		(long) args.len);

I don't think we need this cast.
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Darrick J. Wong Jan. 26, 2018, 9:46 p.m. UTC | #2
On Fri, Jan 26, 2018 at 04:17:16AM -0800, Christoph Hellwig wrote:
> On Wed, Jan 24, 2018 at 09:26:47PM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Since we now have a dedicated function for dealing with CoW allocation
> > related quota updates in xfs_bmap_btalloc, we might as well refactor the
> > data/attr fork quota update into its own function too.
> 
> Any good reason not to have this merged with the cow fork side helper?
> 
> > +	/*
> > +	 * Adjust the disk quota also. This was reserved
> > +	 * earlier.
> > +	 */
> 
> Please use the full available line length for comments.
> 
> > +	xfs_trans_mod_dquot_byino(ap->tp, ap->ip,
> > +		ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : XFS_TRANS_DQ_BCOUNT,
> > +		(long) args.len);
> 
> I don't think we need this cast.

I fixed all of these; will have a new series out soon.

--D

> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 4144487..2d99b7a 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -3402,6 +3402,25 @@  xfs_bmap_btalloc_filestreams(
 	return 0;
 }
 
+/* Deal with data/attr fork accounting when we allocate a block. */
+static void
+xfs_bmap_btalloc_quota(
+	struct xfs_bmalloca	*ap,
+	struct xfs_alloc_arg	*args)
+{
+	ap->ip->i_d.di_nblocks += args.len;
+	xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
+	if (ap->wasdel)
+		ap->ip->i_delayed_blks -= args.len;
+	/*
+	 * Adjust the disk quota also. This was reserved
+	 * earlier.
+	 */
+	xfs_trans_mod_dquot_byino(ap->tp, ap->ip,
+		ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : XFS_TRANS_DQ_BCOUNT,
+		(long) args.len);
+}
+
 /* Deal with CoW fork accounting when we allocate a block. */
 static void
 xfs_bmap_btalloc_quota_cow(
@@ -3679,18 +3698,7 @@  xfs_bmap_btalloc(
 			xfs_bmap_btalloc_quota_cow(ap, &args, orig_offset,
 					orig_length);
 		} else {
-			ap->ip->i_d.di_nblocks += args.len;
-			xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
-			if (ap->wasdel)
-				ap->ip->i_delayed_blks -= args.len;
-			/*
-			 * Adjust the disk quota also. This was reserved
-			 * earlier.
-			 */
-			xfs_trans_mod_dquot_byino(ap->tp, ap->ip,
-				ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT :
-						XFS_TRANS_DQ_BCOUNT,
-				(long) args.len);
+			xfs_bmap_btalloc_quota(ap, &args);
 		}
 	} else {
 		ap->blkno = NULLFSBLOCK;