From patchwork Tue Nov 5 22:40:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13863711 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C707F20D51E for ; Tue, 5 Nov 2024 22:40:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730846403; cv=none; b=hXQcRfyPw2P4h4MjGKpsxdjIQ5KjKrdvjsgVC8xV7uFDJhwaf6xfVllkYUnGs6aE82Qm3FlSMlk8WrO1KYeyQ4p7CUMpbUxUB92WkemFbQmgV4YAxw/pdISCF4qrqr+Z2+rYSx2CMORW6omjbeYbQD9UTgyhU5vWI36cAPMLwQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730846403; c=relaxed/simple; bh=MuVt0g2/DTHoiVaud7kOp0RIW7jHbo/hJf8g0oFWEbM=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aeT62NYUQS26pJceP6xAUyLmMCHvzy/vPua0X99luDxpqxQ2pzmuTALlf4ikfQzRGS7eHjdGzApgCXxwhslszlbyTS/JqBEVm946dztkAgoKMdLIk70nFYuWUSWsmDs2Gae7n8VgH4a/pCsnZ3P3Msk731MSXWwUG4bZjwNbXxE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Kg0wTatu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Kg0wTatu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D50BC4CECF; Tue, 5 Nov 2024 22:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730846403; bh=MuVt0g2/DTHoiVaud7kOp0RIW7jHbo/hJf8g0oFWEbM=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Kg0wTatuWMM4VOJ4TdqHuhD8xClfY9VBSsuZDTjTAL48gyCD3PUykhAIPkYAYnoOl KZTxlZbmwNbNKmO3NIKLyaWinIj8RRZxz1ybdGw/nZUkIziiRQ986NYOH8ZlL2FGUA VLVgHszrDxYhPBaGtAOyCcKAIGYDdKIxPT6JvJmZzmR1Uu3WbvZygQabY6BdLFlgzj Wtri5PusSvwepDy+PSFPIA7qlrCAzoCnOoPPfuQGGirm4akhRGUIM9RxUtHWl7kCo+ Vp389Lpa+RkeSapgs/byrkVVXvsfuEsMwDtEU79FxHUtHq46R4hlLWfmwUXJXI1IXN sCZFY8Rua0SQA== Date: Tue, 05 Nov 2024 14:40:03 -0800 Subject: [PATCH 1/6] xfs: fix chown with rt quota From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <173084399580.1873230.12328173862811234009.stgit@frogsfrogsfrogs> In-Reply-To: <173084399548.1873230.14221538780736772304.stgit@frogsfrogsfrogs> References: <173084399548.1873230.14221538780736772304.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Make chown's quota adjustments work with realtime files. This is mostly a matter of calling xfs_inode_count_blocks on a given file to figure out the number of blocks allocated to the data device and to the realtime device, and using those quantities to update the quota accounting when the id changes. Delayed allocation reservations are moved from the old dquot's incore reservation to the new dquot's incore reservation. Note that there was a missing ILOCK bug in xfs_qm_dqusage_adjust that we must fix before calling xfs_iread_extents. Prior to 2.6.37 the locking was correct, but then someone removed the ILOCK as part of a cleanup. Nobody noticed because nowhere in the git history have we ever supported rt+quota so nobody can use this. I'm leaving git breadcrumbs in case anyone is desperate enough to try to backport the rtquota code to old kernels. Not-Cc: # v2.6.37 Fixes: 52fda114249578 ("xfs: simplify xfs_qm_dqusage_adjust") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_qm.c | 44 +++++++++++++++++++++++++++----------------- fs/xfs/xfs_trans.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 19 deletions(-) diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index d9d09195eabb0d..1c7d861dfbeceb 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -1351,8 +1351,8 @@ xfs_qm_dqusage_adjust( void *data) { struct xfs_inode *ip; - xfs_qcnt_t nblks; - xfs_filblks_t rtblks = 0; /* total rt blks */ + xfs_filblks_t nblks, rtblks; + unsigned int lock_mode; int error; ASSERT(XFS_IS_QUOTA_ON(mp)); @@ -1393,18 +1393,17 @@ xfs_qm_dqusage_adjust( ASSERT(ip->i_delayed_blks == 0); + lock_mode = xfs_ilock_data_map_shared(ip); if (XFS_IS_REALTIME_INODE(ip)) { - struct xfs_ifork *ifp = xfs_ifork_ptr(ip, XFS_DATA_FORK); - error = xfs_iread_extents(tp, ip, XFS_DATA_FORK); - if (error) + if (error) { + xfs_iunlock(ip, lock_mode); goto error0; - - xfs_bmap_count_leaves(ifp, &rtblks); + } } - - nblks = (xfs_qcnt_t)ip->i_nblocks - rtblks; + xfs_inode_count_blocks(tp, ip, &nblks, &rtblks); xfs_iflags_clear(ip, XFS_IQUOTAUNCHECKED); + xfs_iunlock(ip, lock_mode); /* * Add the (disk blocks and inode) resources occupied by this @@ -2043,9 +2042,8 @@ xfs_qm_vop_chown( struct xfs_dquot *newdq) { struct xfs_dquot *prevdq; - uint bfield = XFS_IS_REALTIME_INODE(ip) ? - XFS_TRANS_DQ_RTBCOUNT : XFS_TRANS_DQ_BCOUNT; - + xfs_filblks_t dblocks, rblocks; + bool isrt = XFS_IS_REALTIME_INODE(ip); xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); ASSERT(XFS_IS_QUOTA_ON(ip->i_mount)); @@ -2056,11 +2054,17 @@ xfs_qm_vop_chown( ASSERT(prevdq); ASSERT(prevdq != newdq); - xfs_trans_mod_ino_dquot(tp, ip, prevdq, bfield, -(ip->i_nblocks)); + xfs_inode_count_blocks(tp, ip, &dblocks, &rblocks); + + xfs_trans_mod_ino_dquot(tp, ip, prevdq, XFS_TRANS_DQ_BCOUNT, + -(xfs_qcnt_t)dblocks); + xfs_trans_mod_ino_dquot(tp, ip, prevdq, XFS_TRANS_DQ_RTBCOUNT, + -(xfs_qcnt_t)rblocks); xfs_trans_mod_ino_dquot(tp, ip, prevdq, XFS_TRANS_DQ_ICOUNT, -1); /* the sparkling new dquot */ - xfs_trans_mod_ino_dquot(tp, ip, newdq, bfield, ip->i_nblocks); + xfs_trans_mod_ino_dquot(tp, ip, newdq, XFS_TRANS_DQ_BCOUNT, dblocks); + xfs_trans_mod_ino_dquot(tp, ip, newdq, XFS_TRANS_DQ_RTBCOUNT, rblocks); xfs_trans_mod_ino_dquot(tp, ip, newdq, XFS_TRANS_DQ_ICOUNT, 1); /* @@ -2070,7 +2074,8 @@ xfs_qm_vop_chown( * (having already bumped up the real counter) so that we don't have * any reservation to give back when we commit. */ - xfs_trans_mod_dquot(tp, newdq, XFS_TRANS_DQ_RES_BLKS, + xfs_trans_mod_dquot(tp, newdq, + isrt ? XFS_TRANS_DQ_RES_RTBLKS : XFS_TRANS_DQ_RES_BLKS, -ip->i_delayed_blks); /* @@ -2082,8 +2087,13 @@ xfs_qm_vop_chown( */ tp->t_flags |= XFS_TRANS_DIRTY; xfs_dqlock(prevdq); - ASSERT(prevdq->q_blk.reserved >= ip->i_delayed_blks); - prevdq->q_blk.reserved -= ip->i_delayed_blks; + if (isrt) { + ASSERT(prevdq->q_rtb.reserved >= ip->i_delayed_blks); + prevdq->q_rtb.reserved -= ip->i_delayed_blks; + } else { + ASSERT(prevdq->q_blk.reserved >= ip->i_delayed_blks); + prevdq->q_blk.reserved -= ip->i_delayed_blks; + } xfs_dqunlock(prevdq); /* diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 4db022c189e134..30fbed27cf05cc 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -1288,11 +1288,26 @@ xfs_trans_alloc_ichange( gdqp = (new_gdqp != ip->i_gdquot) ? new_gdqp : NULL; pdqp = (new_pdqp != ip->i_pdquot) ? new_pdqp : NULL; if (udqp || gdqp || pdqp) { + xfs_filblks_t dblocks, rblocks; unsigned int qflags = XFS_QMOPT_RES_REGBLKS; + bool isrt = XFS_IS_REALTIME_INODE(ip); if (force) qflags |= XFS_QMOPT_FORCE_RES; + if (isrt) { + error = xfs_iread_extents(tp, ip, XFS_DATA_FORK); + if (error) + goto out_cancel; + } + + xfs_inode_count_blocks(tp, ip, &dblocks, &rblocks); + + if (isrt) + rblocks += ip->i_delayed_blks; + else + dblocks += ip->i_delayed_blks; + /* * Reserve enough quota to handle blocks on disk and reserved * for a delayed allocation. We'll actually transfer the @@ -1300,8 +1315,20 @@ xfs_trans_alloc_ichange( * though that part is only semi-transactional. */ error = xfs_trans_reserve_quota_bydquots(tp, mp, udqp, gdqp, - pdqp, ip->i_nblocks + ip->i_delayed_blks, - 1, qflags); + pdqp, dblocks, 1, qflags); + if ((error == -EDQUOT || error == -ENOSPC) && !retried) { + xfs_trans_cancel(tp); + xfs_blockgc_free_dquots(mp, udqp, gdqp, pdqp, 0); + retried = true; + goto retry; + } + if (error) + goto out_cancel; + + /* Do the same for realtime. */ + qflags = XFS_QMOPT_RES_RTBLKS | (qflags & XFS_QMOPT_FORCE_RES); + error = xfs_trans_reserve_quota_bydquots(tp, mp, udqp, gdqp, + pdqp, rblocks, 0, qflags); if ((error == -EDQUOT || error == -ENOSPC) && !retried) { xfs_trans_cancel(tp); xfs_blockgc_free_dquots(mp, udqp, gdqp, pdqp, 0); From patchwork Tue Nov 5 22:40:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13863712 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C839C1CCB2D for ; Tue, 5 Nov 2024 22:40:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730846419; cv=none; b=gPhQonFMD9yaGuB5xfRCkLTo9TYG1SeTqQgdKoMsgALDV49aJsJPrAek0zrDhETF1MKjTh9TYdZx4LFxhy+yWkdU1ET7ikGVUkSmw/CS/oZMN/bJhiYrlFWvwxo9n609myyMpPq15gnWGq6+2ICbZ9L+Rbw4mcD90UZzV+4ctuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730846419; c=relaxed/simple; bh=DA3SVveFGsoBPM1hbpnX29b0Xvm7WuHEsOER3KEx6ZQ=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gC0IbYGpKolKUJsNnPQIhHVfpWpCt383rY8RCNSdQv6aYCx/Y6QkouHkaZRom1frtrpk1QN36NjeacUFfQaQJxamTeWLiaHWUBCG5Ph1awQhZz3V2cfyGgm+htVKZugW3cxpUoVHZicp45y2cq3//DquL0fvHgxB3S4R4tvIGso= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HqvJRRiU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HqvJRRiU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 411EAC4CECF; Tue, 5 Nov 2024 22:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730846419; bh=DA3SVveFGsoBPM1hbpnX29b0Xvm7WuHEsOER3KEx6ZQ=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=HqvJRRiUSw9wQ4NCVVXArYLl4zrBzOIK2pfy8j1v4T9QKxALacYr2H5auk7pPW0Hr XC7ibH/P8lKcK7ZxjbxoygaX1Mu3GPrOLS0WL4bNdEwt4kl7tPsUstcsWfehfoSRB0 4DsbGYuqYOu+NIQMxtt2k0s8Vq3OSvLAqpzrlcouhQeJVaWykD2T/Nqb8yhrgfK8Mh Pxn04/mFf9123chFxoTgYtWjLVXkTHd5UoX5hKDG3FRP5ploNdJrtgFr32Q3pdqDWz Z2hHex1vGoZYG+aw73ICNxcodhAMdzV6aTz67SY5s1M0CS1HMEnFNMayozZRrwHfAv vL7jMaUSHgUIA== Date: Tue, 05 Nov 2024 14:40:18 -0800 Subject: [PATCH 2/6] xfs: advertise realtime quota support in the xqm stat files From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <173084399596.1873230.8956988370471543351.stgit@frogsfrogsfrogs> In-Reply-To: <173084399548.1873230.14221538780736772304.stgit@frogsfrogsfrogs> References: <173084399548.1873230.14221538780736772304.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Add a fifth column to this (really old) stat file to advertise that the kernel supports quota for realtime volumes. This will be used by fstests to detect kernel support. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_stats.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c index ed97d72caa6652..ffb52725c2a8e8 100644 --- a/fs/xfs/xfs_stats.c +++ b/fs/xfs/xfs_stats.c @@ -115,10 +115,11 @@ void xfs_stats_clearall(struct xfsstats __percpu *stats) static int xqm_proc_show(struct seq_file *m, void *v) { - /* maximum; incore; ratio free to inuse; freelist */ - seq_printf(m, "%d\t%d\t%d\t%u\n", + /* maximum; incore; ratio free to inuse; freelist; rtquota */ + seq_printf(m, "%d\t%d\t%d\t%u\t%s\n", 0, counter_val(xfsstats.xs_stats, XFSSTAT_END_XQMSTAT), - 0, counter_val(xfsstats.xs_stats, XFSSTAT_END_XQMSTAT + 1)); + 0, counter_val(xfsstats.xs_stats, XFSSTAT_END_XQMSTAT + 1), + IS_ENABLED(CONFIG_XFS_RT) ? "rtquota" : "quota"); return 0; } From patchwork Tue Nov 5 22:40:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13863713 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDD671CCB2D for ; Tue, 5 Nov 2024 22:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730846435; cv=none; b=q8YSIktpFrAnGOwx+aanGoInO0j6NkEdjDwiYH+QiWYyZvc02m78Xsqcb1e1jhFWl+6k/fn1eyUKvmLJ5H5t0K57BbtVmux+9roF4rWQrOiUyDGSk+7y9dWdMbolcFZ62hdz7CDWZLjKNprmukwYKEHgaR/Jq1OXoy4ia83h5a0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730846435; c=relaxed/simple; bh=u83W6b5fNBnzY4+5wRw+TLr+aMixEG/1D//C68gscs0=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N6owaM9Oc0sFV+jfZx2bg/1ELPH4iqUgXN8cOT/dy4lpYHDX/Wq58lQJQdC7O5cOpMri6ZfZmuHIhskyrjH1wuQsuxnpfGtF4JWthOlLhx0DFWd2apBJ7pVQVoeJxUd0/Ocn0hoVHPYvBVvmSFn/S45g6eXbnzfiDJes89DMpFk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WPQB/hsw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WPQB/hsw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD0ADC4CECF; Tue, 5 Nov 2024 22:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730846434; bh=u83W6b5fNBnzY4+5wRw+TLr+aMixEG/1D//C68gscs0=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=WPQB/hswDh00kIx44rZ0bTsaTPqP1evLMNjTbPHWm0qaJmE5JnO5csGbp0Wprw6FO ayEC00Jw3E6mQijcGRrWqYhL6ff4PERLwgF2zfxyrbTXLwtlMHmpsXPksfp0OVmysV weqJjQo+JjzGgqUVYWAOQTZksJiooBLHMh0EWGiBwZiY1wUa+rmMIQOuXCLH7LkHGk Aa8du+WnBRIz1oarsZsS75CFlV4dnoHloe/RU9r4fHuCEdU8PVwCbRS/t+mB+xAQMP yXB5tQ0Jz4EkXPGZrp43Tq325lY3R9S+LA/hjtxdwtTTMOe+ogWn8ukEIFSkfSGjOY uWwlggLuIYYtw== Date: Tue, 05 Nov 2024 14:40:34 -0800 Subject: [PATCH 3/6] xfs: report realtime block quota limits on realtime directories From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <173084399613.1873230.10368889388480660250.stgit@frogsfrogsfrogs> In-Reply-To: <173084399548.1873230.14221538780736772304.stgit@frogsfrogsfrogs> References: <173084399548.1873230.14221538780736772304.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong On the data device, calling statvfs on a projinherit directory results in the block and avail counts being curtailed to the project quota block limits, if any are set. Do the same for realtime files or directories, only use the project quota rt block limits. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_qm_bhv.c | 18 ++++++++++++------ fs/xfs/xfs_super.c | 11 +++++------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/fs/xfs/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c index 79a96558f739e3..847ba29630e9d8 100644 --- a/fs/xfs/xfs_qm_bhv.c +++ b/fs/xfs/xfs_qm_bhv.c @@ -19,18 +19,24 @@ STATIC void xfs_fill_statvfs_from_dquot( struct kstatfs *statp, + struct xfs_inode *ip, struct xfs_dquot *dqp) { + struct xfs_dquot_res *blkres = &dqp->q_blk; uint64_t limit; - limit = dqp->q_blk.softlimit ? - dqp->q_blk.softlimit : - dqp->q_blk.hardlimit; + if (XFS_IS_REALTIME_MOUNT(ip->i_mount) && + (ip->i_diflags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) + blkres = &dqp->q_rtb; + + limit = blkres->softlimit ? + blkres->softlimit : + blkres->hardlimit; if (limit && statp->f_blocks > limit) { statp->f_blocks = limit; statp->f_bfree = statp->f_bavail = - (statp->f_blocks > dqp->q_blk.reserved) ? - (statp->f_blocks - dqp->q_blk.reserved) : 0; + (statp->f_blocks > blkres->reserved) ? + (statp->f_blocks - blkres->reserved) : 0; } limit = dqp->q_ino.softlimit ? @@ -61,7 +67,7 @@ xfs_qm_statvfs( struct xfs_dquot *dqp; if (!xfs_qm_dqget(mp, ip->i_projid, XFS_DQTYPE_PROJ, false, &dqp)) { - xfs_fill_statvfs_from_dquot(statp, dqp); + xfs_fill_statvfs_from_dquot(statp, ip, dqp); xfs_qm_dqput(dqp); } } diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 20fde2442768c4..f8d59081950a72 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -877,12 +877,6 @@ xfs_fs_statfs( ffree = statp->f_files - (icount - ifree); statp->f_ffree = max_t(int64_t, ffree, 0); - - if ((ip->i_diflags & XFS_DIFLAG_PROJINHERIT) && - ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) == - (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD)) - xfs_qm_statvfs(ip, statp); - if (XFS_IS_REALTIME_MOUNT(mp) && (ip->i_diflags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) { s64 freertx; @@ -893,6 +887,11 @@ xfs_fs_statfs( xfs_rtbxlen_to_blen(mp, freertx); } + if ((ip->i_diflags & XFS_DIFLAG_PROJINHERIT) && + ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) == + (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD)) + xfs_qm_statvfs(ip, statp); + return 0; } From patchwork Tue Nov 5 22:40:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13863714 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D3EF1CCB2D for ; Tue, 5 Nov 2024 22:40:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730846450; cv=none; b=WfVzh6gut93ydXF4ch2soZ9inCRynhd1uhqrgB2N55bX+iW5o/BSKgUXts4dInlKI+um9yrvqg1fuvXthG3co312kdCvWfgdhGYTduQUyWPfW11dZhgyi2E+1N3vHsMs31eBPu+IKIEOqUv+OHkwjXw7Xl6bL6/ecgtZhdDcIzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730846450; c=relaxed/simple; bh=NQ6ku4PobNjBoQsGGWM2PUM1aTzf28bTKEAfCPBqoKo=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kTBcdFkhLSN0RdWxXA3t/MFaxjHprtFz7/KoY9U+xgUByQ/RPVIVo+T+JWrYihwFx8mVOWXgUzk2TTY3VdAx9pCliflJg63sKPheaGgsUS2luOn07UvoRmD8ePHU7GTff0KOmrl2njFL69sGjzyZXoj9iRLdt7vmmzH4qphg2qk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cwTXZqGx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cwTXZqGx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6366DC4CECF; Tue, 5 Nov 2024 22:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730846450; bh=NQ6ku4PobNjBoQsGGWM2PUM1aTzf28bTKEAfCPBqoKo=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=cwTXZqGxXNlzeblklxvqmsuR5zjk7P0aos3PIF4q8whyzhW3qJtHs89jo/DZBIo5H 0sAiJDWljZWWBCS5ksoauRH7OYQrketAEviXK0PAGVp1Bm1WUUmRhsDxavl+QaFfYU JRotdQ02gsBou60yA3Uzp8+DP4fiKCZQXFV0QMl91KdTcfOxCHypXfDFlcr8tiNK7c qkHC7lhFPmveizOuV5gGKxsLUxsSo0o6Vf2dFKVBmtvxKzNMAevOPrSC6E8LghElQn T4qOeLFTsgt8NPuzDCiWhKlOkUeu6W6FNDYEO+GBk4xGkPWCdsh2c4SH1tqYB6AMZX lIVVbuiDE3Rlg== Date: Tue, 05 Nov 2024 14:40:49 -0800 Subject: [PATCH 4/6] xfs: create quota preallocation watermarks for realtime quota From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <173084399630.1873230.10827415923801994697.stgit@frogsfrogsfrogs> In-Reply-To: <173084399548.1873230.14221538780736772304.stgit@frogsfrogsfrogs> References: <173084399548.1873230.14221538780736772304.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Refactor the quota preallocation watermarking code so that it'll work for realtime quota too. Convert the do_div calls into div_u64 for compactness. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_dquot.c | 37 +++++++++++++++++++++---------------- fs/xfs/xfs_dquot.h | 18 ++++++++++++++---- fs/xfs/xfs_iomap.c | 37 ++++++++++++++++++++++++++++++------- fs/xfs/xfs_qm.c | 21 ++++++++++++++++----- 4 files changed, 81 insertions(+), 32 deletions(-) diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 3bf47458c517af..ff982d983989b0 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -277,6 +277,25 @@ xfs_qm_init_dquot_blk( xfs_trans_log_buf(tp, bp, 0, BBTOB(q->qi_dqchunklen) - 1); } +static void +xfs_dquot_set_prealloc( + struct xfs_dquot_pre *pre, + const struct xfs_dquot_res *res) +{ + xfs_qcnt_t space; + + pre->q_prealloc_hi_wmark = res->hardlimit; + pre->q_prealloc_lo_wmark = res->softlimit; + + space = div_u64(pre->q_prealloc_hi_wmark, 100); + if (!pre->q_prealloc_lo_wmark) + pre->q_prealloc_lo_wmark = space * 95; + + pre->q_low_space[XFS_QLOWSP_1_PCNT] = space; + pre->q_low_space[XFS_QLOWSP_3_PCNT] = space * 3; + pre->q_low_space[XFS_QLOWSP_5_PCNT] = space * 5; +} + /* * Initialize the dynamic speculative preallocation thresholds. The lo/hi * watermarks correspond to the soft and hard limits by default. If a soft limit @@ -285,22 +304,8 @@ xfs_qm_init_dquot_blk( void xfs_dquot_set_prealloc_limits(struct xfs_dquot *dqp) { - uint64_t space; - - dqp->q_prealloc_hi_wmark = dqp->q_blk.hardlimit; - dqp->q_prealloc_lo_wmark = dqp->q_blk.softlimit; - if (!dqp->q_prealloc_lo_wmark) { - dqp->q_prealloc_lo_wmark = dqp->q_prealloc_hi_wmark; - do_div(dqp->q_prealloc_lo_wmark, 100); - dqp->q_prealloc_lo_wmark *= 95; - } - - space = dqp->q_prealloc_hi_wmark; - - do_div(space, 100); - dqp->q_low_space[XFS_QLOWSP_1_PCNT] = space; - dqp->q_low_space[XFS_QLOWSP_3_PCNT] = space * 3; - dqp->q_low_space[XFS_QLOWSP_5_PCNT] = space * 5; + xfs_dquot_set_prealloc(&dqp->q_blk_prealloc, &dqp->q_blk); + xfs_dquot_set_prealloc(&dqp->q_rtb_prealloc, &dqp->q_rtb); } /* diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h index 677bb2dc9ac913..d73d179df00958 100644 --- a/fs/xfs/xfs_dquot.h +++ b/fs/xfs/xfs_dquot.h @@ -56,6 +56,12 @@ xfs_dquot_res_over_limits( return false; } +struct xfs_dquot_pre { + xfs_qcnt_t q_prealloc_lo_wmark; + xfs_qcnt_t q_prealloc_hi_wmark; + int64_t q_low_space[XFS_QLOWSP_MAX]; +}; + /* * The incore dquot structure */ @@ -76,9 +82,9 @@ struct xfs_dquot { struct xfs_dq_logitem q_logitem; - xfs_qcnt_t q_prealloc_lo_wmark; - xfs_qcnt_t q_prealloc_hi_wmark; - int64_t q_low_space[XFS_QLOWSP_MAX]; + struct xfs_dquot_pre q_blk_prealloc; + struct xfs_dquot_pre q_rtb_prealloc; + struct mutex q_qlock; struct completion q_flush; atomic_t q_pincount; @@ -192,7 +198,11 @@ static inline bool xfs_dquot_lowsp(struct xfs_dquot *dqp) int64_t freesp; freesp = dqp->q_blk.hardlimit - dqp->q_blk.reserved; - if (freesp < dqp->q_low_space[XFS_QLOWSP_1_PCNT]) + if (freesp < dqp->q_blk_prealloc.q_low_space[XFS_QLOWSP_1_PCNT]) + return true; + + freesp = dqp->q_rtb.hardlimit - dqp->q_rtb.reserved; + if (freesp < dqp->q_rtb_prealloc.q_low_space[XFS_QLOWSP_1_PCNT]) return true; return false; diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 17e5c273e28c45..a6fc5acbb6f2c7 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -353,16 +353,26 @@ xfs_quota_need_throttle( xfs_fsblock_t alloc_blocks) { struct xfs_dquot *dq = xfs_inode_dquot(ip, type); + struct xfs_dquot_res *res; + struct xfs_dquot_pre *pre; if (!dq || !xfs_this_quota_on(ip->i_mount, type)) return false; + if (XFS_IS_REALTIME_INODE(ip)) { + res = &dq->q_rtb; + pre = &dq->q_rtb_prealloc; + } else { + res = &dq->q_blk; + pre = &dq->q_blk_prealloc; + } + /* no hi watermark, no throttle */ - if (!dq->q_prealloc_hi_wmark) + if (!pre->q_prealloc_hi_wmark) return false; /* under the lo watermark, no throttle */ - if (dq->q_blk.reserved + alloc_blocks < dq->q_prealloc_lo_wmark) + if (res->reserved + alloc_blocks < pre->q_prealloc_lo_wmark) return false; return true; @@ -377,22 +387,35 @@ xfs_quota_calc_throttle( int64_t *qfreesp) { struct xfs_dquot *dq = xfs_inode_dquot(ip, type); + struct xfs_dquot_res *res; + struct xfs_dquot_pre *pre; int64_t freesp; int shift = 0; + if (!dq) { + res = NULL; + pre = NULL; + } else if (XFS_IS_REALTIME_INODE(ip)) { + res = &dq->q_rtb; + pre = &dq->q_rtb_prealloc; + } else { + res = &dq->q_blk; + pre = &dq->q_blk_prealloc; + } + /* no dq, or over hi wmark, squash the prealloc completely */ - if (!dq || dq->q_blk.reserved >= dq->q_prealloc_hi_wmark) { + if (!res || res->reserved >= pre->q_prealloc_hi_wmark) { *qblocks = 0; *qfreesp = 0; return; } - freesp = dq->q_prealloc_hi_wmark - dq->q_blk.reserved; - if (freesp < dq->q_low_space[XFS_QLOWSP_5_PCNT]) { + freesp = pre->q_prealloc_hi_wmark - res->reserved; + if (freesp < pre->q_low_space[XFS_QLOWSP_5_PCNT]) { shift = 2; - if (freesp < dq->q_low_space[XFS_QLOWSP_3_PCNT]) + if (freesp < pre->q_low_space[XFS_QLOWSP_3_PCNT]) shift += 2; - if (freesp < dq->q_low_space[XFS_QLOWSP_1_PCNT]) + if (freesp < pre->q_low_space[XFS_QLOWSP_1_PCNT]) shift += 2; } diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 1c7d861dfbeceb..90d45aae5cb891 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -2178,6 +2178,8 @@ xfs_inode_near_dquot_enforcement( xfs_dqtype_t type) { struct xfs_dquot *dqp; + struct xfs_dquot_res *res; + struct xfs_dquot_pre *pre; int64_t freesp; /* We only care for quotas that are enabled and enforced. */ @@ -2186,21 +2188,30 @@ xfs_inode_near_dquot_enforcement( return false; if (xfs_dquot_res_over_limits(&dqp->q_ino) || + xfs_dquot_res_over_limits(&dqp->q_blk) || xfs_dquot_res_over_limits(&dqp->q_rtb)) return true; + if (XFS_IS_REALTIME_INODE(ip)) { + res = &dqp->q_rtb; + pre = &dqp->q_rtb_prealloc; + } else { + res = &dqp->q_blk; + pre = &dqp->q_blk_prealloc; + } + /* For space on the data device, check the various thresholds. */ - if (!dqp->q_prealloc_hi_wmark) + if (!pre->q_prealloc_hi_wmark) return false; - if (dqp->q_blk.reserved < dqp->q_prealloc_lo_wmark) + if (res->reserved < pre->q_prealloc_lo_wmark) return false; - if (dqp->q_blk.reserved >= dqp->q_prealloc_hi_wmark) + if (res->reserved >= pre->q_prealloc_hi_wmark) return true; - freesp = dqp->q_prealloc_hi_wmark - dqp->q_blk.reserved; - if (freesp < dqp->q_low_space[XFS_QLOWSP_5_PCNT]) + freesp = pre->q_prealloc_hi_wmark - res->reserved; + if (freesp < pre->q_low_space[XFS_QLOWSP_5_PCNT]) return true; return false; From patchwork Tue Nov 5 22:41:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13863715 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 743A01D172A for ; Tue, 5 Nov 2024 22:41:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730846466; cv=none; b=Qx+SSiVJSjprY/fBWAaUEdVnSx3cRMapMEz+IsoGiMx0PQVY8X6CLfdEpJKVYRfxcw7M6/l1XX3PJ8XD+tROCi+FrjSzqb6PLx9quJq7r2QXAfkAnpkgUwDMcJJZJTfs5bG0TBaRNTgzRC68Q84EANV2kLY3i6fodgLR3oYW33Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730846466; c=relaxed/simple; bh=0xtQPuYsFx6+EaDmrN6skq2nN6sSjNCg3Y9AEFd1TbE=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=b9kUm2147mGNlPA19zxbPKQ1DbAbX8p92/6lwg/qfDX7THY0MCg7KO6+EtCz4OBiiZ6NB6a9xsX18/hzsTqsfBVwYQ8goo+TE5FxKoP59is8fn0UmDBqpZ1g27en8TZnfRUMXLko/c8wUe02I1QlSOi12I9xhUUF7VaD1DHp0EI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IfxQrF8T; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IfxQrF8T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08650C4CECF; Tue, 5 Nov 2024 22:41:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730846466; bh=0xtQPuYsFx6+EaDmrN6skq2nN6sSjNCg3Y9AEFd1TbE=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=IfxQrF8TEIALO9XI4R/oHRn20SDWC8xfroImLrh5/3f/TXPUh89cHwjyNwolWcnHe 8mdHHNK/zCiuqOwzDyj9jdb1HU6latn5Qg79u7kSrqGU4JOO/N2rypo/aBcxk3Zzwn zSZR5qUNp+5xaa3jWcbuAlqwpLFei07ggXTXMb2VJ3yPyjdLCyYuozsD3VF5ZcQNxu qeDUFIuzngy1/U5QEEDX8WlN0Zm3YFKTWB1jf2Hm5nxNQxNnY2KXoy7Pfs5nRCrosu PYcEudYmWwEUHEfjQo7ywGWwC7sNScnRueT54EbG2VktInekLIu2o2eeoFvdfHCmLx BgrPhHdeWKDxA== Date: Tue, 05 Nov 2024 14:41:05 -0800 Subject: [PATCH 5/6] xfs: reserve quota for realtime files correctly From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <173084399647.1873230.17634497666081035380.stgit@frogsfrogsfrogs> In-Reply-To: <173084399548.1873230.14221538780736772304.stgit@frogsfrogsfrogs> References: <173084399548.1873230.14221538780736772304.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Fix xfs_quota_reserve_blkres to reserve rt block quota whenever we're dealing with a realtime file. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_quota.h | 12 ++++++------ fs/xfs/xfs_trans_dquot.c | 11 +++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h index 2d36d967380e7c..fa1317cc396c96 100644 --- a/fs/xfs/xfs_quota.h +++ b/fs/xfs/xfs_quota.h @@ -130,6 +130,7 @@ 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 *); bool xfs_inode_near_dquot_enforcement(struct xfs_inode *ip, xfs_dqtype_t type); +int xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t blocks); # ifdef CONFIG_XFS_LIVE_HOOKS void xfs_trans_mod_ino_dquot(struct xfs_trans *tp, struct xfs_inode *ip, @@ -209,6 +210,11 @@ xfs_trans_reserve_quota_icreate(struct xfs_trans *tp, struct xfs_dquot *udqp, #define xfs_qm_unmount_quotas(mp) #define xfs_inode_near_dquot_enforcement(ip, type) (false) +static inline int xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t blocks) +{ + return 0; +} + # ifdef CONFIG_XFS_LIVE_HOOKS # define xfs_dqtrx_hook_enable() ((void)0) # define xfs_dqtrx_hook_disable() ((void)0) @@ -216,12 +222,6 @@ xfs_trans_reserve_quota_icreate(struct xfs_trans *tp, struct xfs_dquot *udqp, #endif /* CONFIG_XFS_QUOTA */ -static inline int -xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t blocks) -{ - return xfs_trans_reserve_quota_nblks(NULL, ip, blocks, 0, false); -} - static inline void xfs_quota_unreserve_blkres(struct xfs_inode *ip, uint64_t blocks) { diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index ca7df018290e0e..481ba3dc9f190d 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -1031,3 +1031,14 @@ xfs_trans_free_dqinfo( kmem_cache_free(xfs_dqtrx_cache, tp->t_dqinfo); tp->t_dqinfo = NULL; } + +int +xfs_quota_reserve_blkres( + struct xfs_inode *ip, + int64_t blocks) +{ + if (XFS_IS_REALTIME_INODE(ip)) + return xfs_trans_reserve_quota_nblks(NULL, ip, 0, blocks, + false); + return xfs_trans_reserve_quota_nblks(NULL, ip, blocks, 0, false); +} From patchwork Tue Nov 5 22:41:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13863716 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C44A920D51E for ; Tue, 5 Nov 2024 22:41:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730846481; cv=none; b=qhcAPMEHDh+IUVB9D57s/ITudjl1/il+OjgftmjQsRGRJfE2TxMI8Jwrol6Pb4C7r7+nEymW8LLwm8mofBDL9k4yI4c4npDAoG0gznpmu58YwEQvOmmZluT8S6fGGuIMYuYGF3o5AxlEd5CiIdgtwU7hGLWZ9Q3X01g6T7Hg1eY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730846481; c=relaxed/simple; bh=Y75ctLb6UH431sT2pn2oip6YtVvXhcwrRAD7PhAI1fU=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q6TY2+WBj9OfmaTT1B8crUjPcalOVfrtJ3kYVMUmpauPC/KPlp8rgldoarPruO5JS8dMiecpWQw83PeJ/iTSylBbAlFswHA91mALzjjtzPBIP9Giwq9j2W234X540OLAT2D4FhFY3s4Adk/TLXTWrTVaBahotE4hLAfwM6Wh5l8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TTF/lCmW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TTF/lCmW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EF0BC4CECF; Tue, 5 Nov 2024 22:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730846481; bh=Y75ctLb6UH431sT2pn2oip6YtVvXhcwrRAD7PhAI1fU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=TTF/lCmWFF/L4BGRNrKkOCBVbkOm3Rpw2zWqKofUL13oBTegkpUZ3NUZee6hF8VQt 2YD4HyPeci+N5AQ9s4gWbkd8A/P7XVsHNRPHhxAvb8/OE+0gDh94+aPFQqI2ckZfxb O6FOXbqjSlKSA47f+nAMJm3Ybj99R5ujeeSoXZ1I2ysgZEmZzAXT3dHEcvcMIt2ATh 2pqLpD3i4ev6DuzBHaNo61yJAF9nVrbfiV3aovhVGvd0+eQegUe4s48ZzZH9rw1gIE cKDtLViytL+jOL/K8RG1ZBVXHGyhqUrukB3+uIhZWzpiER2Hx64C6afjuMHFTxcmB2 4d394AJstxLgA== Date: Tue, 05 Nov 2024 14:41:21 -0800 Subject: [PATCH 6/6] xfs: enable realtime quota again From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <173084399664.1873230.9165782253353224379.stgit@frogsfrogsfrogs> In-Reply-To: <173084399548.1873230.14221538780736772304.stgit@frogsfrogsfrogs> References: <173084399548.1873230.14221538780736772304.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Enable quotas for the realtime device. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_qm.c | 7 ++++--- fs/xfs/xfs_rtalloc.c | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 90d45aae5cb891..b928b036990bc3 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -1663,10 +1663,11 @@ xfs_qm_mount_quotas( uint sbf; /* - * If quotas on realtime volumes is not supported, we disable - * quotas immediately. + * If quotas on realtime volumes is not supported, disable quotas + * immediately. We only support rtquota if rtgroups are enabled to + * avoid problems with older kernels. */ - if (mp->m_sb.sb_rextents) { + if (mp->m_sb.sb_rextents && !xfs_has_rtgroups(mp)) { xfs_notice(mp, "Cannot turn on quotas for realtime filesystem"); mp->m_qflags = 0; goto write_changes; diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 7ecea7623a151a..0cb534d71119a5 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -1265,7 +1265,9 @@ xfs_growfs_rt( /* Unsupported realtime features. */ error = -EOPNOTSUPP; - if (xfs_has_rmapbt(mp) || xfs_has_reflink(mp) || xfs_has_quota(mp)) + if (xfs_has_quota(mp) && !xfs_has_rtgroups(mp)) + goto out_unlock; + if (xfs_has_rmapbt(mp) || xfs_has_reflink(mp)) goto out_unlock; error = xfs_sb_validate_fsb_count(&mp->m_sb, in->newblocks);