From patchwork Sat Jan 23 18:51:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12041785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01F39C433DB for ; Sat, 23 Jan 2021 18:52:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1A4222D50 for ; Sat, 23 Jan 2021 18:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726021AbhAWSwU (ORCPT ); Sat, 23 Jan 2021 13:52:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:34938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725765AbhAWSwT (ORCPT ); Sat, 23 Jan 2021 13:52:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2483E22D2B; Sat, 23 Jan 2021 18:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611427899; bh=B0yXme5QCx/90B5R7AzLaX9Y6j2dq9GE1iNP/0zhHtk=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=CZ7R6hKZ6SQ2WS0zulngQVfw/5sKhS6dQzEPwp3OcPCBu8EmKKg12YSAlNrb/jtp6 6Ud12ZXmIqWXOCj+DCUzhYnsn8hcOV6gUNBIStBccJNwu42uR6TIS/nHV0QwQGWw1N Tb5/hOHVP6yykxnBvenh3lrMkP/RRHhRgaFEgHWH9wO4UeOjmmPdHpoZQgkxADpz4m qmiz+WyNpPy7hLlPft8nJ8CRd+3F723lAf3geZI06kjQ8eAU3S8E+3O42PcQ1HZuzc 4avLEdaXTc6Az2Y7GMQ6N83QqsRO8ROaXBi444Gk7PUwh338u0ThWDouMlsxQPw+Ad CWacbkQMjZ+Sg== Subject: [PATCH 1/4] xfs: clean up quota reservation callsites From: "Darrick J. Wong" To: djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org, hch@infradead.org, david@fromorbit.com Date: Sat, 23 Jan 2021 10:51:40 -0800 Message-ID: <161142790077.2170981.3836953907583983452.stgit@magnolia> In-Reply-To: <161142789504.2170981.1372317837643770452.stgit@magnolia> References: <161142789504.2170981.1372317837643770452.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Convert a few xfs_trans_*reserve* callsites that are open-coding other convenience functions. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster --- 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; From patchwork Sat Jan 23 18:51:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12041787 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C4F2C433E6 for ; Sat, 23 Jan 2021 18:52:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA8E723159 for ; Sat, 23 Jan 2021 18:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726119AbhAWSw1 (ORCPT ); Sat, 23 Jan 2021 13:52:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:34998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725765AbhAWSw0 (ORCPT ); Sat, 23 Jan 2021 13:52:26 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9B5A122D50; Sat, 23 Jan 2021 18:51:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611427904; bh=llBlieBzD0qXo7dRkt0KOyj7QJgAtUDZqawLr0vBf0I=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=HdRcjoq2SoY1UWKbYG+8r2HcVigS/9aL84E9EU0Cx513CEEi9sbnzYNcQ3fThqIem guX9eZqCz4pJaZdcGW5lrmokwiKpwzG/gQS1ebfTeo2gpo2DveyAFygD628NbAyeRN bvdB2FMdhyGaRWEO7B5GLzE716QgJW5Fh523Ndeb6oEjUckCmFaB9c2erCCAJwlUnO p+PjqT3kIr6geCrVVk3THdtUordT+jrCd87aufdKNPlGFSyLJbuZJx2Jj/R28LY1f1 FSbcimPOftWao6AHkh3X7NfL82qmXmeWdz6/fp8sUCb98p2Bbq+Og/qEC/utwXUEQJ 6y5SyNkTW2fMw== Subject: [PATCH 2/4] xfs: clean up quota reservation wrappers From: "Darrick J. Wong" To: djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org, hch@infradead.org, david@fromorbit.com Date: Sat, 23 Jan 2021 10:51:46 -0800 Message-ID: <161142790628.2170981.7372348604132126587.stgit@magnolia> In-Reply-To: <161142789504.2170981.1372317837643770452.stgit@magnolia> References: <161142789504.2170981.1372317837643770452.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong 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 Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster --- 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) From patchwork Sat Jan 23 18:51:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12041789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98F4DC433DB for ; Sat, 23 Jan 2021 18:52:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6043123340 for ; Sat, 23 Jan 2021 18:52:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726057AbhAWSwr (ORCPT ); Sat, 23 Jan 2021 13:52:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:35030 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726151AbhAWSwb (ORCPT ); Sat, 23 Jan 2021 13:52:31 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 26A5922D57; Sat, 23 Jan 2021 18:51:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611427910; bh=J619jnrWkyLVw5zOkr76AmmOJ/QMSYPoRwWobWJH6tE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=CQF0md3z2rUNeCjmsqdNAKQuviKjLJKTzQWysKAxEkcFg1mYhta/RKF9E9gHRFj2N NxMMj2YvtuztGxtUcnb7DtdbQtyjQxX/0vQZWPYTgH58DTXE5tvOCuNn9YYLo1yLQP vRYRsd5m0mesEPJYa5gquXAxT1xgsoS2zB68d3D1sR3v1dAwnAJwy88ShwdxestsI0 PpZ4ex9ErdJNZiZQOjl3ta8MUEep8CH0Ncpd+Ou8gFUSkiLWgf94rWbBoIDHPlN4tF lGOyAj17FCHo4oGxZtMBlKgbu5wBuH4JNx00aKcrqznp21iKvyBisDvmVEFAzUimzg UMZn33Ky+hICQ== Subject: [PATCH 3/4] xfs: create convenience wrappers for incore quota block reservations From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@infradead.org, david@fromorbit.com Date: Sat, 23 Jan 2021 10:51:51 -0800 Message-ID: <161142791177.2170981.5671264062040255172.stgit@magnolia> In-Reply-To: <161142789504.2170981.1372317837643770452.stgit@magnolia> References: <161142789504.2170981.1372317837643770452.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Create a couple of convenience wrappers for creating and deleting quota block reservations against future changes. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- 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 { From patchwork Sat Jan 23 18:51:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12041791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD4F6C433E0 for ; Sat, 23 Jan 2021 18:52:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF19B23340 for ; Sat, 23 Jan 2021 18:52:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726151AbhAWSws (ORCPT ); Sat, 23 Jan 2021 13:52:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:35058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726131AbhAWSwg (ORCPT ); Sat, 23 Jan 2021 13:52:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AACC122DBF; Sat, 23 Jan 2021 18:51:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611427915; bh=leG9vUxipS1mLBwulMHto+l1Qe/GZyBl2RVx6RkehIQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=jC0YlG7Mk6+uROJ03jxrH7m4VmDDABcf/HOlP9PoVV3P7Ces/j8SabEMNL+hS1JiE Ozd81+yzeXxaUny4l0sPrNSNgTHRX8wH1ww3c+TTrIwlQ/Fs68jVc1yO193P9olCgy 4b4ttwngGazdgyOxgjWyfDVkgFLiXSQhpIGO3384zhSHCXAegPDSqMwNbwSM7bsopC 3OcVIjdcPU6GOIAlviG/VMR5AKaWDJMBZlF38rE1cqqS7DmhTswa7DAY828UA8f+hF UCuZ+U7MSZ1MbplreZvTlSe494r3g05FLFWPPH/K28IrqQmqJvoE/RFdbvD0bYtPcA kdM0pbbDy9j5g== Subject: [PATCH 4/4] xfs: clean up icreate quota reservation calls From: "Darrick J. Wong" To: djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org, hch@infradead.org, david@fromorbit.com Date: Sat, 23 Jan 2021 10:51:57 -0800 Message-ID: <161142791730.2170981.16295389347749875438.stgit@magnolia> In-Reply-To: <161142789504.2170981.1372317837643770452.stgit@magnolia> References: <161142789504.2170981.1372317837643770452.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Create a proper helper so that inode creation calls can reserve quota with a dedicated function. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- 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. */ From patchwork Tue Jan 26 04:51:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12049625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4B4DC4332B for ; Wed, 27 Jan 2021 10:21:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B44F720731 for ; Wed, 27 Jan 2021 10:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S313957AbhAZXC5 (ORCPT ); Tue, 26 Jan 2021 18:02:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:54600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730497AbhAZFAL (ORCPT ); Tue, 26 Jan 2021 00:00:11 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id EF57222B2C; Tue, 26 Jan 2021 04:51:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611636689; bh=H5Bd24pqMbMofDbBIoiTClFy4h+2Zy2uKRkMvNh8H1o=; h=Date:From:To:Subject:References:In-Reply-To:From; b=Tt4d7urCW102j+6wKVfF7c8tnMR5P2Dq6ytmYwkkOa/H6xassqPfJ8oYDoRcf4pDy 8ifJ+sIt8ElMZhFWButtZo3TZGzBPf/VrWnNxcabZ71JPOUlSFVa9JnBw/dEkSnYGr 0GPXQSNtDQdzhSVdlfTjEr57MzyXUlAAuNMhs4Rnvlkj+G292Ry4VIXahUe0MKXyR6 MW5WjrBUBIN6oMOXCTURmIGSZ5ztBDE5FocnUKCnR8IsrP9cRsOQcmjIrf3c9lv7sI XSbWCDFDJ+8+AamJV1kexNXeV47i3vNs0Sp6+duYil3oz5c4x9RCSoh1l4e1uElLUq olVuUZuQ+pYLQ== Date: Mon, 25 Jan 2021 20:51:28 -0800 From: "Darrick J. Wong" To: Christoph Hellwig , linux-xfs@vger.kernel.org, hch@infradead.org, david@fromorbit.com Subject: [PATCH 5/4] xfs: fix up build warnings when quotas are disabled Message-ID: <20210126045128.GL7698@magnolia> References: <161142789504.2170981.1372317837643770452.stgit@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <161142789504.2170981.1372317837643770452.stgit@magnolia> Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Fix some build warnings on gcc 10.2 when quotas are disabled. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- 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)