linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET v2 0/4] xfs: minor cleanups of the quota functions
@ 2021-01-23 18:51 Darrick J. Wong
  2021-01-23 18:51 ` [PATCH 1/4] xfs: clean up quota reservation callsites Darrick J. Wong
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-01-23 18:51 UTC (permalink / raw)
  To: djwong; +Cc: Christoph Hellwig, linux-xfs, hch, david

Hi all,

This series reworks some of the internal quota APIs and cleans up some
of the function calls so that we have a clean(er) place to start the
space reclamation patchset.  There should be no behavioral changes in
this series.

v2: rework the xfs_quota_reserve_blkres calling conventions per hch

If you're going to start using this mess, you probably ought to just
pull from my git trees, which are linked below.

This is an extraordinary way to destroy everything.  Enjoy!
Comments and questions are, as always, welcome.

--D

kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=quota-function-cleanups-5.12
---
 fs/xfs/libxfs/xfs_bmap.c |   13 ++++++-------
 fs/xfs/xfs_bmap_util.c   |    4 ++--
 fs/xfs/xfs_inode.c       |    8 ++++----
 fs/xfs/xfs_quota.h       |   41 ++++++++++++++++++++++++++++++++++++-----
 fs/xfs/xfs_reflink.c     |    6 +++---
 fs/xfs/xfs_symlink.c     |    4 ++--
 fs/xfs/xfs_trans_dquot.c |   21 +++++++++++++++++++++
 7 files changed, 74 insertions(+), 23 deletions(-)


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

* [PATCH 1/4] xfs: clean up quota reservation callsites
  2021-01-23 18:51 [PATCHSET v2 0/4] xfs: minor cleanups of the quota functions Darrick J. Wong
@ 2021-01-23 18:51 ` Darrick J. Wong
  2021-01-25 15:13   ` Brian Foster
  2021-01-23 18:51 ` [PATCH 2/4] xfs: clean up quota reservation wrappers Darrick J. Wong
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Darrick J. Wong @ 2021-01-23 18:51 UTC (permalink / raw)
  To: djwong; +Cc: Christoph Hellwig, linux-xfs, hch, david

From: Darrick J. Wong <djwong@kernel.org>

Convert a few xfs_trans_*reserve* callsites that are open-coding other
convenience functions.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_bmap.c |    3 +--
 fs/xfs/xfs_bmap_util.c   |    4 ++--
 fs/xfs/xfs_reflink.c     |    4 ++--
 3 files changed, 5 insertions(+), 6 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 2cd24bb06040..aea179212946 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -4938,8 +4938,7 @@ xfs_bmap_del_extent_delay(
 	 * sb counters as we might have to borrow some blocks for the
 	 * indirect block accounting.
 	 */
-	error = xfs_trans_reserve_quota_nblks(NULL, ip,
-			-((long)del->br_blockcount), 0,
+	error = xfs_trans_unreserve_quota_nblks(NULL, ip, del->br_blockcount, 0,
 			isrt ? XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS);
 	if (error)
 		return error;
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index f3f8c48ff5bf..792809debaaa 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -884,8 +884,8 @@ xfs_unmap_extent(
 	}
 
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
-	error = xfs_trans_reserve_quota(tp, mp, ip->i_udquot, ip->i_gdquot,
-			ip->i_pdquot, resblks, 0, XFS_QMOPT_RES_REGBLKS);
+	error = xfs_trans_reserve_quota_nblks(tp, ip, resblks, 0,
+			XFS_QMOPT_RES_REGBLKS);
 	if (error)
 		goto out_trans_cancel;
 
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index e1c98dbf79e4..183142fd0961 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -508,8 +508,8 @@ xfs_reflink_cancel_cow_blocks(
 			xfs_bmap_del_extent_cow(ip, &icur, &got, &del);
 
 			/* Remove the quota reservation */
-			error = xfs_trans_reserve_quota_nblks(NULL, ip,
-					-(long)del.br_blockcount, 0,
+			error = xfs_trans_unreserve_quota_nblks(NULL, ip,
+					del.br_blockcount, 0,
 					XFS_QMOPT_RES_REGBLKS);
 			if (error)
 				break;


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

* [PATCH 2/4] xfs: clean up quota reservation wrappers
  2021-01-23 18:51 [PATCHSET v2 0/4] xfs: minor cleanups of the quota functions Darrick J. Wong
  2021-01-23 18:51 ` [PATCH 1/4] xfs: clean up quota reservation callsites Darrick J. Wong
@ 2021-01-23 18:51 ` Darrick J. Wong
  2021-01-25 15:13   ` Brian Foster
  2021-01-23 18:51 ` [PATCH 3/4] xfs: create convenience wrappers for incore quota block reservations Darrick J. Wong
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Darrick J. Wong @ 2021-01-23 18:51 UTC (permalink / raw)
  To: djwong; +Cc: Christoph Hellwig, linux-xfs, hch, david

From: Darrick J. Wong <djwong@kernel.org>

Replace a couple of quota reservation macros with properly typechecked
static inline functions ahead of more restructuring in the next patches.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_quota.h |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)


diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h
index 5a62398940d0..bd28d17941e7 100644
--- a/fs/xfs/xfs_quota.h
+++ b/fs/xfs/xfs_quota.h
@@ -151,8 +151,13 @@ static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
 #define xfs_qm_unmount_quotas(mp)
 #endif /* CONFIG_XFS_QUOTA */
 
-#define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \
-	xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags)
+static inline int
+xfs_trans_unreserve_quota_nblks(struct xfs_trans *tp, struct xfs_inode *ip,
+		int64_t nblks, long ninos, unsigned int flags)
+{
+	return xfs_trans_reserve_quota_nblks(tp, ip, -nblks, -ninos, flags);
+}
+
 #define xfs_trans_reserve_quota(tp, mp, ud, gd, pd, nb, ni, f) \
 	xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \
 				f | XFS_QMOPT_RES_REGBLKS)


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

* [PATCH 3/4] xfs: create convenience wrappers for incore quota block reservations
  2021-01-23 18:51 [PATCHSET v2 0/4] xfs: minor cleanups of the quota functions Darrick J. Wong
  2021-01-23 18:51 ` [PATCH 1/4] xfs: clean up quota reservation callsites Darrick J. Wong
  2021-01-23 18:51 ` [PATCH 2/4] xfs: clean up quota reservation wrappers Darrick J. Wong
@ 2021-01-23 18:51 ` Darrick J. Wong
  2021-01-24  9:33   ` Christoph Hellwig
  2021-01-25 15:15   ` Brian Foster
  2021-01-23 18:51 ` [PATCH 4/4] xfs: clean up icreate quota reservation calls Darrick J. Wong
  2021-01-26  4:51 ` [PATCH 5/4] xfs: fix up build warnings when quotas are disabled Darrick J. Wong
  4 siblings, 2 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-01-23 18:51 UTC (permalink / raw)
  To: djwong; +Cc: linux-xfs, hch, david

From: Darrick J. Wong <djwong@kernel.org>

Create a couple of convenience wrappers for creating and deleting quota
block reservations against future changes.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/libxfs/xfs_bmap.c |   12 ++++++------
 fs/xfs/xfs_quota.h       |   19 +++++++++++++++++++
 fs/xfs/xfs_reflink.c     |    6 +++---
 3 files changed, 28 insertions(+), 9 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index aea179212946..908b7d49da60 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -4067,9 +4067,12 @@ xfs_bmapi_reserve_delalloc(
 	struct xfs_ifork	*ifp = XFS_IFORK_PTR(ip, whichfork);
 	xfs_extlen_t		alen;
 	xfs_extlen_t		indlen;
+	bool			isrt;
 	int			error;
 	xfs_fileoff_t		aoff = off;
 
+	isrt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip);
+
 	/*
 	 * Cap the alloc length. Keep track of prealloc so we know whether to
 	 * tag the inode before we return.
@@ -4098,8 +4101,7 @@ xfs_bmapi_reserve_delalloc(
 	 * blocks.  This number gets adjusted later.  We return if we haven't
 	 * allocated blocks already inside this loop.
 	 */
-	error = xfs_trans_reserve_quota_nblks(NULL, ip, (long)alen, 0,
-						XFS_QMOPT_RES_REGBLKS);
+	error = xfs_quota_reserve_blkres(ip, alen, isrt);
 	if (error)
 		return error;
 
@@ -4145,8 +4147,7 @@ xfs_bmapi_reserve_delalloc(
 	xfs_mod_fdblocks(mp, alen, false);
 out_unreserve_quota:
 	if (XFS_IS_QUOTA_ON(mp))
-		xfs_trans_unreserve_quota_nblks(NULL, ip, (long)alen, 0,
-						XFS_QMOPT_RES_REGBLKS);
+		xfs_quota_unreserve_blkres(ip, alen, isrt);
 	return error;
 }
 
@@ -4938,8 +4939,7 @@ xfs_bmap_del_extent_delay(
 	 * sb counters as we might have to borrow some blocks for the
 	 * indirect block accounting.
 	 */
-	error = xfs_trans_unreserve_quota_nblks(NULL, ip, del->br_blockcount, 0,
-			isrt ? XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS);
+	error = xfs_quota_unreserve_blkres(ip, del->br_blockcount, isrt);
 	if (error)
 		return error;
 	ip->i_delayed_blks -= del->br_blockcount;
diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h
index bd28d17941e7..a25e3ce04c60 100644
--- a/fs/xfs/xfs_quota.h
+++ b/fs/xfs/xfs_quota.h
@@ -108,6 +108,12 @@ extern void xfs_qm_mount_quotas(struct xfs_mount *);
 extern void xfs_qm_unmount(struct xfs_mount *);
 extern void xfs_qm_unmount_quotas(struct xfs_mount *);
 
+static inline int
+xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t nblks, bool isrt)
+{
+	return xfs_trans_reserve_quota_nblks(NULL, ip, nblks, 0,
+			isrt ? XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS);
+}
 #else
 static inline int
 xfs_qm_vop_dqalloc(struct xfs_inode *ip, kuid_t kuid, kgid_t kgid,
@@ -136,6 +142,13 @@ static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
 {
 	return 0;
 }
+
+static inline int
+xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t nblks, bool isrt)
+{
+	return 0;
+}
+
 #define xfs_qm_vop_create_dqattach(tp, ip, u, g, p)
 #define xfs_qm_vop_rename_dqattach(it)					(0)
 #define xfs_qm_vop_chown(tp, ip, old, new)				(NULL)
@@ -162,6 +175,12 @@ xfs_trans_unreserve_quota_nblks(struct xfs_trans *tp, struct xfs_inode *ip,
 	xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \
 				f | XFS_QMOPT_RES_REGBLKS)
 
+static inline int
+xfs_quota_unreserve_blkres(struct xfs_inode *ip, int64_t nblks, bool isrt)
+{
+	return xfs_quota_reserve_blkres(ip, -nblks, isrt);
+}
+
 extern int xfs_mount_reset_sbqflags(struct xfs_mount *);
 
 #endif	/* __XFS_QUOTA_H__ */
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 183142fd0961..0da1a603b7d8 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -508,9 +508,9 @@ xfs_reflink_cancel_cow_blocks(
 			xfs_bmap_del_extent_cow(ip, &icur, &got, &del);
 
 			/* Remove the quota reservation */
-			error = xfs_trans_unreserve_quota_nblks(NULL, ip,
-					del.br_blockcount, 0,
-					XFS_QMOPT_RES_REGBLKS);
+			error = xfs_quota_unreserve_blkres(ip,
+					del.br_blockcount,
+					XFS_IS_REALTIME_INODE(ip));
 			if (error)
 				break;
 		} else {


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

* [PATCH 4/4] xfs: clean up icreate quota reservation calls
  2021-01-23 18:51 [PATCHSET v2 0/4] xfs: minor cleanups of the quota functions Darrick J. Wong
                   ` (2 preceding siblings ...)
  2021-01-23 18:51 ` [PATCH 3/4] xfs: create convenience wrappers for incore quota block reservations Darrick J. Wong
@ 2021-01-23 18:51 ` Darrick J. Wong
  2021-01-25 15:17   ` Brian Foster
  2021-01-26  4:51 ` [PATCH 5/4] xfs: fix up build warnings when quotas are disabled Darrick J. Wong
  4 siblings, 1 reply; 16+ messages in thread
From: Darrick J. Wong @ 2021-01-23 18:51 UTC (permalink / raw)
  To: djwong; +Cc: Christoph Hellwig, linux-xfs, hch, david

From: Darrick J. Wong <djwong@kernel.org>

Create a proper helper so that inode creation calls can reserve quota
with a dedicated function.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_inode.c       |    8 ++++----
 fs/xfs/xfs_quota.h       |   15 +++++++++++----
 fs/xfs/xfs_symlink.c     |    4 ++--
 fs/xfs/xfs_trans_dquot.c |   21 +++++++++++++++++++++
 4 files changed, 38 insertions(+), 10 deletions(-)


diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index e2a1db4cee43..e909da05cd28 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1037,8 +1037,8 @@ xfs_create(
 	/*
 	 * Reserve disk quota and the inode.
 	 */
-	error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp,
-						pdqp, resblks, 1, 0);
+	error = xfs_trans_reserve_quota_icreate(tp, dp, udqp, gdqp, pdqp,
+			resblks);
 	if (error)
 		goto out_trans_cancel;
 
@@ -1169,8 +1169,8 @@ xfs_create_tmpfile(
 	if (error)
 		goto out_release_inode;
 
-	error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp,
-						pdqp, resblks, 1, 0);
+	error = xfs_trans_reserve_quota_icreate(tp, dp, udqp, gdqp, pdqp,
+			resblks);
 	if (error)
 		goto out_trans_cancel;
 
diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h
index a25e3ce04c60..16a2e7adf4da 100644
--- a/fs/xfs/xfs_quota.h
+++ b/fs/xfs/xfs_quota.h
@@ -86,6 +86,9 @@ extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *,
 extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *,
 		struct xfs_mount *, struct xfs_dquot *,
 		struct xfs_dquot *, struct xfs_dquot *, int64_t, long, uint);
+int xfs_trans_reserve_quota_icreate(struct xfs_trans *tp, struct xfs_inode *dp,
+		struct xfs_dquot *udqp, struct xfs_dquot *gdqp,
+		struct xfs_dquot *pdqp, int64_t nblks);
 
 extern int xfs_qm_vop_dqalloc(struct xfs_inode *, kuid_t, kgid_t,
 		prid_t, uint, struct xfs_dquot **, struct xfs_dquot **,
@@ -149,6 +152,14 @@ xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t nblks, bool isrt)
 	return 0;
 }
 
+static inline int
+xfs_trans_reserve_quota_icreate(struct xfs_trans *tp, struct xfs_inode *dp,
+		struct xfs_dquot *udqp, struct xfs_dquot *gdqp,
+		struct xfs_dquot *pdqp, int64_t nblks)
+{
+	return 0;
+}
+
 #define xfs_qm_vop_create_dqattach(tp, ip, u, g, p)
 #define xfs_qm_vop_rename_dqattach(it)					(0)
 #define xfs_qm_vop_chown(tp, ip, old, new)				(NULL)
@@ -171,10 +182,6 @@ xfs_trans_unreserve_quota_nblks(struct xfs_trans *tp, struct xfs_inode *ip,
 	return xfs_trans_reserve_quota_nblks(tp, ip, -nblks, -ninos, flags);
 }
 
-#define xfs_trans_reserve_quota(tp, mp, ud, gd, pd, nb, ni, f) \
-	xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \
-				f | XFS_QMOPT_RES_REGBLKS)
-
 static inline int
 xfs_quota_unreserve_blkres(struct xfs_inode *ip, int64_t nblks, bool isrt)
 {
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 7f96649e918a..f8bfa51bdeef 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -215,8 +215,8 @@ xfs_symlink(
 	/*
 	 * Reserve disk quota : blocks and inode.
 	 */
-	error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp,
-						pdqp, resblks, 1, 0);
+	error = xfs_trans_reserve_quota_icreate(tp, dp, udqp, gdqp, pdqp,
+			resblks);
 	if (error)
 		goto out_trans_cancel;
 
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index 28b8ac701919..3315498a6fa1 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -804,6 +804,27 @@ xfs_trans_reserve_quota_nblks(
 						nblks, ninos, flags);
 }
 
+/* Change the quota reservations for an inode creation activity. */
+int
+xfs_trans_reserve_quota_icreate(
+	struct xfs_trans	*tp,
+	struct xfs_inode	*dp,
+	struct xfs_dquot	*udqp,
+	struct xfs_dquot	*gdqp,
+	struct xfs_dquot	*pdqp,
+	int64_t			nblks)
+{
+	struct xfs_mount	*mp = dp->i_mount;
+
+	if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp))
+		return 0;
+
+	ASSERT(!xfs_is_quota_inode(&mp->m_sb, dp->i_ino));
+
+	return xfs_trans_reserve_quota_bydquots(tp, dp->i_mount, udqp, gdqp,
+			pdqp, nblks, 1, XFS_QMOPT_RES_REGBLKS);
+}
+
 /*
  * This routine is called to allocate a quotaoff log item.
  */


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

* Re: [PATCH 3/4] xfs: create convenience wrappers for incore quota block reservations
  2021-01-23 18:51 ` [PATCH 3/4] xfs: create convenience wrappers for incore quota block reservations Darrick J. Wong
@ 2021-01-24  9:33   ` Christoph Hellwig
  2021-01-25 15:15   ` Brian Foster
  1 sibling, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2021-01-24  9:33 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, hch, david

On Sat, Jan 23, 2021 at 10:51:51AM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Create a couple of convenience wrappers for creating and deleting quota
> block reservations against future changes.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

Looks good,

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

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

* Re: [PATCH 1/4] xfs: clean up quota reservation callsites
  2021-01-23 18:51 ` [PATCH 1/4] xfs: clean up quota reservation callsites Darrick J. Wong
@ 2021-01-25 15:13   ` Brian Foster
  0 siblings, 0 replies; 16+ messages in thread
From: Brian Foster @ 2021-01-25 15:13 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Christoph Hellwig, linux-xfs, hch, david

On Sat, Jan 23, 2021 at 10:51:40AM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Convert a few xfs_trans_*reserve* callsites that are open-coding other
> convenience functions.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/libxfs/xfs_bmap.c |    3 +--
>  fs/xfs/xfs_bmap_util.c   |    4 ++--
>  fs/xfs/xfs_reflink.c     |    4 ++--
>  3 files changed, 5 insertions(+), 6 deletions(-)
> 
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 2cd24bb06040..aea179212946 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -4938,8 +4938,7 @@ xfs_bmap_del_extent_delay(
>  	 * sb counters as we might have to borrow some blocks for the
>  	 * indirect block accounting.
>  	 */
> -	error = xfs_trans_reserve_quota_nblks(NULL, ip,
> -			-((long)del->br_blockcount), 0,
> +	error = xfs_trans_unreserve_quota_nblks(NULL, ip, del->br_blockcount, 0,
>  			isrt ? XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS);
>  	if (error)
>  		return error;
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index f3f8c48ff5bf..792809debaaa 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -884,8 +884,8 @@ xfs_unmap_extent(
>  	}
>  
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
> -	error = xfs_trans_reserve_quota(tp, mp, ip->i_udquot, ip->i_gdquot,
> -			ip->i_pdquot, resblks, 0, XFS_QMOPT_RES_REGBLKS);
> +	error = xfs_trans_reserve_quota_nblks(tp, ip, resblks, 0,
> +			XFS_QMOPT_RES_REGBLKS);
>  	if (error)
>  		goto out_trans_cancel;
>  
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index e1c98dbf79e4..183142fd0961 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -508,8 +508,8 @@ xfs_reflink_cancel_cow_blocks(
>  			xfs_bmap_del_extent_cow(ip, &icur, &got, &del);
>  
>  			/* Remove the quota reservation */
> -			error = xfs_trans_reserve_quota_nblks(NULL, ip,
> -					-(long)del.br_blockcount, 0,
> +			error = xfs_trans_unreserve_quota_nblks(NULL, ip,
> +					del.br_blockcount, 0,
>  					XFS_QMOPT_RES_REGBLKS);
>  			if (error)
>  				break;
> 


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

* Re: [PATCH 2/4] xfs: clean up quota reservation wrappers
  2021-01-23 18:51 ` [PATCH 2/4] xfs: clean up quota reservation wrappers Darrick J. Wong
@ 2021-01-25 15:13   ` Brian Foster
  0 siblings, 0 replies; 16+ messages in thread
From: Brian Foster @ 2021-01-25 15:13 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Christoph Hellwig, linux-xfs, hch, david

On Sat, Jan 23, 2021 at 10:51:46AM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Replace a couple of quota reservation macros with properly typechecked
> static inline functions ahead of more restructuring in the next patches.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_quota.h |    9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> 
> diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h
> index 5a62398940d0..bd28d17941e7 100644
> --- a/fs/xfs/xfs_quota.h
> +++ b/fs/xfs/xfs_quota.h
> @@ -151,8 +151,13 @@ static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
>  #define xfs_qm_unmount_quotas(mp)
>  #endif /* CONFIG_XFS_QUOTA */
>  
> -#define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \
> -	xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags)
> +static inline int
> +xfs_trans_unreserve_quota_nblks(struct xfs_trans *tp, struct xfs_inode *ip,
> +		int64_t nblks, long ninos, unsigned int flags)
> +{
> +	return xfs_trans_reserve_quota_nblks(tp, ip, -nblks, -ninos, flags);
> +}
> +
>  #define xfs_trans_reserve_quota(tp, mp, ud, gd, pd, nb, ni, f) \
>  	xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \
>  				f | XFS_QMOPT_RES_REGBLKS)
> 


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

* Re: [PATCH 3/4] xfs: create convenience wrappers for incore quota block reservations
  2021-01-23 18:51 ` [PATCH 3/4] xfs: create convenience wrappers for incore quota block reservations Darrick J. Wong
  2021-01-24  9:33   ` Christoph Hellwig
@ 2021-01-25 15:15   ` Brian Foster
  2021-01-26 20:37     ` Darrick J. Wong
  1 sibling, 1 reply; 16+ messages in thread
From: Brian Foster @ 2021-01-25 15:15 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, hch, david

On Sat, Jan 23, 2021 at 10:51:51AM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Create a couple of convenience wrappers for creating and deleting quota
> block reservations against future changes.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  fs/xfs/libxfs/xfs_bmap.c |   12 ++++++------
>  fs/xfs/xfs_quota.h       |   19 +++++++++++++++++++
>  fs/xfs/xfs_reflink.c     |    6 +++---
>  3 files changed, 28 insertions(+), 9 deletions(-)
> 
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index aea179212946..908b7d49da60 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -4067,9 +4067,12 @@ xfs_bmapi_reserve_delalloc(
>  	struct xfs_ifork	*ifp = XFS_IFORK_PTR(ip, whichfork);
>  	xfs_extlen_t		alen;
>  	xfs_extlen_t		indlen;
> +	bool			isrt;
>  	int			error;
>  	xfs_fileoff_t		aoff = off;
>  
> +	isrt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip);
> +

What's the reason for checking isrt where we didn't before? Is that what
the commit log means by "... against future changes?" (If so, a sentence
or two more of "why" context in the commit log please..? :)

Brian

>  	/*
>  	 * Cap the alloc length. Keep track of prealloc so we know whether to
>  	 * tag the inode before we return.
> @@ -4098,8 +4101,7 @@ xfs_bmapi_reserve_delalloc(
>  	 * blocks.  This number gets adjusted later.  We return if we haven't
>  	 * allocated blocks already inside this loop.
>  	 */
> -	error = xfs_trans_reserve_quota_nblks(NULL, ip, (long)alen, 0,
> -						XFS_QMOPT_RES_REGBLKS);
> +	error = xfs_quota_reserve_blkres(ip, alen, isrt);
>  	if (error)
>  		return error;
>  
> @@ -4145,8 +4147,7 @@ xfs_bmapi_reserve_delalloc(
>  	xfs_mod_fdblocks(mp, alen, false);
>  out_unreserve_quota:
>  	if (XFS_IS_QUOTA_ON(mp))
> -		xfs_trans_unreserve_quota_nblks(NULL, ip, (long)alen, 0,
> -						XFS_QMOPT_RES_REGBLKS);
> +		xfs_quota_unreserve_blkres(ip, alen, isrt);
>  	return error;
>  }
>  
> @@ -4938,8 +4939,7 @@ xfs_bmap_del_extent_delay(
>  	 * sb counters as we might have to borrow some blocks for the
>  	 * indirect block accounting.
>  	 */
> -	error = xfs_trans_unreserve_quota_nblks(NULL, ip, del->br_blockcount, 0,
> -			isrt ? XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS);
> +	error = xfs_quota_unreserve_blkres(ip, del->br_blockcount, isrt);
>  	if (error)
>  		return error;
>  	ip->i_delayed_blks -= del->br_blockcount;
> diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h
> index bd28d17941e7..a25e3ce04c60 100644
> --- a/fs/xfs/xfs_quota.h
> +++ b/fs/xfs/xfs_quota.h
> @@ -108,6 +108,12 @@ extern void xfs_qm_mount_quotas(struct xfs_mount *);
>  extern void xfs_qm_unmount(struct xfs_mount *);
>  extern void xfs_qm_unmount_quotas(struct xfs_mount *);
>  
> +static inline int
> +xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t nblks, bool isrt)
> +{
> +	return xfs_trans_reserve_quota_nblks(NULL, ip, nblks, 0,
> +			isrt ? XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS);
> +}
>  #else
>  static inline int
>  xfs_qm_vop_dqalloc(struct xfs_inode *ip, kuid_t kuid, kgid_t kgid,
> @@ -136,6 +142,13 @@ static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
>  {
>  	return 0;
>  }
> +
> +static inline int
> +xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t nblks, bool isrt)
> +{
> +	return 0;
> +}
> +
>  #define xfs_qm_vop_create_dqattach(tp, ip, u, g, p)
>  #define xfs_qm_vop_rename_dqattach(it)					(0)
>  #define xfs_qm_vop_chown(tp, ip, old, new)				(NULL)
> @@ -162,6 +175,12 @@ xfs_trans_unreserve_quota_nblks(struct xfs_trans *tp, struct xfs_inode *ip,
>  	xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \
>  				f | XFS_QMOPT_RES_REGBLKS)
>  
> +static inline int
> +xfs_quota_unreserve_blkres(struct xfs_inode *ip, int64_t nblks, bool isrt)
> +{
> +	return xfs_quota_reserve_blkres(ip, -nblks, isrt);
> +}
> +
>  extern int xfs_mount_reset_sbqflags(struct xfs_mount *);
>  
>  #endif	/* __XFS_QUOTA_H__ */
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 183142fd0961..0da1a603b7d8 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -508,9 +508,9 @@ xfs_reflink_cancel_cow_blocks(
>  			xfs_bmap_del_extent_cow(ip, &icur, &got, &del);
>  
>  			/* Remove the quota reservation */
> -			error = xfs_trans_unreserve_quota_nblks(NULL, ip,
> -					del.br_blockcount, 0,
> -					XFS_QMOPT_RES_REGBLKS);
> +			error = xfs_quota_unreserve_blkres(ip,
> +					del.br_blockcount,
> +					XFS_IS_REALTIME_INODE(ip));
>  			if (error)
>  				break;
>  		} else {
> 


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

* Re: [PATCH 4/4] xfs: clean up icreate quota reservation calls
  2021-01-23 18:51 ` [PATCH 4/4] xfs: clean up icreate quota reservation calls Darrick J. Wong
@ 2021-01-25 15:17   ` Brian Foster
  2021-01-26 18:23     ` Darrick J. Wong
  0 siblings, 1 reply; 16+ messages in thread
From: Brian Foster @ 2021-01-25 15:17 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Christoph Hellwig, linux-xfs, hch, david

On Sat, Jan 23, 2021 at 10:51:57AM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Create a proper helper so that inode creation calls can reserve quota
> with a dedicated function.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_inode.c       |    8 ++++----
>  fs/xfs/xfs_quota.h       |   15 +++++++++++----
>  fs/xfs/xfs_symlink.c     |    4 ++--
>  fs/xfs/xfs_trans_dquot.c |   21 +++++++++++++++++++++
>  4 files changed, 38 insertions(+), 10 deletions(-)
> 
> 
...
> diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
> index 28b8ac701919..3315498a6fa1 100644
> --- a/fs/xfs/xfs_trans_dquot.c
> +++ b/fs/xfs/xfs_trans_dquot.c
> @@ -804,6 +804,27 @@ xfs_trans_reserve_quota_nblks(
>  						nblks, ninos, flags);
>  }
>  
> +/* Change the quota reservations for an inode creation activity. */
> +int
> +xfs_trans_reserve_quota_icreate(
> +	struct xfs_trans	*tp,
> +	struct xfs_inode	*dp,
> +	struct xfs_dquot	*udqp,
> +	struct xfs_dquot	*gdqp,
> +	struct xfs_dquot	*pdqp,
> +	int64_t			nblks)
> +{
> +	struct xfs_mount	*mp = dp->i_mount;
> +
> +	if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp))
> +		return 0;
> +
> +	ASSERT(!xfs_is_quota_inode(&mp->m_sb, dp->i_ino));
> +
> +	return xfs_trans_reserve_quota_bydquots(tp, dp->i_mount, udqp, gdqp,
> +			pdqp, nblks, 1, XFS_QMOPT_RES_REGBLKS);

Considering we can get mp from tp (and it looks like we always pass tp),
is it worth even passing in dp for an (unlikely) assert? That seems a
little odd anyways since nothing down in this path actually uses or
cares about the parent inode. Also, no need to pass dp->i_mount above if
we've already defined mp, at least.

Brian

> +}
> +
>  /*
>   * This routine is called to allocate a quotaoff log item.
>   */
> 


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

* [PATCH 5/4] xfs: fix up build warnings when quotas are disabled
  2021-01-23 18:51 [PATCHSET v2 0/4] xfs: minor cleanups of the quota functions Darrick J. Wong
                   ` (3 preceding siblings ...)
  2021-01-23 18:51 ` [PATCH 4/4] xfs: clean up icreate quota reservation calls Darrick J. Wong
@ 2021-01-26  4:51 ` Darrick J. Wong
  2021-01-27 16:58   ` Christoph Hellwig
  4 siblings, 1 reply; 16+ messages in thread
From: Darrick J. Wong @ 2021-01-26  4:51 UTC (permalink / raw)
  To: Christoph Hellwig, linux-xfs, hch, david

From: Darrick J. Wong <djwong@kernel.org>

Fix some build warnings on gcc 10.2 when quotas are disabled.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/xfs_quota.h |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h
index 16a2e7adf4da..4cafc1c78879 100644
--- a/fs/xfs/xfs_quota.h
+++ b/fs/xfs/xfs_quota.h
@@ -130,7 +130,7 @@ xfs_qm_vop_dqalloc(struct xfs_inode *ip, kuid_t kuid, kgid_t kgid,
 }
 #define xfs_trans_dup_dqinfo(tp, tp2)
 #define xfs_trans_free_dqinfo(tp)
-#define xfs_trans_mod_dquot_byino(tp, ip, fields, delta)
+#define xfs_trans_mod_dquot_byino(tp, ip, fields, delta) do { } while (0)
 #define xfs_trans_apply_dquot_deltas(tp)
 #define xfs_trans_unreserve_and_mod_dquots(tp)
 static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp,
@@ -167,8 +167,8 @@ xfs_trans_reserve_quota_icreate(struct xfs_trans *tp, struct xfs_inode *dp,
 #define xfs_qm_dqattach(ip)						(0)
 #define xfs_qm_dqattach_locked(ip, fl)					(0)
 #define xfs_qm_dqdetach(ip)
-#define xfs_qm_dqrele(d)
-#define xfs_qm_statvfs(ip, s)
+#define xfs_qm_dqrele(d)			do { (d) = (d); } while(0)
+#define xfs_qm_statvfs(ip, s)			do { } while(0)
 #define xfs_qm_newmount(mp, a, b)					(0)
 #define xfs_qm_mount_quotas(mp)
 #define xfs_qm_unmount(mp)

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

* Re: [PATCH 4/4] xfs: clean up icreate quota reservation calls
  2021-01-25 15:17   ` Brian Foster
@ 2021-01-26 18:23     ` Darrick J. Wong
  0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-01-26 18:23 UTC (permalink / raw)
  To: Brian Foster; +Cc: Christoph Hellwig, linux-xfs, hch, david

On Mon, Jan 25, 2021 at 10:17:22AM -0500, Brian Foster wrote:
> On Sat, Jan 23, 2021 at 10:51:57AM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > Create a proper helper so that inode creation calls can reserve quota
> > with a dedicated function.
> > 
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > ---
> >  fs/xfs/xfs_inode.c       |    8 ++++----
> >  fs/xfs/xfs_quota.h       |   15 +++++++++++----
> >  fs/xfs/xfs_symlink.c     |    4 ++--
> >  fs/xfs/xfs_trans_dquot.c |   21 +++++++++++++++++++++
> >  4 files changed, 38 insertions(+), 10 deletions(-)
> > 
> > 
> ...
> > diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
> > index 28b8ac701919..3315498a6fa1 100644
> > --- a/fs/xfs/xfs_trans_dquot.c
> > +++ b/fs/xfs/xfs_trans_dquot.c
> > @@ -804,6 +804,27 @@ xfs_trans_reserve_quota_nblks(
> >  						nblks, ninos, flags);
> >  }
> >  
> > +/* Change the quota reservations for an inode creation activity. */
> > +int
> > +xfs_trans_reserve_quota_icreate(
> > +	struct xfs_trans	*tp,
> > +	struct xfs_inode	*dp,
> > +	struct xfs_dquot	*udqp,
> > +	struct xfs_dquot	*gdqp,
> > +	struct xfs_dquot	*pdqp,
> > +	int64_t			nblks)
> > +{
> > +	struct xfs_mount	*mp = dp->i_mount;
> > +
> > +	if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp))
> > +		return 0;
> > +
> > +	ASSERT(!xfs_is_quota_inode(&mp->m_sb, dp->i_ino));
> > +
> > +	return xfs_trans_reserve_quota_bydquots(tp, dp->i_mount, udqp, gdqp,
> > +			pdqp, nblks, 1, XFS_QMOPT_RES_REGBLKS);
> 
> Considering we can get mp from tp (and it looks like we always pass tp),
> is it worth even passing in dp for an (unlikely) assert? That seems a
> little odd anyways since nothing down in this path actually uses or
> cares about the parent inode. Also, no need to pass dp->i_mount above if
> we've already defined mp, at least.

You're correct, we can drop the *dp parameter entirely.

--D

> Brian
> 
> > +}
> > +
> >  /*
> >   * This routine is called to allocate a quotaoff log item.
> >   */
> > 
> 

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

* Re: [PATCH 3/4] xfs: create convenience wrappers for incore quota block reservations
  2021-01-25 15:15   ` Brian Foster
@ 2021-01-26 20:37     ` Darrick J. Wong
  0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-01-26 20:37 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs, hch, david

On Mon, Jan 25, 2021 at 10:15:19AM -0500, Brian Foster wrote:
> On Sat, Jan 23, 2021 at 10:51:51AM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > Create a couple of convenience wrappers for creating and deleting quota
> > block reservations against future changes.
> > 
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> >  fs/xfs/libxfs/xfs_bmap.c |   12 ++++++------
> >  fs/xfs/xfs_quota.h       |   19 +++++++++++++++++++
> >  fs/xfs/xfs_reflink.c     |    6 +++---
> >  3 files changed, 28 insertions(+), 9 deletions(-)
> > 
> > 
> > diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> > index aea179212946..908b7d49da60 100644
> > --- a/fs/xfs/libxfs/xfs_bmap.c
> > +++ b/fs/xfs/libxfs/xfs_bmap.c
> > @@ -4067,9 +4067,12 @@ xfs_bmapi_reserve_delalloc(
> >  	struct xfs_ifork	*ifp = XFS_IFORK_PTR(ip, whichfork);
> >  	xfs_extlen_t		alen;
> >  	xfs_extlen_t		indlen;
> > +	bool			isrt;
> >  	int			error;
> >  	xfs_fileoff_t		aoff = off;
> >  
> > +	isrt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip);
> > + 
> What's the reason for checking isrt where we didn't before? Is that what
> the commit log means by "... against future changes?" (If so, a sentence
> or two more of "why" context in the commit log please..? :)

Well right now this function makes a delalloc reservation .... oh , the
rest of the function is totally broken wrt realtime anyway, so maybe I
should just ditch that isrt parameter completely.

--D

> Brian
> 
> >  	/*
> >  	 * Cap the alloc length. Keep track of prealloc so we know whether to
> >  	 * tag the inode before we return.
> > @@ -4098,8 +4101,7 @@ xfs_bmapi_reserve_delalloc(
> >  	 * blocks.  This number gets adjusted later.  We return if we haven't
> >  	 * allocated blocks already inside this loop.
> >  	 */
> > -	error = xfs_trans_reserve_quota_nblks(NULL, ip, (long)alen, 0,
> > -						XFS_QMOPT_RES_REGBLKS);
> > +	error = xfs_quota_reserve_blkres(ip, alen, isrt);
> >  	if (error)
> >  		return error;
> >  
> > @@ -4145,8 +4147,7 @@ xfs_bmapi_reserve_delalloc(
> >  	xfs_mod_fdblocks(mp, alen, false);
> >  out_unreserve_quota:
> >  	if (XFS_IS_QUOTA_ON(mp))
> > -		xfs_trans_unreserve_quota_nblks(NULL, ip, (long)alen, 0,
> > -						XFS_QMOPT_RES_REGBLKS);
> > +		xfs_quota_unreserve_blkres(ip, alen, isrt);
> >  	return error;
> >  }
> >  
> > @@ -4938,8 +4939,7 @@ xfs_bmap_del_extent_delay(
> >  	 * sb counters as we might have to borrow some blocks for the
> >  	 * indirect block accounting.
> >  	 */
> > -	error = xfs_trans_unreserve_quota_nblks(NULL, ip, del->br_blockcount, 0,
> > -			isrt ? XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS);
> > +	error = xfs_quota_unreserve_blkres(ip, del->br_blockcount, isrt);
> >  	if (error)
> >  		return error;
> >  	ip->i_delayed_blks -= del->br_blockcount;
> > diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h
> > index bd28d17941e7..a25e3ce04c60 100644
> > --- a/fs/xfs/xfs_quota.h
> > +++ b/fs/xfs/xfs_quota.h
> > @@ -108,6 +108,12 @@ extern void xfs_qm_mount_quotas(struct xfs_mount *);
> >  extern void xfs_qm_unmount(struct xfs_mount *);
> >  extern void xfs_qm_unmount_quotas(struct xfs_mount *);
> >  
> > +static inline int
> > +xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t nblks, bool isrt)
> > +{
> > +	return xfs_trans_reserve_quota_nblks(NULL, ip, nblks, 0,
> > +			isrt ? XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS);
> > +}
> >  #else
> >  static inline int
> >  xfs_qm_vop_dqalloc(struct xfs_inode *ip, kuid_t kuid, kgid_t kgid,
> > @@ -136,6 +142,13 @@ static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
> >  {
> >  	return 0;
> >  }
> > +
> > +static inline int
> > +xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t nblks, bool isrt)
> > +{
> > +	return 0;
> > +}
> > +
> >  #define xfs_qm_vop_create_dqattach(tp, ip, u, g, p)
> >  #define xfs_qm_vop_rename_dqattach(it)					(0)
> >  #define xfs_qm_vop_chown(tp, ip, old, new)				(NULL)
> > @@ -162,6 +175,12 @@ xfs_trans_unreserve_quota_nblks(struct xfs_trans *tp, struct xfs_inode *ip,
> >  	xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \
> >  				f | XFS_QMOPT_RES_REGBLKS)
> >  
> > +static inline int
> > +xfs_quota_unreserve_blkres(struct xfs_inode *ip, int64_t nblks, bool isrt)
> > +{
> > +	return xfs_quota_reserve_blkres(ip, -nblks, isrt);
> > +}
> > +
> >  extern int xfs_mount_reset_sbqflags(struct xfs_mount *);
> >  
> >  #endif	/* __XFS_QUOTA_H__ */
> > diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> > index 183142fd0961..0da1a603b7d8 100644
> > --- a/fs/xfs/xfs_reflink.c
> > +++ b/fs/xfs/xfs_reflink.c
> > @@ -508,9 +508,9 @@ xfs_reflink_cancel_cow_blocks(
> >  			xfs_bmap_del_extent_cow(ip, &icur, &got, &del);
> >  
> >  			/* Remove the quota reservation */
> > -			error = xfs_trans_unreserve_quota_nblks(NULL, ip,
> > -					del.br_blockcount, 0,
> > -					XFS_QMOPT_RES_REGBLKS);
> > +			error = xfs_quota_unreserve_blkres(ip,
> > +					del.br_blockcount,
> > +					XFS_IS_REALTIME_INODE(ip));
> >  			if (error)
> >  				break;
> >  		} else {
> > 
> 

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

* Re: [PATCH 5/4] xfs: fix up build warnings when quotas are disabled
  2021-01-26  4:51 ` [PATCH 5/4] xfs: fix up build warnings when quotas are disabled Darrick J. Wong
@ 2021-01-27 16:58   ` Christoph Hellwig
  0 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2021-01-27 16:58 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Christoph Hellwig, linux-xfs, hch, david

On Mon, Jan 25, 2021 at 08:51:28PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Fix some build warnings on gcc 10.2 when quotas are disabled.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

Looks good,

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

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

* Re: [PATCH 1/4] xfs: clean up quota reservation callsites
  2021-01-18 22:11 ` [PATCH 1/4] xfs: clean up quota reservation callsites Darrick J. Wong
@ 2021-01-19  6:35   ` Christoph Hellwig
  0 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2021-01-19  6:35 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs

Looks good,

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

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

* [PATCH 1/4] xfs: clean up quota reservation callsites
  2021-01-18 22:11 [PATCHSET 0/4] xfs: minor cleanups of the quota functions Darrick J. Wong
@ 2021-01-18 22:11 ` Darrick J. Wong
  2021-01-19  6:35   ` Christoph Hellwig
  0 siblings, 1 reply; 16+ messages in thread
From: Darrick J. Wong @ 2021-01-18 22:11 UTC (permalink / raw)
  To: djwong; +Cc: linux-xfs

From: Darrick J. Wong <djwong@kernel.org>

Convert a few xfs_trans_*reserve* callsites that are open-coding other
convenience functions.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/libxfs/xfs_bmap.c |    3 +--
 fs/xfs/xfs_bmap_util.c   |    4 ++--
 fs/xfs/xfs_reflink.c     |    4 ++--
 3 files changed, 5 insertions(+), 6 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index bc446418e227..21076ac2485a 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -4826,8 +4826,7 @@ xfs_bmap_del_extent_delay(
 	 * sb counters as we might have to borrow some blocks for the
 	 * indirect block accounting.
 	 */
-	error = xfs_trans_reserve_quota_nblks(NULL, ip,
-			-((long)del->br_blockcount), 0,
+	error = xfs_trans_unreserve_quota_nblks(NULL, ip, del->br_blockcount, 0,
 			isrt ? XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS);
 	if (error)
 		return error;
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 7371a7f7c652..671cb104861e 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -879,8 +879,8 @@ xfs_unmap_extent(
 	}
 
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
-	error = xfs_trans_reserve_quota(tp, mp, ip->i_udquot, ip->i_gdquot,
-			ip->i_pdquot, resblks, 0, XFS_QMOPT_RES_REGBLKS);
+	error = xfs_trans_reserve_quota_nblks(tp, ip, resblks, 0,
+			XFS_QMOPT_RES_REGBLKS);
 	if (error)
 		goto out_trans_cancel;
 
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 6fa05fb78189..20321d03e31c 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -508,8 +508,8 @@ xfs_reflink_cancel_cow_blocks(
 			xfs_bmap_del_extent_cow(ip, &icur, &got, &del);
 
 			/* Remove the quota reservation */
-			error = xfs_trans_reserve_quota_nblks(NULL, ip,
-					-(long)del.br_blockcount, 0,
+			error = xfs_trans_unreserve_quota_nblks(NULL, ip,
+					del.br_blockcount, 0,
 					XFS_QMOPT_RES_REGBLKS);
 			if (error)
 				break;


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

end of thread, other threads:[~2021-01-27 17:02 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-23 18:51 [PATCHSET v2 0/4] xfs: minor cleanups of the quota functions Darrick J. Wong
2021-01-23 18:51 ` [PATCH 1/4] xfs: clean up quota reservation callsites Darrick J. Wong
2021-01-25 15:13   ` Brian Foster
2021-01-23 18:51 ` [PATCH 2/4] xfs: clean up quota reservation wrappers Darrick J. Wong
2021-01-25 15:13   ` Brian Foster
2021-01-23 18:51 ` [PATCH 3/4] xfs: create convenience wrappers for incore quota block reservations Darrick J. Wong
2021-01-24  9:33   ` Christoph Hellwig
2021-01-25 15:15   ` Brian Foster
2021-01-26 20:37     ` Darrick J. Wong
2021-01-23 18:51 ` [PATCH 4/4] xfs: clean up icreate quota reservation calls Darrick J. Wong
2021-01-25 15:17   ` Brian Foster
2021-01-26 18:23     ` Darrick J. Wong
2021-01-26  4:51 ` [PATCH 5/4] xfs: fix up build warnings when quotas are disabled Darrick J. Wong
2021-01-27 16:58   ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2021-01-18 22:11 [PATCHSET 0/4] xfs: minor cleanups of the quota functions Darrick J. Wong
2021-01-18 22:11 ` [PATCH 1/4] xfs: clean up quota reservation callsites Darrick J. Wong
2021-01-19  6:35   ` Christoph Hellwig

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).