From patchwork Thu Oct 17 19:10:45 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: 13840745 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 A636C1E0DC3 for ; Thu, 17 Oct 2024 19:10:45 +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=1729192245; cv=none; b=XA0bjpq6YQe5+EWvFT1ew98UprKzI7S90pedOi8+r0bCxUt/fiF5PlmNdRaFRxep6VBczSBIJavswSKt/5hEs2jWiQQ4scdbLkA0rlisO0Qt1UIUTPr+YF3l9dzNdNVZtWIMVfJ/ngDR6637oy02RSFVyndwpky5Fx1MAWElqP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729192245; c=relaxed/simple; bh=MuVt0g2/DTHoiVaud7kOp0RIW7jHbo/hJf8g0oFWEbM=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FsiduegoNhn9cTsbhlVnh2fwgpxh8bP/mbD7lFmJekVlEsvmd+Y3hs2tP2oz3Ye+9OPMZ3Z21SJdYwpckXTG/rNZoawdoCoIXBH6FILQ0DZcG5w2n9wXHnuGt0xqDL+jhZ/2wskqytdiCdE3j1cy46RzhWLumD7rWAtowK0PqRI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CnqMYapq; 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="CnqMYapq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BDB5C4CECD; Thu, 17 Oct 2024 19:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729192245; bh=MuVt0g2/DTHoiVaud7kOp0RIW7jHbo/hJf8g0oFWEbM=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=CnqMYapqMtE17UytcIJ7OuaBDPKwIdyZSLe01klTy6iIeSO57VAMNUYlShJBz6YuB wC0Z5jm7/a437G43+AutVJVAgEo12NIaC4UG+M+YeB4Lweb6U3z/A8if62E6qBW7E+ CBo+A+fIZAUAm2cSglqrIsd1ugKvctJIsGMygeowJ+kr15kUuZS9wjJiH42d4Dsjun 3jlKlU62nq80i+jqFz+GfTqa0lQGuY7kmCmY3DeJ7B0wFuKILiLYT6qVozMys6v1Hr yIvFKsMigHQklwXg8mbBijuD2T58NaoJtsLLCpidtT/KIegIlDYoLbglqrmoXBczDe wnFzzOJgpZXSg== Date: Thu, 17 Oct 2024 12:10:45 -0700 Subject: [PATCH 1/6] xfs: fix chown with rt quota From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <172919073095.3456016.16539272245715469066.stgit@frogsfrogsfrogs> In-Reply-To: <172919073062.3456016.13160926749424883839.stgit@frogsfrogsfrogs> References: <172919073062.3456016.13160926749424883839.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 Thu Oct 17 19:10:55 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: 13840746 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 6EEF81E0DC3 for ; Thu, 17 Oct 2024 19:10:56 +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=1729192256; cv=none; b=iZQiE/VKYgBj4hmKRsjS5uU+u8bZ+gUA8jrIu1py9PnBGXxvep1JmU728KVtCWBDcV+onInjuFUu1HGk3ISVZoDezU0AejwBMZ3URPEG/WGBU9wtS+qH6x+5GfVcscaTjta2058n/88ViKeViS2Azda0Wa71nfdRPqlimD2cSbg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729192256; c=relaxed/simple; bh=tOcCmBanszvQH4PbKdDB6HDeGg+LmTn56EZDvi6/LGo=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rUVQhF16NAzvc3Z+lDvRLJlfLuMmoBbTrO1Cil0ayYAMoGqKKGFVqiLZOutcXL2hZcgB2PP3lIaz6P2pgK159QsrrWD0izljUMTQLK528aYitl0MzqeEEyRIG/bW1WEwUNiGdi1MZTGCaEOEHVeKk0NhJ6NC5x7S54y5qm7RdHo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=r7e+CHKq; 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="r7e+CHKq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10EB1C4CEC3; Thu, 17 Oct 2024 19:10:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729192256; bh=tOcCmBanszvQH4PbKdDB6HDeGg+LmTn56EZDvi6/LGo=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=r7e+CHKqcWOfli7VF589dG31zPyaKqqynDT40EIovogXCB8MPPmEDbfLF6OXxn5s4 UayUbCZJRDBunA3fju41gsuEI1oaN9JUCqhuPBPmpsZd3zcE67cbxEiHhRDmLxs3C1 1A9z38ZF+IYUwx1R9+wlFDUcYGDaQ9ulV0uVt2PdKAqyWufxZC9d8QZb3hb6aRllD7 YZYRcQmdDrXwIR/mC8NGMKymj9hEJQOxsl+Scb61/25PA4VHcEgq6QlW0bKQpQrcNk 5Gpdj0huJ2AG5VQK0jGSumAaSiFW2ix39LnpfpQOt1cz0Q+hzkxfHace26OwrV3aPs 5AH76szTHWheg== Date: Thu, 17 Oct 2024 12:10:55 -0700 Subject: [PATCH 2/6] xfs: advertise realtime quota support in the xqm stat files From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <172919073112.3456016.11369324005013611455.stgit@frogsfrogsfrogs> In-Reply-To: <172919073062.3456016.13160926749424883839.stgit@frogsfrogsfrogs> References: <172919073062.3456016.13160926749424883839.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 Thu Oct 17 19:11:06 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: 13840747 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 33DDA2194B7 for ; Thu, 17 Oct 2024 19:11: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=1729192267; cv=none; b=eJlJ5fAS8s8Hn/oZwnRCyTWYeiOwNiSGkWh9ws+J1e7S+t2RaIUtFEghwSxxHec/1Rmzek3eIt4FmPoIPblJiQINWfaxJ4YYdaG4LXRrcyZu+Ihes9t5lTaYK8mcPj+DKTO1nGUCHDeFcYfRJBvhaJ4kwUkx2HL3xoyZz7eKmD4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729192267; c=relaxed/simple; bh=vIIDjwyLOZ75SAZIx0/aNIuCXHCl6sG4okw4vzsAfFI=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=igSsY4v3p1NhkIJLfjp7eyMWAUpbx+uRUnMDyTjDIxRKbOeuVKHPc4cyxFq+2ZeMFYhUIcHIFWZ6uG1qupRGIemrNY7JUSasSYA6MtBp3PGeCPdfdinBGT5NKZqJVZHEmRzpU0dLt2b5IaBOyqx/1+exCmfB9dSSmlHMNID3ga4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Emy7VccC; 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="Emy7VccC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B47F9C4CEC3; Thu, 17 Oct 2024 19:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729192266; bh=vIIDjwyLOZ75SAZIx0/aNIuCXHCl6sG4okw4vzsAfFI=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Emy7VccCaEaetR29azQf25wCI5peiMwUxVGuRKbp87VUva6diM222FPSvVF8zPAZ/ 5tn6EMyCLyRDteEP5bIOY9rtpzp5z+uwjtQnRdtroNLBotn/u4v7FVW5upVbZP2DRw g43dWHHVSeHJfxHO5C31nqqD2e7cJbWudOR082l06u686PN0MLjXXT2kKr1fcVFh/U t7DavCa7JNx2PC7UFbnYgSEWx/wGlnxVXy27LaEIb0qZ9mCBrdKsqCayHemF5aBKFC xsOO84rMi6zH+q5bVKc3xA4PULOqDY8iQ7NuLXsBueqbuVu+8Ikw3kHKidgz5VMPR/ eB5LyGyvCLwOg== Date: Thu, 17 Oct 2024 12:11:06 -0700 Subject: [PATCH 3/6] xfs: report realtime block quota limits on realtime directories From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <172919073129.3456016.18028274540878573379.stgit@frogsfrogsfrogs> In-Reply-To: <172919073062.3456016.13160926749424883839.stgit@frogsfrogsfrogs> References: <172919073062.3456016.13160926749424883839.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 7a9cfdb66c0313..8bbe6511fec7c2 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 Thu Oct 17 19:11:16 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: 13840748 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 CAD5C21D2A8 for ; Thu, 17 Oct 2024 19:11:17 +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=1729192279; cv=none; b=SYBgWMd2Dlk9x5H+zlmQhPUkdvFVaOMoqMhe1+pjX5dTrW++mD6Ysa1RRwHWfcr4V5NgBhfMTlOMTr3x3Lf15n44T0n7VpdHB/FXV+4p/WYN62PSIQ/y0YNqVWIFGorbpVFLarpbrV5hwTAAOK5/FNq5lP/rWWV3XHMtv7/qfgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729192279; c=relaxed/simple; bh=/qo2NLoLP/FRF3Ei4YqTe+kUmcrldmr07GlKBHV25f4=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=U2SzSec7s/OvMWP3C/rwdfTammaq4jOnt8Nd1i8a0S/RF1BnpXnHPzjxSdYHvaJb84ewmcS5gM8zBYF4o++ipcXflecD3MajJ6YwPecnVUZZqFAEqgkD3/XwZgMXmGZIBjKqEO96cOmHyiQqJHfgLDM/0Jl1u7ZI/erluXJzuBw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TgkDQ7Ma; 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="TgkDQ7Ma" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53015C4CED2; Thu, 17 Oct 2024 19:11:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729192277; bh=/qo2NLoLP/FRF3Ei4YqTe+kUmcrldmr07GlKBHV25f4=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=TgkDQ7MaMqgsSwxjUS0Yhysl8B95z1dnLyC8FHAmoRBWTOZaRXVZPiw7Q68uR6Qg4 /2rcK/Cl8OGspZymzqwMs0pX31EQRDj8S8T84OvacCEZuhn1VBYDWxj0KPgU7jjKwX as1cmrxxBPPQ5STQ1TJkG9UQIoKU+BxIbFFSxw/tqPob760hEUoe6HggsjmtqjAJO3 0NVODEmZFVD+JK6cPPcSbzqS0R85kiRn8SRjZkbVQuMCwaAUK3TSGb35ZPGNDSoGPl P1o/htW8iQ+xPPXP3WeRZDHaf5sFvH925yDsArAK9VF9ilaKOEHPoQOxVk+aM0+SQN WVChObnXKVE4A== Date: Thu, 17 Oct 2024 12:11:16 -0700 Subject: [PATCH 4/6] xfs: create quota preallocation watermarks for realtime quota From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <172919073146.3456016.16479833105039108998.stgit@frogsfrogsfrogs> In-Reply-To: <172919073062.3456016.13160926749424883839.stgit@frogsfrogsfrogs> References: <172919073062.3456016.13160926749424883839.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 fc952fe6269385..d763ef7c9dddfa 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 Thu Oct 17 19:11:27 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: 13840749 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 1E56A1E0DC3 for ; Thu, 17 Oct 2024 19:11:28 +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=1729192288; cv=none; b=MBQG5lZ3L039yNanIsQEIjigxYeog1adk0HkGg0f0Z1KnDC2KNPEBRHhNakR68EC+8tvkxVsK/ZzqE+Qx+Y5Ua3XPnBIa0HJvdNj9JWU6jw8CTlSfNl8JKz8TiKo4q98kUCixjeU/Mr3OxR7PsOdRlv7QCswo3Qewt9kCkfdm68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729192288; c=relaxed/simple; bh=0xtQPuYsFx6+EaDmrN6skq2nN6sSjNCg3Y9AEFd1TbE=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Wy+Xoy/CwjYAq7Z8YNVZW9rb4W0hkHFlqERMl20xfP8yXcFe2aUizbx5BFK9lXbVa9JZhQsvtS68EEaHjtjXSTKMuQZ+dWrSuPFHMaIMQ/NRo3Wht9uSqhFExLAjFCUHlsHeb1AfSfu086G3IsJO+/aXlUQvFwF1Y3ORhQ0SXBA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IzQKtRky; 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="IzQKtRky" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5EA3C4CECD; Thu, 17 Oct 2024 19:11:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729192288; bh=0xtQPuYsFx6+EaDmrN6skq2nN6sSjNCg3Y9AEFd1TbE=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=IzQKtRkyhb59kxYgg8/l1bti/M43OFRUwXnpPn2bsVQ0dFsCzjsdTb880/WytDO32 70XMLz5bNSKoUAywQ4a24mm+Y27BBolJHpQn4DUgNRYU7hKDk0VwhPUZQZDR6Ys2I1 +R9IyIOsLyQ9CD0FaN6VLD5JO6dfIKLDfvM8O69lJveJeE+7mAGoC8a/0dznRHjEak BptzZNkRw6RAS2Z7DWofLqY21TeeoTj9yFGyLFZxEiKX70rO0YmXSxxumpZXC3ysT1 9S6BN1Bnyuy2PCyBYf7aoZ/KFvPeL6HakjlBmqjyR1147GGWv0vzXadtKKj1IzJQo2 Pwobqj4CDavBA== Date: Thu, 17 Oct 2024 12:11:27 -0700 Subject: [PATCH 5/6] xfs: reserve quota for realtime files correctly From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <172919073164.3456016.15663661470844952824.stgit@frogsfrogsfrogs> In-Reply-To: <172919073062.3456016.13160926749424883839.stgit@frogsfrogsfrogs> References: <172919073062.3456016.13160926749424883839.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 Thu Oct 17 19:11:38 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: 13840750 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 DC48A21B45F for ; Thu, 17 Oct 2024 19:11:38 +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=1729192298; cv=none; b=LHLtExrqXFRIeaExS4+P1QxEwQfIYDWI3dz5E9jUQL7gAnBdalW3jOWvDfwFKWCURII/tjQ/rffrGUtIYvx7pT6HiRkEuDT3mR1R6ub8m4Qv0om2L5kowdmFJ1ZxfUYJ9aU64kyerR2YVzpm+AHV09F7bNfe+PBO2KoDgKPT774= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729192298; c=relaxed/simple; bh=UMdToS5oT8aELM+6cb9lj5eIzs+DwrmvIY32iezD7CU=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=T5OgjHxN1P1f58012xtHv2ULTfuyjBLJA0FDiPRWaOhr/Qwsso/bYgT5sgt1O2/GRTvfxTUD5ZQ31wGTShKhNKlVMAYQR7i++8GFNxq8IT1onr4rWUGPFfnkL06VOvzfViOUXHLo3I69EysfQ4gzJZ+NNPzUzis+MoZgOS5VEXo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rwKHog+P; 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="rwKHog+P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7816AC4CEC3; Thu, 17 Oct 2024 19:11:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729192298; bh=UMdToS5oT8aELM+6cb9lj5eIzs+DwrmvIY32iezD7CU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=rwKHog+PCDJAjy81dGsosgRbX7veweFOyh2jTKlvWrXrBRVl95vBigUYqOySEtXnk A+sylPNkR+uyNZLqHPI8yYhIEgzj+6wHUCyYS8cIcXSy8dV9VNytHAHB+XmlgO2WxB HmFzH9mOu6fbZDFOQfQhZ542w5oeB0eGjtTa5uC4MAuO97L40utU5UAPoULLC8ByPm nJMBWs2JsbwwRFFNQv4J8tO9KBxnbNLMsjwoLNFK+361Gs/D29tO1wFGHHV2/swFto ykaXmwzcJ1ins8eQ9FW+X/X+N9jcBd/1Lxz2+1JV4t24FicYDvoQx+URxqjDV9gITt 4oMi1nS9P+pIQ== Date: Thu, 17 Oct 2024 12:11:38 -0700 Subject: [PATCH 6/6] xfs: enable realtime quota again From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <172919073181.3456016.10141558876859300958.stgit@frogsfrogsfrogs> In-Reply-To: <172919073062.3456016.13160926749424883839.stgit@frogsfrogsfrogs> References: <172919073062.3456016.13160926749424883839.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 8a8210d45f4f03..845c1264456f77 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);