From patchwork Fri Dec 6 23:30:31 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: 13897929 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 C02111FCD18 for ; Fri, 6 Dec 2024 23:30:32 +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=1733527832; cv=none; b=ptfmtiyw4VZ7JVdofzfckllozqDcV9FYnPlcmnnh9P+zo9e2AX7u4SC4iI10JUHbsrNPQaV0MyBgo0+mXfGjJB4+2Rl9ElwdhTujT47M8tezpqiqjn9KC8iIGwYljGsLTbmqSrP+9MlOvZhpy6vHESN6VYxD96waECBP/R5C0kI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733527832; c=relaxed/simple; bh=d3Vu/YGQ49fxEhHmTCNaDmt+0LxGV0BHuA0IUFIHU7E=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tCAsSWaUQYqiMVQcErum78hVFydYOvkSy8fP3MoRCN/z6D8eP6kVokiOauIJUgu3uAA92tBG7Wa+EhmADfh2rWVKHwUqjADmNn6xoBaRwFm/aRTsOPNlqQ5HE7NXEmHIrcQuCk4RDLyiCXRrZ3KVo4gpsZ5+ryJsRFoO6pxGdY0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pRCxw5jX; 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="pRCxw5jX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C61DC4CED1; Fri, 6 Dec 2024 23:30:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733527832; bh=d3Vu/YGQ49fxEhHmTCNaDmt+0LxGV0BHuA0IUFIHU7E=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=pRCxw5jXsAzUicOQ2jAgDkgXJctqaUQETgSV93TMDAtdNBugHUEtzv/e9/hv5kA8e ivwgi1b+nctx4xHlcIZF9d4xCyS2FvuPIlK6yyUm6pjL2U0DZHegaoKjiXgUqNOIVz LNqzFJY5PuqzG2hPxxIZ1R+LkRO+nTyWsZZBkYcY4uGehunqEPPdXJceBDHM7q1DAT 76beCfG630LUNBONH0xJH+Y8Wzax/gPtR+2PMprMH+Utg3ro60ilDfoRHkwAzqda07 8jAlySJzK4gsDLisMurjqbO66YxdJma0zNfZgtWofdaWizsFTZ41qT0JJwnlUQJ9tB jL2wHT0rV06uQ== Date: Fri, 06 Dec 2024 15:30:31 -0800 Subject: [PATCH 01/36] xfs: remove the redundant xfs_alloc_log_agf From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: leo.lilong@huawei.com, dchinner@redhat.com, cem@kernel.org, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352746897.121772.5621271968296589393.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Long Li Source kernel commit: 8b9b261594d8ef218ef4d0e732dad153f82aab49 There are two invocations of xfs_alloc_log_agf in xfs_alloc_put_freelist. The AGF does not change between the two calls. Although this does not pose any practical problems, it seems like a small mistake. Therefore, fix it by removing the first xfs_alloc_log_agf invocation. Signed-off-by: Long Li Reviewed-by: Dave Chinner Signed-off-by: Carlos Maiolino --- libxfs/xfs_alloc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index f0635b17f18548..355f8ef1a872d3 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -3152,8 +3152,6 @@ xfs_alloc_put_freelist( logflags |= XFS_AGF_BTREEBLKS; } - xfs_alloc_log_agf(tp, agbp, logflags); - ASSERT(be32_to_cpu(agf->agf_flcount) <= xfs_agfl_size(mp)); agfl_bno = xfs_buf_to_agfl_bno(agflbp); From patchwork Fri Dec 6 23:30:47 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: 13897930 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 506131FBE80 for ; Fri, 6 Dec 2024 23:30:47 +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=1733527848; cv=none; b=V8wrBUQJHsOs+mmAKRlLMugjyu20nPn9WZ+9lRqnei/JeNMlV1wVNrpZVrV8K/p5y9XyQraJMcWFyqqCon5yyyxmeYi0TtyyxsBISVTm2dAWD6QvZ6xjU4s5fGAEcwijeE7Oetqf9mAqnVUolWAfANDBggjaCa7G90fCpMpGBMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733527848; c=relaxed/simple; bh=CtffnXfGf6THJ0fayY3LRBO/9ddE9d7SukxYgoSwDHg=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NKDHLTy6x2gmtHQew0uk/ouIg2QOfHl9UdJ85gx3SV7dcsWt+1s5eJBmBOevr6cWBRAZVIwAkXNVkhXhWVPnLMGAefoiRWi9KTUEHsqFH11YDWiopsqyW5vRoOkGfDlfzwCdPx5kLxKSSXORGJVoGyCDseSLovJiK8qCiWGDQqQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ucWqP0gS; 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="ucWqP0gS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1BFEC4CED1; Fri, 6 Dec 2024 23:30:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733527847; bh=CtffnXfGf6THJ0fayY3LRBO/9ddE9d7SukxYgoSwDHg=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ucWqP0gSqyum1JpLDb8QtBpn8wB7zgeCAI7lFikdLaQGk6fdfWghsV2YfVXdi2O2q OOfdZN8ryVVCd681lKO5nk9Vu2GyIDmQaeK9TN6yNKO8Z+2f7M+APOaKdt9GELiT8p Mf2vdy42TTAVxFfWbRDrlKExy77IJTc2VpctdC7vRLvpUccRdgxHlXCUWdo9LZwK5w s6+WIJgKy8DtzXGrpWbaQLhZwNSVUNmZc2FlnOcedA1Aoyb/Sk9lKaLhPFXew5N0PH o8GT+rg9pwtLjGEiapD2UjFvKx9wcC3dr1bd2FHxgnUAmZW9acp0SKm0TU5xdnmoK6 LdVaMeicWgdQQ== Date: Fri, 06 Dec 2024 15:30:47 -0800 Subject: [PATCH 02/36] xfs: sb_spino_align is not verified From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: dchinner@redhat.com, cem@kernel.org, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352746912.121772.17815430564700417233.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Dave Chinner Source kernel commit: 59e43f5479cce106d71c0b91a297c7ad1913176c It's just read in from the superblock and used without doing any validity checks at all on the value. Fixes: fb4f2b4e5a82 ("xfs: add sparse inode chunk alignment superblock field") Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Carlos Maiolino --- libxfs/xfs_sb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 0603e5087f2e46..0d98b8a344209e 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -395,6 +395,20 @@ xfs_validate_sb_common( sbp->sb_inoalignmt, align); return -EINVAL; } + + if (!sbp->sb_spino_align || + sbp->sb_spino_align > sbp->sb_inoalignmt || + (sbp->sb_inoalignmt % sbp->sb_spino_align) != 0) { + xfs_warn(mp, + "Sparse inode alignment (%u) is invalid.", + sbp->sb_spino_align); + return -EINVAL; + } + } else if (sbp->sb_spino_align) { + xfs_warn(mp, + "Sparse inode alignment (%u) should be zero.", + sbp->sb_spino_align); + return -EINVAL; } } else if (sbp->sb_qflags & (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) { From patchwork Fri Dec 6 23:31: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: 13897931 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 9660A19ABC6 for ; Fri, 6 Dec 2024 23:31: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=1733527863; cv=none; b=Qs5zc/XHR0hgzTy2CF88x2YjyUF0uhIe/ujTwcRrucwkjAvlH/4wyMSW66ObK6BPFKdMH5nZpibAEZ56pCQGhTC3Xs8alC42zmkaQ4EyoZcvYpH6+RMZDbu0+vmfxxOz+cvJLDE5wbioCu/hXKPF928PlVXQLWh9+nJ7xbfI6gY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733527863; c=relaxed/simple; bh=zOQwcc2ma2oaoCcJydH0vvlUBAvRdDbpRFDdFiF2sRg=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Yfob/QJUXg9gl97tYT9WkuVQ/AlHeJP3BZ3w3llbmAWIuy8JMeLu/LxBqaKCfkxCvdsL7Qb6oXwY89vNwI5bmEAyQrMWtTfxZf/HY2nQhIneMp2JZuyaQTML2clCgeuBpUZqkjaNJnbUUJRldC4YHmyfz2l8+iI/IY/2Up2pMi4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Kaj380/l; 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="Kaj380/l" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FB0BC4CED1; Fri, 6 Dec 2024 23:31:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733527863; bh=zOQwcc2ma2oaoCcJydH0vvlUBAvRdDbpRFDdFiF2sRg=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Kaj380/lCmzG7CZ/XB96AJOQvgoQrPq/OFXPM59cEsz5Qh1mTHu5X+UrxovL3d1D3 dmoDpBhxuZqFMljcq7Xanji6if3ox7mehmIEtfeMdnRzKpLLnYpkQe6NcF/nLhbLa3 2BRZA1Pi0Ws3Pjp/H1ps/DyGO7CY6q2e7SQFItYfNxWIQr4yCPU2btnBdzAmHCcNWJ YU2IyHoU0vXzuuwGA2LiRUaUMBzAhaXd9HE3XGHZ+ha7O2697l/hbjtiEiExvbIFd7 Mf3qJB66h/cK6koGa/KKh0t4FfJbVbmvXfTArVP9YqwZLUd7AbdVH8fBF/phuCaF26 hzW81wKewSInw== Date: Fri, 06 Dec 2024 15:31:03 -0800 Subject: [PATCH 03/36] xfs: remove the unused pagb_count field in struct xfs_perag From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352746928.121772.3549052117395667321.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: 4e071d79e477189a6c318f598634799e50921994 Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_ag.c | 1 - libxfs/xfs_ag.h | 1 - 2 files changed, 2 deletions(-) diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index 79ee483b42695a..975b139ca497a2 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -325,7 +325,6 @@ xfs_initialize_perag( xfs_defer_drain_init(&pag->pag_intents_drain); init_waitqueue_head(&pag->pagb_wait); init_waitqueue_head(&pag->pag_active_wq); - pag->pagb_count = 0; pag->pagb_tree = RB_ROOT; xfs_hooks_init(&pag->pag_rmap_update_hooks); #endif /* __KERNEL__ */ diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h index 9edfe0e9643964..79149a5ec44e9a 100644 --- a/libxfs/xfs_ag.h +++ b/libxfs/xfs_ag.h @@ -55,7 +55,6 @@ struct xfs_perag { xfs_agino_t pagl_leftrec; xfs_agino_t pagl_rightrec; - int pagb_count; /* pagb slots in use */ uint8_t pagf_refcount_level; /* recount btree height */ /* Blocks reserved for all kinds of metadata. */ From patchwork Fri Dec 6 23:31: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: 13897932 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 3639619ABC6 for ; Fri, 6 Dec 2024 23:31: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=1733527879; cv=none; b=VPHy8xAgbAe6OrF/IIar3pMtEN79LGHwf59B5k7lyZmR/D6gyEsh/7YXUl9y7uNs8XxOkyRNQxMacO3twMyFzBYGcJtUUGOWOJXRVAJM0VtoD2E+9PFpnBX0mqA6zQo/FlRDJmP0EHl8ezt32BUMqKHK3dQlTVQi/BFuS2RX/xk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733527879; c=relaxed/simple; bh=m62REzub7rkUjtm2kv5C6S/AAnYWC2c5oqlgxAiwkJM=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S2BYOzG4+PxyyHOHrsYX+UzJnYXTLZGL8dGevCFP+dB1N0Q/YQnYru1EPr+l7gm6cWYlu9VGaPvza8bD2R7g5X3H0bppdvZESc5dJ6uq9o08hypSQIiiYbDMQwvPfL1v/Mikg1P2Bm+HErnvNKWQjTRHrXiVJhsiOz5fYEhEAt4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dcNCyxFN; 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="dcNCyxFN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BEC3C4CED1; Fri, 6 Dec 2024 23:31:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733527879; bh=m62REzub7rkUjtm2kv5C6S/AAnYWC2c5oqlgxAiwkJM=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=dcNCyxFN6HRoHz7whsgYWSA90sFMzAKdIzC8IwpF9OUsab6uIpFblCaXq9wWTnRmm LKnkIakRe8gp94E0fW0CRn+ZSkjcYW7nSYZN3fXdpu+ylGza4tI9S0Lc9BPHURlljb hlqsRdBAM0DZFQwipcclte/NPOSBak1PF86cBt4OMSJAceHGWtj8K6nAkbf7ZDtl4i DeE+dmf4izkFWK9ArQXl9PjtHYTqReWZIamIoCKGM/QSaokliW7NHiIlJLEV9yusQa U+Fjr2TfQ/zkPajvzvZ9DaCkl7ubP5k8IR1GVjnSXWCvNg5TZF/9Y4J/xa0paDGmnR XorqN11j6QKuw== Date: Fri, 06 Dec 2024 15:31:18 -0800 Subject: [PATCH 04/36] xfs: remove the unused pag_active_wq field in struct xfs_perag From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352746943.121772.5882998905672943388.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: 9943b45732905a70496fc44368ab85b230c70db4 pag_active_wq is only woken, but never waited for. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_ag.c | 4 +--- libxfs/xfs_ag.h | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index 975b139ca497a2..62fc21fe7109b9 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -105,8 +105,7 @@ xfs_perag_rele( struct xfs_perag *pag) { trace_xfs_perag_rele(pag, _RET_IP_); - if (atomic_dec_and_test(&pag->pag_active_ref)) - wake_up(&pag->pag_active_wq); + atomic_dec(&pag->pag_active_ref); } /* @@ -324,7 +323,6 @@ xfs_initialize_perag( INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC); xfs_defer_drain_init(&pag->pag_intents_drain); init_waitqueue_head(&pag->pagb_wait); - init_waitqueue_head(&pag->pag_active_wq); pag->pagb_tree = RB_ROOT; xfs_hooks_init(&pag->pag_rmap_update_hooks); #endif /* __KERNEL__ */ diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h index 79149a5ec44e9a..958ca82524292f 100644 --- a/libxfs/xfs_ag.h +++ b/libxfs/xfs_ag.h @@ -34,7 +34,6 @@ struct xfs_perag { xfs_agnumber_t pag_agno; /* AG this structure belongs to */ atomic_t pag_ref; /* passive reference count */ atomic_t pag_active_ref; /* active reference count */ - wait_queue_head_t pag_active_wq;/* woken active_ref falls to zero */ unsigned long pag_opstate; uint8_t pagf_bno_level; /* # of levels in bno btree */ uint8_t pagf_cnt_level; /* # of levels in cnt btree */ From patchwork Fri Dec 6 23:31: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: 13897933 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 2F87619ABC6 for ; Fri, 6 Dec 2024 23:31: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=1733527895; cv=none; b=Ung2uHWL9+54TVxF9Kv70Y1WAZfQKLDwT7hhp84ZNk8KD/dll+0ygYUGaO+WfzfRrRnfdgX7vPApoJtXHnAN0saHoKeyDiLlneoKmJXZofDpVweaRMWCz1vfgKR/+0lk4JaSThagkxl5OidxBmFFaNbbFx+rYsEfRA2GUQlmZyo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733527895; c=relaxed/simple; bh=GfJ65CSgYgfbSRdIEUtWZHicj9onwQP8nkKgxveDk1k=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Qc/R/CeR5aMesoz/Ia2nt7FW9sKGkCAVUAn/dcFJpf5zAJEdzXkNmSTk2ryvNkS4UvYtiPsxdOYmOP5W5hqifSQnlr+DCdLctXxRwQRuOdn6dfF8QvOq5gOECM0LQgzt8JkBXuse0x4tfKk1EuxpfOt59uJrqag8g07P6DOgrmI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g+dJXkq1; 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="g+dJXkq1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAFA8C4CED1; Fri, 6 Dec 2024 23:31:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733527894; bh=GfJ65CSgYgfbSRdIEUtWZHicj9onwQP8nkKgxveDk1k=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=g+dJXkq1pkgEI4afRM/QSm75vandRLxUY6bvzilT6khI2ox8awEB/Cu5P1CuCLyTk z3OXSgAWszWjX74arDCQSiBCToePi4KouTE71PrBHlqv5M6zQipB2gjcsFjx76Rod+ 2KEF8yzGdbBEcGFoUfOmBPxgljmr3Zh0YYPF0E+tz7xTDF6+zTQyfx/yLckSTRYScN /39ZoXwO0Nrdy54DlFAw73XCtV8TQl0sQdUqZVMsZiCzl0+cp8NFFLpd5cgF+2QN6K bcRL/IIeBCfdQkHVoPMH+YYUaQ8RErodT5lNxla6fe8WluWPrKDPQhkU5fXN4f9l8/ HHQjANlhg6BvA== Date: Fri, 06 Dec 2024 15:31:34 -0800 Subject: [PATCH 05/36] xfs: pass a pag to xfs_difree_inode_chunk From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352746958.121772.13626400528946092757.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: 67ce5ba575354da1542e0579fb8c7a871cbf57b3 We'll want to use more than just the agno field in a bit. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_ialloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 43af698fa90903..10d88eb0b5bc32 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -1969,10 +1969,11 @@ xfs_dialloc( static int xfs_difree_inode_chunk( struct xfs_trans *tp, - xfs_agnumber_t agno, + struct xfs_perag *pag, struct xfs_inobt_rec_incore *rec) { struct xfs_mount *mp = tp->t_mountp; + xfs_agnumber_t agno = pag->pag_agno; xfs_agblock_t sagbno = XFS_AGINO_TO_AGBNO(mp, rec->ir_startino); int startidx, endidx; @@ -2143,7 +2144,7 @@ xfs_difree_inobt( goto error0; } - error = xfs_difree_inode_chunk(tp, pag->pag_agno, &rec); + error = xfs_difree_inode_chunk(tp, pag, &rec); if (error) goto error0; } else { From patchwork Fri Dec 6 23:31: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: 13897934 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 AF33519ABC6 for ; Fri, 6 Dec 2024 23:31: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=1733527910; cv=none; b=ifXQqN0AgbR6PQ9wyx4jO8oGYs/CAAsoszc83Bj9cPf8fYkSH8R5FHvCKy8a0sTaPYshUScT+QmA9UG/h0JFuK+ThjH3LqpM3OIaMmx5cqrekFYGBRJNAwCIuOL3/AbN+raLKQUH+QBVMAh7Iv1QKJtFiXVfiMwmct/4yWLKa6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733527910; c=relaxed/simple; bh=vrMPnrRaYRkiNdG4MiJxqqLdOmx09Sodwja2ZkB02Lc=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hAuwFFJ+biCAUomX79o6ycjvnoW5WH5BWEoxUKSWIPh9EkVn+AW8GBAmyKftFT1FwvNn84dMwH/xUfMc2EMX4st+b09pJMDVnhuLIPRYBuoNA1CBEvoGChDZVjS27IufHWgMOuqk6qTaNQ9fjGOLKg2BFN4ZaSDR6+AgS5osLiY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qlwrpCYl; 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="qlwrpCYl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D976C4CED1; Fri, 6 Dec 2024 23:31:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733527910; bh=vrMPnrRaYRkiNdG4MiJxqqLdOmx09Sodwja2ZkB02Lc=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=qlwrpCYlud1JgRjER5/Ct8gZWhSeMxqLOwRf7xgg5IzFi6JrdbLFej3pDDP/OY04I fatOrK/cYBvFG9GLVq/N17aIovmzz2xzUWOJDwC+v4nlim2QrIu+jcr4x1OlgUxraq vHTixM2kBnMAby3ilVDgbrZECtEjqiRYlgta0sTirpUuD5iDJhTjDXnWf+WITXNuJB fa8nFrL7Aeqsj8GrhMJuzDop09tEEiHdhSs4a1a+F9hIM0qDiA8T5kQUuyajngW9PZ bby/5nvdosMDzupunjJtyz/KmQLLDXfHsne973nIXF3yNlFuvXDw0YjLcvND05IGoL noNEGTzMKeoRA== Date: Fri, 06 Dec 2024 15:31:49 -0800 Subject: [PATCH 06/36] xfs: remove the agno argument to xfs_free_ag_extent From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352746974.121772.17151135890289334210.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: db129fa01113f767d5b7a6fd339114a962023464 xfs_free_ag_extent already has a pointer to the pag structure through the agf buffer. Use that instead of passing the redundant argument, and do the same for the tracepoint. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- include/xfs_trace.h | 2 +- libxfs/defer_item.c | 4 ++-- libxfs/xfs_alloc.c | 10 ++++------ libxfs/xfs_alloc.h | 5 ++--- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/include/xfs_trace.h b/include/xfs_trace.h index f6d6a6ea1af9e1..ba51419b3df3d3 100644 --- a/include/xfs_trace.h +++ b/include/xfs_trace.h @@ -79,7 +79,7 @@ #define trace_xfs_btree_free_block(...) ((void) 0) #define trace_xfs_btree_alloc_block(...) ((void) 0) -#define trace_xfs_free_extent(a,b,c,d,e,f,g) ((void) 0) +#define trace_xfs_free_extent(...) ((void) 0) #define trace_xfs_agf(a,b,c,d) ((void) 0) #define trace_xfs_read_agf(a,b) ((void) 0) #define trace_xfs_alloc_read_agf(a,b) ((void) 0) diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index 2b48ed14d67bcb..d5e075362ababe 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -181,8 +181,8 @@ xfs_agfl_free_finish_item( error = xfs_alloc_read_agf(xefi->xefi_pag, tp, 0, &agbp); if (!error) - error = xfs_free_ag_extent(tp, agbp, xefi->xefi_pag->pag_agno, - agbno, 1, &oinfo, XFS_AG_RESV_AGFL); + error = xfs_free_ag_extent(tp, agbp, agbno, 1, &oinfo, + XFS_AG_RESV_AGFL); xfs_extent_free_cancel_item(item); return error; diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index 355f8ef1a872d3..1f4740cced73a1 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -2033,7 +2033,6 @@ int xfs_free_ag_extent( struct xfs_trans *tp, struct xfs_buf *agbp, - xfs_agnumber_t agno, xfs_agblock_t bno, xfs_extlen_t len, const struct xfs_owner_info *oinfo, @@ -2354,19 +2353,19 @@ xfs_free_ag_extent( * Update the freespace totals in the ag and superblock. */ error = xfs_alloc_update_counters(tp, agbp, len); - xfs_ag_resv_free_extent(agbp->b_pag, type, tp, len); + xfs_ag_resv_free_extent(pag, type, tp, len); if (error) goto error0; XFS_STATS_INC(mp, xs_freex); XFS_STATS_ADD(mp, xs_freeb, len); - trace_xfs_free_extent(mp, agno, bno, len, type, haveleft, haveright); + trace_xfs_free_extent(pag, bno, len, type, haveleft, haveright); return 0; error0: - trace_xfs_free_extent(mp, agno, bno, len, type, -1, -1); + trace_xfs_free_extent(pag, bno, len, type, -1, -1); if (bno_cur) xfs_btree_del_cursor(bno_cur, XFS_BTREE_ERROR); if (cnt_cur) @@ -4006,8 +4005,7 @@ __xfs_free_extent( goto err_release; } - error = xfs_free_ag_extent(tp, agbp, pag->pag_agno, agbno, len, oinfo, - type); + error = xfs_free_ag_extent(tp, agbp, agbno, len, oinfo, type); if (error) goto err_release; diff --git a/libxfs/xfs_alloc.h b/libxfs/xfs_alloc.h index 0165452e7cd055..88fbce5001185f 100644 --- a/libxfs/xfs_alloc.h +++ b/libxfs/xfs_alloc.h @@ -79,9 +79,8 @@ int xfs_alloc_put_freelist(struct xfs_perag *pag, struct xfs_trans *tp, struct xfs_buf *agfbp, struct xfs_buf *agflbp, xfs_agblock_t bno, int btreeblk); int xfs_free_ag_extent(struct xfs_trans *tp, struct xfs_buf *agbp, - xfs_agnumber_t agno, xfs_agblock_t bno, - xfs_extlen_t len, const struct xfs_owner_info *oinfo, - enum xfs_ag_resv_type type); + xfs_agblock_t bno, xfs_extlen_t len, + const struct xfs_owner_info *oinfo, enum xfs_ag_resv_type type); /* * Compute and fill in value of m_alloc_maxlevels. From patchwork Fri Dec 6 23:32: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: 13897935 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 761B119ABC6 for ; Fri, 6 Dec 2024 23:32: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=1733527926; cv=none; b=V604qPJtIuFikEGokz15fAn9z/xvcY/4ev/xOnAGiiYw7nCfISnWVydOhUzpcnezIEYcXuFT9jJ7cIUczPCRIQ24JZ7QbmBFf6/mfJLM/jq+nQ/uaFZga1rvc7zr22aSxWJotIr+yTdqrmEyvvPW2JpjD5ZK7V84QPljdpETYbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733527926; c=relaxed/simple; bh=zU+OX1XUkgVzINUad+SN8IXdHhIu6ZcqKirMjtO0YjA=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UvI1k/QjsGSTthXnEKlUuh5f/r3FZ9caxaAPlDVgwouvCoeZfTRj3AoZUhkyMyp98uAVGcGFNpNRBSXbj/0CGnzWUuWV8wVIg/4npD+4NlcZiqI0khrwRIXC3I2qqJRgeSmDZNtvvM7m4gEy/gtELwbU7V15bXEC6V1P22DqoYQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iJLPXzCI; 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="iJLPXzCI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1447C4CED1; Fri, 6 Dec 2024 23:32:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733527925; bh=zU+OX1XUkgVzINUad+SN8IXdHhIu6ZcqKirMjtO0YjA=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=iJLPXzCIoj4ofMgSdab3z2UQKTdZgx8LVaGbeJXH2ApTR5gcsqj0Wk6JZzOazYRXz qOfNnfU2HyYrwGtPz8eYvQvqD642V1v5MjAPU6qNtVq4wBRjif/A7NYpeHz7JGU8JS Ikrm1vhfLIsx/AQ2fExM6IdGxofzdM3JND9dcpNHIzdf5KFm7kUyHzbgFgtm46dAuQ m0WVr+pfegHBJ2YGU2paGjbLSIpLh42HSABu+65gN+tyvQLbLRJKkXdPThhoY5W2Ww 5rmx1JQh/HmWy16Un9zqbvMLK/idklF22CBwBILmMyF5hdpRC3sE1F8ERvr2nqOHJE Hda5vG5ox4hqw== Date: Fri, 06 Dec 2024 15:32:05 -0800 Subject: [PATCH 07/36] xfs: add xfs_agbno_to_fsb and xfs_agbno_to_daddr helpers From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352746989.121772.17399100636055953099.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: 856a920ac2bbb2352ef6aa9e1e052f2e80677df7 Add helpers to convert an agbno to a daddr or fsbno based on a pag structure. This provides a simpler conversion and better type safety compared to the existing code that passes the mount structure and the agno separately. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_ag.c | 2 +- libxfs/xfs_ag.h | 16 ++++++++++++++++ libxfs/xfs_alloc.c | 14 ++++++-------- libxfs/xfs_btree.c | 7 +++---- libxfs/xfs_ialloc.c | 29 +++++++++++++---------------- libxfs/xfs_ialloc_btree.c | 2 +- libxfs/xfs_refcount.c | 11 ++++------- libxfs/xfs_refcount_btree.c | 3 +-- 8 files changed, 45 insertions(+), 39 deletions(-) diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index 62fc21fe7109b9..a6b5a7d71bbf80 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -867,7 +867,7 @@ xfs_ag_shrink_space( /* internal log shouldn't also show up in the free space btrees */ error = xfs_alloc_vextent_exact_bno(&args, - XFS_AGB_TO_FSB(mp, pag->pag_agno, aglen - delta)); + xfs_agbno_to_fsb(pag, aglen - delta)); if (!error && args.agbno == NULLAGBLOCK) error = -ENOSPC; diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h index 958ca82524292f..c0a30141ddc330 100644 --- a/libxfs/xfs_ag.h +++ b/libxfs/xfs_ag.h @@ -330,4 +330,20 @@ int xfs_ag_extend_space(struct xfs_perag *pag, struct xfs_trans *tp, xfs_extlen_t len); int xfs_ag_get_geometry(struct xfs_perag *pag, struct xfs_ag_geometry *ageo); +static inline xfs_fsblock_t +xfs_agbno_to_fsb( + struct xfs_perag *pag, + xfs_agblock_t agbno) +{ + return XFS_AGB_TO_FSB(pag->pag_mount, pag->pag_agno, agbno); +} + +static inline xfs_daddr_t +xfs_agbno_to_daddr( + struct xfs_perag *pag, + xfs_agblock_t agbno) +{ + return XFS_AGB_TO_DADDR(pag->pag_mount, pag->pag_agno, agbno); +} + #endif /* __LIBXFS_AG_H */ diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index 1f4740cced73a1..19b38eaf45dd07 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -1255,7 +1255,7 @@ xfs_alloc_ag_vextent_small( struct xfs_buf *bp; error = xfs_trans_get_buf(args->tp, args->mp->m_ddev_targp, - XFS_AGB_TO_DADDR(args->mp, args->agno, fbno), + xfs_agbno_to_daddr(args->pag, fbno), args->mp->m_bsize, 0, &bp); if (error) goto error; @@ -2929,9 +2929,8 @@ xfs_alloc_fix_freelist( * Deferring the free disconnects freeing up the AGFL slot from * freeing the block. */ - error = xfs_free_extent_later(tp, - XFS_AGB_TO_FSB(mp, args->agno, bno), 1, - &targs.oinfo, XFS_AG_RESV_AGFL, 0); + error = xfs_free_extent_later(tp, xfs_agbno_to_fsb(pag, bno), + 1, &targs.oinfo, XFS_AG_RESV_AGFL, 0); if (error) goto out_agbp_relse; } @@ -3590,7 +3589,7 @@ xfs_alloc_vextent_finish( goto out_drop_perag; } - args->fsbno = XFS_AGB_TO_FSB(mp, args->agno, args->agbno); + args->fsbno = xfs_agbno_to_fsb(args->pag, args->agbno); ASSERT(args->len >= args->minlen); ASSERT(args->len <= args->maxlen); @@ -3642,7 +3641,6 @@ xfs_alloc_vextent_this_ag( struct xfs_alloc_arg *args, xfs_agnumber_t agno) { - struct xfs_mount *mp = args->mp; xfs_agnumber_t minimum_agno; uint32_t alloc_flags = 0; int error; @@ -3655,8 +3653,8 @@ xfs_alloc_vextent_this_ag( trace_xfs_alloc_vextent_this_ag(args); - error = xfs_alloc_vextent_check_args(args, XFS_AGB_TO_FSB(mp, agno, 0), - &minimum_agno); + error = xfs_alloc_vextent_check_args(args, + xfs_agbno_to_fsb(args->pag, 0), &minimum_agno); if (error) { if (error == -ENOSPC) return 0; diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index bb53b6d7af22f6..4f04a92f6513bf 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -1015,21 +1015,20 @@ xfs_btree_readahead_agblock( struct xfs_btree_block *block) { struct xfs_mount *mp = cur->bc_mp; - xfs_agnumber_t agno = cur->bc_ag.pag->pag_agno; xfs_agblock_t left = be32_to_cpu(block->bb_u.s.bb_leftsib); xfs_agblock_t right = be32_to_cpu(block->bb_u.s.bb_rightsib); int rval = 0; if ((lr & XFS_BTCUR_LEFTRA) && left != NULLAGBLOCK) { xfs_buf_readahead(mp->m_ddev_targp, - XFS_AGB_TO_DADDR(mp, agno, left), + xfs_agbno_to_daddr(cur->bc_ag.pag, left), mp->m_bsize, cur->bc_ops->buf_ops); rval++; } if ((lr & XFS_BTCUR_RIGHTRA) && right != NULLAGBLOCK) { xfs_buf_readahead(mp->m_ddev_targp, - XFS_AGB_TO_DADDR(mp, agno, right), + xfs_agbno_to_daddr(cur->bc_ag.pag, right), mp->m_bsize, cur->bc_ops->buf_ops); rval++; } @@ -1089,7 +1088,7 @@ xfs_btree_ptr_to_daddr( switch (cur->bc_ops->type) { case XFS_BTREE_TYPE_AG: - *daddr = XFS_AGB_TO_DADDR(cur->bc_mp, cur->bc_ag.pag->pag_agno, + *daddr = xfs_agbno_to_daddr(cur->bc_ag.pag, be32_to_cpu(ptr->s)); break; case XFS_BTREE_TYPE_INODE: diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 10d88eb0b5bc32..6694ee2370411a 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -763,8 +763,7 @@ xfs_ialloc_ag_alloc( /* Allow space for the inode btree to split. */ args.minleft = igeo->inobt_maxlevels; error = xfs_alloc_vextent_exact_bno(&args, - XFS_AGB_TO_FSB(args.mp, pag->pag_agno, - args.agbno)); + xfs_agbno_to_fsb(pag, args.agbno)); if (error) return error; @@ -806,8 +805,8 @@ xfs_ialloc_ag_alloc( */ args.minleft = igeo->inobt_maxlevels; error = xfs_alloc_vextent_near_bno(&args, - XFS_AGB_TO_FSB(args.mp, pag->pag_agno, - be32_to_cpu(agi->agi_root))); + xfs_agbno_to_fsb(pag, + be32_to_cpu(agi->agi_root))); if (error) return error; } @@ -819,8 +818,8 @@ xfs_ialloc_ag_alloc( if (isaligned && args.fsbno == NULLFSBLOCK) { args.alignment = igeo->cluster_align; error = xfs_alloc_vextent_near_bno(&args, - XFS_AGB_TO_FSB(args.mp, pag->pag_agno, - be32_to_cpu(agi->agi_root))); + xfs_agbno_to_fsb(pag, + be32_to_cpu(agi->agi_root))); if (error) return error; } @@ -855,8 +854,8 @@ xfs_ialloc_ag_alloc( igeo->ialloc_blks; error = xfs_alloc_vextent_near_bno(&args, - XFS_AGB_TO_FSB(args.mp, pag->pag_agno, - be32_to_cpu(agi->agi_root))); + xfs_agbno_to_fsb(pag, + be32_to_cpu(agi->agi_root))); if (error) return error; @@ -1973,7 +1972,6 @@ xfs_difree_inode_chunk( struct xfs_inobt_rec_incore *rec) { struct xfs_mount *mp = tp->t_mountp; - xfs_agnumber_t agno = pag->pag_agno; xfs_agblock_t sagbno = XFS_AGINO_TO_AGBNO(mp, rec->ir_startino); int startidx, endidx; @@ -1984,8 +1982,7 @@ xfs_difree_inode_chunk( if (!xfs_inobt_issparse(rec->ir_holemask)) { /* not sparse, calculate extent info directly */ - return xfs_free_extent_later(tp, - XFS_AGB_TO_FSB(mp, agno, sagbno), + return xfs_free_extent_later(tp, xfs_agbno_to_fsb(pag, sagbno), M_IGEO(mp)->ialloc_blks, &XFS_RMAP_OINFO_INODES, XFS_AG_RESV_NONE, 0); } @@ -2031,9 +2028,9 @@ xfs_difree_inode_chunk( ASSERT(agbno % mp->m_sb.sb_spino_align == 0); ASSERT(contigblk % mp->m_sb.sb_spino_align == 0); - error = xfs_free_extent_later(tp, - XFS_AGB_TO_FSB(mp, agno, agbno), contigblk, - &XFS_RMAP_OINFO_INODES, XFS_AG_RESV_NONE, 0); + error = xfs_free_extent_later(tp, xfs_agbno_to_fsb(pag, agbno), + contigblk, &XFS_RMAP_OINFO_INODES, + XFS_AG_RESV_NONE, 0); if (error) return error; @@ -2503,7 +2500,7 @@ xfs_imap( offset = XFS_INO_TO_OFFSET(mp, ino); ASSERT(offset < mp->m_sb.sb_inopblock); - imap->im_blkno = XFS_AGB_TO_DADDR(mp, pag->pag_agno, agbno); + imap->im_blkno = xfs_agbno_to_daddr(pag, agbno); imap->im_len = XFS_FSB_TO_BB(mp, 1); imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog); @@ -2533,7 +2530,7 @@ xfs_imap( offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) + XFS_INO_TO_OFFSET(mp, ino); - imap->im_blkno = XFS_AGB_TO_DADDR(mp, pag->pag_agno, cluster_agbno); + imap->im_blkno = xfs_agbno_to_daddr(pag, cluster_agbno); imap->im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster); imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog); diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c index ffca4a80219d6d..f80368b4d5fa5f 100644 --- a/libxfs/xfs_ialloc_btree.c +++ b/libxfs/xfs_ialloc_btree.c @@ -119,7 +119,7 @@ __xfs_inobt_alloc_block( args.resv = resv; error = xfs_alloc_vextent_near_bno(&args, - XFS_AGB_TO_FSB(args.mp, args.pag->pag_agno, sbno)); + xfs_agbno_to_fsb(args.pag, sbno)); if (error) return error; diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 22f8afb27ece1c..eeddec68a08539 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -1153,8 +1153,7 @@ xfs_refcount_adjust_extents( goto out_error; } } else { - fsbno = XFS_AGB_TO_FSB(cur->bc_mp, - cur->bc_ag.pag->pag_agno, + fsbno = xfs_agbno_to_fsb(cur->bc_ag.pag, tmp.rc_startblock); error = xfs_free_extent_later(cur->bc_tp, fsbno, tmp.rc_blockcount, NULL, @@ -1216,8 +1215,7 @@ xfs_refcount_adjust_extents( } goto advloop; } else { - fsbno = XFS_AGB_TO_FSB(cur->bc_mp, - cur->bc_ag.pag->pag_agno, + fsbno = xfs_agbno_to_fsb(cur->bc_ag.pag, ext.rc_startblock); error = xfs_free_extent_later(cur->bc_tp, fsbno, ext.rc_blockcount, NULL, @@ -1319,7 +1317,7 @@ xfs_refcount_continue_op( return -EFSCORRUPTED; } - ri->ri_startblock = XFS_AGB_TO_FSB(mp, pag->pag_agno, new_agbno); + ri->ri_startblock = xfs_agbno_to_fsb(pag, new_agbno); ASSERT(xfs_verify_fsbext(mp, ri->ri_startblock, ri->ri_blockcount)); ASSERT(pag->pag_agno == XFS_FSB_TO_AGNO(mp, ri->ri_startblock)); @@ -1955,8 +1953,7 @@ xfs_refcount_recover_cow_leftovers( goto out_free; /* Free the orphan record */ - fsb = XFS_AGB_TO_FSB(mp, pag->pag_agno, - rr->rr_rrec.rc_startblock); + fsb = xfs_agbno_to_fsb(pag, rr->rr_rrec.rc_startblock); xfs_refcount_free_cow_extent(tp, fsb, rr->rr_rrec.rc_blockcount); diff --git a/libxfs/xfs_refcount_btree.c b/libxfs/xfs_refcount_btree.c index 9028dea06b0c07..5913f4176889ea 100644 --- a/libxfs/xfs_refcount_btree.c +++ b/libxfs/xfs_refcount_btree.c @@ -73,8 +73,7 @@ xfs_refcountbt_alloc_block( args.resv = XFS_AG_RESV_METADATA; error = xfs_alloc_vextent_near_bno(&args, - XFS_AGB_TO_FSB(args.mp, args.pag->pag_agno, - xfs_refc_block(args.mp))); + xfs_agbno_to_fsb(args.pag, xfs_refc_block(args.mp))); if (error) goto out_error; if (args.fsbno == NULLFSBLOCK) { From patchwork Fri Dec 6 23:32: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: 13897936 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 AF98819ABC6 for ; Fri, 6 Dec 2024 23:32: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=1733527941; cv=none; b=uq26Vl3UljuwGK0lfano+5Q3/eA67MT3P5AjGoHFUst98UR2DV7KIGFkDhfyJhRLdnH2cnd3jAD4ZEXmRvvSkl591BhMYDDi8/2T78BhRxxL3csDhW8O7NAC4+iYsMdWQlYoQy2h0c00tl7HWMPw+IYmn1qqLHkcSaBABHZB/0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733527941; c=relaxed/simple; bh=mJxq8u5Ig474T4JleUh06uBvfu1HTb+fZ8MAslQ8Ucw=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BeHdohbmmvRFFE7XfLBxZJhzdqW2WqbKv7x7XCnwiiF/ppne/jTtncyr5WyaCpt1L4CQaP+d0AG4hg0bQGljQD58MAqRH+Yp2G8VNuGTUl+egZzdRkv3fNaIsny/WaD3dezZ/6+aeX/itzY5qGiKC8E3TbrxnjXyHuo4ihVcCSg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cqR4M6SC; 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="cqR4M6SC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83CACC4CED1; Fri, 6 Dec 2024 23:32:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733527941; bh=mJxq8u5Ig474T4JleUh06uBvfu1HTb+fZ8MAslQ8Ucw=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=cqR4M6SCEAnFfuc4M8NIqV3PGcWLyWNp7KPs9lFZugQEemm7P3mdI8434xY0OtvAO Bz4sSEYp6yTACaGx9/xsKXII4wzFnxbMJUtXwsnGVOW0QvStNEQ/u0g5xXlv5/UvKc V+g71bT3QwPUphFMGtT7RJoqqCFSwhbeZKrCPNKNYlzwmZaXTZ92ehzN9iW3r3VzzI afX1R9khkwC06PVmgXYm3IUzyIMgri7qhXxggJ0BoMeUbGOYa5jp3dL0572i1zZgQL 881n+dXM42Mfj50UobpCAOAcJ7plDrqnzKVeOvNlav7sCFJY6rq9JSp1Oe0y2ajNdr iVNonf2X1ICmg== Date: Fri, 06 Dec 2024 15:32:21 -0800 Subject: [PATCH 08/36] xfs: add a xfs_agino_to_ino helper From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747005.121772.6563246433541426499.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: 6abd82ab6ea48430c13caebaad436ca6b5f2c34d Add a helpers to convert an agino to an ino based on a pag structure. This provides a simpler conversion and better type safety compared to the existing code that passes the mount structure and the agno separately. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_ag.h | 8 ++++++++ libxfs/xfs_ialloc.c | 24 +++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h index c0a30141ddc330..e0f567d90debee 100644 --- a/libxfs/xfs_ag.h +++ b/libxfs/xfs_ag.h @@ -346,4 +346,12 @@ xfs_agbno_to_daddr( return XFS_AGB_TO_DADDR(pag->pag_mount, pag->pag_agno, agbno); } +static inline xfs_ino_t +xfs_agino_to_ino( + struct xfs_perag *pag, + xfs_agino_t agino) +{ + return XFS_AGINO_TO_INO(pag->pag_mount, pag->pag_agno, agino); +} + #endif /* __LIBXFS_AG_H */ diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 6694ee2370411a..01b2e2d8c27c22 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -909,8 +909,7 @@ xfs_ialloc_ag_alloc( if (error == -EFSCORRUPTED) { xfs_alert(args.mp, "invalid sparse inode record: ino 0x%llx holemask 0x%x count %u", - XFS_AGINO_TO_INO(args.mp, pag->pag_agno, - rec.ir_startino), + xfs_agino_to_ino(pag, rec.ir_startino), rec.ir_holemask, rec.ir_count); xfs_force_shutdown(args.mp, SHUTDOWN_CORRUPT_INCORE); } @@ -1329,7 +1328,7 @@ xfs_dialloc_ag_inobt( ASSERT(offset < XFS_INODES_PER_CHUNK); ASSERT((XFS_AGINO_TO_OFFSET(mp, rec.ir_startino) % XFS_INODES_PER_CHUNK) == 0); - ino = XFS_AGINO_TO_INO(mp, pag->pag_agno, rec.ir_startino + offset); + ino = xfs_agino_to_ino(pag, rec.ir_startino + offset); if (xfs_ag_has_sickness(pag, XFS_SICK_AG_INODES)) { error = xfs_dialloc_check_ino(pag, tp, ino); @@ -1610,7 +1609,7 @@ xfs_dialloc_ag( ASSERT(offset < XFS_INODES_PER_CHUNK); ASSERT((XFS_AGINO_TO_OFFSET(mp, rec.ir_startino) % XFS_INODES_PER_CHUNK) == 0); - ino = XFS_AGINO_TO_INO(mp, pag->pag_agno, rec.ir_startino + offset); + ino = xfs_agino_to_ino(pag, rec.ir_startino + offset); if (xfs_ag_has_sickness(pag, XFS_SICK_AG_INODES)) { error = xfs_dialloc_check_ino(pag, tp, ino); @@ -2117,8 +2116,7 @@ xfs_difree_inobt( if (!xfs_has_ikeep(mp) && rec.ir_free == XFS_INOBT_ALL_FREE && mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK) { xic->deleted = true; - xic->first_ino = XFS_AGINO_TO_INO(mp, pag->pag_agno, - rec.ir_startino); + xic->first_ino = xfs_agino_to_ino(pag, rec.ir_startino); xic->alloc = xfs_inobt_irec_to_allocmask(&rec); /* @@ -2317,10 +2315,10 @@ xfs_difree( return -EINVAL; } agino = XFS_INO_TO_AGINO(mp, inode); - if (inode != XFS_AGINO_TO_INO(mp, pag->pag_agno, agino)) { - xfs_warn(mp, "%s: inode != XFS_AGINO_TO_INO() (%llu != %llu).", + if (inode != xfs_agino_to_ino(pag, agino)) { + xfs_warn(mp, "%s: inode != xfs_agino_to_ino() (%llu != %llu).", __func__, (unsigned long long)inode, - (unsigned long long)XFS_AGINO_TO_INO(mp, pag->pag_agno, agino)); + (unsigned long long)xfs_agino_to_ino(pag, agino)); ASSERT(0); return -EINVAL; } @@ -2451,7 +2449,7 @@ xfs_imap( agino = XFS_INO_TO_AGINO(mp, ino); agbno = XFS_AGINO_TO_AGBNO(mp, agino); if (agbno >= mp->m_sb.sb_agblocks || - ino != XFS_AGINO_TO_INO(mp, pag->pag_agno, agino)) { + ino != xfs_agino_to_ino(pag, agino)) { error = -EINVAL; #ifdef DEBUG /* @@ -2466,11 +2464,11 @@ xfs_imap( __func__, (unsigned long long)agbno, (unsigned long)mp->m_sb.sb_agblocks); } - if (ino != XFS_AGINO_TO_INO(mp, pag->pag_agno, agino)) { + if (ino != xfs_agino_to_ino(pag, agino)) { xfs_alert(mp, - "%s: ino (0x%llx) != XFS_AGINO_TO_INO() (0x%llx)", + "%s: ino (0x%llx) != xfs_agino_to_ino() (0x%llx)", __func__, ino, - XFS_AGINO_TO_INO(mp, pag->pag_agno, agino)); + xfs_agino_to_ino(pag, agino)); } xfs_stack_trace(); #endif /* DEBUG */ From patchwork Fri Dec 6 23:32:36 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: 13897937 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 E799B19ABC6 for ; Fri, 6 Dec 2024 23:32:37 +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=1733527959; cv=none; b=XLhPd7hxZZY2jB9rbhaNZ7yS97KT6m7JmeZeTjAgReDReUGutgPuidkwOGXTY3vZGzX+3FpQL/eIjk2o0bRU0LEuxYN+8acFEs9uxqWUn8yL4Z8QN0UBx2q4TcbnQv8Sec8D9rEgHLqRj5Gwp0TWNziymFhXMIoLrGqHeoe8vhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733527959; c=relaxed/simple; bh=KEhSsLTnaY7UnBeoreGM63Inqj2K6baPa++qObMUUEY=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bJnCh50XzIsZoUEg+CFXevfwBQVMZBxjkhRu4bruWyGtK9j6mplIRpoJQpu+oOPu64DjR5NJP9G9P/DTjOB6E7uHh+9CXopZcgsplARJONmsLIlUNibJzsYHO5afKY9R/DmY3oTL4/qK9/QzkScjvu4NwRAlHFjG8XqIy4jIDpI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bjfa1Yfx; 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="bjfa1Yfx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B036C4CED1; Fri, 6 Dec 2024 23:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733527957; bh=KEhSsLTnaY7UnBeoreGM63Inqj2K6baPa++qObMUUEY=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=bjfa1YfxsYsimYm8jYEOeohLIdhktXA/9dGxnxOR6tuQQvpKAhzy7XD6cxPsGXS/m FbOiQqmiKTubHc6+Zo52IP27fVG/q2lW9nPGrgRvlyDorUvtOGPBgfnv5/VlHBdM7U knHTAnh3T370uFnbBWpfuETTYXcBxGniPAWL7vlHp+x+VKeraDCe1kzE6zxFaQmMEr 7+0ELa8R0h6PzAob7uoiMyE3S33ryuFrCnKzXGRVYPglvKZT2yQTE/fsf58DlWYqyA dQmBQWlskMTQAHwjxS/gMeJCDd8wuZ16Io4RsaZOpnE6SuogI1baWG1UF984COXYa7 1EMhwAUDj5bbA== Date: Fri, 06 Dec 2024 15:32:36 -0800 Subject: [PATCH 09/36] xfs: pass a pag to xfs_extent_busy_{search,reuse} From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747020.121772.7695574959492573033.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: b6dc8c6dd2d3f230e1a554f869d6df4568a2dfbb Replace the [mp,agno] tuple with the perag structure, which will become more useful later. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/libxfs_priv.h | 2 +- libxfs/xfs_alloc.c | 4 ++-- libxfs/xfs_alloc_btree.c | 2 +- libxfs/xfs_rmap_btree.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 97f5003ea53862..9505806131bc42 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -465,7 +465,7 @@ xfs_buf_readahead( #define XFS_EXTENT_BUSY_DISCARDED 0x01 /* undergoing a discard op. */ #define XFS_EXTENT_BUSY_SKIP_DISCARD 0x02 /* do not discard */ -#define xfs_extent_busy_reuse(mp,ag,bno,len,user) ((void) 0) +#define xfs_extent_busy_reuse(...) ((void) 0) /* avoid unused variable warning */ #define xfs_extent_busy_insert(tp,pag,bno,len,flags)({ \ struct xfs_perag *__foo = pag; \ diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index 19b38eaf45dd07..ed04e40856740b 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -1248,7 +1248,7 @@ xfs_alloc_ag_vextent_small( if (fbno == NULLAGBLOCK) goto out; - xfs_extent_busy_reuse(args->mp, args->pag, fbno, 1, + xfs_extent_busy_reuse(args->pag, fbno, 1, (args->datatype & XFS_ALLOC_NOBUSY)); if (args->datatype & XFS_ALLOC_USERDATA) { @@ -3610,7 +3610,7 @@ xfs_alloc_vextent_finish( if (error) goto out_drop_perag; - ASSERT(!xfs_extent_busy_search(mp, args->pag, args->agbno, + ASSERT(!xfs_extent_busy_search(args->pag, args->agbno, args->len)); } diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c index 4a711f2463cd30..949cd18ab16a99 100644 --- a/libxfs/xfs_alloc_btree.c +++ b/libxfs/xfs_alloc_btree.c @@ -84,7 +84,7 @@ xfs_allocbt_alloc_block( } atomic64_inc(&cur->bc_mp->m_allocbt_blks); - xfs_extent_busy_reuse(cur->bc_mp, cur->bc_ag.pag, bno, 1, false); + xfs_extent_busy_reuse(cur->bc_ag.pag, bno, 1, false); new->s = cpu_to_be32(bno); diff --git a/libxfs/xfs_rmap_btree.c b/libxfs/xfs_rmap_btree.c index ada58e92645020..c261d6eae3bc3b 100644 --- a/libxfs/xfs_rmap_btree.c +++ b/libxfs/xfs_rmap_btree.c @@ -101,7 +101,7 @@ xfs_rmapbt_alloc_block( return 0; } - xfs_extent_busy_reuse(cur->bc_mp, pag, bno, 1, false); + xfs_extent_busy_reuse(pag, bno, 1, false); new->s = cpu_to_be32(bno); be32_add_cpu(&agf->agf_rmap_blocks, 1); From patchwork Fri Dec 6 23:32:52 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: 13897938 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 325E619ABC6 for ; Fri, 6 Dec 2024 23:32:53 +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=1733527973; cv=none; b=cUN5HVjS04GBLHvFVEJtmEjNUsTG2JKwK4iN3Inb047u02z8LIuNueLhezmVRLpMWcmBI4qbBsMXDUzbtubWuFs5ydxtav1RVGA+KvMesHAJb1XsD2P9Ec0FBV/FP50zdM4WdmxbqfmWVUexVsRenH/+QueBzIyfVA0AcPSp/mc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733527973; c=relaxed/simple; bh=8T4uZ7gG3nMLVdc9LmI9tmDtQNJDJE1GMr6WjWuYkUc=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LqwiiPg0axypR7PiD01p/HEazrmABXWsWgqDk446ql317LfBMvCmugaKCks206kzX4oztgPNoMqDBvCxInop4MD7S3lx8JQ4s38SlNfahBj4Gz2gOuBUXVavuiahdNnZB+nYWIZmvOONPVg8X9EMuhgkW0BYyvF8WHxamBGi1Lc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q8TyMfpq; 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="Q8TyMfpq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C359C4CED1; Fri, 6 Dec 2024 23:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733527973; bh=8T4uZ7gG3nMLVdc9LmI9tmDtQNJDJE1GMr6WjWuYkUc=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Q8TyMfpq1gMhP92kT/DhP+NcFzX2K8zMaNHvkYIOiS8GZXmIH808Q8mZUmxzOomDQ 3SEiyfJ7KkRYOnrWYqofeD5bzb/WN2tqSxmL4a1GsIj3NW+i3bakb0B82PGX6LkCqr ODixVgul64PqhJUGcQkY0lfIrtFumR6VifQ6vXM+YBNBGZeM0TWZhbOqvAhQdgTuoY HgKZQt5B8hyEUifwGKpXysdxA7lecDNs6oatdmiqpSV/xuFu5ALxWMxreXCpBd/YVW F7phUlnQdMrQBtkU13R91dtbfx2xbjfX22FwC3YQnltdHpszrpb+EuBS3gUKC1HeTQ BHL1Cs1kXxvkA== Date: Fri, 06 Dec 2024 15:32:52 -0800 Subject: [PATCH 10/36] xfs: pass a perag structure to the xfs_ag_resv_init_error trace point From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747035.121772.10444497231852416605.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: 835ddb592fab75ed96828ee3f12ea44496882d6b And remove the single instance class indirection for it. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_ag_resv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libxfs/xfs_ag_resv.c b/libxfs/xfs_ag_resv.c index 7e5cbe0cb6afd3..d1657d6c636546 100644 --- a/libxfs/xfs_ag_resv.c +++ b/libxfs/xfs_ag_resv.c @@ -205,8 +205,7 @@ __xfs_ag_resv_init( else error = xfs_dec_fdblocks(mp, hidden_space, true); if (error) { - trace_xfs_ag_resv_init_error(pag->pag_mount, pag->pag_agno, - error, _RET_IP_); + trace_xfs_ag_resv_init_error(pag, error, _RET_IP_); xfs_warn(mp, "Per-AG reservation for AG %u failed. Filesystem may run out of space.", pag->pag_agno); From patchwork Fri Dec 6 23:33:08 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: 13897939 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 CFAB019ABC6 for ; Fri, 6 Dec 2024 23:33:08 +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=1733527988; cv=none; b=s68dw69LoMHbmhmIA+ptIZEKeWMIjv3o1vCDJnmANgSiQXbZONtc7ZLWDNahnRySQb/jVciMpRb0kNym23sWG1jylvOE+1zC746ud+H7WQ8clNyZMZj7XTiD7xUATDt/4bSn8T6YkoUFsbotTaJZtS463SGoxKEAlK9tRy1TstE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733527988; c=relaxed/simple; bh=NGvDRMBLvP9BJGTwSqiDYz4TMwxEiPGpkTwPVPUp7RQ=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z4FFp03MHjI4Yry+N9khUFiIRHM56GTQD7SKEadCMZk1WWuZ50SWWoJApaqfc6Gs7FVd/ZTOx687FVCBlllYfig1O7vpry2ic/0WUVR3ThqqOsx4ITxBiM9/JDFOfm4XJJ/ozRkrO8SPeiUH4/8DEBaQcWjcK8kc8ZpgAUup9tM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IQ3E93Zi; 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="IQ3E93Zi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7D19C4CED1; Fri, 6 Dec 2024 23:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733527988; bh=NGvDRMBLvP9BJGTwSqiDYz4TMwxEiPGpkTwPVPUp7RQ=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=IQ3E93ZiewGb7wFWcZ8fIId7CeBfhEApjmNOHhnkcuYkBDmn66M+sv+QAX0z8cL19 fmFcZp4k0WqdbNIbBftORK4oYVcGIu3UpoesGAN1SoKLV8qgEtmhS0+DQmel6e5JwD GjSJA9k2tdmhNihspkOuLTOzoEQSsqesILpnjAKhNL85B3/l/o2asXdAzVZ+NP5hKC ch6epBItEUe2MICaxKE9Z1bRHM6eCONbVY8PYomrDGE3v6btRzkijHF35wm4ay4FEJ dFxwAV2ctzKjdSs/FIsb0LiaFmB86RPTeFoONtF5lVQsCbMwcr56boiKg8keBF3z4X NGLloMpI0CS1g== Date: Fri, 06 Dec 2024 15:33:08 -0800 Subject: [PATCH 11/36] xfs: pass objects to the xfs_irec_merge_{pre,post} trace points From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747050.121772.11443088190171169129.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: 487092ceaa72448ca3a82ea9fb89768c88f6abec Pass the perag structure and the irec to these tracepoints so that the decoding is only done when tracing is actually enabled and the call sites look a lot neater. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- include/xfs_trace.h | 4 ++-- libxfs/xfs_ialloc.c | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/include/xfs_trace.h b/include/xfs_trace.h index ba51419b3df3d3..0986e1621437d4 100644 --- a/include/xfs_trace.h +++ b/include/xfs_trace.h @@ -85,8 +85,8 @@ #define trace_xfs_alloc_read_agf(a,b) ((void) 0) #define trace_xfs_read_agi(a,b) ((void) 0) #define trace_xfs_ialloc_read_agi(a,b) ((void) 0) -#define trace_xfs_irec_merge_pre(a,b,c,d,e,f) ((void) 0) -#define trace_xfs_irec_merge_post(a,b,c,d) ((void) 0) +#define trace_xfs_irec_merge_pre(...) ((void) 0) +#define trace_xfs_irec_merge_post(...) ((void) 0) #define trace_xfs_iext_insert(a,b,c,d) ((void) 0) #define trace_xfs_iext_remove(a,b,c,d) ((void) 0) diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 01b2e2d8c27c22..b3d6f7f4212588 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -601,15 +601,12 @@ xfs_inobt_insert_sprec( goto error; } - trace_xfs_irec_merge_pre(mp, pag->pag_agno, rec.ir_startino, - rec.ir_holemask, nrec->ir_startino, - nrec->ir_holemask); + trace_xfs_irec_merge_pre(pag, &rec, nrec); /* merge to nrec to output the updated record */ __xfs_inobt_rec_merge(nrec, &rec); - trace_xfs_irec_merge_post(mp, pag->pag_agno, nrec->ir_startino, - nrec->ir_holemask); + trace_xfs_irec_merge_post(pag, nrec); error = xfs_inobt_rec_check_count(mp, nrec); if (error) From patchwork Fri Dec 6 23:33:23 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: 13897940 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 7609119ABC6 for ; Fri, 6 Dec 2024 23:33:24 +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=1733528004; cv=none; b=XDghvouf2s4HyJY0fdw0LRhiYD9X7+Xt5H/jieNGnFzhWMxaZ7IOIf8qPHfhP4eG9Xbo3HffTDOUBu8rFLu7WwPtjKQU/n9fxeA25uS/qssiM7i0OFBLPlT+JME9e0vSxlN1S2vUD0Haf7fndEdCnY/W+WM8P0Z+vfG727+Rrr0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528004; c=relaxed/simple; bh=0fY6gMu+rHt8126cgZ0KY+hYhAZW3qU5Dl2vTVDU6sM=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FkwMowJp/dwWNx+9BQkoEsNldOIU0LsnBFAvdoPcTVuCFpy/KHSQG1HRMExKkSbAfxT8HXgwixg/6nXX4vQ8w7nhw2C1lwLC0lIbYGRd2JA+4434Z3tFJ7AZq9MPkpPZg5kVKYtWJQ1QmnMQ4b4lglHWzRgkYt2EZOQb5s+u8NI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZmQwRt6I; 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="ZmQwRt6I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45C34C4CED2; Fri, 6 Dec 2024 23:33:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528004; bh=0fY6gMu+rHt8126cgZ0KY+hYhAZW3qU5Dl2vTVDU6sM=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ZmQwRt6IIZR8AgiIvTn3u+o0cyEwlRGNHWe3daHCOsbDSxlEEtG30w7v8qPnEYuSv kw9U+/uAjNIGZ4CXQRaAtQfKtkEfAJJr4PH575/HWy1gKLlc599/kfnqrLmjet4BIY 1DSKPOF7jls1bg+trv8plV66zXzeiOP1VP9cF/qCgI2aUXhIO+prcpLVFl9Sb68jkL xFf9ZIo8RyxrkeiLWK0r6J2+wGP9Eu0l86U4uSOd0hmm36Zi31usqmySlcNCLo5Q/I 9Vq3seEN8oMLodCGmwTQpr+UNdLw4xOVfudGpY+DMWL7+m6RJmBbFeyYYilsETSh4T +8sQcMTkO+j4Q== Date: Fri, 06 Dec 2024 15:33:23 -0800 Subject: [PATCH 12/36] xfs: convert remaining trace points to pass pag structures From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747065.121772.10878241875389916748.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: c4ae021bcb6bf8bbb329ce8ef947a43009bc2fe4 Convert all tracepoints that take [mp,agno] tuples to take a pag argument instead so that decoding only happens when tracepoints are enabled and to clean up the callers. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- include/xfs_trace.h | 8 ++++---- libxfs/xfs_alloc.c | 4 ++-- libxfs/xfs_ialloc.c | 4 ++-- libxfs/xfs_inode_util.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/xfs_trace.h b/include/xfs_trace.h index 0986e1621437d4..012e0018cb8367 100644 --- a/include/xfs_trace.h +++ b/include/xfs_trace.h @@ -81,10 +81,10 @@ #define trace_xfs_free_extent(...) ((void) 0) #define trace_xfs_agf(a,b,c,d) ((void) 0) -#define trace_xfs_read_agf(a,b) ((void) 0) -#define trace_xfs_alloc_read_agf(a,b) ((void) 0) -#define trace_xfs_read_agi(a,b) ((void) 0) -#define trace_xfs_ialloc_read_agi(a,b) ((void) 0) +#define trace_xfs_read_agf(...) ((void) 0) +#define trace_xfs_alloc_read_agf(...) ((void) 0) +#define trace_xfs_read_agi(...) ((void) 0) +#define trace_xfs_ialloc_read_agi(...) ((void) 0) #define trace_xfs_irec_merge_pre(...) ((void) 0) #define trace_xfs_irec_merge_post(...) ((void) 0) diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index ed04e40856740b..bd39bcde0ea224 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -3354,7 +3354,7 @@ xfs_read_agf( struct xfs_mount *mp = pag->pag_mount; int error; - trace_xfs_read_agf(pag->pag_mount, pag->pag_agno); + trace_xfs_read_agf(pag); error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, XFS_AG_DADDR(mp, pag->pag_agno, XFS_AGF_DADDR(mp)), @@ -3385,7 +3385,7 @@ xfs_alloc_read_agf( int error; int allocbt_blks; - trace_xfs_alloc_read_agf(pag->pag_mount, pag->pag_agno); + trace_xfs_alloc_read_agf(pag); /* We don't support trylock when freeing. */ ASSERT((flags & (XFS_ALLOC_FLAG_FREEING | XFS_ALLOC_FLAG_TRYLOCK)) != diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index b3d6f7f4212588..4f087e6b074081 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -2724,7 +2724,7 @@ xfs_read_agi( struct xfs_mount *mp = pag->pag_mount; int error; - trace_xfs_read_agi(pag->pag_mount, pag->pag_agno); + trace_xfs_read_agi(pag); error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, XFS_AG_DADDR(mp, pag->pag_agno, XFS_AGI_DADDR(mp)), @@ -2755,7 +2755,7 @@ xfs_ialloc_read_agi( struct xfs_agi *agi; int error; - trace_xfs_ialloc_read_agi(pag->pag_mount, pag->pag_agno); + trace_xfs_ialloc_read_agi(pag); error = xfs_read_agi(pag, tp, (flags & XFS_IALLOC_FLAG_TRYLOCK) ? XBF_TRYLOCK : 0, diff --git a/libxfs/xfs_inode_util.c b/libxfs/xfs_inode_util.c index 92bfdf0715f02e..f9f16c7e2d0788 100644 --- a/libxfs/xfs_inode_util.c +++ b/libxfs/xfs_inode_util.c @@ -439,8 +439,8 @@ xfs_iunlink_update_bucket( ASSERT(xfs_verify_agino_or_null(pag, new_agino)); old_value = be32_to_cpu(agi->agi_unlinked[bucket_index]); - trace_xfs_iunlink_update_bucket(tp->t_mountp, pag->pag_agno, bucket_index, - old_value, new_agino); + trace_xfs_iunlink_update_bucket(pag, bucket_index, old_value, + new_agino); /* * We should never find the head of the list already set to the value From patchwork Fri Dec 6 23:33:39 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: 13897941 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 03D6519ABC6 for ; Fri, 6 Dec 2024 23:33:40 +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=1733528020; cv=none; b=Kl3vJGO77fAdCkWrCtKEYAkSDixOQCw50HFtyj5lr8WO9xv/IuGKHa3TFMvWc5g96NWCLrTXjOe9q38fsMQnoNiisIdqcPHpR1R2Lillqg5BOTWEFUTv6SPJNNCFNDVRO+7FNeFyTLpQj2QHoKX4G26m75kIMK513u3QJ+7xfV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528020; c=relaxed/simple; bh=aaU/ItFh4ML8lKga//9VnJCvPUjNn47R20Qd2exN4TY=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IvVYJl+fAkUcbL8qxCBHO/kLho31JC1CJQsRTmzQfYfDOZUNrJyGxzyobznlnKbFq9LlXtyDhG/Z41iQ+5lp/QsYcJw/ccVOqL//MX79PE9hL64/EV4a8nn/AYyhs5yQECPmh2qDo2ruwEMFwr3UjfHytE6mtt3Td0bGUJBk3c8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OltBgvLW; 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="OltBgvLW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D077FC4CED1; Fri, 6 Dec 2024 23:33:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528019; bh=aaU/ItFh4ML8lKga//9VnJCvPUjNn47R20Qd2exN4TY=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=OltBgvLWbDKtzeD5jiFX3rN6HSFcdfsXtKKg2z5jf106lH3w+1fVBzcVjSg54KP1I XAnqUO/bBODAiI30YakIBGVT9Djx4LoiZ77fhxzgrLEtyUv+ytq1gF3l05nXB6pnaX sHzniAahWdXMBQi97KpSGt6tiIv+wPUkdObVyKCyTXQTSFDKswWDkRZoo8rA1SAI9V s/Er5MMCFhbNPjw/epJUUPapqcrMbQoh/36sa/N9g7dr3OXhBYPCPj+DnDwX8V51O0 t6UTkbYj2tKglHcopFx3RMd/9Suj5m89yw36ad3NZ2ryi5Wywyo6xKm853C2ZbiCNL 8zrkdmZeYSSLg== Date: Fri, 06 Dec 2024 15:33:39 -0800 Subject: [PATCH 13/36] xfs: split xfs_initialize_perag From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747080.121772.867951615956948252.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: 201c5fa342af75adaf762fd6c63380bb8001762d Factor out a xfs_perag_alloc helper that allocates a single perag structure. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_ag.c | 121 ++++++++++++++++++++++++++++++++----------------------- libxfs/xfs_ag.h | 4 +- 2 files changed, 72 insertions(+), 53 deletions(-) diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index a6b5a7d71bbf80..8809d76d496ae9 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -270,6 +270,10 @@ xfs_agino_range( return __xfs_agino_range(mp, xfs_ag_block_count(mp, agno), first, last); } +/* + * Update the perag of the previous tail AG if it has been changed during + * recovery (i.e. recovery of a growfs). + */ int xfs_update_last_ag_size( struct xfs_mount *mp, @@ -287,69 +291,57 @@ xfs_update_last_ag_size( return 0; } -int -xfs_initialize_perag( +static int +xfs_perag_alloc( struct xfs_mount *mp, - xfs_agnumber_t old_agcount, - xfs_agnumber_t new_agcount, - xfs_rfsblock_t dblocks, - xfs_agnumber_t *maxagi) + xfs_agnumber_t index, + xfs_agnumber_t agcount, + xfs_rfsblock_t dblocks) { struct xfs_perag *pag; - xfs_agnumber_t index; int error; - for (index = old_agcount; index < new_agcount; index++) { - pag = kzalloc(sizeof(*pag), GFP_KERNEL); - if (!pag) { - error = -ENOMEM; - goto out_unwind_new_pags; - } - pag->pag_agno = index; - pag->pag_mount = mp; + pag = kzalloc(sizeof(*pag), GFP_KERNEL); + if (!pag) + return -ENOMEM; - error = xa_insert(&mp->m_perags, index, pag, GFP_KERNEL); - if (error) { - WARN_ON_ONCE(error == -EBUSY); - goto out_free_pag; - } + pag->pag_agno = index; + pag->pag_mount = mp; + + error = xa_insert(&mp->m_perags, index, pag, GFP_KERNEL); + if (error) { + WARN_ON_ONCE(error == -EBUSY); + goto out_free_pag; + } #ifdef __KERNEL__ - /* Place kernel structure only init below this point. */ - spin_lock_init(&pag->pag_ici_lock); - spin_lock_init(&pag->pagb_lock); - spin_lock_init(&pag->pag_state_lock); - INIT_DELAYED_WORK(&pag->pag_blockgc_work, xfs_blockgc_worker); - INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC); - xfs_defer_drain_init(&pag->pag_intents_drain); - init_waitqueue_head(&pag->pagb_wait); - pag->pagb_tree = RB_ROOT; - xfs_hooks_init(&pag->pag_rmap_update_hooks); + /* Place kernel structure only init below this point. */ + spin_lock_init(&pag->pag_ici_lock); + spin_lock_init(&pag->pagb_lock); + spin_lock_init(&pag->pag_state_lock); + INIT_DELAYED_WORK(&pag->pag_blockgc_work, xfs_blockgc_worker); + INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC); + xfs_defer_drain_init(&pag->pag_intents_drain); + init_waitqueue_head(&pag->pagb_wait); + pag->pagb_tree = RB_ROOT; + xfs_hooks_init(&pag->pag_rmap_update_hooks); #endif /* __KERNEL__ */ - error = xfs_buf_cache_init(&pag->pag_bcache); - if (error) - goto out_remove_pag; + error = xfs_buf_cache_init(&pag->pag_bcache); + if (error) + goto out_remove_pag; - /* Active ref owned by mount indicates AG is online. */ - atomic_set(&pag->pag_active_ref, 1); + /* Active ref owned by mount indicates AG is online. */ + atomic_set(&pag->pag_active_ref, 1); - /* - * Pre-calculated geometry - */ - pag->block_count = __xfs_ag_block_count(mp, index, new_agcount, - dblocks); - pag->min_block = XFS_AGFL_BLOCK(mp); - __xfs_agino_range(mp, pag->block_count, &pag->agino_min, - &pag->agino_max); - } + /* + * Pre-calculated geometry + */ + pag->block_count = __xfs_ag_block_count(mp, index, agcount, dblocks); + pag->min_block = XFS_AGFL_BLOCK(mp); + __xfs_agino_range(mp, pag->block_count, &pag->agino_min, + &pag->agino_max); - index = xfs_set_inode_alloc(mp, new_agcount); - - if (maxagi) - *maxagi = index; - - mp->m_ag_prealloc_blocks = xfs_prealloc_blocks(mp); return 0; out_remove_pag: @@ -357,8 +349,35 @@ xfs_initialize_perag( pag = xa_erase(&mp->m_perags, index); out_free_pag: kfree(pag); + return error; +} + +int +xfs_initialize_perag( + struct xfs_mount *mp, + xfs_agnumber_t orig_agcount, + xfs_agnumber_t new_agcount, + xfs_rfsblock_t dblocks, + xfs_agnumber_t *maxagi) +{ + xfs_agnumber_t index; + int error; + + if (orig_agcount >= new_agcount) + return 0; + + for (index = orig_agcount; index < new_agcount; index++) { + error = xfs_perag_alloc(mp, index, new_agcount, dblocks); + if (error) + goto out_unwind_new_pags; + } + + *maxagi = xfs_set_inode_alloc(mp, new_agcount); + mp->m_ag_prealloc_blocks = xfs_prealloc_blocks(mp); + return 0; + out_unwind_new_pags: - xfs_free_perag_range(mp, old_agcount, index); + xfs_free_perag_range(mp, orig_agcount, index); return error; } diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h index e0f567d90debee..8787823ae37f9f 100644 --- a/libxfs/xfs_ag.h +++ b/libxfs/xfs_ag.h @@ -142,8 +142,8 @@ __XFS_AG_OPSTATE(prefers_metadata, PREFERS_METADATA) __XFS_AG_OPSTATE(allows_inodes, ALLOWS_INODES) __XFS_AG_OPSTATE(agfl_needs_reset, AGFL_NEEDS_RESET) -int xfs_initialize_perag(struct xfs_mount *mp, xfs_agnumber_t old_agcount, - xfs_agnumber_t agcount, xfs_rfsblock_t dcount, +int xfs_initialize_perag(struct xfs_mount *mp, xfs_agnumber_t orig_agcount, + xfs_agnumber_t new_agcount, xfs_rfsblock_t dcount, xfs_agnumber_t *maxagi); void xfs_free_perag_range(struct xfs_mount *mp, xfs_agnumber_t first_agno, xfs_agnumber_t end_agno); From patchwork Fri Dec 6 23:33: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: 13897956 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 F068819ABC6 for ; Fri, 6 Dec 2024 23:33:55 +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=1733528036; cv=none; b=VGO+XWfVWBd/S0FZUXJImsOI6igTXy8W3hVo+m8qGW0hIHtLLvRNbwJKJq3F+F8ouK0VEAUNqdGpjABtQC+vM4UAl1Sp6cwrGi42BpisMVf30qWl12x5L01Pka4EOFm9ky4wVRnX9oPfZVXH85mNuJ/8hzpmBK/n24W/Jxv0p7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528036; c=relaxed/simple; bh=kPh+7hR6WjnZh61MuInuDgdrM2HGcfyY2SlOrYc3Gzs=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SJYyWSwGuhd0rm7YY/BS/T9fI13TXHtrtFar985bU1Bg+bNGyKv3dV55xkpEopHTKPXoi/dMAgjEGwZitCDlspC+Alg2OJlAaipZ8REdJHspMTSBna2ZFqk4vYpof0Ruq/gyFMUvBZDS43YkqKL6fn703Kiq7yorLPSiGZe4PVg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vBfqH5M+; 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="vBfqH5M+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78E7EC4CED1; Fri, 6 Dec 2024 23:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528035; bh=kPh+7hR6WjnZh61MuInuDgdrM2HGcfyY2SlOrYc3Gzs=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=vBfqH5M+2QXBQ/dFWSo56Q01mAnu1ixZ2yhbKy1jvqncMTfTG8+Zbtxnr0MVKQ9VS SZG4r6kzWuPXkZCdYkAMiCktCZFwHuDK4NHQzdUP5xhcgwqNv91DIk1v2YHAQOyv4x JEZFHAF//Ze+TDVAmWTDXV33eWsunajb6MGl3l9hH+E8K031VK6/PJx0EeBJFCqdZx OlnV7lkOSzMwrLgDItPdGH1DbTOeCXlph7R/lkOJ1R3UXr1VlpYf+c8LCliGsYI9Ng tsMT2iZpzCyR2aZ2Uk4d3Lo/wBIsQr4mOLs7uG0ZcmF3w6IVLGLuPZi4vzWLgEEckS 2R+j6kkxPW55w== Date: Fri, 06 Dec 2024 15:33:55 -0800 Subject: [PATCH 14/36] xfs: insert the pag structures into the xarray later From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747092.121772.9805864329051373584.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: d66496578b2a099ea453f56782f1cd2bf63a8029 Cleaning up is much easier if a structure can't be looked up yet, so only insert the pag once it is fully set up. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_ag.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index 8809d76d496ae9..e22ce4e83f4a62 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -305,15 +305,6 @@ xfs_perag_alloc( if (!pag) return -ENOMEM; - pag->pag_agno = index; - pag->pag_mount = mp; - - error = xa_insert(&mp->m_perags, index, pag, GFP_KERNEL); - if (error) { - WARN_ON_ONCE(error == -EBUSY); - goto out_free_pag; - } - #ifdef __KERNEL__ /* Place kernel structure only init below this point. */ spin_lock_init(&pag->pag_ici_lock); @@ -329,10 +320,7 @@ xfs_perag_alloc( error = xfs_buf_cache_init(&pag->pag_bcache); if (error) - goto out_remove_pag; - - /* Active ref owned by mount indicates AG is online. */ - atomic_set(&pag->pag_active_ref, 1); + goto out_defer_drain_free; /* * Pre-calculated geometry @@ -342,12 +330,23 @@ xfs_perag_alloc( __xfs_agino_range(mp, pag->block_count, &pag->agino_min, &pag->agino_max); + pag->pag_agno = index; + pag->pag_mount = mp; + /* Active ref owned by mount indicates AG is online. */ + atomic_set(&pag->pag_active_ref, 1); + + error = xa_insert(&mp->m_perags, index, pag, GFP_KERNEL); + if (error) { + WARN_ON_ONCE(error == -EBUSY); + goto out_buf_cache_destroy; + } + return 0; -out_remove_pag: +out_buf_cache_destroy: + xfs_buf_cache_destroy(&pag->pag_bcache); +out_defer_drain_free: xfs_defer_drain_free(&pag->pag_intents_drain); - pag = xa_erase(&mp->m_perags, index); -out_free_pag: kfree(pag); return error; } From patchwork Fri Dec 6 23:34:10 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: 13897957 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 8C4C919ABC6 for ; Fri, 6 Dec 2024 23:34:11 +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=1733528051; cv=none; b=Jj89StLPM4XBSul+gc++CxW8o34GrYwsDiyn3L2ApRqZdp004G3XTc4mDNBLcMqxwlTUpPdtPS8Onxt3xCbCVLhohfbI/4X7UuQuP5Gr9essjDRKsJn4xnwFO8vN9wthY4g3a+8kY4ty9fOeR/uTJGb+KtHv1wg5ciHaN65ltns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528051; c=relaxed/simple; bh=rdAlbBVcmbVTPzjnC0Cy/CklPAgZPGnmVqUr83TtR+U=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HZJBlsGAVJfVMoA4RkHYeqGNaqNP+mZ2gbCBm8zKqeE3JhU498+aBeATh1r1D1Fhz0Lh2L+16+mj3K5jKQ2f+z9IlSTO2fH1fCjtWiNTuzdrK0z71ykoDIFUyBrlJBiHeATRZoecnKeIDTul2xxIWJjclLSKPzqnBxn6B9MU3sg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=goBr7jIa; 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="goBr7jIa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FB20C4CED1; Fri, 6 Dec 2024 23:34:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528051; bh=rdAlbBVcmbVTPzjnC0Cy/CklPAgZPGnmVqUr83TtR+U=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=goBr7jIaSixN9wvKCIPn451xFpkGNnSvthRFZODb2GtFEON6gMfcRfen3y7TCPtDC oBR+AZYTxQHGqTtEy695pqlzb7k3tZ+tRjU9ZBddwSljbSgGqJTiVxt+LjpMNnPP2U G/2RioWcjmNeuEc+BPIoBHEx0mBrlve938a052d05dD9tGghr6qU7o2XG9slsOR5LJ /LzSfcRSRMVGNI8adh7/XwA7fhs+k6CmxRIBlOADxHgxJZ83LBnm5HoacHciSM8YpC D1v0qsrlNb9RYvefcCJtbxZThYmh6HzDD4lLIrAXS2eVN4Sebu4eG79Qp2jVbC2zhf 1RjmqqIc0emdA== Date: Fri, 06 Dec 2024 15:34:10 -0800 Subject: [PATCH 15/36] xfs: factor out a generic xfs_group structure From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747106.121772.10175587019231035828.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: e9c4d8bfb26c13c41b73fdf4183d3df2d392101e Split the lookup and refcount handling of struct xfs_perag into an embedded xfs_group structure that can be reused for the upcoming realtime groups. It will be extended with more features later. Note that he xg_type field will only need a single bit even with realtime group support. For now it fills a hole, but it might be worth to fold it into another field if we can use this space better. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- db/fsmap.c | 6 +- db/info.c | 2 - db/iunlink.c | 2 - include/xfs_mount.h | 6 +- include/xfs_trace.h | 7 ++ libfrog/radix-tree.h | 9 ++ libxfs/Makefile | 2 + libxfs/defer_item.c | 6 +- libxfs/init.c | 8 +- libxfs/iunlink.c | 11 ++- libxfs/xfs_ag.c | 139 +++++++----------------------------- libxfs/xfs_ag.h | 81 +++++++++++++++++---- libxfs/xfs_ag_resv.c | 19 +++-- libxfs/xfs_alloc.c | 39 +++++----- libxfs/xfs_alloc_btree.c | 2 - libxfs/xfs_bmap.c | 2 - libxfs/xfs_btree.c | 6 +- libxfs/xfs_group.c | 168 +++++++++++++++++++++++++++++++++++++++++++ libxfs/xfs_group.h | 41 ++++++++++ libxfs/xfs_ialloc.c | 40 +++++----- libxfs/xfs_ialloc_btree.c | 16 ++-- libxfs/xfs_refcount.c | 4 + libxfs/xfs_refcount_btree.c | 8 +- libxfs/xfs_rmap.c | 4 + libxfs/xfs_rmap_btree.c | 7 +- libxfs/xfs_sb.c | 6 +- libxfs/xfs_types.h | 8 ++ repair/agbtree.c | 27 +++---- repair/bmap_repair.c | 4 - repair/bulkload.c | 9 +- repair/phase2.c | 10 +-- repair/phase5.c | 2 - repair/rmap.c | 10 +-- 33 files changed, 455 insertions(+), 256 deletions(-) create mode 100644 libxfs/xfs_group.c create mode 100644 libxfs/xfs_group.h diff --git a/db/fsmap.c b/db/fsmap.c index 7fd42df2a1c854..923d7568b9d977 100644 --- a/db/fsmap.c +++ b/db/fsmap.c @@ -64,7 +64,7 @@ fsmap( info.nr = 0; for_each_perag_range(mp, start_ag, end_ag, pag) { - if (pag->pag_agno == end_ag) + if (pag_agno(pag) == end_ag) high.rm_startblock = XFS_FSB_TO_AGBNO(mp, end_fsb); error = -libxfs_alloc_read_agf(pag, NULL, 0, &agbp); @@ -82,7 +82,7 @@ fsmap( return; } - info.agno = pag->pag_agno; + info.agno = pag_agno(pag); error = -libxfs_rmap_query_range(bt_cur, &low, &high, fsmap_fn, &info); if (error) { @@ -97,7 +97,7 @@ fsmap( libxfs_btree_del_cursor(bt_cur, XFS_BTREE_NOERROR); libxfs_buf_relse(agbp); - if (pag->pag_agno == start_ag) + if (pag_agno(pag) == start_ag) low.rm_startblock = 0; } } diff --git a/db/info.c b/db/info.c index 9c6203f029d41c..6a8765ec761a49 100644 --- a/db/info.c +++ b/db/info.c @@ -66,7 +66,7 @@ print_agresv_info( { struct xfs_buf *bp; struct xfs_agf *agf; - xfs_agnumber_t agno = pag->pag_agno; + xfs_agnumber_t agno = pag_agno(pag); xfs_extlen_t ask = 0; xfs_extlen_t used = 0; xfs_extlen_t free = 0; diff --git a/db/iunlink.c b/db/iunlink.c index 55ba5af5a3c563..c9977a859e2842 100644 --- a/db/iunlink.c +++ b/db/iunlink.c @@ -117,7 +117,7 @@ dump_unlinked( bool verbose) { struct xfs_buf *agi_bp; - xfs_agnumber_t agno = pag->pag_agno; + xfs_agnumber_t agno = pag_agno(pag); int error; error = -libxfs_ialloc_read_agi(pag, NULL, 0, &agi_bp); diff --git a/include/xfs_mount.h b/include/xfs_mount.h index e2add8a648f887..2102009aa8df73 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -24,6 +24,10 @@ enum { XFS_LOWSP_MAX, }; +struct xfs_groups { + struct xarray xa; +}; + /* * Define a user-level mount structure with all we need * in order to make use of the numerous XFS_* macros. @@ -91,7 +95,7 @@ typedef struct xfs_mount { xfs_extlen_t m_ag_prealloc_blocks; /* reserved ag blocks */ uint m_alloc_set_aside; /* space we can't use */ uint m_ag_max_usable; /* max space per AG */ - struct xarray m_perags; + struct xfs_groups m_groups[XG_TYPE_MAX]; uint64_t m_features; /* active filesystem features */ uint64_t m_low_space[XFS_LOWSP_MAX]; uint64_t m_rtxblkmask; /* rt extent block mask */ diff --git a/include/xfs_trace.h b/include/xfs_trace.h index 012e0018cb8367..de435a9d1a2a64 100644 --- a/include/xfs_trace.h +++ b/include/xfs_trace.h @@ -366,4 +366,11 @@ #define trace_xfs_iunlink_reload_next(...) ((void) 0) #define trace_xfs_iunlink_remove(...) ((void) 0) +#define trace_xfs_group_get(...) ((void) 0) +#define trace_xfs_group_grab_next_tag(...) ((void) 0) +#define trace_xfs_group_grab(...) ((void) 0) +#define trace_xfs_group_hold(...) ((void) 0) +#define trace_xfs_group_put(...) ((void) 0) +#define trace_xfs_group_rele(...) ((void) 0) + #endif /* __TRACE_H__ */ diff --git a/libfrog/radix-tree.h b/libfrog/radix-tree.h index fe896134eeb283..0a4e3bb4f9defc 100644 --- a/libfrog/radix-tree.h +++ b/libfrog/radix-tree.h @@ -72,6 +72,8 @@ struct xarray { struct radix_tree_root r; }; +typedef unsigned xa_mark_t; + static inline void xa_init(struct xarray *xa) { INIT_RADIX_TREE(&xa->r, GFP_KERNEL); @@ -98,4 +100,11 @@ static inline int xa_insert(struct xarray *xa, unsigned long index, void *entry, return error; } +static inline void *xa_find(struct xarray *xa, unsigned long *indexp, + unsigned long max, xa_mark_t filter) +{ + /* not implemented */ + return NULL; +} + #endif /* __LIBFROG_RADIX_TREE_H__ */ diff --git a/libxfs/Makefile b/libxfs/Makefile index aca28440adac08..470583006de69a 100644 --- a/libxfs/Makefile +++ b/libxfs/Makefile @@ -49,6 +49,7 @@ HFILES = \ xfs_dir2.h \ xfs_errortag.h \ xfs_exchmaps.h \ + xfs_group.h \ xfs_ialloc.h \ xfs_ialloc_btree.h \ xfs_inode_buf.h \ @@ -105,6 +106,7 @@ CFILES = buf_mem.c \ xfs_dir2_sf.c \ xfs_dquot_buf.c \ xfs_exchmaps.c \ + xfs_group.c \ xfs_ialloc.c \ xfs_iext_tree.c \ xfs_inode_buf.c \ diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index d5e075362ababe..f0f35361a0ff97 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -48,7 +48,7 @@ xfs_extent_free_diff_items( struct xfs_extent_free_item *ra = xefi_entry(a); struct xfs_extent_free_item *rb = xefi_entry(b); - return ra->xefi_pag->pag_agno - rb->xefi_pag->pag_agno; + return pag_agno(ra->xefi_pag) - pag_agno(rb->xefi_pag); } /* Get an EFI. */ @@ -215,7 +215,7 @@ xfs_rmap_update_diff_items( struct xfs_rmap_intent *ra = ri_entry(a); struct xfs_rmap_intent *rb = ri_entry(b); - return ra->ri_pag->pag_agno - rb->ri_pag->pag_agno; + return pag_agno(ra->ri_pag) - pag_agno(rb->ri_pag); } /* Get an RUI. */ @@ -336,7 +336,7 @@ xfs_refcount_update_diff_items( struct xfs_refcount_intent *ra = ci_entry(a); struct xfs_refcount_intent *rb = ci_entry(b); - return ra->ri_pag->pag_agno - rb->ri_pag->pag_agno; + return pag_agno(ra->ri_pag) - pag_agno(rb->ri_pag); } /* Get an CUI. */ diff --git a/libxfs/init.c b/libxfs/init.c index 483cd99546052f..beb58706629d23 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -360,7 +360,7 @@ xfs_set_inode_alloc_perag( xfs_ino_t ino, xfs_agnumber_t max_metadata) { - if (!xfs_is_inode32(pag->pag_mount)) { + if (!xfs_is_inode32(pag_mount(pag))) { set_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate); clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); return false; @@ -373,7 +373,7 @@ xfs_set_inode_alloc_perag( } set_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate); - if (pag->pag_agno < max_metadata) + if (pag_agno(pag) < max_metadata) set_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); else clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); @@ -650,6 +650,7 @@ libxfs_mount( struct xfs_buf *bp; struct xfs_sb *sbp; xfs_daddr_t d; + int i; int error; mp->m_features = xfs_sb_version_to_features(sb); @@ -667,7 +668,8 @@ libxfs_mount( mp->m_finobt_nores = true; xfs_set_inode32(mp); mp->m_sb = *sb; - xa_init(&mp->m_perags); + for (i = 0; i < XG_TYPE_MAX; i++) + xa_init(&mp->m_groups[i].xa); sbp = &mp->m_sb; spin_lock_init(&mp->m_sb_lock); spin_lock_init(&mp->m_agirotor_lock); diff --git a/libxfs/iunlink.c b/libxfs/iunlink.c index 6d0554535994c9..53e36cdc3439b2 100644 --- a/libxfs/iunlink.c +++ b/libxfs/iunlink.c @@ -65,9 +65,10 @@ xfs_iunlink_log_dinode( goto out; } - trace_xfs_iunlink_update_dinode(mp, iup->pag->pag_agno, - XFS_INO_TO_AGINO(mp, ip->i_ino), - be32_to_cpu(dip->di_next_unlinked), iup->next_agino); + trace_xfs_iunlink_update_dinode(mp, pag_agno(iup->pag), + XFS_INO_TO_AGINO(mp, ip->i_ino), + be32_to_cpu(dip->di_next_unlinked), + iup->next_agino); dip->di_next_unlinked = cpu_to_be32(iup->next_agino); offset = ip->i_imap.im_boffset + @@ -137,14 +138,14 @@ xfs_iunlink_reload_next( xfs_agino_t next_agino) { struct xfs_perag *pag = agibp->b_pag; - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); struct xfs_inode *next_ip = NULL; xfs_ino_t ino; int error; ASSERT(next_agino != NULLAGINO); - ino = XFS_AGINO_TO_INO(mp, pag->pag_agno, next_agino); + ino = XFS_AGINO_TO_INO(mp, pag_agno(pag), next_agino); error = libxfs_iget(mp, tp, ino, XFS_IGET_UNTRUSTED, &next_ip); if (error) return error; diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index e22ce4e83f4a62..15d4ac5a99f0e7 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -28,85 +28,7 @@ #include "xfs_trans.h" #include "xfs_trace.h" #include "xfs_inode.h" - - -/* - * Passive reference counting access wrappers to the perag structures. If the - * per-ag structure is to be freed, the freeing code is responsible for cleaning - * up objects with passive references before freeing the structure. This is - * things like cached buffers. - */ -struct xfs_perag * -xfs_perag_get( - struct xfs_mount *mp, - xfs_agnumber_t agno) -{ - struct xfs_perag *pag; - - rcu_read_lock(); - pag = xa_load(&mp->m_perags, agno); - if (pag) { - trace_xfs_perag_get(pag, _RET_IP_); - ASSERT(atomic_read(&pag->pag_ref) >= 0); - atomic_inc(&pag->pag_ref); - } - rcu_read_unlock(); - return pag; -} - -/* Get a passive reference to the given perag. */ -struct xfs_perag * -xfs_perag_hold( - struct xfs_perag *pag) -{ - ASSERT(atomic_read(&pag->pag_ref) > 0 || - atomic_read(&pag->pag_active_ref) > 0); - - trace_xfs_perag_hold(pag, _RET_IP_); - atomic_inc(&pag->pag_ref); - return pag; -} - -void -xfs_perag_put( - struct xfs_perag *pag) -{ - trace_xfs_perag_put(pag, _RET_IP_); - ASSERT(atomic_read(&pag->pag_ref) > 0); - atomic_dec(&pag->pag_ref); -} - -/* - * Active references for perag structures. This is for short term access to the - * per ag structures for walking trees or accessing state. If an AG is being - * shrunk or is offline, then this will fail to find that AG and return NULL - * instead. - */ -struct xfs_perag * -xfs_perag_grab( - struct xfs_mount *mp, - xfs_agnumber_t agno) -{ - struct xfs_perag *pag; - - rcu_read_lock(); - pag = xa_load(&mp->m_perags, agno); - if (pag) { - trace_xfs_perag_grab(pag, _RET_IP_); - if (!atomic_inc_not_zero(&pag->pag_active_ref)) - pag = NULL; - } - rcu_read_unlock(); - return pag; -} - -void -xfs_perag_rele( - struct xfs_perag *pag) -{ - trace_xfs_perag_rele(pag, _RET_IP_); - atomic_dec(&pag->pag_active_ref); -} +#include "xfs_group.h" /* * xfs_initialize_perag_data @@ -181,6 +103,19 @@ xfs_initialize_perag_data( return error; } +static void +xfs_perag_uninit( + struct xfs_group *xg) +{ +#ifdef __KERNEL__ + struct xfs_perag *pag = to_perag(xg); + + xfs_defer_drain_free(&pag->pag_intents_drain); + cancel_delayed_work_sync(&pag->pag_blockgc_work); + xfs_buf_cache_destroy(&pag->pag_bcache); +#endif +} + /* * Free up the per-ag resources within the specified AG range. */ @@ -193,22 +128,8 @@ xfs_free_perag_range( { xfs_agnumber_t agno; - for (agno = first_agno; agno < end_agno; agno++) { - struct xfs_perag *pag = xa_erase(&mp->m_perags, agno); - - ASSERT(pag); - XFS_IS_CORRUPT(pag->pag_mount, atomic_read(&pag->pag_ref) != 0); - xfs_defer_drain_free(&pag->pag_intents_drain); - - cancel_delayed_work_sync(&pag->pag_blockgc_work); - xfs_buf_cache_destroy(&pag->pag_bcache); - - /* drop the mount's active reference */ - xfs_perag_rele(pag); - XFS_IS_CORRUPT(pag->pag_mount, - atomic_read(&pag->pag_active_ref) != 0); - kfree_rcu_mightsleep(pag); - } + for (agno = first_agno; agno < end_agno; agno++) + xfs_group_free(mp, agno, XG_TYPE_AG, xfs_perag_uninit); } /* Find the size of the AG, in blocks. */ @@ -330,16 +251,9 @@ xfs_perag_alloc( __xfs_agino_range(mp, pag->block_count, &pag->agino_min, &pag->agino_max); - pag->pag_agno = index; - pag->pag_mount = mp; - /* Active ref owned by mount indicates AG is online. */ - atomic_set(&pag->pag_active_ref, 1); - - error = xa_insert(&mp->m_perags, index, pag, GFP_KERNEL); - if (error) { - WARN_ON_ONCE(error == -EBUSY); + error = xfs_group_insert(mp, pag_group(pag), index, XG_TYPE_AG); + if (error) goto out_buf_cache_destroy; - } return 0; @@ -831,7 +745,7 @@ xfs_ag_shrink_space( struct xfs_trans **tpp, xfs_extlen_t delta) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); struct xfs_alloc_arg args = { .tp = *tpp, .mp = mp, @@ -848,7 +762,7 @@ xfs_ag_shrink_space( xfs_agblock_t aglen; int error, err2; - ASSERT(pag->pag_agno == mp->m_sb.sb_agcount - 1); + ASSERT(pag_agno(pag) == mp->m_sb.sb_agcount - 1); error = xfs_ialloc_read_agi(pag, *tpp, 0, &agibp); if (error) return error; @@ -945,8 +859,8 @@ xfs_ag_shrink_space( /* Update perag geometry */ pag->block_count -= delta; - __xfs_agino_range(pag->pag_mount, pag->block_count, &pag->agino_min, - &pag->agino_max); + __xfs_agino_range(mp, pag->block_count, &pag->agino_min, + &pag->agino_max); xfs_ialloc_log_agi(*tpp, agibp, XFS_AGI_LENGTH); xfs_alloc_log_agf(*tpp, agfbp, XFS_AGF_LENGTH); @@ -971,12 +885,13 @@ xfs_ag_extend_space( struct xfs_trans *tp, xfs_extlen_t len) { + struct xfs_mount *mp = pag_mount(pag); struct xfs_buf *bp; struct xfs_agi *agi; struct xfs_agf *agf; int error; - ASSERT(pag->pag_agno == pag->pag_mount->m_sb.sb_agcount - 1); + ASSERT(pag_agno(pag) == mp->m_sb.sb_agcount - 1); error = xfs_ialloc_read_agi(pag, tp, 0, &bp); if (error) @@ -1016,8 +931,8 @@ xfs_ag_extend_space( /* Update perag geometry */ pag->block_count = be32_to_cpu(agf->agf_length); - __xfs_agino_range(pag->pag_mount, pag->block_count, &pag->agino_min, - &pag->agino_max); + __xfs_agino_range(mp, pag->block_count, &pag->agino_min, + &pag->agino_max); return 0; } @@ -1044,7 +959,7 @@ xfs_ag_get_geometry( /* Fill out form. */ memset(ageo, 0, sizeof(*ageo)); - ageo->ag_number = pag->pag_agno; + ageo->ag_number = pag_agno(pag); agi = agi_bp->b_addr; ageo->ag_icount = be32_to_cpu(agi->agi_count); diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h index 8787823ae37f9f..69b934ad2c4aad 100644 --- a/libxfs/xfs_ag.h +++ b/libxfs/xfs_ag.h @@ -7,6 +7,8 @@ #ifndef __LIBXFS_AG_H #define __LIBXFS_AG_H 1 +#include "xfs_group.h" + struct xfs_mount; struct xfs_trans; struct xfs_perag; @@ -30,10 +32,7 @@ struct xfs_ag_resv { * performance of allocation group selection. */ struct xfs_perag { - struct xfs_mount *pag_mount; /* owner filesystem */ - xfs_agnumber_t pag_agno; /* AG this structure belongs to */ - atomic_t pag_ref; /* passive reference count */ - atomic_t pag_active_ref; /* active reference count */ + struct xfs_group pag_group; unsigned long pag_opstate; uint8_t pagf_bno_level; /* # of levels in bno btree */ uint8_t pagf_cnt_level; /* # of levels in cnt btree */ @@ -121,6 +120,26 @@ struct xfs_perag { #endif /* __KERNEL__ */ }; +static inline struct xfs_perag *to_perag(struct xfs_group *xg) +{ + return container_of(xg, struct xfs_perag, pag_group); +} + +static inline struct xfs_group *pag_group(struct xfs_perag *pag) +{ + return &pag->pag_group; +} + +static inline struct xfs_mount *pag_mount(const struct xfs_perag *pag) +{ + return pag->pag_group.xg_mount; +} + +static inline xfs_agnumber_t pag_agno(const struct xfs_perag *pag) +{ + return pag->pag_group.xg_gno; +} + /* * Per-AG operational state. These are atomic flag bits. */ @@ -151,13 +170,43 @@ int xfs_initialize_perag_data(struct xfs_mount *mp, xfs_agnumber_t agno); int xfs_update_last_ag_size(struct xfs_mount *mp, xfs_agnumber_t prev_agcount); /* Passive AG references */ -struct xfs_perag *xfs_perag_get(struct xfs_mount *mp, xfs_agnumber_t agno); -struct xfs_perag *xfs_perag_hold(struct xfs_perag *pag); -void xfs_perag_put(struct xfs_perag *pag); +static inline struct xfs_perag * +xfs_perag_get( + struct xfs_mount *mp, + xfs_agnumber_t agno) +{ + return to_perag(xfs_group_get(mp, agno, XG_TYPE_AG)); +} + +static inline struct xfs_perag * +xfs_perag_hold( + struct xfs_perag *pag) +{ + return to_perag(xfs_group_hold(pag_group(pag))); +} + +static inline void +xfs_perag_put( + struct xfs_perag *pag) +{ + xfs_group_put(pag_group(pag)); +} /* Active AG references */ -struct xfs_perag *xfs_perag_grab(struct xfs_mount *, xfs_agnumber_t); -void xfs_perag_rele(struct xfs_perag *pag); +static inline struct xfs_perag * +xfs_perag_grab( + struct xfs_mount *mp, + xfs_agnumber_t agno) +{ + return to_perag(xfs_group_grab(mp, agno, XG_TYPE_AG)); +} + +static inline void +xfs_perag_rele( + struct xfs_perag *pag) +{ + xfs_group_rele(pag_group(pag)); +} /* * Per-ag geometry infomation and validation @@ -233,9 +282,9 @@ xfs_perag_next( xfs_agnumber_t *agno, xfs_agnumber_t end_agno) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); - *agno = pag->pag_agno + 1; + *agno = pag_agno(pag) + 1; xfs_perag_rele(pag); while (*agno <= end_agno) { pag = xfs_perag_grab(mp, *agno); @@ -266,9 +315,9 @@ xfs_perag_next_wrap( xfs_agnumber_t restart_agno, xfs_agnumber_t wrap_agno) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); - *agno = pag->pag_agno + 1; + *agno = pag_agno(pag) + 1; xfs_perag_rele(pag); while (*agno != stop_agno) { if (*agno >= wrap_agno) { @@ -335,7 +384,7 @@ xfs_agbno_to_fsb( struct xfs_perag *pag, xfs_agblock_t agbno) { - return XFS_AGB_TO_FSB(pag->pag_mount, pag->pag_agno, agbno); + return XFS_AGB_TO_FSB(pag_mount(pag), pag_agno(pag), agbno); } static inline xfs_daddr_t @@ -343,7 +392,7 @@ xfs_agbno_to_daddr( struct xfs_perag *pag, xfs_agblock_t agbno) { - return XFS_AGB_TO_DADDR(pag->pag_mount, pag->pag_agno, agbno); + return XFS_AGB_TO_DADDR(pag_mount(pag), pag_agno(pag), agbno); } static inline xfs_ino_t @@ -351,7 +400,7 @@ xfs_agino_to_ino( struct xfs_perag *pag, xfs_agino_t agino) { - return XFS_AGINO_TO_INO(pag->pag_mount, pag->pag_agno, agino); + return XFS_AGINO_TO_INO(pag_mount(pag), pag_agno(pag), agino); } #endif /* __LIBXFS_AG_H */ diff --git a/libxfs/xfs_ag_resv.c b/libxfs/xfs_ag_resv.c index d1657d6c636546..f5cbaa94664f22 100644 --- a/libxfs/xfs_ag_resv.c +++ b/libxfs/xfs_ag_resv.c @@ -69,6 +69,7 @@ xfs_ag_resv_critical( struct xfs_perag *pag, enum xfs_ag_resv_type type) { + struct xfs_mount *mp = pag_mount(pag); xfs_extlen_t avail; xfs_extlen_t orig; @@ -91,8 +92,8 @@ xfs_ag_resv_critical( /* Critically low if less than 10% or max btree height remains. */ return XFS_TEST_ERROR(avail < orig / 10 || - avail < pag->pag_mount->m_agbtree_maxlevels, - pag->pag_mount, XFS_ERRTAG_AG_RESV_CRITICAL); + avail < mp->m_agbtree_maxlevels, + mp, XFS_ERRTAG_AG_RESV_CRITICAL); } /* @@ -136,8 +137,8 @@ __xfs_ag_resv_free( trace_xfs_ag_resv_free(pag, type, 0); resv = xfs_perag_resv(pag, type); - if (pag->pag_agno == 0) - pag->pag_mount->m_ag_max_usable += resv->ar_asked; + if (pag_agno(pag) == 0) + pag_mount(pag)->m_ag_max_usable += resv->ar_asked; /* * RMAPBT blocks come from the AGFL and AGFL blocks are always * considered "free", so whatever was reserved at mount time must be @@ -147,7 +148,7 @@ __xfs_ag_resv_free( oldresv = resv->ar_orig_reserved; else oldresv = resv->ar_reserved; - xfs_add_fdblocks(pag->pag_mount, oldresv); + xfs_add_fdblocks(pag_mount(pag), oldresv); resv->ar_reserved = 0; resv->ar_asked = 0; resv->ar_orig_reserved = 0; @@ -169,7 +170,7 @@ __xfs_ag_resv_init( xfs_extlen_t ask, xfs_extlen_t used) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); struct xfs_ag_resv *resv; int error; xfs_extlen_t hidden_space; @@ -208,7 +209,7 @@ __xfs_ag_resv_init( trace_xfs_ag_resv_init_error(pag, error, _RET_IP_); xfs_warn(mp, "Per-AG reservation for AG %u failed. Filesystem may run out of space.", - pag->pag_agno); + pag_agno(pag)); return error; } @@ -218,7 +219,7 @@ __xfs_ag_resv_init( * counter, we only make the adjustment for AG 0. This assumes that * there aren't any AGs hungrier for per-AG reservation than AG 0. */ - if (pag->pag_agno == 0) + if (pag_agno(pag) == 0) mp->m_ag_max_usable -= ask; resv = xfs_perag_resv(pag, type); @@ -236,7 +237,7 @@ xfs_ag_resv_init( struct xfs_perag *pag, struct xfs_trans *tp) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); xfs_extlen_t ask; xfs_extlen_t used; int error = 0, error2; diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index bd39bcde0ea224..39e1961078ae3a 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -271,7 +271,7 @@ xfs_alloc_complain_bad_rec( xfs_warn(mp, "%sbt record corruption in AG %d detected at %pS!", - cur->bc_ops->name, cur->bc_ag.pag->pag_agno, fa); + cur->bc_ops->name, pag_agno(cur->bc_ag.pag), fa); xfs_warn(mp, "start block 0x%x block count 0x%x", irec->ar_startblock, irec->ar_blockcount); @@ -795,7 +795,7 @@ xfs_agfl_verify( * use it by using uncached buffers that don't have the perag attached * so we can detect and avoid this problem. */ - if (bp->b_pag && be32_to_cpu(agfl->agfl_seqno) != bp->b_pag->pag_agno) + if (bp->b_pag && be32_to_cpu(agfl->agfl_seqno) != pag_agno((bp->b_pag))) return __this_address; for (i = 0; i < xfs_agfl_size(mp); i++) { @@ -875,13 +875,12 @@ xfs_alloc_read_agfl( struct xfs_trans *tp, struct xfs_buf **bpp) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); struct xfs_buf *bp; int error; - error = xfs_trans_read_buf( - mp, tp, mp->m_ddev_targp, - XFS_AG_DADDR(mp, pag->pag_agno, XFS_AGFL_DADDR(mp)), + error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, + XFS_AG_DADDR(mp, pag_agno(pag), XFS_AGFL_DADDR(mp)), XFS_FSS_TO_BB(mp, 1), 0, &bp, &xfs_agfl_buf_ops); if (xfs_metadata_is_sick(error)) xfs_ag_mark_sick(pag, XFS_SICK_AG_AGFL); @@ -2424,7 +2423,7 @@ xfs_alloc_longest_free_extent( * reservations and AGFL rules in place, we can return this extent. */ if (pag->pagf_longest > delta) - return min_t(xfs_extlen_t, pag->pag_mount->m_ag_max_usable, + return min_t(xfs_extlen_t, pag_mount(pag)->m_ag_max_usable, pag->pagf_longest - delta); /* Otherwise, let the caller try for 1 block if there's space. */ @@ -2607,7 +2606,7 @@ xfs_agfl_reset( xfs_warn(mp, "WARNING: Reset corrupted AGFL on AG %u. %d blocks leaked. " "Please unmount and run xfs_repair.", - pag->pag_agno, pag->pagf_flcount); + pag_agno(pag), pag->pagf_flcount); agf->agf_flfirst = 0; agf->agf_fllast = cpu_to_be32(xfs_agfl_size(mp) - 1); @@ -3182,7 +3181,7 @@ xfs_validate_ag_length( * use it by using uncached buffers that don't have the perag attached * so we can detect and avoid this problem. */ - if (bp->b_pag && seqno != bp->b_pag->pag_agno) + if (bp->b_pag && seqno != pag_agno(bp->b_pag)) return __this_address; /* @@ -3351,13 +3350,13 @@ xfs_read_agf( int flags, struct xfs_buf **agfbpp) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); int error; trace_xfs_read_agf(pag); error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, - XFS_AG_DADDR(mp, pag->pag_agno, XFS_AGF_DADDR(mp)), + XFS_AG_DADDR(mp, pag_agno(pag), XFS_AGF_DADDR(mp)), XFS_FSS_TO_BB(mp, 1), flags, agfbpp, &xfs_agf_buf_ops); if (xfs_metadata_is_sick(error)) xfs_ag_mark_sick(pag, XFS_SICK_AG_AGF); @@ -3380,6 +3379,7 @@ xfs_alloc_read_agf( int flags, struct xfs_buf **agfbpp) { + struct xfs_mount *mp = pag_mount(pag); struct xfs_buf *agfbp; struct xfs_agf *agf; int error; @@ -3406,7 +3406,7 @@ xfs_alloc_read_agf( pag->pagf_cnt_level = be32_to_cpu(agf->agf_cnt_level); pag->pagf_rmap_level = be32_to_cpu(agf->agf_rmap_level); pag->pagf_refcount_level = be32_to_cpu(agf->agf_refcount_level); - if (xfs_agfl_needs_reset(pag->pag_mount, agf)) + if (xfs_agfl_needs_reset(mp, agf)) set_bit(XFS_AGSTATE_AGFL_NEEDS_RESET, &pag->pag_opstate); else clear_bit(XFS_AGSTATE_AGFL_NEEDS_RESET, &pag->pag_opstate); @@ -3419,16 +3419,15 @@ xfs_alloc_read_agf( * counter only tracks non-root blocks. */ allocbt_blks = pag->pagf_btreeblks; - if (xfs_has_rmapbt(pag->pag_mount)) + if (xfs_has_rmapbt(mp)) allocbt_blks -= be32_to_cpu(agf->agf_rmap_blocks) - 1; if (allocbt_blks > 0) - atomic64_add(allocbt_blks, - &pag->pag_mount->m_allocbt_blks); + atomic64_add(allocbt_blks, &mp->m_allocbt_blks); set_bit(XFS_AGSTATE_AGF_INIT, &pag->pag_opstate); } #ifdef DEBUG - else if (!xfs_is_shutdown(pag->pag_mount)) { + else if (!xfs_is_shutdown(mp)) { ASSERT(pag->pagf_freeblks == be32_to_cpu(agf->agf_freeblks)); ASSERT(pag->pagf_btreeblks == be32_to_cpu(agf->agf_btreeblks)); ASSERT(pag->pagf_flcount == be32_to_cpu(agf->agf_flcount)); @@ -3646,7 +3645,7 @@ xfs_alloc_vextent_this_ag( int error; ASSERT(args->pag != NULL); - ASSERT(args->pag->pag_agno == agno); + ASSERT(pag_agno(args->pag) == agno); args->agno = agno; args->agbno = 0; @@ -3859,7 +3858,7 @@ xfs_alloc_vextent_exact_bno( int error; ASSERT(args->pag != NULL); - ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target)); + ASSERT(pag_agno(args->pag) == XFS_FSB_TO_AGNO(mp, target)); args->agno = XFS_FSB_TO_AGNO(mp, target); args->agbno = XFS_FSB_TO_AGBNO(mp, target); @@ -3898,7 +3897,7 @@ xfs_alloc_vextent_near_bno( int error; if (!needs_perag) - ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target)); + ASSERT(pag_agno(args->pag) == XFS_FSB_TO_AGNO(mp, target)); args->agno = XFS_FSB_TO_AGNO(mp, target); args->agbno = XFS_FSB_TO_AGBNO(mp, target); @@ -3935,7 +3934,7 @@ xfs_free_extent_fix_freelist( memset(&args, 0, sizeof(struct xfs_alloc_arg)); args.tp = tp; args.mp = tp->t_mountp; - args.agno = pag->pag_agno; + args.agno = pag_agno(pag); args.pag = pag; /* diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c index 949cd18ab16a99..667655a639fef1 100644 --- a/libxfs/xfs_alloc_btree.c +++ b/libxfs/xfs_alloc_btree.c @@ -176,7 +176,7 @@ xfs_allocbt_init_ptr_from_cur( { struct xfs_agf *agf = cur->bc_ag.agbp->b_addr; - ASSERT(cur->bc_ag.pag->pag_agno == be32_to_cpu(agf->agf_seqno)); + ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agf->agf_seqno)); if (xfs_btree_is_bno(cur->bc_ops)) ptr->s = agf->agf_bno_root; diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index aec378ff4a9193..13cd4faa492838 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -3274,7 +3274,7 @@ xfs_bmap_longest_free_extent( } longest = xfs_alloc_longest_free_extent(pag, - xfs_alloc_min_freelist(pag->pag_mount, pag), + xfs_alloc_min_freelist(pag_mount(pag), pag), xfs_ag_resv_needed(pag, XFS_AG_RESV_NONE)); if (*blen < longest) *blen = longest; diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index 4f04a92f6513bf..2b63c18114763c 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -370,7 +370,7 @@ xfs_btree_check_ptr( case XFS_BTREE_TYPE_AG: xfs_err(cur->bc_mp, "AG %u: Corrupt %sbt pointer at level %d index %d.", - cur->bc_ag.pag->pag_agno, cur->bc_ops->name, + pag_agno(cur->bc_ag.pag), cur->bc_ops->name, level, index); break; } @@ -1310,7 +1310,7 @@ xfs_btree_owner( case XFS_BTREE_TYPE_INODE: return cur->bc_ino.ip->i_ino; case XFS_BTREE_TYPE_AG: - return cur->bc_ag.pag->pag_agno; + return pag_agno(cur->bc_ag.pag); default: ASSERT(0); return 0; @@ -4742,7 +4742,7 @@ xfs_btree_agblock_v5hdr_verify( return __this_address; if (block->bb_u.s.bb_blkno != cpu_to_be64(xfs_buf_daddr(bp))) return __this_address; - if (pag && be32_to_cpu(block->bb_u.s.bb_owner) != pag->pag_agno) + if (pag && be32_to_cpu(block->bb_u.s.bb_owner) != pag_agno(pag)) return __this_address; return NULL; } diff --git a/libxfs/xfs_group.c b/libxfs/xfs_group.c new file mode 100644 index 00000000000000..8a67148362b0d7 --- /dev/null +++ b/libxfs/xfs_group.c @@ -0,0 +1,168 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2018 Red Hat, Inc. + */ + +#include "libxfs_priv.h" +#include "xfs_shared.h" +#include "xfs_format.h" +#include "xfs_trans_resv.h" +#include "xfs_mount.h" +#include "xfs_trace.h" +#include "xfs_group.h" + +/* + * Groups can have passive and active references. + * + * For passive references the code freeing a group is responsible for cleaning + * up objects that hold the passive references (e.g. cached buffers). + * Routines manipulating passive references are xfs_group_get, xfs_group_hold + * and xfs_group_put. + * + * Active references are for short term access to the group for walking trees or + * accessing state. If a group is being shrunk or offlined, the lookup will fail + * to find that group and return NULL instead. + * Routines manipulating active references are xfs_group_grab and + * xfs_group_rele. + */ + +struct xfs_group * +xfs_group_get( + struct xfs_mount *mp, + uint32_t index, + enum xfs_group_type type) +{ + struct xfs_group *xg; + + rcu_read_lock(); + xg = xa_load(&mp->m_groups[type].xa, index); + if (xg) { + trace_xfs_group_get(xg, _RET_IP_); + ASSERT(atomic_read(&xg->xg_ref) >= 0); + atomic_inc(&xg->xg_ref); + } + rcu_read_unlock(); + return xg; +} + +struct xfs_group * +xfs_group_hold( + struct xfs_group *xg) +{ + ASSERT(atomic_read(&xg->xg_ref) > 0 || + atomic_read(&xg->xg_active_ref) > 0); + + trace_xfs_group_hold(xg, _RET_IP_); + atomic_inc(&xg->xg_ref); + return xg; +} + +void +xfs_group_put( + struct xfs_group *xg) +{ + trace_xfs_group_put(xg, _RET_IP_); + + ASSERT(atomic_read(&xg->xg_ref) > 0); + atomic_dec(&xg->xg_ref); +} + +struct xfs_group * +xfs_group_grab( + struct xfs_mount *mp, + uint32_t index, + enum xfs_group_type type) +{ + struct xfs_group *xg; + + rcu_read_lock(); + xg = xa_load(&mp->m_groups[type].xa, index); + if (xg) { + trace_xfs_group_grab(xg, _RET_IP_); + if (!atomic_inc_not_zero(&xg->xg_active_ref)) + xg = NULL; + } + rcu_read_unlock(); + return xg; +} + +/* + * Find the next group after @xg, or the first group if @xg is NULL. + */ +struct xfs_group * +xfs_group_grab_next_mark( + struct xfs_mount *mp, + struct xfs_group *xg, + xa_mark_t mark, + enum xfs_group_type type) +{ + unsigned long index = 0; + + if (xg) { + index = xg->xg_gno + 1; + xfs_group_rele(xg); + } + + rcu_read_lock(); + xg = xa_find(&mp->m_groups[type].xa, &index, ULONG_MAX, mark); + if (xg) { + trace_xfs_group_grab_next_tag(xg, _RET_IP_); + if (!atomic_inc_not_zero(&xg->xg_active_ref)) + xg = NULL; + } + rcu_read_unlock(); + return xg; +} + +void +xfs_group_rele( + struct xfs_group *xg) +{ + trace_xfs_group_rele(xg, _RET_IP_); + atomic_dec(&xg->xg_active_ref); +} + +void +xfs_group_free( + struct xfs_mount *mp, + uint32_t index, + enum xfs_group_type type, + void (*uninit)(struct xfs_group *xg)) +{ + struct xfs_group *xg = xa_erase(&mp->m_groups[type].xa, index); + + XFS_IS_CORRUPT(mp, atomic_read(&xg->xg_ref) != 0); + + if (uninit) + uninit(xg); + + /* drop the mount's active reference */ + xfs_group_rele(xg); + XFS_IS_CORRUPT(mp, atomic_read(&xg->xg_active_ref) != 0); + kfree_rcu_mightsleep(xg); +} + +int +xfs_group_insert( + struct xfs_mount *mp, + struct xfs_group *xg, + uint32_t index, + enum xfs_group_type type) +{ + int error; + + xg->xg_mount = mp; + xg->xg_gno = index; + xg->xg_type = type; + + /* Active ref owned by mount indicates group is online. */ + atomic_set(&xg->xg_active_ref, 1); + + error = xa_insert(&mp->m_groups[type].xa, index, xg, GFP_KERNEL); + if (error) { + WARN_ON_ONCE(error == -EBUSY); + return error; + } + + return 0; +} diff --git a/libxfs/xfs_group.h b/libxfs/xfs_group.h new file mode 100644 index 00000000000000..e3b6be7ff9e802 --- /dev/null +++ b/libxfs/xfs_group.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2018 Red Hat, Inc. + */ +#ifndef __LIBXFS_GROUP_H +#define __LIBXFS_GROUP_H 1 + +struct xfs_group { + struct xfs_mount *xg_mount; + uint32_t xg_gno; + enum xfs_group_type xg_type; + atomic_t xg_ref; /* passive reference count */ + atomic_t xg_active_ref; /* active reference count */ +}; + +struct xfs_group *xfs_group_get(struct xfs_mount *mp, uint32_t index, + enum xfs_group_type type); +struct xfs_group *xfs_group_hold(struct xfs_group *xg); +void xfs_group_put(struct xfs_group *xg); + +struct xfs_group *xfs_group_grab(struct xfs_mount *mp, uint32_t index, + enum xfs_group_type type); +struct xfs_group *xfs_group_grab_next_mark(struct xfs_mount *mp, + struct xfs_group *xg, xa_mark_t mark, enum xfs_group_type type); +void xfs_group_rele(struct xfs_group *xg); + +void xfs_group_free(struct xfs_mount *mp, uint32_t index, + enum xfs_group_type type, void (*uninit)(struct xfs_group *xg)); +int xfs_group_insert(struct xfs_mount *mp, struct xfs_group *xg, + uint32_t index, enum xfs_group_type); + +#define xfs_group_set_mark(_xg, _mark) \ + xa_set_mark(&(_xg)->xg_mount->m_groups[(_xg)->xg_type].xa, \ + (_xg)->xg_gno, (_mark)) +#define xfs_group_clear_mark(_xg, _mark) \ + xa_clear_mark(&(_xg)->xg_mount->m_groups[(_xg)->xg_type].xa, \ + (_xg)->xg_gno, (_mark)) +#define xfs_group_marked(_mp, _type, _mark) \ + xa_marked(&(_mp)->m_groups[(_type)].xa, (_mark)) + +#endif /* __LIBXFS_GROUP_H */ diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 4f087e6b074081..e4b9d3e2fbb5ce 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -137,7 +137,7 @@ xfs_inobt_complain_bad_rec( xfs_warn(mp, "%sbt record corruption in AG %d detected at %pS!", - cur->bc_ops->name, cur->bc_ag.pag->pag_agno, fa); + cur->bc_ops->name, pag_agno(cur->bc_ag.pag), fa); xfs_warn(mp, "start inode 0x%x, count 0x%x, free 0x%x freemask 0x%llx, holemask 0x%x", irec->ir_startino, irec->ir_count, irec->ir_freecount, @@ -546,7 +546,7 @@ xfs_inobt_insert_sprec( struct xfs_buf *agbp, struct xfs_inobt_rec_incore *nrec) /* in/out: new/merged rec. */ { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); struct xfs_btree_cur *cur; int error; int i; @@ -640,7 +640,7 @@ xfs_finobt_insert_sprec( struct xfs_buf *agbp, struct xfs_inobt_rec_incore *nrec) /* in/out: new rec. */ { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); struct xfs_btree_cur *cur; int error; int i; @@ -875,7 +875,7 @@ xfs_ialloc_ag_alloc( * rather than a linear progression to prevent the next generation * number from being easily guessable. */ - error = xfs_ialloc_inode_init(args.mp, tp, NULL, newlen, pag->pag_agno, + error = xfs_ialloc_inode_init(args.mp, tp, NULL, newlen, pag_agno(pag), args.agbno, args.len, get_random_u32()); if (error) @@ -1066,7 +1066,7 @@ xfs_dialloc_check_ino( if (error) return -EAGAIN; - error = xfs_imap_to_bp(pag->pag_mount, tp, &imap, &bp); + error = xfs_imap_to_bp(pag_mount(pag), tp, &imap, &bp); if (error) return -EAGAIN; @@ -1117,7 +1117,7 @@ xfs_dialloc_ag_inobt( /* * If in the same AG as the parent, try to get near the parent. */ - if (pagno == pag->pag_agno) { + if (pagno == pag_agno(pag)) { int doneleft; /* done, to the left */ int doneright; /* done, to the right */ @@ -1594,7 +1594,7 @@ xfs_dialloc_ag( * parent. If so, find the closest available inode to the parent. If * not, consider the agi hint or find the first free inode in the AG. */ - if (pag->pag_agno == pagno) + if (pag_agno(pag) == pagno) error = xfs_dialloc_ag_finobt_near(pagino, &cur, &rec); else error = xfs_dialloc_ag_finobt_newino(agi, cur, &rec); @@ -2048,7 +2048,7 @@ xfs_difree_inobt( struct xfs_icluster *xic, struct xfs_inobt_rec_incore *orec) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); struct xfs_agi *agi = agbp->b_addr; struct xfs_btree_cur *cur; struct xfs_inobt_rec_incore rec; @@ -2182,7 +2182,7 @@ xfs_difree_finobt( xfs_agino_t agino, struct xfs_inobt_rec_incore *ibtrec) /* inobt record */ { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); struct xfs_btree_cur *cur; struct xfs_inobt_rec_incore rec; int offset = agino - ibtrec->ir_startino; @@ -2305,9 +2305,9 @@ xfs_difree( /* * Break up inode number into its components. */ - if (pag->pag_agno != XFS_INO_TO_AGNO(mp, inode)) { - xfs_warn(mp, "%s: agno != pag->pag_agno (%d != %d).", - __func__, XFS_INO_TO_AGNO(mp, inode), pag->pag_agno); + if (pag_agno(pag) != XFS_INO_TO_AGNO(mp, inode)) { + xfs_warn(mp, "%s: agno != pag_agno(pag) (%d != %d).", + __func__, XFS_INO_TO_AGNO(mp, inode), pag_agno(pag)); ASSERT(0); return -EINVAL; } @@ -2368,7 +2368,7 @@ xfs_imap_lookup( xfs_agblock_t *offset_agbno, int flags) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); struct xfs_inobt_rec_incore rec; struct xfs_btree_cur *cur; struct xfs_buf *agbp; @@ -2379,7 +2379,7 @@ xfs_imap_lookup( if (error) { xfs_alert(mp, "%s: xfs_ialloc_read_agi() returned error %d, agno %d", - __func__, error, pag->pag_agno); + __func__, error, pag_agno(pag)); return error; } @@ -2429,7 +2429,7 @@ xfs_imap( struct xfs_imap *imap, /* location map structure */ uint flags) /* flags for inode btree lookup */ { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); xfs_agblock_t agbno; /* block number of inode in the alloc group */ xfs_agino_t agino; /* inode number within alloc group */ xfs_agblock_t chunk_agbno; /* first block in inode chunk */ @@ -2721,13 +2721,13 @@ xfs_read_agi( xfs_buf_flags_t flags, struct xfs_buf **agibpp) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); int error; trace_xfs_read_agi(pag); error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, - XFS_AG_DADDR(mp, pag->pag_agno, XFS_AGI_DADDR(mp)), + XFS_AG_DADDR(mp, pag_agno(pag), XFS_AGI_DADDR(mp)), XFS_FSS_TO_BB(mp, 1), flags, agibpp, &xfs_agi_buf_ops); if (xfs_metadata_is_sick(error)) xfs_ag_mark_sick(pag, XFS_SICK_AG_AGI); @@ -2775,7 +2775,7 @@ xfs_ialloc_read_agi( * we are in the middle of a forced shutdown. */ ASSERT(pag->pagi_freecount == be32_to_cpu(agi->agi_freecount) || - xfs_is_shutdown(pag->pag_mount)); + xfs_is_shutdown(pag_mount(pag))); if (agibpp) *agibpp = agibp; else @@ -3114,13 +3114,13 @@ xfs_ialloc_check_shrink( int has; int error; - if (!xfs_has_sparseinodes(pag->pag_mount)) + if (!xfs_has_sparseinodes(pag_mount(pag))) return 0; cur = xfs_inobt_init_cursor(pag, tp, agibp); /* Look up the inobt record that would correspond to the new EOFS. */ - agino = XFS_AGB_TO_AGINO(pag->pag_mount, new_length); + agino = XFS_AGB_TO_AGINO(pag_mount(pag), new_length); error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE, &has); if (error || !has) goto out; diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c index f80368b4d5fa5f..45908cce464dff 100644 --- a/libxfs/xfs_ialloc_btree.c +++ b/libxfs/xfs_ialloc_btree.c @@ -247,7 +247,7 @@ xfs_inobt_init_ptr_from_cur( { struct xfs_agi *agi = cur->bc_ag.agbp->b_addr; - ASSERT(cur->bc_ag.pag->pag_agno == be32_to_cpu(agi->agi_seqno)); + ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agi->agi_seqno)); ptr->s = agi->agi_root; } @@ -259,7 +259,7 @@ xfs_finobt_init_ptr_from_cur( { struct xfs_agi *agi = cur->bc_ag.agbp->b_addr; - ASSERT(cur->bc_ag.pag->pag_agno == be32_to_cpu(agi->agi_seqno)); + ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agi->agi_seqno)); ptr->s = agi->agi_free_root; } @@ -477,7 +477,7 @@ xfs_inobt_init_cursor( struct xfs_trans *tp, struct xfs_buf *agbp) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); struct xfs_btree_cur *cur; cur = xfs_btree_alloc_cursor(mp, tp, &xfs_inobt_ops, @@ -503,7 +503,7 @@ xfs_finobt_init_cursor( struct xfs_trans *tp, struct xfs_buf *agbp) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); struct xfs_btree_cur *cur; cur = xfs_btree_alloc_cursor(mp, tp, &xfs_finobt_ops, @@ -714,7 +714,7 @@ static xfs_extlen_t xfs_inobt_max_size( struct xfs_perag *pag) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); xfs_agblock_t agblocks = pag->block_count; /* Bail out if we're uninitialized, which can happen in mkfs. */ @@ -726,7 +726,7 @@ xfs_inobt_max_size( * never be available for the kinds of things that would require btree * expansion. We therefore can pretend the space isn't there. */ - if (xfs_ag_contains_log(mp, pag->pag_agno)) + if (xfs_ag_contains_log(mp, pag_agno(pag))) agblocks -= mp->m_sb.sb_logblocks; return xfs_btree_calc_size(M_IGEO(mp)->inobt_mnr, @@ -790,10 +790,10 @@ xfs_finobt_calc_reserves( xfs_extlen_t tree_len = 0; int error; - if (!xfs_has_finobt(pag->pag_mount)) + if (!xfs_has_finobt(pag_mount(pag))) return 0; - if (xfs_has_inobtcounts(pag->pag_mount)) + if (xfs_has_inobtcounts(pag_mount(pag))) error = xfs_finobt_read_blocks(pag, tp, &tree_len); else error = xfs_finobt_count_blocks(pag, tp, &tree_len); diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index eeddec68a08539..9507cf74578d4f 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -153,7 +153,7 @@ xfs_refcount_complain_bad_rec( xfs_warn(mp, "Refcount BTree record corruption in AG %d detected at %pS!", - cur->bc_ag.pag->pag_agno, fa); + pag_agno(cur->bc_ag.pag), fa); xfs_warn(mp, "Start block 0x%x, block count 0x%x, references 0x%x", irec->rc_startblock, irec->rc_blockcount, irec->rc_refcount); @@ -1320,7 +1320,7 @@ xfs_refcount_continue_op( ri->ri_startblock = xfs_agbno_to_fsb(pag, new_agbno); ASSERT(xfs_verify_fsbext(mp, ri->ri_startblock, ri->ri_blockcount)); - ASSERT(pag->pag_agno == XFS_FSB_TO_AGNO(mp, ri->ri_startblock)); + ASSERT(pag_agno(pag) == XFS_FSB_TO_AGNO(mp, ri->ri_startblock)); return 0; } diff --git a/libxfs/xfs_refcount_btree.c b/libxfs/xfs_refcount_btree.c index 5913f4176889ea..e9c4fc419a6114 100644 --- a/libxfs/xfs_refcount_btree.c +++ b/libxfs/xfs_refcount_btree.c @@ -80,7 +80,7 @@ xfs_refcountbt_alloc_block( *stat = 0; return 0; } - ASSERT(args.agno == cur->bc_ag.pag->pag_agno); + ASSERT(args.agno == pag_agno(cur->bc_ag.pag)); ASSERT(args.len == 1); new->s = cpu_to_be32(args.agbno); @@ -168,7 +168,7 @@ xfs_refcountbt_init_ptr_from_cur( { struct xfs_agf *agf = cur->bc_ag.agbp->b_addr; - ASSERT(cur->bc_ag.pag->pag_agno == be32_to_cpu(agf->agf_seqno)); + ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agf->agf_seqno)); ptr->s = agf->agf_refcount_root; } @@ -360,7 +360,7 @@ xfs_refcountbt_init_cursor( { struct xfs_btree_cur *cur; - ASSERT(pag->pag_agno < mp->m_sb.sb_agcount); + ASSERT(pag_agno(pag) < mp->m_sb.sb_agcount); cur = xfs_btree_alloc_cursor(mp, tp, &xfs_refcountbt_ops, mp->m_refc_maxlevels, xfs_refcountbt_cur_cache); @@ -513,7 +513,7 @@ xfs_refcountbt_calc_reserves( * never be available for the kinds of things that would require btree * expansion. We therefore can pretend the space isn't there. */ - if (xfs_ag_contains_log(mp, pag->pag_agno)) + if (xfs_ag_contains_log(mp, pag_agno(pag))) agblocks -= mp->m_sb.sb_logblocks; *ask += xfs_refcountbt_max_size(mp, agblocks); diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index 22947e3c9ae310..0f7dee40bda87a 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -212,7 +212,7 @@ xfs_rmap_check_irec( struct xfs_perag *pag, const struct xfs_rmap_irec *irec) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); bool is_inode; bool is_unwritten; bool is_bmbt; @@ -287,7 +287,7 @@ xfs_rmap_complain_bad_rec( else xfs_warn(mp, "Reverse Mapping BTree record corruption in AG %d detected at %pS!", - cur->bc_ag.pag->pag_agno, fa); + pag_agno(cur->bc_ag.pag), fa); xfs_warn(mp, "Owner 0x%llx, flags 0x%x, start block 0x%x block count 0x%x", irec->rm_owner, irec->rm_flags, irec->rm_startblock, diff --git a/libxfs/xfs_rmap_btree.c b/libxfs/xfs_rmap_btree.c index c261d6eae3bc3b..ebb2519cf8baf3 100644 --- a/libxfs/xfs_rmap_btree.c +++ b/libxfs/xfs_rmap_btree.c @@ -226,7 +226,7 @@ xfs_rmapbt_init_ptr_from_cur( { struct xfs_agf *agf = cur->bc_ag.agbp->b_addr; - ASSERT(cur->bc_ag.pag->pag_agno == be32_to_cpu(agf->agf_seqno)); + ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agf->agf_seqno)); ptr->s = agf->agf_rmap_root; } @@ -646,9 +646,8 @@ xfs_rmapbt_mem_cursor( struct xfbtree *xfbt) { struct xfs_btree_cur *cur; - struct xfs_mount *mp = pag->pag_mount; - cur = xfs_btree_alloc_cursor(mp, tp, &xfs_rmapbt_mem_ops, + cur = xfs_btree_alloc_cursor(pag_mount(pag), tp, &xfs_rmapbt_mem_ops, xfs_rmapbt_maxlevels_ondisk(), xfs_rmapbt_cur_cache); cur->bc_mem.xfbtree = xfbt; cur->bc_nlevels = xfbt->nlevels; @@ -862,7 +861,7 @@ xfs_rmapbt_calc_reserves( * never be available for the kinds of things that would require btree * expansion. We therefore can pretend the space isn't there. */ - if (xfs_ag_contains_log(mp, pag->pag_agno)) + if (xfs_ag_contains_log(mp, pag_agno(pag))) agblocks -= mp->m_sb.sb_logblocks; /* Reserve 1% of the AG or enough for 1 block per record. */ diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 0d98b8a344209e..f534ae5d4c4db2 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -1131,7 +1131,7 @@ xfs_update_secondary_sbs( struct xfs_buf *bp; error = xfs_buf_get(mp->m_ddev_targp, - XFS_AG_DADDR(mp, pag->pag_agno, XFS_SB_DADDR), + XFS_AG_DADDR(mp, pag_agno(pag), XFS_SB_DADDR), XFS_FSS_TO_BB(mp, 1), &bp); /* * If we get an error reading or writing alternate superblocks, @@ -1143,7 +1143,7 @@ xfs_update_secondary_sbs( if (error) { xfs_warn(mp, "error allocating secondary superblock for ag %d", - pag->pag_agno); + pag_agno(pag)); if (!saved_error) saved_error = error; continue; @@ -1164,7 +1164,7 @@ xfs_update_secondary_sbs( if (error) { xfs_warn(mp, "write error %d updating a secondary superblock near ag %d", - error, pag->pag_agno); + error, pag_agno(pag)); if (!saved_error) saved_error = error; continue; diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index a8cd44d03ef648..d3cb6ff3b91301 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -212,6 +212,14 @@ enum xbtree_recpacking { XBTREE_RECPACKING_FULL, }; +enum xfs_group_type { + XG_TYPE_AG, + XG_TYPE_MAX, +} __packed; + +#define XG_TYPE_STRINGS \ + { XG_TYPE_AG, "ag" } + /* * Type verifier functions */ diff --git a/repair/agbtree.c b/repair/agbtree.c index c8f75f49e6b363..67baa1acba9907 100644 --- a/repair/agbtree.c +++ b/repair/agbtree.c @@ -166,8 +166,7 @@ finish_rebuild( if (resv->used == resv->len) continue; - fsbno = XFS_AGB_TO_FSB(mp, resv->pag->pag_agno, - resv->agbno + resv->used); + fsbno = xfs_agbno_to_fsb(resv->pag, resv->agbno + resv->used); error = bitmap_set(lost_blocks, fsbno, resv->len - resv->used); if (error) do_error( @@ -203,7 +202,7 @@ get_bno_rec( struct xfs_btree_cur *cur, struct extent_tree_node *prev_value) { - xfs_agnumber_t agno = cur->bc_ag.pag->pag_agno; + xfs_agnumber_t agno = pag_agno(cur->bc_ag.pag); if (xfs_btree_is_bno(cur->bc_ops)) { if (!prev_value) @@ -254,7 +253,7 @@ init_freespace_cursors( struct bt_rebuild *btr_bno, struct bt_rebuild *btr_cnt) { - xfs_agnumber_t agno = pag->pag_agno; + xfs_agnumber_t agno = pag_agno(pag); unsigned int agfl_goal; int error; @@ -377,7 +376,7 @@ get_ino_rec( struct xfs_btree_cur *cur, struct ino_tree_node *prev_value) { - xfs_agnumber_t agno = cur->bc_ag.pag->pag_agno; + xfs_agnumber_t agno = pag_agno(cur->bc_ag.pag); if (xfs_btree_is_ino(cur->bc_ops)) { if (!prev_value) @@ -482,7 +481,7 @@ init_ino_cursors( struct bt_rebuild *btr_fino) { struct ino_tree_node *ino_rec; - xfs_agnumber_t agno = pag->pag_agno; + xfs_agnumber_t agno = pag_agno(pag); unsigned int ino_recs = 0; unsigned int fino_recs = 0; bool finobt; @@ -615,7 +614,7 @@ get_rmapbt_records( if (ret == 0) do_error( _("ran out of records while rebuilding AG %u rmap btree\n"), - cur->bc_ag.pag->pag_agno); + pag_agno(cur->bc_ag.pag)); block_rec = libxfs_btree_rec_addr(cur, idx, block); cur->bc_ops->init_rec_from_cur(cur, block_rec); @@ -632,7 +631,7 @@ init_rmapbt_cursor( unsigned int est_agfreeblocks, struct bt_rebuild *btr) { - xfs_agnumber_t agno = pag->pag_agno; + xfs_agnumber_t agno = pag_agno(pag); int error; if (!xfs_has_rmapbt(sc->mp)) @@ -715,7 +714,7 @@ init_refc_cursor( unsigned int est_agfreeblocks, struct bt_rebuild *btr) { - xfs_agnumber_t agno = pag->pag_agno; + xfs_agnumber_t agno = pag_agno(pag); int error; if (!xfs_has_reflink(sc->mp)) @@ -769,7 +768,7 @@ estimate_allocbt_blocks( unsigned int nr_extents) { /* Account for space consumed by both free space btrees */ - return libxfs_allocbt_calc_size(pag->pag_mount, nr_extents) * 2; + return libxfs_allocbt_calc_size(pag_mount(pag), nr_extents) * 2; } static xfs_extlen_t @@ -777,7 +776,7 @@ estimate_inobt_blocks( struct xfs_perag *pag) { struct ino_tree_node *ino_rec; - xfs_agnumber_t agno = pag->pag_agno; + xfs_agnumber_t agno = pag_agno(pag); unsigned int ino_recs = 0; unsigned int fino_recs = 0; xfs_extlen_t ret; @@ -807,9 +806,9 @@ estimate_inobt_blocks( fino_recs++; } - ret = libxfs_iallocbt_calc_size(pag->pag_mount, ino_recs); - if (xfs_has_finobt(pag->pag_mount)) - ret += libxfs_iallocbt_calc_size(pag->pag_mount, fino_recs); + ret = libxfs_iallocbt_calc_size(pag_mount(pag), ino_recs); + if (xfs_has_finobt(pag_mount(pag))) + ret += libxfs_iallocbt_calc_size(pag_mount(pag), fino_recs); return ret; } diff --git a/repair/bmap_repair.c b/repair/bmap_repair.c index b341caf627d5fd..7ccbb96fa8dc5e 100644 --- a/repair/bmap_repair.c +++ b/repair/bmap_repair.c @@ -129,7 +129,6 @@ xrep_bmap_walk_rmap( void *priv) { struct xrep_bmap *rb = priv; - struct xfs_mount *mp = cur->bc_mp; xfs_fsblock_t fsbno; int error; @@ -155,8 +154,7 @@ xrep_bmap_walk_rmap( !(rec->rm_flags & XFS_RMAP_ATTR_FORK)) return 0; - fsbno = XFS_AGB_TO_FSB(mp, cur->bc_ag.pag->pag_agno, - rec->rm_startblock); + fsbno = xfs_agbno_to_fsb(cur->bc_ag.pag, rec->rm_startblock); if (rec->rm_flags & XFS_RMAP_BMBT_BLOCK) { rb->old_bmbt_block_count += rec->rm_blockcount; diff --git a/repair/bulkload.c b/repair/bulkload.c index c96e569ef2979e..aada5bbae579f8 100644 --- a/repair/bulkload.c +++ b/repair/bulkload.c @@ -74,11 +74,10 @@ bulkload_add_extent( xfs_agblock_t agbno, xfs_extlen_t len) { - struct xfs_mount *mp = bkl->sc->mp; struct xfs_alloc_arg args = { .tp = NULL, /* no autoreap */ .oinfo = bkl->oinfo, - .fsbno = XFS_AGB_TO_FSB(mp, pag->pag_agno, agbno), + .fsbno = xfs_agbno_to_fsb(pag, agbno), .len = len, .resv = XFS_AG_RESV_NONE, }; @@ -194,7 +193,7 @@ bulkload_free_extent( * Use EFIs to free the reservations. We don't need to use EFIs here * like the kernel, but we'll do it to keep the code matched. */ - fsbno = XFS_AGB_TO_FSB(sc->mp, resv->pag->pag_agno, free_agbno); + fsbno = xfs_agbno_to_fsb(resv->pag, free_agbno); error = -libxfs_free_extent_later(sc->tp, fsbno, free_aglen, &bkl->oinfo, XFS_AG_RESV_NONE, XFS_FREE_EXTENT_SKIP_DISCARD); @@ -290,7 +289,6 @@ bulkload_claim_block( union xfs_btree_ptr *ptr) { struct bulkload_resv *resv; - struct xfs_mount *mp = cur->bc_mp; xfs_agblock_t agbno; /* @@ -316,8 +314,7 @@ bulkload_claim_block( list_move_tail(&resv->list, &bkl->resv_list); if (cur->bc_ops->ptr_len == XFS_BTREE_LONG_PTR_LEN) - ptr->l = cpu_to_be64(XFS_AGB_TO_FSB(mp, resv->pag->pag_agno, - agbno)); + ptr->l = cpu_to_be64(xfs_agbno_to_fsb(resv->pag, agbno)); else ptr->s = cpu_to_be32(agbno); return 0; diff --git a/repair/phase2.c b/repair/phase2.c index e50cd3f8c2759d..42a2861dcc3714 100644 --- a/repair/phase2.c +++ b/repair/phase2.c @@ -304,13 +304,13 @@ check_fs_free_space( if (error) do_error( _("Cannot read AGI %u for upgrade check, err=%d.\n"), - pag->pag_agno, error); + pag_agno(pag), error); error = -libxfs_alloc_read_agf(pag, tp, 0, &agf_bp); if (error) do_error( _("Cannot read AGF %u for upgrade check, err=%d.\n"), - pag->pag_agno, error); + pag_agno(pag), error); agf = agf_bp->b_addr; agblocks = be32_to_cpu(agf->agf_length); @@ -326,13 +326,13 @@ check_fs_free_space( if (error == ENOSPC) { printf( _("Not enough free space would remain in AG %u for metadata.\n"), - pag->pag_agno); + pag_agno(pag)); exit(1); } if (error) do_error( _("Error %d while checking AG %u space reservation.\n"), - error, pag->pag_agno); + error, pag_agno(pag)); /* * Would the post-upgrade filesystem have enough free space in @@ -345,7 +345,7 @@ check_fs_free_space( if (!check_free_space(mp, avail, agblocks)) { printf( _("AG %u will be low on space after upgrade.\n"), - pag->pag_agno); + pag_agno(pag)); exit(1); } libxfs_trans_cancel(tp); diff --git a/repair/phase5.c b/repair/phase5.c index 9207da7172c05b..fdbd9f56998fb4 100644 --- a/repair/phase5.c +++ b/repair/phase5.c @@ -441,7 +441,7 @@ phase5_func( struct bt_rebuild btr_fino; struct bt_rebuild btr_rmap; struct bt_rebuild btr_refc; - xfs_agnumber_t agno = pag->pag_agno; + xfs_agnumber_t agno = pag_agno(pag); int extra_blocks = 0; uint num_freeblocks; xfs_agblock_t num_extents; diff --git a/repair/rmap.c b/repair/rmap.c index 553c7a6c3658a0..29af74eee11831 100644 --- a/repair/rmap.c +++ b/repair/rmap.c @@ -1694,7 +1694,7 @@ xfs_extlen_t estimate_rmapbt_blocks( struct xfs_perag *pag) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); struct xfs_ag_rmap *x; unsigned long long nr_recs = 0; @@ -1707,12 +1707,12 @@ estimate_rmapbt_blocks( * means we can use SEEK_DATA/HOLE on the xfile, which is faster than * walking the entire btree to count records. */ - x = &ag_rmaps[pag->pag_agno]; + x = &ag_rmaps[pag_agno(pag)]; if (!rmaps_has_observations(x)) return 0; nr_recs = xmbuf_bytes(x->ar_xmbtp) / sizeof(struct xfs_rmap_rec); - return libxfs_rmapbt_calc_size(pag->pag_mount, nr_recs); + return libxfs_rmapbt_calc_size(pag_mount(pag), nr_recs); } /* Estimate the size of the ondisk refcountbt from the incore data. */ @@ -1720,13 +1720,13 @@ xfs_extlen_t estimate_refcountbt_blocks( struct xfs_perag *pag) { - struct xfs_mount *mp = pag->pag_mount; + struct xfs_mount *mp = pag_mount(pag); struct xfs_ag_rmap *x; if (!rmap_needs_work(mp) || !xfs_has_reflink(mp)) return 0; - x = &ag_rmaps[pag->pag_agno]; + x = &ag_rmaps[pag_agno(pag)]; if (!x->ar_refcount_items) return 0; From patchwork Fri Dec 6 23:34:26 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: 13897958 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 308A319ABC6 for ; Fri, 6 Dec 2024 23:34:26 +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=1733528067; cv=none; b=HOvv5lusnBD8uVignm+bPmtsmRlOiSXNgD3la2kwKnJb7C5IFxD3RS8PhbvTUeTnWlIxsws3yfF6gAcQknjnTKeNFZBu1DsocQ/8n3VeZer7ikGyhjhhaBelNiVp3Ca/VbBTVVQH2hgRI7jROarGVPZU4t6J1Vz8MXwurfcMJbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528067; c=relaxed/simple; bh=LW2P5VN7FXCh2ZwtvU1Yo/7u8S76LEE/hbhWgoMVBfA=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qUIdWaYD3YoK6VrqVjRdVxhr7IbE1KzhswEbkB9y7mQL8sQFyQphkUtE3rE+MKTQsbVxHc6cFBpmtSHtbAQd2p59nkYdHRSHihpUy3Te1xXit/j7bIfSZWrILpQzcrTbZwziqhACYh15BKIkEkiHHcYgxZSwjinldszfaAnhpzQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YIx+/vip; 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="YIx+/vip" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4377C4CED1; Fri, 6 Dec 2024 23:34:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528066; bh=LW2P5VN7FXCh2ZwtvU1Yo/7u8S76LEE/hbhWgoMVBfA=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=YIx+/vipgnN5nIJnikGG93OsPZW4j3fuS3fQJwqycEO75EHCiqbucepAJj9cEcAOZ guDHuz2eUwHCR1eiamfnV+28DAW4K4vGUfFSfqkifFE+AWKTuZ4Z+u1U9WFXt+6LJO UtD8EAcIkT9FhbHrQwX9DwTRmfg/IRzIDVzWWW+1kkaCFESfTyVMep9whdJCrGRjLi 7cAQlaI3A6pbaBFu1lwKS7nH3Pzj5qQ2aMzbcwIQCQXCez4/7FvTAcqn1Ixfwru/n4 0fkzlahTzonoMz6CKVnCjwpUVdkVzGm5eaqLMbRzlN50crpIZfTyOF1JXt9dH46abc +7TJJuSiLcc5A== Date: Fri, 06 Dec 2024 15:34:26 -0800 Subject: [PATCH 16/36] xfs: add a xfs_group_next_range helper From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747123.121772.4416461135513997240.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: 819928770bd91960f88f5a4dfa21b35a1bade61b Add a helper to iterate over iterate over all groups, which can be used as a simple while loop: struct xfs_group *xg = NULL; while ((xg = xfs_group_next_range(mp, xg, 0, MAX_GROUP))) { ... } This will be wrapped by the realtime group code first, and eventually replace the for_each_rtgroup_from and for_each_rtgroup_range helpers. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_group.c | 26 ++++++++++++++++++++++++++ libxfs/xfs_group.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/libxfs/xfs_group.c b/libxfs/xfs_group.c index 8a67148362b0d7..04d65033b75eca 100644 --- a/libxfs/xfs_group.c +++ b/libxfs/xfs_group.c @@ -86,6 +86,32 @@ xfs_group_grab( return xg; } +/* + * Iterate to the next group. To start the iteration at @start_index, a %NULL + * @xg is passed, else the previous group returned from this function. The + * caller should break out of the loop when this returns %NULL. If the caller + * wants to break out of a loop that did not finish it needs to release the + * active reference to @xg using xfs_group_rele() itself. + */ +struct xfs_group * +xfs_group_next_range( + struct xfs_mount *mp, + struct xfs_group *xg, + uint32_t start_index, + uint32_t end_index, + enum xfs_group_type type) +{ + uint32_t index = start_index; + + if (xg) { + index = xg->xg_gno + 1; + xfs_group_rele(xg); + } + if (index > end_index) + return NULL; + return xfs_group_grab(mp, index, type); +} + /* * Find the next group after @xg, or the first group if @xg is NULL. */ diff --git a/libxfs/xfs_group.h b/libxfs/xfs_group.h index e3b6be7ff9e802..dd7da90443054b 100644 --- a/libxfs/xfs_group.h +++ b/libxfs/xfs_group.h @@ -20,6 +20,9 @@ void xfs_group_put(struct xfs_group *xg); struct xfs_group *xfs_group_grab(struct xfs_mount *mp, uint32_t index, enum xfs_group_type type); +struct xfs_group *xfs_group_next_range(struct xfs_mount *mp, + struct xfs_group *xg, uint32_t start_index, uint32_t end_index, + enum xfs_group_type type); struct xfs_group *xfs_group_grab_next_mark(struct xfs_mount *mp, struct xfs_group *xg, xa_mark_t mark, enum xfs_group_type type); void xfs_group_rele(struct xfs_group *xg); From patchwork Fri Dec 6 23:34:41 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: 13897959 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 7C1FB19ABC6 for ; Fri, 6 Dec 2024 23:34:42 +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=1733528082; cv=none; b=Pts9PODqEkJkfdvpn6+0twNC7Pru3O4fpucg9KDojGhp48WYGb/uSI41HguwwSXxDO365MD18dJNCA/MbH/g9aGLHMzaH8bIdw9jeq2OGBfF1mEHBkAZBPOWHGImqI6dcAJ8vaKEL8Ev6+gfOsVh3NP/ogvXX6MfTNM+Wy1AIgk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528082; c=relaxed/simple; bh=03b6bvIzDIWUT/6CD/uSRAo4qT7p+t7mH0FyxxOz1lE=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W2rsGgW8/EXIRs07VAFSmSUsdEF2hAvUfqRBvHoVAVkJBFjNSe7r+Z42UekqjvN3oNrt308/QaGROhGr37S0lo2iBkimT1063ToYTokx1ZQvvFvdRTEEl/t0YVahozKHGDQfkXsGL08n3bm5eWetdd7mw5N2toHxcjn0zFuGM0k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BjUSutIp; 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="BjUSutIp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 518E1C4CED1; Fri, 6 Dec 2024 23:34:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528082; bh=03b6bvIzDIWUT/6CD/uSRAo4qT7p+t7mH0FyxxOz1lE=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=BjUSutIp8Hkw8dOKgE7Te0mdVhBaGTD3s7CQUldfHNGjldPm0m0dQBrjqCNcouG55 6XsK/DTAT+/TW6J5rth6wdPRPl3gORH2N9sUtU+3vYQbLmeC2+hwnRGrbKB9vOFy5R zB9OCtd+h2rwOwt/2WaNXEZRze0JWfVsuH+lrgQKsey8iUyPDU20Ptlk36oKfeg0nJ oBcIjkjhHEvj/GW/lA83C/AdupjagSEiLtxFuaz5D1J9FFK/pqcVv7mfjEjU5CSs9g DXQMrnIM55afDe8T1QO2c1n+/ARHT2fW50p7bgHYgTMNxtKYrKo2l3tTefrKDNAZy8 QxF1D2UHP+wGg== Date: Fri, 06 Dec 2024 15:34:41 -0800 Subject: [PATCH 17/36] xfs: switch perag iteration from the for_each macros to a while based iterator From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747139.121772.12867537320145180139.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: 86437e6abbd2ef040f42ef190264819db6118415 The current for_each_perag* macros are a bit annoying in that they require the caller to both provide an object and an index iterator, and also somewhat obsfucate the underlying control flow mechanism. Switch to open coded while loops using new xfs_perag_next{,_from,_range} helpers that return the next pag structure to iterate on based on the previous one or NULL for the loop start. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- db/fsmap.c | 4 ++- db/info.c | 5 ++-- db/iunlink.c | 4 ++- libxfs/xfs_ag.h | 62 +++++++++++++++++++++++--------------------------- libxfs/xfs_sb.c | 15 ++++-------- libxfs/xfs_types.c | 5 ++-- repair/bmap_repair.c | 5 ++-- repair/phase2.c | 7 ++---- repair/phase5.c | 4 ++- 9 files changed, 48 insertions(+), 63 deletions(-) diff --git a/db/fsmap.c b/db/fsmap.c index 923d7568b9d977..a9259c4632185b 100644 --- a/db/fsmap.c +++ b/db/fsmap.c @@ -46,7 +46,7 @@ fsmap( struct xfs_rmap_irec high = {0}; struct xfs_btree_cur *bt_cur; struct xfs_buf *agbp; - struct xfs_perag *pag; + struct xfs_perag *pag = NULL; int error; eofs = XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks); @@ -63,7 +63,7 @@ fsmap( end_ag = XFS_FSB_TO_AGNO(mp, end_fsb); info.nr = 0; - for_each_perag_range(mp, start_ag, end_ag, pag) { + while ((pag = xfs_perag_next_range(mp, pag, start_ag, end_ag))) { if (pag_agno(pag) == end_ag) high.rm_startblock = XFS_FSB_TO_AGBNO(mp, end_fsb); diff --git a/db/info.c b/db/info.c index 6a8765ec761a49..9a86d247839f84 100644 --- a/db/info.c +++ b/db/info.c @@ -104,8 +104,7 @@ agresv_f( int argc, char **argv) { - struct xfs_perag *pag; - xfs_agnumber_t agno; + struct xfs_perag *pag = NULL; int i; if (argc > 1) { @@ -134,7 +133,7 @@ agresv_f( return 0; } - for_each_perag(mp, agno, pag) + while ((pag = xfs_perag_next(mp, pag))) print_agresv_info(pag); return 0; diff --git a/db/iunlink.c b/db/iunlink.c index c9977a859e2842..c73f818242b983 100644 --- a/db/iunlink.c +++ b/db/iunlink.c @@ -144,7 +144,7 @@ dump_iunlinked_f( int argc, char **argv) { - struct xfs_perag *pag; + struct xfs_perag *pag = NULL; xfs_agnumber_t agno = NULLAGNUMBER; unsigned int bucket = -1U; bool quiet = false; @@ -189,7 +189,7 @@ dump_iunlinked_f( return 0; } - for_each_perag(mp, agno, pag) + while ((pag = xfs_perag_next(mp, pag))) dump_unlinked(pag, bucket, quiet, verbose); return 0; diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h index 69b934ad2c4aad..80969682dc4746 100644 --- a/libxfs/xfs_ag.h +++ b/libxfs/xfs_ag.h @@ -208,6 +208,34 @@ xfs_perag_rele( xfs_group_rele(pag_group(pag)); } +static inline struct xfs_perag * +xfs_perag_next_range( + struct xfs_mount *mp, + struct xfs_perag *pag, + xfs_agnumber_t start_agno, + xfs_agnumber_t end_agno) +{ + return to_perag(xfs_group_next_range(mp, pag ? pag_group(pag) : NULL, + start_agno, end_agno, XG_TYPE_AG)); +} + +static inline struct xfs_perag * +xfs_perag_next_from( + struct xfs_mount *mp, + struct xfs_perag *pag, + xfs_agnumber_t start_agno) +{ + return xfs_perag_next_range(mp, pag, start_agno, mp->m_sb.sb_agcount - 1); +} + +static inline struct xfs_perag * +xfs_perag_next( + struct xfs_mount *mp, + struct xfs_perag *pag) +{ + return xfs_perag_next_from(mp, pag, 0); +} + /* * Per-ag geometry infomation and validation */ @@ -273,40 +301,6 @@ xfs_ag_contains_log(struct xfs_mount *mp, xfs_agnumber_t agno) agno == XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart); } -/* - * Perag iteration APIs - */ -static inline struct xfs_perag * -xfs_perag_next( - struct xfs_perag *pag, - xfs_agnumber_t *agno, - xfs_agnumber_t end_agno) -{ - struct xfs_mount *mp = pag_mount(pag); - - *agno = pag_agno(pag) + 1; - xfs_perag_rele(pag); - while (*agno <= end_agno) { - pag = xfs_perag_grab(mp, *agno); - if (pag) - return pag; - (*agno)++; - } - return NULL; -} - -#define for_each_perag_range(mp, agno, end_agno, pag) \ - for ((pag) = xfs_perag_grab((mp), (agno)); \ - (pag) != NULL; \ - (pag) = xfs_perag_next((pag), &(agno), (end_agno))) - -#define for_each_perag_from(mp, agno, pag) \ - for_each_perag_range((mp), (agno), (mp)->m_sb.sb_agcount - 1, (pag)) - -#define for_each_perag(mp, agno, pag) \ - (agno) = 0; \ - for_each_perag_from((mp), (agno), (pag)) - static inline struct xfs_perag * xfs_perag_next_wrap( struct xfs_perag *pag, diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index f534ae5d4c4db2..d32f789037389f 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -1120,14 +1120,13 @@ int xfs_update_secondary_sbs( struct xfs_mount *mp) { - struct xfs_perag *pag; - xfs_agnumber_t agno = 1; + struct xfs_perag *pag = NULL; int saved_error = 0; int error = 0; LIST_HEAD (buffer_list); /* update secondary superblocks. */ - for_each_perag_from(mp, agno, pag) { + while ((pag = xfs_perag_next_from(mp, pag, 1))) { struct xfs_buf *bp; error = xfs_buf_get(mp->m_ddev_targp, @@ -1157,7 +1156,7 @@ xfs_update_secondary_sbs( xfs_buf_relse(bp); /* don't hold too many buffers at once */ - if (agno % 16) + if (pag_agno(pag) % 16) continue; error = xfs_buf_delwri_submit(&buffer_list); @@ -1171,12 +1170,8 @@ xfs_update_secondary_sbs( } } error = xfs_buf_delwri_submit(&buffer_list); - if (error) { - xfs_warn(mp, - "write error %d updating a secondary superblock near ag %d", - error, agno); - } - + if (error) + xfs_warn(mp, "error %d writing secondary superblocks", error); return saved_error ? saved_error : error; } diff --git a/libxfs/xfs_types.c b/libxfs/xfs_types.c index 74ab1965a8f49c..0d1b86ae59d93e 100644 --- a/libxfs/xfs_types.c +++ b/libxfs/xfs_types.c @@ -170,13 +170,12 @@ xfs_icount_range( unsigned long long *max) { unsigned long long nr_inos = 0; - struct xfs_perag *pag; - xfs_agnumber_t agno; + struct xfs_perag *pag = NULL; /* root, rtbitmap, rtsum all live in the first chunk */ *min = XFS_INODES_PER_CHUNK; - for_each_perag(mp, agno, pag) + while ((pag = xfs_perag_next(mp, pag))) nr_inos += pag->agino_max - pag->agino_min + 1; *max = nr_inos; } diff --git a/repair/bmap_repair.c b/repair/bmap_repair.c index 7ccbb96fa8dc5e..3a214c85a1de5f 100644 --- a/repair/bmap_repair.c +++ b/repair/bmap_repair.c @@ -218,12 +218,11 @@ STATIC int xrep_bmap_find_mappings( struct xrep_bmap *rb) { - struct xfs_perag *pag; - xfs_agnumber_t agno; + struct xfs_perag *pag = NULL; int error; /* Iterate the rmaps for extents. */ - for_each_perag(rb->sc->mp, agno, pag) { + while ((pag = xfs_perag_next(rb->sc->mp, pag))) { error = xrep_bmap_scan_ag(rb, pag); if (error) { libxfs_perag_put(pag); diff --git a/repair/phase2.c b/repair/phase2.c index 42a2861dcc3714..17966bb54db09d 100644 --- a/repair/phase2.c +++ b/repair/phase2.c @@ -274,12 +274,11 @@ check_fs_free_space( const struct check_state *old, struct xfs_sb *new_sb) { - struct xfs_perag *pag; - xfs_agnumber_t agno; + struct xfs_perag *pag = NULL; int error; /* Make sure we have enough space for per-AG reservations. */ - for_each_perag(mp, agno, pag) { + while ((pag = xfs_perag_next(mp, pag))) { struct xfs_trans *tp; struct xfs_agf *agf; struct xfs_buf *agi_bp, *agf_bp; @@ -365,7 +364,7 @@ check_fs_free_space( * uninitialized so that we don't trip over stale cached counters * after the upgrade/ */ - for_each_perag(mp, agno, pag) { + while ((pag = xfs_perag_next(mp, pag))) { libxfs_ag_resv_free(pag); clear_bit(XFS_AGSTATE_AGF_INIT, &pag->pag_opstate); clear_bit(XFS_AGSTATE_AGI_INIT, &pag->pag_opstate); diff --git a/repair/phase5.c b/repair/phase5.c index fdbd9f56998fb4..86b1f681a72bb8 100644 --- a/repair/phase5.c +++ b/repair/phase5.c @@ -632,7 +632,7 @@ void phase5(xfs_mount_t *mp) { struct bitmap *lost_blocks = NULL; - struct xfs_perag *pag; + struct xfs_perag *pag = NULL; xfs_agnumber_t agno; int error; @@ -679,7 +679,7 @@ phase5(xfs_mount_t *mp) if (error) do_error(_("cannot alloc lost block bitmap\n")); - for_each_perag(mp, agno, pag) + while ((pag = xfs_perag_next(mp, pag))) phase5_func(mp, pag, lost_blocks); print_final_rpt(); From patchwork Fri Dec 6 23:34:57 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: 13897960 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 180DA19ABC6 for ; Fri, 6 Dec 2024 23:34:58 +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=1733528098; cv=none; b=pAHhYmBTq/q8CtX+kVxWtZD+Fr887gpFivQpbEAgHRk4ygWcDVxliHMK6T8M3tu4NRwdvqVWE3ZelJeSDuB/9MKFG9xTwhBMIvdWv2kg6klcBkNVhSOhWPNR5zY2RXe7DOAosuywYpaA/mKcghj2aV529m/ODEqKah0Rh6DeTcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528098; c=relaxed/simple; bh=tERi46s4eRjksKAoa2U9sVNBZ3K4aXo0dEKPfKyah/Y=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qu9x34Ltz99OEv4tlNRTSsr8eISF6bq23prkoFuTi0JS1tivR81l/491hx9kgbtxOO+M25/bgh89s8XbxMmdXWWANod8sstTbadKQppaKKZuPRRCBKaSsmvH8ERwdoBjGcRhlPOQOjNXB1I9YlyJtWoHIGZ38JIOJVUdw7W9exg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gHBey3kQ; 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="gHBey3kQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EACB1C4CED1; Fri, 6 Dec 2024 23:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528098; bh=tERi46s4eRjksKAoa2U9sVNBZ3K4aXo0dEKPfKyah/Y=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=gHBey3kQbpWawVXpWFG0BHCg7ulyiXVm/PlirpmT9phRGZnexq/SuVgKLVZbnOvm1 3j5KLjysz8mOaKFqIWMn3rFD4Xybev1mLK/ZIthiEFah7dKGsz+1Ipey1UVN8l+CcV 4ah3a0ENjt24CGKQPNX+9QJ3DA+wsy0s8bZYeTRuT9/5Sp+oiu76fJSeC+5mkoTI2e pAjHX43KDcp8/9wqRw5/zhD0pP3flbIHIRyw2TpJ3TX/Xo4gBvmUut3pbaMhdvF72u J69nLoXnqQzvNXYiNyEv2GHYn6QK6x2kfCOhMRCb0cuwn84xub51W7PCyzjHg6zgQq AjzIfx9a6xjRw== Date: Fri, 06 Dec 2024 15:34:57 -0800 Subject: [PATCH 18/36] xfs: move metadata health tracking to the generic group structure From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747152.121772.7792514725151292550.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: 5c8483cec3fe261a5c1ede7430bab042ed156361 Prepare for also tracking the health status of the upcoming realtime groups by moving the health tracking code to the generic xfs_group structure. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/util.c | 4 ++-- libxfs/xfs_ag.c | 1 - libxfs/xfs_ag.h | 9 --------- libxfs/xfs_group.c | 4 ++++ libxfs/xfs_group.h | 12 ++++++++++++ libxfs/xfs_health.h | 45 +++++++++++++++++---------------------------- 6 files changed, 35 insertions(+), 40 deletions(-) diff --git a/libxfs/util.c b/libxfs/util.c index a3f3ad299336c7..97da94506aee01 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -449,8 +449,8 @@ void xfs_ag_geom_health(struct xfs_perag *pag, struct xfs_ag_geometry *ageo) { } void xfs_fs_mark_sick(struct xfs_mount *mp, unsigned int mask) { } void xfs_agno_mark_sick(struct xfs_mount *mp, xfs_agnumber_t agno, unsigned int mask) { } -void xfs_ag_mark_sick(struct xfs_perag *pag, unsigned int mask) { } -void xfs_ag_measure_sickness(struct xfs_perag *pag, unsigned int *sick, +void xfs_group_mark_sick(struct xfs_group *xg, unsigned int mask) { } +void xfs_group_measure_sickness(struct xfs_group *xg, unsigned int *sick, unsigned int *checked) { *sick = 0; diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index 15d4ac5a99f0e7..20af8b67d86e88 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -230,7 +230,6 @@ xfs_perag_alloc( /* Place kernel structure only init below this point. */ spin_lock_init(&pag->pag_ici_lock); spin_lock_init(&pag->pagb_lock); - spin_lock_init(&pag->pag_state_lock); INIT_DELAYED_WORK(&pag->pag_blockgc_work, xfs_blockgc_worker); INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC); xfs_defer_drain_init(&pag->pag_intents_drain); diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h index 80969682dc4746..8271cb72c88387 100644 --- a/libxfs/xfs_ag.h +++ b/libxfs/xfs_ag.h @@ -69,13 +69,6 @@ struct xfs_perag { #ifdef __KERNEL__ /* -- kernel only structures below this line -- */ - /* - * Bitsets of per-ag metadata that have been checked and/or are sick. - * Callers should hold pag_state_lock before accessing this field. - */ - uint16_t pag_checked; - uint16_t pag_sick; - #ifdef CONFIG_XFS_ONLINE_REPAIR /* * Alternate btree heights so that online repair won't trip the write @@ -87,8 +80,6 @@ struct xfs_perag { uint8_t pagf_repair_rmap_level; #endif - spinlock_t pag_state_lock; - spinlock_t pagb_lock; /* lock for pagb_tree */ struct rb_root pagb_tree; /* ordered tree of busy extents */ unsigned int pagb_gen; /* generation count for pagb_tree */ diff --git a/libxfs/xfs_group.c b/libxfs/xfs_group.c index 04d65033b75eca..c5269cd659f327 100644 --- a/libxfs/xfs_group.c +++ b/libxfs/xfs_group.c @@ -181,6 +181,10 @@ xfs_group_insert( xg->xg_gno = index; xg->xg_type = type; +#ifdef __KERNEL__ + spin_lock_init(&xg->xg_state_lock); +#endif + /* Active ref owned by mount indicates group is online. */ atomic_set(&xg->xg_active_ref, 1); diff --git a/libxfs/xfs_group.h b/libxfs/xfs_group.h index dd7da90443054b..d2c61dd1f43e44 100644 --- a/libxfs/xfs_group.h +++ b/libxfs/xfs_group.h @@ -11,6 +11,18 @@ struct xfs_group { enum xfs_group_type xg_type; atomic_t xg_ref; /* passive reference count */ atomic_t xg_active_ref; /* active reference count */ + +#ifdef __KERNEL__ + /* -- kernel only structures below this line -- */ + + /* + * Bitsets of per-ag metadata that have been checked and/or are sick. + * Callers should hold xg_state_lock before accessing this field. + */ + uint16_t xg_checked; + uint16_t xg_sick; + spinlock_t xg_state_lock; +#endif /* __KERNEL__ */ }; struct xfs_group *xfs_group_get(struct xfs_mount *mp, uint32_t index, diff --git a/libxfs/xfs_health.h b/libxfs/xfs_health.h index b0edb4288e5929..13301420a2f670 100644 --- a/libxfs/xfs_health.h +++ b/libxfs/xfs_health.h @@ -6,6 +6,8 @@ #ifndef __XFS_HEALTH_H__ #define __XFS_HEALTH_H__ +struct xfs_group; + /* * In-Core Filesystem Health Assessments * ===================================== @@ -197,10 +199,12 @@ void xfs_rt_measure_sickness(struct xfs_mount *mp, unsigned int *sick, void xfs_agno_mark_sick(struct xfs_mount *mp, xfs_agnumber_t agno, unsigned int mask); -void xfs_ag_mark_sick(struct xfs_perag *pag, unsigned int mask); -void xfs_ag_mark_corrupt(struct xfs_perag *pag, unsigned int mask); -void xfs_ag_mark_healthy(struct xfs_perag *pag, unsigned int mask); -void xfs_ag_measure_sickness(struct xfs_perag *pag, unsigned int *sick, +void xfs_group_mark_sick(struct xfs_group *xg, unsigned int mask); +#define xfs_ag_mark_sick(pag, mask) \ + xfs_group_mark_sick(pag_group(pag), (mask)) +void xfs_group_mark_corrupt(struct xfs_group *xg, unsigned int mask); +void xfs_group_mark_healthy(struct xfs_group *xg, unsigned int mask); +void xfs_group_measure_sickness(struct xfs_group *xg, unsigned int *sick, unsigned int *checked); void xfs_inode_mark_sick(struct xfs_inode *ip, unsigned int mask); @@ -227,22 +231,19 @@ xfs_fs_has_sickness(struct xfs_mount *mp, unsigned int mask) } static inline bool -xfs_rt_has_sickness(struct xfs_mount *mp, unsigned int mask) +xfs_group_has_sickness( + struct xfs_group *xg, + unsigned int mask) { - unsigned int sick, checked; + unsigned int sick, checked; - xfs_rt_measure_sickness(mp, &sick, &checked); - return sick & mask; -} - -static inline bool -xfs_ag_has_sickness(struct xfs_perag *pag, unsigned int mask) -{ - unsigned int sick, checked; - - xfs_ag_measure_sickness(pag, &sick, &checked); + xfs_group_measure_sickness(xg, &sick, &checked); return sick & mask; } +#define xfs_ag_has_sickness(pag, mask) \ + xfs_group_has_sickness(pag_group(pag), (mask)) +#define xfs_ag_is_healthy(pag) \ + (!xfs_ag_has_sickness((pag), UINT_MAX)) static inline bool xfs_inode_has_sickness(struct xfs_inode *ip, unsigned int mask) @@ -259,18 +260,6 @@ xfs_fs_is_healthy(struct xfs_mount *mp) return !xfs_fs_has_sickness(mp, -1U); } -static inline bool -xfs_rt_is_healthy(struct xfs_mount *mp) -{ - return !xfs_rt_has_sickness(mp, -1U); -} - -static inline bool -xfs_ag_is_healthy(struct xfs_perag *pag) -{ - return !xfs_ag_has_sickness(pag, -1U); -} - static inline bool xfs_inode_is_healthy(struct xfs_inode *ip) { From patchwork Fri Dec 6 23:35:13 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: 13897961 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 A9EC419ABC6 for ; Fri, 6 Dec 2024 23:35:13 +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=1733528113; cv=none; b=iibjsDLlJfLEGamdCYhkqCZrkYTnBIeqmvhpuHsn4KlUl2W4XYijElKc2uBedsnhpbwKQgKoSAq1KftgAj3fRZXeYDJdf4P4g+sjqnRw/WeOyNMKhexYdzPM8VbHIN8pOFg0ofU+w61esu+U4XWL1YiSwB3nLzqX650CX7QCtKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528113; c=relaxed/simple; bh=2+0NHwJPfZbN3FbvKf+1GSVKoi27sF11Vfu7nE3YvjU=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JznEIQSmC1226AdxjNVckjTpyAOsKyWY5Q+cyt2y59BrNmAZAbDdTiqdApAyE41wFx/WKHRkN6ZE2K9aWdgC6O4Ko42yhUszsS7tTqoJkOEcOyjJ1ZcD8JshVM1AZx2ikEAVHGGtXcjol8Jwk/yvd4lYhQRNrAtTcshuxi/QR28= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JqgITbuT; 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="JqgITbuT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81E96C4CED1; Fri, 6 Dec 2024 23:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528113; bh=2+0NHwJPfZbN3FbvKf+1GSVKoi27sF11Vfu7nE3YvjU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=JqgITbuTaBO68UiqcACUM8HW4+VQPAj3uOJGFeqtnoZKtP8R19j/sl75EV/Gi16i1 AEm7WvUMdASXX0/Au2nUFp0cDGEYLCaB6O3kN4wZgoOfB0vhqprOChiUdqhSTp1ic6 tf35yzHtEEKo6BI78NtZaTqX94yS+9nSQZtOC2CZ059oRwJKKZqUWNiIj5sGucQlaM gzUaYZId+NoJeyY12Vkc+16VEQLzlXPwLKrk8eX7Kq3VqugV9+zoGz8t9tNX4F/Ys4 vqHOLCRTNKSR23H8fpj9GyJIONO4gKgbSnVl3zDj25B5rd0Pi9dBY15hRWarF2nBp6 1RJ/aBLpyq1BQ== Date: Fri, 06 Dec 2024 15:35:13 -0800 Subject: [PATCH 19/36] xfs: move draining of deferred operations to the generic group structure From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747165.121772.8123048951170093788.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: 34cf3a6f3952ecabd54b4fe3d431aa44ce98fe45 Prepare supporting the upcoming realtime groups feature by moving the deferred operation draining to the generic xfs_group structure. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_ag.c | 7 ++----- libxfs/xfs_ag.h | 9 --------- libxfs/xfs_group.c | 4 ++++ libxfs/xfs_group.h | 9 +++++++++ 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index 20af8b67d86e88..d67e40f49a3fc0 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -110,7 +110,6 @@ xfs_perag_uninit( #ifdef __KERNEL__ struct xfs_perag *pag = to_perag(xg); - xfs_defer_drain_free(&pag->pag_intents_drain); cancel_delayed_work_sync(&pag->pag_blockgc_work); xfs_buf_cache_destroy(&pag->pag_bcache); #endif @@ -232,7 +231,6 @@ xfs_perag_alloc( spin_lock_init(&pag->pagb_lock); INIT_DELAYED_WORK(&pag->pag_blockgc_work, xfs_blockgc_worker); INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC); - xfs_defer_drain_init(&pag->pag_intents_drain); init_waitqueue_head(&pag->pagb_wait); pag->pagb_tree = RB_ROOT; xfs_hooks_init(&pag->pag_rmap_update_hooks); @@ -240,7 +238,7 @@ xfs_perag_alloc( error = xfs_buf_cache_init(&pag->pag_bcache); if (error) - goto out_defer_drain_free; + goto out_free_perag; /* * Pre-calculated geometry @@ -258,8 +256,7 @@ xfs_perag_alloc( out_buf_cache_destroy: xfs_buf_cache_destroy(&pag->pag_bcache); -out_defer_drain_free: - xfs_defer_drain_free(&pag->pag_intents_drain); +out_free_perag: kfree(pag); return error; } diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h index 8271cb72c88387..45f8de06cdbc8a 100644 --- a/libxfs/xfs_ag.h +++ b/libxfs/xfs_ag.h @@ -97,15 +97,6 @@ struct xfs_perag { /* background prealloc block trimming */ struct delayed_work pag_blockgc_work; - /* - * We use xfs_drain to track the number of deferred log intent items - * that have been queued (but not yet processed) so that waiters (e.g. - * scrub) will not lock resources when other threads are in the middle - * of processing a chain of intent items only to find momentary - * inconsistencies. - */ - struct xfs_defer_drain pag_intents_drain; - /* Hook to feed rmapbt updates to an active online repair. */ struct xfs_hooks pag_rmap_update_hooks; #endif /* __KERNEL__ */ diff --git a/libxfs/xfs_group.c b/libxfs/xfs_group.c index c5269cd659f327..dfcebf2e9b30f8 100644 --- a/libxfs/xfs_group.c +++ b/libxfs/xfs_group.c @@ -159,6 +159,8 @@ xfs_group_free( XFS_IS_CORRUPT(mp, atomic_read(&xg->xg_ref) != 0); + xfs_defer_drain_free(&xg->xg_intents_drain); + if (uninit) uninit(xg); @@ -184,6 +186,7 @@ xfs_group_insert( #ifdef __KERNEL__ spin_lock_init(&xg->xg_state_lock); #endif + xfs_defer_drain_init(&xg->xg_intents_drain); /* Active ref owned by mount indicates group is online. */ atomic_set(&xg->xg_active_ref, 1); @@ -191,6 +194,7 @@ xfs_group_insert( error = xa_insert(&mp->m_groups[type].xa, index, xg, GFP_KERNEL); if (error) { WARN_ON_ONCE(error == -EBUSY); + xfs_defer_drain_free(&xg->xg_intents_drain); return error; } diff --git a/libxfs/xfs_group.h b/libxfs/xfs_group.h index d2c61dd1f43e44..ebefbba7d98cc2 100644 --- a/libxfs/xfs_group.h +++ b/libxfs/xfs_group.h @@ -22,6 +22,15 @@ struct xfs_group { uint16_t xg_checked; uint16_t xg_sick; spinlock_t xg_state_lock; + + /* + * We use xfs_drain to track the number of deferred log intent items + * that have been queued (but not yet processed) so that waiters (e.g. + * scrub) will not lock resources when other threads are in the middle + * of processing a chain of intent items only to find momentary + * inconsistencies. + */ + struct xfs_defer_drain xg_intents_drain; #endif /* __KERNEL__ */ }; From patchwork Fri Dec 6 23:35:28 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: 13897962 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 A782719ABC6 for ; Fri, 6 Dec 2024 23:35:29 +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=1733528129; cv=none; b=Fb0vl2GKhOUX1aDponIrPWoKNbzgyap9JTpi2nCOILA3X8oBF0wT803D1XsGAXHd+c+HcLfOQ5u/jP1tnGCsMYr9sE67fWsXwBude7twmM/dCeEgMNWX1fBksqdqc7iBvSbvWqzbXJKK6B9RA4lHFCgLs0cTf7M0ugYck7DX/ww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528129; c=relaxed/simple; bh=SAj7uXJsuNCGSZqu/M47GZIqIp0+p7nHnu1QuOwjvhg=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pm3J30lXdeO1bsXAQfwKI8jNX/oY3RFcQnTbvwfM177SgSFaGSK1IP7tD6XrXgz+z2hgeObiwVAwFUZ9w1r4m2nO22PhmpCP56XwrKJ/thvuv6mN31rMR08/q3Z2n2vVuCwXC8H7E3EODd9UOEvO3yVPViptZd3U0HOJUZ4VXz0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uPBuuubM; 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="uPBuuubM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20E14C4CED1; Fri, 6 Dec 2024 23:35:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528129; bh=SAj7uXJsuNCGSZqu/M47GZIqIp0+p7nHnu1QuOwjvhg=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=uPBuuubM1CfkmQqhkWPbhrD1j2xNnzGSY95AtKAUbl3TtLriOWltFRagRVN3J1GSt Bknp978HGZRTdkAt4ICvYEZSyAhJnHMxqtgMB1C1B3kibe/Y2B0rPwJtYWHzMV18Pj UP/4cBTXH9YikLa3LydtV039Uc3FwULcjfCPU3sxNtOWLnw0VDklbGf30aWf3VCr6l aa/QUD2axK9CFXVkCJPl8cTjdrn8Q+5kOLFvaNTxBUiMNfQulfWQi1/Dw1ziSG6Ry9 AV3ToqMjpuJ8OoLIdwe/lAha1VJJrZBpI1XMF/Eo0RhrMD0oVCdsY9Zfqu3PltLq92 qo5e7fNkopF3Q== Date: Fri, 06 Dec 2024 15:35:28 -0800 Subject: [PATCH 20/36] xfs: move the online repair rmap hooks to the generic group structure From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747180.121772.11042488996630419562.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: eb4a84a3c2bd09efe770fa940fb68e349f90c8c6 Prepare for the upcoming realtime groups feature by moving the online repair rmap hooks to based to the generic xfs_group structure. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_ag.c | 1 - libxfs/xfs_ag.h | 3 --- libxfs/xfs_group.c | 1 + libxfs/xfs_group.h | 5 +++++ libxfs/xfs_rmap.c | 24 +++++++++++++----------- libxfs/xfs_rmap.h | 4 ++-- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index d67e40f49a3fc0..1542fea06e305e 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -233,7 +233,6 @@ xfs_perag_alloc( INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC); init_waitqueue_head(&pag->pagb_wait); pag->pagb_tree = RB_ROOT; - xfs_hooks_init(&pag->pag_rmap_update_hooks); #endif /* __KERNEL__ */ error = xfs_buf_cache_init(&pag->pag_bcache); diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h index 45f8de06cdbc8a..042ee0913fb9b9 100644 --- a/libxfs/xfs_ag.h +++ b/libxfs/xfs_ag.h @@ -96,9 +96,6 @@ struct xfs_perag { /* background prealloc block trimming */ struct delayed_work pag_blockgc_work; - - /* Hook to feed rmapbt updates to an active online repair. */ - struct xfs_hooks pag_rmap_update_hooks; #endif /* __KERNEL__ */ }; diff --git a/libxfs/xfs_group.c b/libxfs/xfs_group.c index dfcebf2e9b30f8..58ace330a765cf 100644 --- a/libxfs/xfs_group.c +++ b/libxfs/xfs_group.c @@ -185,6 +185,7 @@ xfs_group_insert( #ifdef __KERNEL__ spin_lock_init(&xg->xg_state_lock); + xfs_hooks_init(&xg->xg_rmap_update_hooks); #endif xfs_defer_drain_init(&xg->xg_intents_drain); diff --git a/libxfs/xfs_group.h b/libxfs/xfs_group.h index ebefbba7d98cc2..a87b9b80ef7516 100644 --- a/libxfs/xfs_group.h +++ b/libxfs/xfs_group.h @@ -31,6 +31,11 @@ struct xfs_group { * inconsistencies. */ struct xfs_defer_drain xg_intents_drain; + + /* + * Hook to feed rmapbt updates to an active online repair. + */ + struct xfs_hooks xg_rmap_update_hooks; #endif /* __KERNEL__ */ }; diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index 0f7dee40bda87a..e13f4aa7e99538 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -834,7 +834,7 @@ xfs_rmap_hook_enable(void) static inline void xfs_rmap_update_hook( struct xfs_trans *tp, - struct xfs_perag *pag, + struct xfs_group *xg, enum xfs_rmap_intent_type op, xfs_agblock_t startblock, xfs_extlen_t blockcount, @@ -849,27 +849,27 @@ xfs_rmap_update_hook( .oinfo = *oinfo, /* struct copy */ }; - if (pag) - xfs_hooks_call(&pag->pag_rmap_update_hooks, op, &p); + if (xg) + xfs_hooks_call(&xg->xg_rmap_update_hooks, op, &p); } } /* Call the specified function during a reverse mapping update. */ int xfs_rmap_hook_add( - struct xfs_perag *pag, + struct xfs_group *xg, struct xfs_rmap_hook *hook) { - return xfs_hooks_add(&pag->pag_rmap_update_hooks, &hook->rmap_hook); + return xfs_hooks_add(&xg->xg_rmap_update_hooks, &hook->rmap_hook); } /* Stop calling the specified function during a reverse mapping update. */ void xfs_rmap_hook_del( - struct xfs_perag *pag, + struct xfs_group *xg, struct xfs_rmap_hook *hook) { - xfs_hooks_del(&pag->pag_rmap_update_hooks, &hook->rmap_hook); + xfs_hooks_del(&xg->xg_rmap_update_hooks, &hook->rmap_hook); } /* Configure rmap update hook functions. */ @@ -904,7 +904,8 @@ xfs_rmap_free( return 0; cur = xfs_rmapbt_init_cursor(mp, tp, agbp, pag); - xfs_rmap_update_hook(tp, pag, XFS_RMAP_UNMAP, bno, len, false, oinfo); + xfs_rmap_update_hook(tp, pag_group(pag), XFS_RMAP_UNMAP, bno, len, + false, oinfo); error = xfs_rmap_unmap(cur, bno, len, false, oinfo); xfs_btree_del_cursor(cur, error); @@ -1148,7 +1149,8 @@ xfs_rmap_alloc( return 0; cur = xfs_rmapbt_init_cursor(mp, tp, agbp, pag); - xfs_rmap_update_hook(tp, pag, XFS_RMAP_MAP, bno, len, false, oinfo); + xfs_rmap_update_hook(tp, pag_group(pag), XFS_RMAP_MAP, bno, len, false, + oinfo); error = xfs_rmap_map(cur, bno, len, false, oinfo); xfs_btree_del_cursor(cur, error); @@ -2619,8 +2621,8 @@ xfs_rmap_finish_one( if (error) return error; - xfs_rmap_update_hook(tp, ri->ri_pag, ri->ri_type, bno, - ri->ri_bmap.br_blockcount, unwritten, &oinfo); + xfs_rmap_update_hook(tp, pag_group(ri->ri_pag), ri->ri_type, bno, + ri->ri_bmap.br_blockcount, unwritten, &oinfo); return 0; } diff --git a/libxfs/xfs_rmap.h b/libxfs/xfs_rmap.h index b783dd4dd95d1a..d409b463bc6662 100644 --- a/libxfs/xfs_rmap.h +++ b/libxfs/xfs_rmap.h @@ -264,8 +264,8 @@ struct xfs_rmap_hook { void xfs_rmap_hook_disable(void); void xfs_rmap_hook_enable(void); -int xfs_rmap_hook_add(struct xfs_perag *pag, struct xfs_rmap_hook *hook); -void xfs_rmap_hook_del(struct xfs_perag *pag, struct xfs_rmap_hook *hook); +int xfs_rmap_hook_add(struct xfs_group *xg, struct xfs_rmap_hook *hook); +void xfs_rmap_hook_del(struct xfs_group *xg, struct xfs_rmap_hook *hook); void xfs_rmap_hook_setup(struct xfs_rmap_hook *hook, notifier_fn_t mod_fn); #endif From patchwork Fri Dec 6 23:35:44 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: 13897963 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 D6F101D04A4 for ; Fri, 6 Dec 2024 23:35:44 +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=1733528144; cv=none; b=ftZbbI6mQk6WJDEPYdbY2iVSnQBfS5ifhdIIyOPfYjWvdVTXlJrBSAyL+S3d28hO+QacNLFWp2w+WRGUVlrO2ePj03PHGdaN/gu1loXEHjX0QR2+dYv6+AWw1AVWXPuZyDYT5WiO/fCiHrJny3/YQSOKtB/1iMjtht1Yq7CeYNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528144; c=relaxed/simple; bh=2klDAVxueaajz/YzXZ91UAzparzNVLrWYYs9PNzbmFg=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Qi0VmgW/t8MJweMLP1jl0+L4zNuO7Xa+DzyX5lhMhMyyI06jDczLubRKFAz52q1FWmCefALRjk8BejVPxq3+DTaLrg3N+zC0H73gkV98UipfPvw63Av++NaiPIpd65gzSe7b1SOuiSJrmPMyePSmghtZFxeK/f2Xr57wUnWxMx8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jzSmZagF; 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="jzSmZagF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACD57C4CED1; Fri, 6 Dec 2024 23:35:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528144; bh=2klDAVxueaajz/YzXZ91UAzparzNVLrWYYs9PNzbmFg=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=jzSmZagFogLb7LGi6RVuEMomlsVnkcuFDkYLIjBDFUbumTVbzITwRoxIJVOM1wc8v pJ2xprV8fklN1w3Y1FiQn43y3aK9FlG1qIBey4odwlXGPsRkSQhv6hmP2G7HCfopMZ E2+CyTJpV9J6FLCse9ymmXfD7OLdr7ulNdMWtX/dGifYiMQwjgI3qNXNI8Zg0oF83A 9dV74cdMERXRz+EJMHuT+zild2S+aAX/xSZF/m0SyMOQtxsg1phArCKgr1DtGu0Elt c7thwdCq451o0VSIUXiMrxJsQieVTCiDbLcqRjW7wZTAWM1/pQ19JBwcSq5qK3Uo5z pQWz2px1TIyJg== Date: Fri, 06 Dec 2024 15:35:44 -0800 Subject: [PATCH 21/36] xfs: convert busy extent tracking to the generic group structure From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747195.121772.3209287879404032100.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: adbc76aa0fedcb6da2d1ceb1ce786d1f963afee8 Split busy extent tracking from struct xfs_perag into its own private structure, which can be pointed to by the generic group structure. Note that this structure is now dynamically allocated instead of embedded as the upcoming zone XFS code doesn't need it and will also have an unusually high number of groups due to hardware constraints. Dynamically allocating the structure this is a big memory saver for this case. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/libxfs_priv.h | 6 +++--- libxfs/xfs_ag.c | 3 --- libxfs/xfs_ag.h | 5 ----- libxfs/xfs_alloc.c | 29 +++++++++++++++++------------ libxfs/xfs_alloc_btree.c | 4 ++-- libxfs/xfs_group.c | 15 +++++++++++++-- libxfs/xfs_group.h | 5 +++++ libxfs/xfs_rmap_btree.c | 4 ++-- 8 files changed, 42 insertions(+), 29 deletions(-) diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 9505806131bc42..1b6bb961b7ac06 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -467,11 +467,11 @@ xfs_buf_readahead( #define xfs_extent_busy_reuse(...) ((void) 0) /* avoid unused variable warning */ -#define xfs_extent_busy_insert(tp,pag,bno,len,flags)({ \ - struct xfs_perag *__foo = pag; \ +#define xfs_extent_busy_insert(tp,xg,bno,len,flags)({ \ + struct xfs_group *__foo = xg; \ __foo = __foo; /* no set-but-unused warning */ \ }) -#define xfs_extent_busy_trim(args,bno,len,busy_gen) ({ \ +#define xfs_extent_busy_trim(group,minlen,maxlen,bno,len,busy_gen) ({ \ unsigned __foo = *(busy_gen); \ *(busy_gen) = __foo; \ false; \ diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index 1542fea06e305e..bd38ac175bbae3 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -228,11 +228,8 @@ xfs_perag_alloc( #ifdef __KERNEL__ /* Place kernel structure only init below this point. */ spin_lock_init(&pag->pag_ici_lock); - spin_lock_init(&pag->pagb_lock); INIT_DELAYED_WORK(&pag->pag_blockgc_work, xfs_blockgc_worker); INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC); - init_waitqueue_head(&pag->pagb_wait); - pag->pagb_tree = RB_ROOT; #endif /* __KERNEL__ */ error = xfs_buf_cache_init(&pag->pag_bcache); diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h index 042ee0913fb9b9..7290148fa6e6aa 100644 --- a/libxfs/xfs_ag.h +++ b/libxfs/xfs_ag.h @@ -80,11 +80,6 @@ struct xfs_perag { uint8_t pagf_repair_rmap_level; #endif - spinlock_t pagb_lock; /* lock for pagb_tree */ - struct rb_root pagb_tree; /* ordered tree of busy extents */ - unsigned int pagb_gen; /* generation count for pagb_tree */ - wait_queue_head_t pagb_wait; /* woken when pagb_gen changes */ - atomic_t pagf_fstrms; /* # of filestreams active in this AG */ spinlock_t pag_ici_lock; /* incore inode cache lock */ diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index 39e1961078ae3a..1c50358a8be7ae 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -327,7 +327,8 @@ xfs_alloc_compute_aligned( bool busy; /* Trim busy sections out of found extent */ - busy = xfs_extent_busy_trim(args, &bno, &len, busy_gen); + busy = xfs_extent_busy_trim(pag_group(args->pag), args->minlen, + args->maxlen, &bno, &len, busy_gen); /* * If we have a largish extent that happens to start before min_agbno, @@ -1247,7 +1248,7 @@ xfs_alloc_ag_vextent_small( if (fbno == NULLAGBLOCK) goto out; - xfs_extent_busy_reuse(args->pag, fbno, 1, + xfs_extent_busy_reuse(pag_group(args->pag), fbno, 1, (args->datatype & XFS_ALLOC_NOBUSY)); if (args->datatype & XFS_ALLOC_USERDATA) { @@ -1360,7 +1361,8 @@ xfs_alloc_ag_vextent_exact( */ tbno = fbno; tlen = flen; - xfs_extent_busy_trim(args, &tbno, &tlen, &busy_gen); + xfs_extent_busy_trim(pag_group(args->pag), args->minlen, args->maxlen, + &tbno, &tlen, &busy_gen); /* * Give up if the start of the extent is busy, or the freespace isn't @@ -1753,8 +1755,9 @@ xfs_alloc_ag_vextent_near( * the allocation can be retried. */ trace_xfs_alloc_near_busy(args); - error = xfs_extent_busy_flush(args->tp, args->pag, - acur.busy_gen, alloc_flags); + error = xfs_extent_busy_flush(args->tp, + pag_group(args->pag), acur.busy_gen, + alloc_flags); if (error) goto out; @@ -1869,8 +1872,9 @@ xfs_alloc_ag_vextent_size( * the allocation can be retried. */ trace_xfs_alloc_size_busy(args); - error = xfs_extent_busy_flush(args->tp, args->pag, - busy_gen, alloc_flags); + error = xfs_extent_busy_flush(args->tp, + pag_group(args->pag), busy_gen, + alloc_flags); if (error) goto error0; @@ -1968,8 +1972,9 @@ xfs_alloc_ag_vextent_size( * the allocation can be retried. */ trace_xfs_alloc_size_busy(args); - error = xfs_extent_busy_flush(args->tp, args->pag, - busy_gen, alloc_flags); + error = xfs_extent_busy_flush(args->tp, + pag_group(args->pag), busy_gen, + alloc_flags); if (error) goto error0; @@ -3609,8 +3614,8 @@ xfs_alloc_vextent_finish( if (error) goto out_drop_perag; - ASSERT(!xfs_extent_busy_search(args->pag, args->agbno, - args->len)); + ASSERT(!xfs_extent_busy_search(pag_group(args->pag), + args->agbno, args->len)); } xfs_ag_resv_alloc_extent(args->pag, args->resv, args); @@ -4008,7 +4013,7 @@ __xfs_free_extent( if (skip_discard) busy_flags |= XFS_EXTENT_BUSY_SKIP_DISCARD; - xfs_extent_busy_insert(tp, pag, agbno, len, busy_flags); + xfs_extent_busy_insert(tp, pag_group(pag), agbno, len, busy_flags); return 0; err_release: diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c index 667655a639fef1..bf906aeb2f8a9e 100644 --- a/libxfs/xfs_alloc_btree.c +++ b/libxfs/xfs_alloc_btree.c @@ -84,7 +84,7 @@ xfs_allocbt_alloc_block( } atomic64_inc(&cur->bc_mp->m_allocbt_blks); - xfs_extent_busy_reuse(cur->bc_ag.pag, bno, 1, false); + xfs_extent_busy_reuse(pag_group(cur->bc_ag.pag), bno, 1, false); new->s = cpu_to_be32(bno); @@ -108,7 +108,7 @@ xfs_allocbt_free_block( return error; atomic64_dec(&cur->bc_mp->m_allocbt_blks); - xfs_extent_busy_insert(cur->bc_tp, agbp->b_pag, bno, 1, + xfs_extent_busy_insert(cur->bc_tp, pag_group(agbp->b_pag), bno, 1, XFS_EXTENT_BUSY_SKIP_DISCARD); return 0; } diff --git a/libxfs/xfs_group.c b/libxfs/xfs_group.c index 58ace330a765cf..9c7fa99d00b802 100644 --- a/libxfs/xfs_group.c +++ b/libxfs/xfs_group.c @@ -160,6 +160,9 @@ xfs_group_free( XFS_IS_CORRUPT(mp, atomic_read(&xg->xg_ref) != 0); xfs_defer_drain_free(&xg->xg_intents_drain); +#ifdef __KERNEL__ + kfree(xg->xg_busy_extents); +#endif if (uninit) uninit(xg); @@ -184,6 +187,9 @@ xfs_group_insert( xg->xg_type = type; #ifdef __KERNEL__ + xg->xg_busy_extents = xfs_extent_busy_alloc(); + if (!xg->xg_busy_extents) + return -ENOMEM; spin_lock_init(&xg->xg_state_lock); xfs_hooks_init(&xg->xg_rmap_update_hooks); #endif @@ -195,9 +201,14 @@ xfs_group_insert( error = xa_insert(&mp->m_groups[type].xa, index, xg, GFP_KERNEL); if (error) { WARN_ON_ONCE(error == -EBUSY); - xfs_defer_drain_free(&xg->xg_intents_drain); - return error; + goto out_drain; } return 0; +out_drain: + xfs_defer_drain_free(&xg->xg_intents_drain); +#ifdef __KERNEL__ + kfree(xg->xg_busy_extents); +#endif + return error; } diff --git a/libxfs/xfs_group.h b/libxfs/xfs_group.h index a87b9b80ef7516..0ff6e1d5635cb1 100644 --- a/libxfs/xfs_group.h +++ b/libxfs/xfs_group.h @@ -15,6 +15,11 @@ struct xfs_group { #ifdef __KERNEL__ /* -- kernel only structures below this line -- */ + /* + * Track freed but not yet committed extents. + */ + struct xfs_extent_busy_tree *xg_busy_extents; + /* * Bitsets of per-ag metadata that have been checked and/or are sick. * Callers should hold xg_state_lock before accessing this field. diff --git a/libxfs/xfs_rmap_btree.c b/libxfs/xfs_rmap_btree.c index ebb2519cf8baf3..5829e68790314a 100644 --- a/libxfs/xfs_rmap_btree.c +++ b/libxfs/xfs_rmap_btree.c @@ -101,7 +101,7 @@ xfs_rmapbt_alloc_block( return 0; } - xfs_extent_busy_reuse(pag, bno, 1, false); + xfs_extent_busy_reuse(pag_group(pag), bno, 1, false); new->s = cpu_to_be32(bno); be32_add_cpu(&agf->agf_rmap_blocks, 1); @@ -135,7 +135,7 @@ xfs_rmapbt_free_block( if (error) return error; - xfs_extent_busy_insert(cur->bc_tp, pag, bno, 1, + xfs_extent_busy_insert(cur->bc_tp, pag_group(pag), bno, 1, XFS_EXTENT_BUSY_SKIP_DISCARD); xfs_ag_resv_free_extent(pag, XFS_AG_RESV_RMAPBT, NULL, 1); From patchwork Fri Dec 6 23:35:59 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: 13897964 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 9CB43212F85 for ; Fri, 6 Dec 2024 23:36:00 +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=1733528160; cv=none; b=pi/WtO5f/P+VcY4QbyeKtFtVbKCLlcYMann4ow+kVSJKxVyFzqVFogWM3VQg4s3H97DyrEMtvdxrf0mIrwoU6sz1uwKMEA43/Hr59Gp5P3G/nbyLEJdJ5e9NISfUefQEO2cSU94jgpukJGuEcUGuomn74eLbj4ant8PPB/qmuHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528160; c=relaxed/simple; bh=SSVr6MODEMUQtVReEtFLLyP/5pSmIDisojFW++NBR+U=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WqdbLfjxmNZAqjd5EPUpJh+bIDsbmoOGoLHyIR+epxAUy1V2tuA3DDkIoUiQ0M3nob+bo7lS7tjJjqb7jFjCPVhukt0bFSI9HWnIq3/u3AGxpJJiUYUdIgNpyuNAK8OPG9OONnkv5NZmffzxyOzol+u0PsfWcCVsFPupRQHqY7U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b2S867sf; 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="b2S867sf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52207C4CED1; Fri, 6 Dec 2024 23:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528160; bh=SSVr6MODEMUQtVReEtFLLyP/5pSmIDisojFW++NBR+U=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=b2S867sfrHnNu9uhzXUmJMkOGUEYZ1gUWuOBTjDsSPxMjyezkK9hVfLKWECe7hWG3 Ra2gnFpMQyyX1V3FeVAEpu/bAOsqir5PMctMKMITzZL7S0kUrV1Gb8+7oAAcllOa4I KGgHgDndGrkJz64bUY27rxZm9vMS3LTxw0275QFV8PL4xO/xUqhu+kwc3w2NVwMSRE jotY/2NMx7zrQ1VhltHue4QbWsIsHr0HVvoJdv4hYcYhzqMAAxY23XwrF2LFmDY7Qh zD5ul+diP2sbGHN+juvoVdTd0ZXsB0YWfxivi8ncFTKjkPCZ7QQ1mk5gKubowU1gXy IFY8taDv6FKyQ== Date: Fri, 06 Dec 2024 15:35:59 -0800 Subject: [PATCH 22/36] xfs: add a generic group pointer to the btree cursor From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747211.121772.6490104857306106223.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: 77a530e6c49d22bd4a221d2f059db24fc30094db Replace the pag pointers in the type specific union with a generic xfs_group pointer. This prepares for adding realtime group support. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_alloc.c | 8 ++++---- libxfs/xfs_alloc_btree.c | 28 ++++++++++++++-------------- libxfs/xfs_btree.c | 35 ++++++++++++----------------------- libxfs/xfs_btree.h | 3 +-- libxfs/xfs_btree_mem.c | 6 ++---- libxfs/xfs_ialloc.c | 12 +++++++----- libxfs/xfs_ialloc_btree.c | 15 ++++++++------- libxfs/xfs_refcount.c | 17 +++++++++-------- libxfs/xfs_refcount_btree.c | 10 +++++----- libxfs/xfs_rmap.c | 8 +++----- libxfs/xfs_rmap_btree.c | 19 ++++++++++--------- repair/agbtree.c | 6 +++--- repair/bmap_repair.c | 4 ++-- 13 files changed, 80 insertions(+), 91 deletions(-) diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index 1c50358a8be7ae..c449285743534d 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -271,7 +271,7 @@ xfs_alloc_complain_bad_rec( xfs_warn(mp, "%sbt record corruption in AG %d detected at %pS!", - cur->bc_ops->name, pag_agno(cur->bc_ag.pag), fa); + cur->bc_ops->name, cur->bc_group->xg_gno, fa); xfs_warn(mp, "start block 0x%x block count 0x%x", irec->ar_startblock, irec->ar_blockcount); @@ -299,7 +299,7 @@ xfs_alloc_get_rec( return error; xfs_alloc_btrec_to_irec(rec, &irec); - fa = xfs_alloc_check_irec(cur->bc_ag.pag, &irec); + fa = xfs_alloc_check_irec(to_perag(cur->bc_group), &irec); if (fa) return xfs_alloc_complain_bad_rec(cur, fa, &irec); @@ -536,7 +536,7 @@ static int xfs_alloc_fixup_longest( struct xfs_btree_cur *cnt_cur) { - struct xfs_perag *pag = cnt_cur->bc_ag.pag; + struct xfs_perag *pag = to_perag(cnt_cur->bc_group); struct xfs_buf *bp = cnt_cur->bc_ag.agbp; struct xfs_agf *agf = bp->b_addr; xfs_extlen_t longest = 0; @@ -4038,7 +4038,7 @@ xfs_alloc_query_range_helper( xfs_failaddr_t fa; xfs_alloc_btrec_to_irec(rec, &irec); - fa = xfs_alloc_check_irec(cur->bc_ag.pag, &irec); + fa = xfs_alloc_check_irec(to_perag(cur->bc_group), &irec); if (fa) return xfs_alloc_complain_bad_rec(cur, fa, &irec); diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c index bf906aeb2f8a9e..63b8db4ed01350 100644 --- a/libxfs/xfs_alloc_btree.c +++ b/libxfs/xfs_alloc_btree.c @@ -26,7 +26,7 @@ xfs_bnobt_dup_cursor( struct xfs_btree_cur *cur) { return xfs_bnobt_init_cursor(cur->bc_mp, cur->bc_tp, cur->bc_ag.agbp, - cur->bc_ag.pag); + to_perag(cur->bc_group)); } STATIC struct xfs_btree_cur * @@ -34,29 +34,29 @@ xfs_cntbt_dup_cursor( struct xfs_btree_cur *cur) { return xfs_cntbt_init_cursor(cur->bc_mp, cur->bc_tp, cur->bc_ag.agbp, - cur->bc_ag.pag); + to_perag(cur->bc_group)); } - STATIC void xfs_allocbt_set_root( struct xfs_btree_cur *cur, const union xfs_btree_ptr *ptr, int inc) { - struct xfs_buf *agbp = cur->bc_ag.agbp; - struct xfs_agf *agf = agbp->b_addr; + struct xfs_perag *pag = to_perag(cur->bc_group); + struct xfs_buf *agbp = cur->bc_ag.agbp; + struct xfs_agf *agf = agbp->b_addr; ASSERT(ptr->s != 0); if (xfs_btree_is_bno(cur->bc_ops)) { agf->agf_bno_root = ptr->s; be32_add_cpu(&agf->agf_bno_level, inc); - cur->bc_ag.pag->pagf_bno_level += inc; + pag->pagf_bno_level += inc; } else { agf->agf_cnt_root = ptr->s; be32_add_cpu(&agf->agf_cnt_level, inc); - cur->bc_ag.pag->pagf_cnt_level += inc; + pag->pagf_cnt_level += inc; } xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_ROOTS | XFS_AGF_LEVELS); @@ -73,7 +73,7 @@ xfs_allocbt_alloc_block( xfs_agblock_t bno; /* Allocate the new block from the freelist. If we can't, give up. */ - error = xfs_alloc_get_freelist(cur->bc_ag.pag, cur->bc_tp, + error = xfs_alloc_get_freelist(to_perag(cur->bc_group), cur->bc_tp, cur->bc_ag.agbp, &bno, 1); if (error) return error; @@ -84,7 +84,7 @@ xfs_allocbt_alloc_block( } atomic64_inc(&cur->bc_mp->m_allocbt_blks); - xfs_extent_busy_reuse(pag_group(cur->bc_ag.pag), bno, 1, false); + xfs_extent_busy_reuse(cur->bc_group, bno, 1, false); new->s = cpu_to_be32(bno); @@ -102,8 +102,8 @@ xfs_allocbt_free_block( int error; bno = xfs_daddr_to_agbno(cur->bc_mp, xfs_buf_daddr(bp)); - error = xfs_alloc_put_freelist(cur->bc_ag.pag, cur->bc_tp, agbp, NULL, - bno, 1); + error = xfs_alloc_put_freelist(to_perag(cur->bc_group), cur->bc_tp, + agbp, NULL, bno, 1); if (error) return error; @@ -176,7 +176,7 @@ xfs_allocbt_init_ptr_from_cur( { struct xfs_agf *agf = cur->bc_ag.agbp->b_addr; - ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agf->agf_seqno)); + ASSERT(cur->bc_group->xg_gno == be32_to_cpu(agf->agf_seqno)); if (xfs_btree_is_bno(cur->bc_ops)) ptr->s = agf->agf_bno_root; @@ -490,7 +490,7 @@ xfs_bnobt_init_cursor( cur = xfs_btree_alloc_cursor(mp, tp, &xfs_bnobt_ops, mp->m_alloc_maxlevels, xfs_allocbt_cur_cache); - cur->bc_ag.pag = xfs_perag_hold(pag); + cur->bc_group = xfs_group_hold(pag_group(pag)); cur->bc_ag.agbp = agbp; if (agbp) { struct xfs_agf *agf = agbp->b_addr; @@ -516,7 +516,7 @@ xfs_cntbt_init_cursor( cur = xfs_btree_alloc_cursor(mp, tp, &xfs_cntbt_ops, mp->m_alloc_maxlevels, xfs_allocbt_cur_cache); - cur->bc_ag.pag = xfs_perag_hold(pag); + cur->bc_group = xfs_group_hold(pag_group(pag)); cur->bc_ag.agbp = agbp; if (agbp) { struct xfs_agf *agf = agbp->b_addr; diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index 2b63c18114763c..3d870f3f4a5165 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -223,7 +223,7 @@ __xfs_btree_check_agblock( struct xfs_buf *bp) { struct xfs_mount *mp = cur->bc_mp; - struct xfs_perag *pag = cur->bc_ag.pag; + struct xfs_perag *pag = to_perag(cur->bc_group); xfs_failaddr_t fa; xfs_agblock_t agbno; @@ -329,7 +329,7 @@ __xfs_btree_check_ptr( return -EFSCORRUPTED; break; case XFS_BTREE_TYPE_AG: - if (!xfs_verify_agbno(cur->bc_ag.pag, + if (!xfs_verify_agbno(to_perag(cur->bc_group), be32_to_cpu((&ptr->s)[index]))) return -EFSCORRUPTED; break; @@ -370,7 +370,7 @@ xfs_btree_check_ptr( case XFS_BTREE_TYPE_AG: xfs_err(cur->bc_mp, "AG %u: Corrupt %sbt pointer at level %d index %d.", - pag_agno(cur->bc_ag.pag), cur->bc_ops->name, + cur->bc_group->xg_gno, cur->bc_ops->name, level, index); break; } @@ -521,20 +521,8 @@ xfs_btree_del_cursor( ASSERT(!xfs_btree_is_bmap(cur->bc_ops) || cur->bc_bmap.allocated == 0 || xfs_is_shutdown(cur->bc_mp) || error != 0); - switch (cur->bc_ops->type) { - case XFS_BTREE_TYPE_AG: - if (cur->bc_ag.pag) - xfs_perag_put(cur->bc_ag.pag); - break; - case XFS_BTREE_TYPE_INODE: - /* nothing to do */ - break; - case XFS_BTREE_TYPE_MEM: - if (cur->bc_mem.pag) - xfs_perag_put(cur->bc_mem.pag); - break; - } - + if (cur->bc_group) + xfs_group_put(cur->bc_group); kmem_cache_free(cur->bc_cache, cur); } @@ -1015,21 +1003,22 @@ xfs_btree_readahead_agblock( struct xfs_btree_block *block) { struct xfs_mount *mp = cur->bc_mp; + struct xfs_perag *pag = to_perag(cur->bc_group); xfs_agblock_t left = be32_to_cpu(block->bb_u.s.bb_leftsib); xfs_agblock_t right = be32_to_cpu(block->bb_u.s.bb_rightsib); int rval = 0; if ((lr & XFS_BTCUR_LEFTRA) && left != NULLAGBLOCK) { xfs_buf_readahead(mp->m_ddev_targp, - xfs_agbno_to_daddr(cur->bc_ag.pag, left), - mp->m_bsize, cur->bc_ops->buf_ops); + xfs_agbno_to_daddr(pag, left), mp->m_bsize, + cur->bc_ops->buf_ops); rval++; } if ((lr & XFS_BTCUR_RIGHTRA) && right != NULLAGBLOCK) { xfs_buf_readahead(mp->m_ddev_targp, - xfs_agbno_to_daddr(cur->bc_ag.pag, right), - mp->m_bsize, cur->bc_ops->buf_ops); + xfs_agbno_to_daddr(pag, right), mp->m_bsize, + cur->bc_ops->buf_ops); rval++; } @@ -1088,7 +1077,7 @@ xfs_btree_ptr_to_daddr( switch (cur->bc_ops->type) { case XFS_BTREE_TYPE_AG: - *daddr = xfs_agbno_to_daddr(cur->bc_ag.pag, + *daddr = xfs_agbno_to_daddr(to_perag(cur->bc_group), be32_to_cpu(ptr->s)); break; case XFS_BTREE_TYPE_INODE: @@ -1310,7 +1299,7 @@ xfs_btree_owner( case XFS_BTREE_TYPE_INODE: return cur->bc_ino.ip->i_ino; case XFS_BTREE_TYPE_AG: - return pag_agno(cur->bc_ag.pag); + return cur->bc_group->xg_gno; default: ASSERT(0); return 0; diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h index 10b7ddc3b2b34e..3b739459ebb0f4 100644 --- a/libxfs/xfs_btree.h +++ b/libxfs/xfs_btree.h @@ -254,6 +254,7 @@ struct xfs_btree_cur union xfs_btree_irec bc_rec; /* current insert/search record value */ uint8_t bc_nlevels; /* number of levels in the tree */ uint8_t bc_maxlevels; /* maximum levels for this btree type */ + struct xfs_group *bc_group; /* per-type information */ union { @@ -264,13 +265,11 @@ struct xfs_btree_cur struct xbtree_ifakeroot *ifake; /* for staging cursor */ } bc_ino; struct { - struct xfs_perag *pag; struct xfs_buf *agbp; struct xbtree_afakeroot *afake; /* for staging cursor */ } bc_ag; struct { struct xfbtree *xfbtree; - struct xfs_perag *pag; } bc_mem; }; diff --git a/libxfs/xfs_btree_mem.c b/libxfs/xfs_btree_mem.c index ae9302b9090f58..8e3efdbccc156a 100644 --- a/libxfs/xfs_btree_mem.c +++ b/libxfs/xfs_btree_mem.c @@ -56,10 +56,8 @@ xfbtree_dup_cursor( ncur->bc_flags = cur->bc_flags; ncur->bc_nlevels = cur->bc_nlevels; ncur->bc_mem.xfbtree = cur->bc_mem.xfbtree; - - if (cur->bc_mem.pag) - ncur->bc_mem.pag = xfs_perag_hold(cur->bc_mem.pag); - + if (cur->bc_group) + ncur->bc_group = xfs_group_hold(cur->bc_group); return ncur; } diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index e4b9d3e2fbb5ce..055eff477faceb 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -137,7 +137,7 @@ xfs_inobt_complain_bad_rec( xfs_warn(mp, "%sbt record corruption in AG %d detected at %pS!", - cur->bc_ops->name, pag_agno(cur->bc_ag.pag), fa); + cur->bc_ops->name, cur->bc_group->xg_gno, fa); xfs_warn(mp, "start inode 0x%x, count 0x%x, free 0x%x freemask 0x%llx, holemask 0x%x", irec->ir_startino, irec->ir_count, irec->ir_freecount, @@ -165,7 +165,7 @@ xfs_inobt_get_rec( return error; xfs_inobt_btrec_to_irec(mp, rec, irec); - fa = xfs_inobt_check_irec(cur->bc_ag.pag, irec); + fa = xfs_inobt_check_irec(to_perag(cur->bc_group), irec); if (fa) return xfs_inobt_complain_bad_rec(cur, fa, irec); @@ -270,8 +270,10 @@ xfs_check_agi_freecount( } } while (i == 1); - if (!xfs_is_shutdown(cur->bc_mp)) - ASSERT(freecount == cur->bc_ag.pag->pagi_freecount); + if (!xfs_is_shutdown(cur->bc_mp)) { + ASSERT(freecount == + to_perag(cur->bc_group)->pagi_freecount); + } } return 0; } @@ -2875,7 +2877,7 @@ xfs_ialloc_count_inodes_rec( xfs_failaddr_t fa; xfs_inobt_btrec_to_irec(cur->bc_mp, rec, &irec); - fa = xfs_inobt_check_irec(cur->bc_ag.pag, &irec); + fa = xfs_inobt_check_irec(to_perag(cur->bc_group), &irec); if (fa) return xfs_inobt_complain_bad_rec(cur, fa, &irec); diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c index 45908cce464dff..4eeea240b0bd89 100644 --- a/libxfs/xfs_ialloc_btree.c +++ b/libxfs/xfs_ialloc_btree.c @@ -36,7 +36,7 @@ STATIC struct xfs_btree_cur * xfs_inobt_dup_cursor( struct xfs_btree_cur *cur) { - return xfs_inobt_init_cursor(cur->bc_ag.pag, cur->bc_tp, + return xfs_inobt_init_cursor(to_perag(cur->bc_group), cur->bc_tp, cur->bc_ag.agbp); } @@ -44,7 +44,7 @@ STATIC struct xfs_btree_cur * xfs_finobt_dup_cursor( struct xfs_btree_cur *cur) { - return xfs_finobt_init_cursor(cur->bc_ag.pag, cur->bc_tp, + return xfs_finobt_init_cursor(to_perag(cur->bc_group), cur->bc_tp, cur->bc_ag.agbp); } @@ -111,7 +111,7 @@ __xfs_inobt_alloc_block( memset(&args, 0, sizeof(args)); args.tp = cur->bc_tp; args.mp = cur->bc_mp; - args.pag = cur->bc_ag.pag; + args.pag = to_perag(cur->bc_group); args.oinfo = XFS_RMAP_OINFO_INOBT; args.minlen = 1; args.maxlen = 1; @@ -247,7 +247,7 @@ xfs_inobt_init_ptr_from_cur( { struct xfs_agi *agi = cur->bc_ag.agbp->b_addr; - ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agi->agi_seqno)); + ASSERT(cur->bc_group->xg_gno == be32_to_cpu(agi->agi_seqno)); ptr->s = agi->agi_root; } @@ -259,7 +259,8 @@ xfs_finobt_init_ptr_from_cur( { struct xfs_agi *agi = cur->bc_ag.agbp->b_addr; - ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agi->agi_seqno)); + ASSERT(cur->bc_group->xg_gno == be32_to_cpu(agi->agi_seqno)); + ptr->s = agi->agi_free_root; } @@ -482,7 +483,7 @@ xfs_inobt_init_cursor( cur = xfs_btree_alloc_cursor(mp, tp, &xfs_inobt_ops, M_IGEO(mp)->inobt_maxlevels, xfs_inobt_cur_cache); - cur->bc_ag.pag = xfs_perag_hold(pag); + cur->bc_group = xfs_group_hold(pag_group(pag)); cur->bc_ag.agbp = agbp; if (agbp) { struct xfs_agi *agi = agbp->b_addr; @@ -508,7 +509,7 @@ xfs_finobt_init_cursor( cur = xfs_btree_alloc_cursor(mp, tp, &xfs_finobt_ops, M_IGEO(mp)->inobt_maxlevels, xfs_inobt_cur_cache); - cur->bc_ag.pag = xfs_perag_hold(pag); + cur->bc_group = xfs_group_hold(pag_group(pag)); cur->bc_ag.agbp = agbp; if (agbp) { struct xfs_agi *agi = agbp->b_addr; diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 9507cf74578d4f..3eccb998545d6f 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -153,7 +153,7 @@ xfs_refcount_complain_bad_rec( xfs_warn(mp, "Refcount BTree record corruption in AG %d detected at %pS!", - pag_agno(cur->bc_ag.pag), fa); + cur->bc_group->xg_gno, fa); xfs_warn(mp, "Start block 0x%x, block count 0x%x, references 0x%x", irec->rc_startblock, irec->rc_blockcount, irec->rc_refcount); @@ -179,7 +179,7 @@ xfs_refcount_get_rec( return error; xfs_refcount_btrec_to_irec(rec, irec); - fa = xfs_refcount_check_irec(cur->bc_ag.pag, irec); + fa = xfs_refcount_check_irec(to_perag(cur->bc_group), irec); if (fa) return xfs_refcount_complain_bad_rec(cur, fa, irec); @@ -1153,7 +1153,7 @@ xfs_refcount_adjust_extents( goto out_error; } } else { - fsbno = xfs_agbno_to_fsb(cur->bc_ag.pag, + fsbno = xfs_agbno_to_fsb(to_perag(cur->bc_group), tmp.rc_startblock); error = xfs_free_extent_later(cur->bc_tp, fsbno, tmp.rc_blockcount, NULL, @@ -1215,7 +1215,7 @@ xfs_refcount_adjust_extents( } goto advloop; } else { - fsbno = xfs_agbno_to_fsb(cur->bc_ag.pag, + fsbno = xfs_agbno_to_fsb(to_perag(cur->bc_group), ext.rc_startblock); error = xfs_free_extent_later(cur->bc_tp, fsbno, ext.rc_blockcount, NULL, @@ -1309,7 +1309,7 @@ xfs_refcount_continue_op( xfs_agblock_t new_agbno) { struct xfs_mount *mp = cur->bc_mp; - struct xfs_perag *pag = cur->bc_ag.pag; + struct xfs_perag *pag = to_perag(cur->bc_group); if (XFS_IS_CORRUPT(mp, !xfs_verify_agbext(pag, new_agbno, ri->ri_blockcount))) { @@ -1357,7 +1357,7 @@ xfs_refcount_finish_one( * If we haven't gotten a cursor or the cursor AG doesn't match * the startblock, get one now. */ - if (rcur != NULL && rcur->bc_ag.pag != ri->ri_pag) { + if (rcur != NULL && to_perag(rcur->bc_group) != ri->ri_pag) { nr_ops = rcur->bc_refc.nr_ops; shape_changes = rcur->bc_refc.shape_changes; xfs_btree_del_cursor(rcur, 0); @@ -1877,7 +1877,8 @@ xfs_refcount_recover_extent( INIT_LIST_HEAD(&rr->rr_list); xfs_refcount_btrec_to_irec(rec, &rr->rr_rrec); - if (xfs_refcount_check_irec(cur->bc_ag.pag, &rr->rr_rrec) != NULL || + if (xfs_refcount_check_irec(to_perag(cur->bc_group), &rr->rr_rrec) != + NULL || XFS_IS_CORRUPT(cur->bc_mp, rr->rr_rrec.rc_domain != XFS_REFC_DOMAIN_COW)) { xfs_btree_mark_sick(cur); @@ -2025,7 +2026,7 @@ xfs_refcount_query_range_helper( xfs_failaddr_t fa; xfs_refcount_btrec_to_irec(rec, &irec); - fa = xfs_refcount_check_irec(cur->bc_ag.pag, &irec); + fa = xfs_refcount_check_irec(to_perag(cur->bc_group), &irec); if (fa) return xfs_refcount_complain_bad_rec(cur, fa, &irec); diff --git a/libxfs/xfs_refcount_btree.c b/libxfs/xfs_refcount_btree.c index e9c4fc419a6114..efb9af710f7361 100644 --- a/libxfs/xfs_refcount_btree.c +++ b/libxfs/xfs_refcount_btree.c @@ -29,7 +29,7 @@ xfs_refcountbt_dup_cursor( struct xfs_btree_cur *cur) { return xfs_refcountbt_init_cursor(cur->bc_mp, cur->bc_tp, - cur->bc_ag.agbp, cur->bc_ag.pag); + cur->bc_ag.agbp, to_perag(cur->bc_group)); } STATIC void @@ -67,7 +67,7 @@ xfs_refcountbt_alloc_block( memset(&args, 0, sizeof(args)); args.tp = cur->bc_tp; args.mp = cur->bc_mp; - args.pag = cur->bc_ag.pag; + args.pag = to_perag(cur->bc_group); args.oinfo = XFS_RMAP_OINFO_REFC; args.minlen = args.maxlen = args.prod = 1; args.resv = XFS_AG_RESV_METADATA; @@ -80,7 +80,7 @@ xfs_refcountbt_alloc_block( *stat = 0; return 0; } - ASSERT(args.agno == pag_agno(cur->bc_ag.pag)); + ASSERT(args.agno == cur->bc_group->xg_gno); ASSERT(args.len == 1); new->s = cpu_to_be32(args.agbno); @@ -168,7 +168,7 @@ xfs_refcountbt_init_ptr_from_cur( { struct xfs_agf *agf = cur->bc_ag.agbp->b_addr; - ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agf->agf_seqno)); + ASSERT(cur->bc_group->xg_gno == be32_to_cpu(agf->agf_seqno)); ptr->s = agf->agf_refcount_root; } @@ -364,7 +364,7 @@ xfs_refcountbt_init_cursor( cur = xfs_btree_alloc_cursor(mp, tp, &xfs_refcountbt_ops, mp->m_refc_maxlevels, xfs_refcountbt_cur_cache); - cur->bc_ag.pag = xfs_perag_hold(pag); + cur->bc_group = xfs_group_hold(pag_group(pag)); cur->bc_refc.nr_ops = 0; cur->bc_refc.shape_changes = 0; cur->bc_ag.agbp = agbp; diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index e13f4aa7e99538..07bcdf82d10081 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -268,9 +268,7 @@ xfs_rmap_check_btrec( struct xfs_btree_cur *cur, const struct xfs_rmap_irec *irec) { - if (xfs_btree_is_mem_rmap(cur->bc_ops)) - return xfs_rmap_check_irec(cur->bc_mem.pag, irec); - return xfs_rmap_check_irec(cur->bc_ag.pag, irec); + return xfs_rmap_check_irec(to_perag(cur->bc_group), irec); } static inline int @@ -287,7 +285,7 @@ xfs_rmap_complain_bad_rec( else xfs_warn(mp, "Reverse Mapping BTree record corruption in AG %d detected at %pS!", - pag_agno(cur->bc_ag.pag), fa); + cur->bc_group->xg_gno, fa); xfs_warn(mp, "Owner 0x%llx, flags 0x%x, start block 0x%x block count 0x%x", irec->rm_owner, irec->rm_flags, irec->rm_startblock, @@ -2587,7 +2585,7 @@ xfs_rmap_finish_one( * If we haven't gotten a cursor or the cursor AG doesn't match * the startblock, get one now. */ - if (rcur != NULL && rcur->bc_ag.pag != ri->ri_pag) { + if (rcur != NULL && to_perag(rcur->bc_group) != ri->ri_pag) { xfs_btree_del_cursor(rcur, 0); rcur = NULL; *pcur = NULL; diff --git a/libxfs/xfs_rmap_btree.c b/libxfs/xfs_rmap_btree.c index 5829e68790314a..f4da35050d2635 100644 --- a/libxfs/xfs_rmap_btree.c +++ b/libxfs/xfs_rmap_btree.c @@ -56,7 +56,7 @@ xfs_rmapbt_dup_cursor( struct xfs_btree_cur *cur) { return xfs_rmapbt_init_cursor(cur->bc_mp, cur->bc_tp, - cur->bc_ag.agbp, cur->bc_ag.pag); + cur->bc_ag.agbp, to_perag(cur->bc_group)); } STATIC void @@ -65,14 +65,15 @@ xfs_rmapbt_set_root( const union xfs_btree_ptr *ptr, int inc) { - struct xfs_buf *agbp = cur->bc_ag.agbp; - struct xfs_agf *agf = agbp->b_addr; + struct xfs_buf *agbp = cur->bc_ag.agbp; + struct xfs_agf *agf = agbp->b_addr; + struct xfs_perag *pag = to_perag(cur->bc_group); ASSERT(ptr->s != 0); agf->agf_rmap_root = ptr->s; be32_add_cpu(&agf->agf_rmap_level, inc); - cur->bc_ag.pag->pagf_rmap_level += inc; + pag->pagf_rmap_level += inc; xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_ROOTS | XFS_AGF_LEVELS); } @@ -86,7 +87,7 @@ xfs_rmapbt_alloc_block( { struct xfs_buf *agbp = cur->bc_ag.agbp; struct xfs_agf *agf = agbp->b_addr; - struct xfs_perag *pag = cur->bc_ag.pag; + struct xfs_perag *pag = to_perag(cur->bc_group); struct xfs_alloc_arg args = { .len = 1 }; int error; xfs_agblock_t bno; @@ -124,7 +125,7 @@ xfs_rmapbt_free_block( { struct xfs_buf *agbp = cur->bc_ag.agbp; struct xfs_agf *agf = agbp->b_addr; - struct xfs_perag *pag = cur->bc_ag.pag; + struct xfs_perag *pag = to_perag(cur->bc_group); xfs_agblock_t bno; int error; @@ -226,7 +227,7 @@ xfs_rmapbt_init_ptr_from_cur( { struct xfs_agf *agf = cur->bc_ag.agbp->b_addr; - ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agf->agf_seqno)); + ASSERT(cur->bc_group->xg_gno == be32_to_cpu(agf->agf_seqno)); ptr->s = agf->agf_rmap_root; } @@ -537,7 +538,7 @@ xfs_rmapbt_init_cursor( cur = xfs_btree_alloc_cursor(mp, tp, &xfs_rmapbt_ops, mp->m_rmap_maxlevels, xfs_rmapbt_cur_cache); - cur->bc_ag.pag = xfs_perag_hold(pag); + cur->bc_group = xfs_group_hold(pag_group(pag)); cur->bc_ag.agbp = agbp; if (agbp) { struct xfs_agf *agf = agbp->b_addr; @@ -652,7 +653,7 @@ xfs_rmapbt_mem_cursor( cur->bc_mem.xfbtree = xfbt; cur->bc_nlevels = xfbt->nlevels; - cur->bc_mem.pag = xfs_perag_hold(pag); + cur->bc_group = xfs_group_hold(pag_group(pag)); return cur; } diff --git a/repair/agbtree.c b/repair/agbtree.c index 67baa1acba9907..42bfeee9eafbcb 100644 --- a/repair/agbtree.c +++ b/repair/agbtree.c @@ -202,7 +202,7 @@ get_bno_rec( struct xfs_btree_cur *cur, struct extent_tree_node *prev_value) { - xfs_agnumber_t agno = pag_agno(cur->bc_ag.pag); + xfs_agnumber_t agno = cur->bc_group->xg_gno; if (xfs_btree_is_bno(cur->bc_ops)) { if (!prev_value) @@ -376,7 +376,7 @@ get_ino_rec( struct xfs_btree_cur *cur, struct ino_tree_node *prev_value) { - xfs_agnumber_t agno = pag_agno(cur->bc_ag.pag); + xfs_agnumber_t agno = cur->bc_group->xg_gno; if (xfs_btree_is_ino(cur->bc_ops)) { if (!prev_value) @@ -614,7 +614,7 @@ get_rmapbt_records( if (ret == 0) do_error( _("ran out of records while rebuilding AG %u rmap btree\n"), - pag_agno(cur->bc_ag.pag)); + cur->bc_group->xg_gno); block_rec = libxfs_btree_rec_addr(cur, idx, block); cur->bc_ops->init_rec_from_cur(cur, block_rec); diff --git a/repair/bmap_repair.c b/repair/bmap_repair.c index 3a214c85a1de5f..f052b5dcddff08 100644 --- a/repair/bmap_repair.c +++ b/repair/bmap_repair.c @@ -104,7 +104,7 @@ xrep_bmap_check_fork_rmap( return EFSCORRUPTED; /* Check that this is within the AG. */ - if (!xfs_verify_agbext(cur->bc_ag.pag, rec->rm_startblock, + if (!xfs_verify_agbext(to_perag(cur->bc_group), rec->rm_startblock, rec->rm_blockcount)) return EFSCORRUPTED; @@ -154,7 +154,7 @@ xrep_bmap_walk_rmap( !(rec->rm_flags & XFS_RMAP_ATTR_FORK)) return 0; - fsbno = xfs_agbno_to_fsb(cur->bc_ag.pag, rec->rm_startblock); + fsbno = xfs_agbno_to_fsb(to_perag(cur->bc_group), rec->rm_startblock); if (rec->rm_flags & XFS_RMAP_BMBT_BLOCK) { rb->old_bmbt_block_count += rec->rm_blockcount; From patchwork Fri Dec 6 23:36:15 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: 13897965 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 9617F1EBFFC for ; Fri, 6 Dec 2024 23:36:16 +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=1733528176; cv=none; b=NYopPQ/Tu6TtrY7ksU4aXHGKT8Vhs6LiiGmwpbKAVVWtPSozG6SQ068Djz1tylT+CKxUhutGiB4lwIV4YAGpHMKtaeiGQTOGUZuQLJGqXB/meJg5Vjvad8/5Jqrj2UZwv3+KlXvKdU7KsRj16DZFUxX495SAj9tkPJbBiYODlV8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528176; c=relaxed/simple; bh=+JgIXlcQ1FvhzVoF6u+0XwZIOBccpNiGVUK++g77swQ=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PRsuRAn5IIq288fi/Ok7/+I7uYvh7IQ4o+aKsUA7Zm63oGGOrWZAdXEog1LGX3ClDLhVn28F0+vNcV2n8a+VVo9MbGPGelhpYBz5PgNMGQaJyZk1n2hBfI6Ht3sXyskpury62axWunBo9aJewveXcOrxM5aB2YVhMh9pJik10NI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZA58Cipj; 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="ZA58Cipj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FBCDC4CED1; Fri, 6 Dec 2024 23:36:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528176; bh=+JgIXlcQ1FvhzVoF6u+0XwZIOBccpNiGVUK++g77swQ=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ZA58CipjUtNcAbMIojGSNfz8TsMb4ZecJDrab8z58MvGXkw0Vly5ruxL0Kt5HpFti MYT2Nr+IVAP/dF7P0UhmX8H5rWntx0LV/szRJvBoD+UdB3w2iunEO6tJHySn0gVLvW /Riogq8Z5w8uOf4v2X4gvfoCicdip6ytazSzt2m0ssxUXm8GjStTnEeVTkwbC283H8 wZUEMPYgcPwAycZln1cBNCV0xRSr39UUKUtTfGqYVmFSnD/2Bjc4zqLEnlW6i+XD17 YxcF75L5RS6J/r4/7mKw9OgvMN93x6H8Bghg5E/jJCR0G+AVVm3pfqeK+nmRwXaKpy 1qF7tpYcAKtoQ== Date: Fri, 06 Dec 2024 15:36:15 -0800 Subject: [PATCH 23/36] xfs: add group based bno conversion helpers From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747227.121772.16956433998495681050.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: 759cc1989a53024066b0f2ea52c206b4ff8f522c Add/move the blocks, blklog and blkmask fields to the generic groups structure so that code can work with AGs and RTGs by just using the right index into the array. Then, add convenience helpers to convert block numbers based on the generic group. This will allow writing code that doesn't care if it is used on AGs or the upcoming realtime groups. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- include/xfs_mount.h | 26 +++++++++++++++++++++ libxfs/libxfs_api_defs.h | 1 + libxfs/xfs_group.c | 9 +++++++ libxfs/xfs_group.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++ libxfs/xfs_sb.c | 7 ++++++ repair/bmap_repair.c | 2 +- 6 files changed, 100 insertions(+), 1 deletion(-) diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 2102009aa8df73..1d36e3986ead2f 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -26,6 +26,32 @@ enum { struct xfs_groups { struct xarray xa; + + /* + * Maximum capacity of the group in FSBs. + * + * Each group is laid out densely in the daddr space. For the + * degenerate case of a pre-rtgroups filesystem, the incore rtgroup + * pretends to have a zero-block and zero-blklog rtgroup. + */ + uint32_t blocks; + + /* + * Log(2) of the logical size of each group. + * + * Compared to the blocks field above this is rounded up to the next + * power of two, and thus lays out the xfs_fsblock_t/xfs_rtblock_t + * space sparsely with a hole from blocks to (1 << blklog) at the end + * of each group. + */ + uint8_t blklog; + + /* + * Mask to extract the group-relative block number from a FSB. + * For a pre-rtgroups filesystem we pretend to have one very large + * rtgroup, so this mask must be 64-bit. + */ + uint64_t blkmask; }; /* diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 8f3e9e8694675d..483a7a9a4cbf45 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -168,6 +168,7 @@ #define xfs_free_extent_later libxfs_free_extent_later #define xfs_free_perag_range libxfs_free_perag_range #define xfs_fs_geometry libxfs_fs_geometry +#define xfs_gbno_to_fsb libxfs_gbno_to_fsb #define xfs_get_initial_prid libxfs_get_initial_prid #define xfs_highbit32 libxfs_highbit32 #define xfs_highbit64 libxfs_highbit64 diff --git a/libxfs/xfs_group.c b/libxfs/xfs_group.c index 9c7fa99d00b802..80b6993cc9916e 100644 --- a/libxfs/xfs_group.c +++ b/libxfs/xfs_group.c @@ -212,3 +212,12 @@ xfs_group_insert( #endif return error; } + +struct xfs_group * +xfs_group_get_by_fsb( + struct xfs_mount *mp, + xfs_fsblock_t fsbno, + enum xfs_group_type type) +{ + return xfs_group_get(mp, xfs_fsb_to_gno(mp, fsbno, type), type); +} diff --git a/libxfs/xfs_group.h b/libxfs/xfs_group.h index 0ff6e1d5635cb1..5b7362277c3f7a 100644 --- a/libxfs/xfs_group.h +++ b/libxfs/xfs_group.h @@ -46,6 +46,8 @@ struct xfs_group { struct xfs_group *xfs_group_get(struct xfs_mount *mp, uint32_t index, enum xfs_group_type type); +struct xfs_group *xfs_group_get_by_fsb(struct xfs_mount *mp, + xfs_fsblock_t fsbno, enum xfs_group_type type); struct xfs_group *xfs_group_hold(struct xfs_group *xg); void xfs_group_put(struct xfs_group *xg); @@ -72,4 +74,58 @@ int xfs_group_insert(struct xfs_mount *mp, struct xfs_group *xg, #define xfs_group_marked(_mp, _type, _mark) \ xa_marked(&(_mp)->m_groups[(_type)].xa, (_mark)) +static inline xfs_agblock_t +xfs_group_max_blocks( + struct xfs_group *xg) +{ + return xg->xg_mount->m_groups[xg->xg_type].blocks; +} + +static inline xfs_fsblock_t +xfs_group_start_fsb( + struct xfs_group *xg) +{ + return ((xfs_fsblock_t)xg->xg_gno) << + xg->xg_mount->m_groups[xg->xg_type].blklog; +} + +static inline xfs_fsblock_t +xfs_gbno_to_fsb( + struct xfs_group *xg, + xfs_agblock_t gbno) +{ + return xfs_group_start_fsb(xg) | gbno; +} + +static inline xfs_daddr_t +xfs_gbno_to_daddr( + struct xfs_group *xg, + xfs_agblock_t gbno) +{ + struct xfs_mount *mp = xg->xg_mount; + uint32_t blocks = mp->m_groups[xg->xg_type].blocks; + + return XFS_FSB_TO_BB(mp, (xfs_fsblock_t)xg->xg_gno * blocks + gbno); +} + +static inline uint32_t +xfs_fsb_to_gno( + struct xfs_mount *mp, + xfs_fsblock_t fsbno, + enum xfs_group_type type) +{ + if (!mp->m_groups[type].blklog) + return 0; + return fsbno >> mp->m_groups[type].blklog; +} + +static inline xfs_agblock_t +xfs_fsb_to_gbno( + struct xfs_mount *mp, + xfs_fsblock_t fsbno, + enum xfs_group_type type) +{ + return fsbno & mp->m_groups[type].blkmask; +} + #endif /* __LIBXFS_GROUP_H */ diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index d32f789037389f..9120a3377735b0 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -999,6 +999,8 @@ xfs_sb_mount_common( struct xfs_mount *mp, struct xfs_sb *sbp) { + struct xfs_groups *ags = &mp->m_groups[XG_TYPE_AG]; + mp->m_agfrotor = 0; atomic_set(&mp->m_agirotor, 0); mp->m_maxagi = mp->m_sb.sb_agcount; @@ -1009,6 +1011,11 @@ xfs_sb_mount_common( mp->m_blockmask = sbp->sb_blocksize - 1; mp->m_blockwsize = sbp->sb_blocksize >> XFS_WORDLOG; mp->m_blockwmask = mp->m_blockwsize - 1; + + ags->blocks = mp->m_sb.sb_agblocks; + ags->blklog = mp->m_sb.sb_agblklog; + ags->blkmask = xfs_mask32lo(mp->m_sb.sb_agblklog); + xfs_mount_sb_set_rextsize(mp, sbp); mp->m_alloc_mxr[0] = xfs_allocbt_maxrecs(mp, sbp->sb_blocksize, true); diff --git a/repair/bmap_repair.c b/repair/bmap_repair.c index f052b5dcddff08..7e7c2a39f5724b 100644 --- a/repair/bmap_repair.c +++ b/repair/bmap_repair.c @@ -154,7 +154,7 @@ xrep_bmap_walk_rmap( !(rec->rm_flags & XFS_RMAP_ATTR_FORK)) return 0; - fsbno = xfs_agbno_to_fsb(to_perag(cur->bc_group), rec->rm_startblock); + fsbno = libxfs_gbno_to_fsb(cur->bc_group, rec->rm_startblock); if (rec->rm_flags & XFS_RMAP_BMBT_BLOCK) { rb->old_bmbt_block_count += rec->rm_blockcount; From patchwork Fri Dec 6 23:36:31 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: 13897966 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 E38F91EBFFC for ; Fri, 6 Dec 2024 23:36:31 +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=1733528192; cv=none; b=rP46Agc0T2hYpfS45B8m+WwM+nJGjKIrk8h5uwcNqk8N0LvmaHNq/9ibWQ+pzD2yE/jpk8lfns3PPnSq4Al8KKBefP32GclqMeH9dxL+Lup/y/cFPw7x/VrsHB2NlmKFjy5zlTfHb4YUZA4uVdqQzd6ct312ytr4vjdDw8D/6LY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528192; c=relaxed/simple; bh=kWq3Z1+kCKM1ahFe4dnRKw45D8YNe2gbwxLt4aS7Yvw=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qMvDg2QtlqptaO0p8HeHwtujKQv4A7zP3HxzV0WuE8gdhqCnpefeKv9NXlGodtKk77aIXn+LCgz75XeoA7xmkwO/dR+EmFfTKyK1QqXLLfl1loqFFvZnzv0LUtXvrtgiEtUZYSs+Uia84BSNWiMohmQlSiXmQoUeNHqC3EwB4L0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dfkgrsIw; 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="dfkgrsIw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6694C4CED2; Fri, 6 Dec 2024 23:36:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528191; bh=kWq3Z1+kCKM1ahFe4dnRKw45D8YNe2gbwxLt4aS7Yvw=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=dfkgrsIw5YPBZU+ybHSF1XtiMqLhFqMaLe0SqihXomQdIdc4JNvuhjCnqX8NLN5CH TZFL2Ljg3VpBVbkGmpKboGr6UEXt/Th/pcrMBE7RAlOySAhcfzv+nzP3xtSxSF516l jMm9yFu4wJfLfKDug8qhsb2ZLrNr3KSjmPR21lzDIZdfZfAUvAKDWXz1DMYWgohBVU Vy+KrgxJiZefT/gVpFhd4VYMmGlERlMR+N0pGsRawTaIHokTka6pV/nXj3inlT0942 MHaSBYOICb557xnEmki2GD7rZjZ+ckoP3Uo3iOGVmUIh9eOV8QQqp1vnZMf7OE4oHn cL+SIX7W03Etw== Date: Fri, 06 Dec 2024 15:36:31 -0800 Subject: [PATCH 24/36] xfs: store a generic group structure in the intents From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747242.121772.14596318667756812717.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Source kernel commit: e5e5cae05b71aa5b5e291c0e74b4e4d98a0b05d4 Replace the pag pointers in the extent free, bmap, rmap and refcount intent structures with a pointer to the generic group to prepare for adding intents for realtime groups. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- include/xfs_mount.h | 11 ++++++----- libxfs/defer_item.c | 31 ++++++++++++++++++------------- libxfs/xfs_alloc.h | 2 +- libxfs/xfs_bmap.h | 2 +- libxfs/xfs_refcount.c | 9 +++++---- libxfs/xfs_refcount.h | 2 +- libxfs/xfs_rmap.c | 16 +++++++++------- libxfs/xfs_rmap.h | 2 +- 8 files changed, 42 insertions(+), 33 deletions(-) diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 1d36e3986ead2f..1179a80d9df94e 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -11,6 +11,7 @@ struct xfs_inode; struct xfs_buftarg; struct xfs_da_geometry; struct libxfs_init; +struct xfs_group; typedef void (*buf_writeback_fn)(struct xfs_buf *bp); @@ -328,12 +329,12 @@ struct xfs_defer_drain { /* empty */ }; #define xfs_defer_drain_init(dr) ((void)0) #define xfs_defer_drain_free(dr) ((void)0) -#define xfs_perag_intent_get(mp, agno) \ - xfs_perag_get((mp), XFS_FSB_TO_AGNO((mp), (agno))) -#define xfs_perag_intent_put(pag) xfs_perag_put(pag) +#define xfs_group_intent_get(mp, fsbno, type) \ + xfs_group_get_by_fsb((mp), (fsbno), (type)) +#define xfs_group_intent_put(xg) xfs_group_put(xg) -static inline void xfs_perag_intent_hold(struct xfs_perag *pag) {} -static inline void xfs_perag_intent_rele(struct xfs_perag *pag) {} +static inline void xfs_group_intent_hold(struct xfs_group *xg) {} +static inline void xfs_group_intent_rele(struct xfs_group *xg) {} static inline void libxfs_buftarg_drain(struct xfs_buftarg *btp) { diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index f0f35361a0ff97..eee84ffbe625d5 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -28,6 +28,7 @@ #include "xfs_ag.h" #include "xfs_exchmaps.h" #include "defer_item.h" +#include "xfs_group.h" /* Dummy defer item ops, since we don't do logging. */ @@ -48,7 +49,7 @@ xfs_extent_free_diff_items( struct xfs_extent_free_item *ra = xefi_entry(a); struct xfs_extent_free_item *rb = xefi_entry(b); - return pag_agno(ra->xefi_pag) - pag_agno(rb->xefi_pag); + return ra->xefi_group->xg_gno - rb->xefi_group->xg_gno; } /* Get an EFI. */ @@ -85,7 +86,8 @@ xfs_extent_free_defer_add( { struct xfs_mount *mp = tp->t_mountp; - xefi->xefi_pag = xfs_perag_intent_get(mp, xefi->xefi_startblock); + xefi->xefi_group = xfs_group_intent_get(mp, xefi->xefi_startblock, + XG_TYPE_AG); if (xefi->xefi_agresv == XFS_AG_RESV_AGFL) *dfpp = xfs_defer_add(tp, &xefi->xefi_list, &xfs_agfl_free_defer_type); @@ -101,7 +103,7 @@ xfs_extent_free_cancel_item( { struct xfs_extent_free_item *xefi = xefi_entry(item); - xfs_perag_intent_put(xefi->xefi_pag); + xfs_group_intent_put(xefi->xefi_group); kmem_cache_free(xfs_extfree_item_cache, xefi); } @@ -127,7 +129,7 @@ xfs_extent_free_finish_item( agbno = XFS_FSB_TO_AGBNO(tp->t_mountp, xefi->xefi_startblock); if (!(xefi->xefi_flags & XFS_EFI_CANCELLED)) { - error = xfs_free_extent(tp, xefi->xefi_pag, agbno, + error = xfs_free_extent(tp, to_perag(xefi->xefi_group), agbno, xefi->xefi_blockcount, &oinfo, XFS_AG_RESV_NONE); } @@ -179,7 +181,7 @@ xfs_agfl_free_finish_item( agbno = XFS_FSB_TO_AGBNO(mp, xefi->xefi_startblock); oinfo.oi_owner = xefi->xefi_owner; - error = xfs_alloc_read_agf(xefi->xefi_pag, tp, 0, &agbp); + error = xfs_alloc_read_agf(to_perag(xefi->xefi_group), tp, 0, &agbp); if (!error) error = xfs_free_ag_extent(tp, agbp, agbno, 1, &oinfo, XFS_AG_RESV_AGFL); @@ -215,7 +217,7 @@ xfs_rmap_update_diff_items( struct xfs_rmap_intent *ra = ri_entry(a); struct xfs_rmap_intent *rb = ri_entry(b); - return pag_agno(ra->ri_pag) - pag_agno(rb->ri_pag); + return ra->ri_group->xg_gno - rb->ri_group->xg_gno; } /* Get an RUI. */ @@ -253,7 +255,8 @@ xfs_rmap_defer_add( trace_xfs_rmap_defer(mp, ri); - ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_bmap.br_startblock); + ri->ri_group = xfs_group_intent_get(mp, ri->ri_bmap.br_startblock, + XG_TYPE_AG); xfs_defer_add(tp, &ri->ri_list, &xfs_rmap_update_defer_type); } @@ -264,7 +267,7 @@ xfs_rmap_update_cancel_item( { struct xfs_rmap_intent *ri = ri_entry(item); - xfs_perag_intent_put(ri->ri_pag); + xfs_group_intent_put(ri->ri_group); kmem_cache_free(xfs_rmap_intent_cache, ri); } @@ -336,7 +339,7 @@ xfs_refcount_update_diff_items( struct xfs_refcount_intent *ra = ci_entry(a); struct xfs_refcount_intent *rb = ci_entry(b); - return pag_agno(ra->ri_pag) - pag_agno(rb->ri_pag); + return ra->ri_group->xg_gno - rb->ri_group->xg_gno; } /* Get an CUI. */ @@ -374,7 +377,8 @@ xfs_refcount_defer_add( trace_xfs_refcount_defer(mp, ri); - ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_startblock); + ri->ri_group = xfs_group_intent_get(mp, ri->ri_startblock, + XG_TYPE_AG); xfs_defer_add(tp, &ri->ri_list, &xfs_refcount_update_defer_type); } @@ -385,7 +389,7 @@ xfs_refcount_update_cancel_item( { struct xfs_refcount_intent *ri = ci_entry(item); - xfs_perag_intent_put(ri->ri_pag); + xfs_group_intent_put(ri->ri_group); kmem_cache_free(xfs_refcount_intent_cache, ri); } @@ -508,7 +512,8 @@ xfs_bmap_update_get_group( * intent drops the intent count, ensuring that the intent count * remains nonzero across the transaction roll. */ - bi->bi_pag = xfs_perag_intent_get(mp, bi->bi_bmap.br_startblock); + bi->bi_group = xfs_group_intent_get(mp, bi->bi_bmap.br_startblock, + XG_TYPE_AG); } /* Add this deferred BUI to the transaction. */ @@ -542,7 +547,7 @@ xfs_bmap_update_put_group( if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork)) return; - xfs_perag_intent_put(bi->bi_pag); + xfs_group_intent_put(bi->bi_group); } /* Cancel a deferred bmap update. */ diff --git a/libxfs/xfs_alloc.h b/libxfs/xfs_alloc.h index 88fbce5001185f..efbde04fbbb15f 100644 --- a/libxfs/xfs_alloc.h +++ b/libxfs/xfs_alloc.h @@ -248,7 +248,7 @@ struct xfs_extent_free_item { uint64_t xefi_owner; xfs_fsblock_t xefi_startblock;/* starting fs block number */ xfs_extlen_t xefi_blockcount;/* number of blocks in extent */ - struct xfs_perag *xefi_pag; + struct xfs_group *xefi_group; unsigned int xefi_flags; enum xfs_ag_resv_type xefi_agresv; }; diff --git a/libxfs/xfs_bmap.h b/libxfs/xfs_bmap.h index 7592d46e97c661..4b721d9359943b 100644 --- a/libxfs/xfs_bmap.h +++ b/libxfs/xfs_bmap.h @@ -248,7 +248,7 @@ struct xfs_bmap_intent { enum xfs_bmap_intent_type bi_type; int bi_whichfork; struct xfs_inode *bi_owner; - struct xfs_perag *bi_pag; + struct xfs_group *bi_group; struct xfs_bmbt_irec bi_bmap; }; diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 3eccb998545d6f..709e2a94176da5 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -1357,7 +1357,7 @@ xfs_refcount_finish_one( * If we haven't gotten a cursor or the cursor AG doesn't match * the startblock, get one now. */ - if (rcur != NULL && to_perag(rcur->bc_group) != ri->ri_pag) { + if (rcur != NULL && rcur->bc_group != ri->ri_group) { nr_ops = rcur->bc_refc.nr_ops; shape_changes = rcur->bc_refc.shape_changes; xfs_btree_del_cursor(rcur, 0); @@ -1365,13 +1365,14 @@ xfs_refcount_finish_one( *pcur = NULL; } if (rcur == NULL) { - error = xfs_alloc_read_agf(ri->ri_pag, tp, + struct xfs_perag *pag = to_perag(ri->ri_group); + + error = xfs_alloc_read_agf(pag, tp, XFS_ALLOC_FLAG_FREEING, &agbp); if (error) return error; - *pcur = rcur = xfs_refcountbt_init_cursor(mp, tp, agbp, - ri->ri_pag); + *pcur = rcur = xfs_refcountbt_init_cursor(mp, tp, agbp, pag); rcur->bc_refc.nr_ops = nr_ops; rcur->bc_refc.shape_changes = shape_changes; } diff --git a/libxfs/xfs_refcount.h b/libxfs/xfs_refcount.h index 68acb0b1b4a878..62d78afcf1f3ff 100644 --- a/libxfs/xfs_refcount.h +++ b/libxfs/xfs_refcount.h @@ -56,7 +56,7 @@ enum xfs_refcount_intent_type { struct xfs_refcount_intent { struct list_head ri_list; - struct xfs_perag *ri_pag; + struct xfs_group *ri_group; enum xfs_refcount_intent_type ri_type; xfs_extlen_t ri_blockcount; xfs_fsblock_t ri_startblock; diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index 07bcdf82d10081..dabc7003586ce4 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -2585,28 +2585,30 @@ xfs_rmap_finish_one( * If we haven't gotten a cursor or the cursor AG doesn't match * the startblock, get one now. */ - if (rcur != NULL && to_perag(rcur->bc_group) != ri->ri_pag) { + if (rcur != NULL && rcur->bc_group != ri->ri_group) { xfs_btree_del_cursor(rcur, 0); rcur = NULL; *pcur = NULL; } if (rcur == NULL) { + struct xfs_perag *pag = to_perag(ri->ri_group); + /* * Refresh the freelist before we start changing the * rmapbt, because a shape change could cause us to * allocate blocks. */ - error = xfs_free_extent_fix_freelist(tp, ri->ri_pag, &agbp); + error = xfs_free_extent_fix_freelist(tp, pag, &agbp); if (error) { - xfs_ag_mark_sick(ri->ri_pag, XFS_SICK_AG_AGFL); + xfs_ag_mark_sick(pag, XFS_SICK_AG_AGFL); return error; } if (XFS_IS_CORRUPT(tp->t_mountp, !agbp)) { - xfs_ag_mark_sick(ri->ri_pag, XFS_SICK_AG_AGFL); + xfs_ag_mark_sick(pag, XFS_SICK_AG_AGFL); return -EFSCORRUPTED; } - *pcur = rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, ri->ri_pag); + *pcur = rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, pag); } xfs_rmap_ino_owner(&oinfo, ri->ri_owner, ri->ri_whichfork, @@ -2619,8 +2621,8 @@ xfs_rmap_finish_one( if (error) return error; - xfs_rmap_update_hook(tp, pag_group(ri->ri_pag), ri->ri_type, bno, - ri->ri_bmap.br_blockcount, unwritten, &oinfo); + xfs_rmap_update_hook(tp, ri->ri_group, ri->ri_type, bno, + ri->ri_bmap.br_blockcount, unwritten, &oinfo); return 0; } diff --git a/libxfs/xfs_rmap.h b/libxfs/xfs_rmap.h index d409b463bc6662..96b4321d831007 100644 --- a/libxfs/xfs_rmap.h +++ b/libxfs/xfs_rmap.h @@ -173,7 +173,7 @@ struct xfs_rmap_intent { int ri_whichfork; uint64_t ri_owner; struct xfs_bmbt_irec ri_bmap; - struct xfs_perag *ri_pag; + struct xfs_group *ri_group; }; /* functions for updating the rmapbt based on bmbt map/unmap operations */ From patchwork Fri Dec 6 23:36:46 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: 13897967 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 8F13B212FB8 for ; Fri, 6 Dec 2024 23:36:47 +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=1733528207; cv=none; b=FNpuuRwm0VGSwC3HnQKkKlTATOIfqgbwGKuwLlLu94vLDxvTrpP54jpwtsZnifgyE4D8KDwRg6NidISQEnBHWw51uOhfnvhWDoDQ0/DcXRtKCTcXtIw0SgHJjq8YCi9TYkkuyjEGaqdfkAbs7/+uFrtMmI0GcNmrBvBeNFUMjFc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528207; c=relaxed/simple; bh=1d92ETI48XjwEGT6jL2iA0Jzg/O6AraTWo+HLjkSJn4=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=anQiBjb+ceaFl+JqCoha/BmO3rRlBzxR+zycTAYgp0beddK7PoQyRsdEQkiT1lNl2OsxX/sjmqijdvNWkc+Qvp+P30ZG0WJl7qIGiUkCpaUWTWsbbPbHQWb2mIsyaUX0uMW8p/BA9YNYHrZp2uYfvJ5ZKCoDiz0pg76hLzEM52A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P11TlZi9; 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="P11TlZi9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C61BC4CED1; Fri, 6 Dec 2024 23:36:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528207; bh=1d92ETI48XjwEGT6jL2iA0Jzg/O6AraTWo+HLjkSJn4=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=P11TlZi9tK6FqyQHBbePiK5C+DpOcb7Yom9QmRQeLnCVZlaKlORmjfs9WBJ8951Cl ChWsyXTiKukVZJmEb8Mv0dfhcG1GtGJMjXfAqix2beVl667FDU2u3KkVLmjVLDNLkA 6w/IAuJvWAkXI7gYVelE2ha3cmrU6Wd2KRjL/bEITbV2m4saWqTlwR8ylrj5rRNKJp CIBToXVO+tgkcSEUw5VzSgcueQE/3Ua53TJO0SprCVdg+nup9xdPIQ3GuFgudSmaN0 w/BZYl2JbrewWFAxYb+UR8x5KgE9eRS67FfBAo54qF8hulRmMx0FLRLetfnmHD5yL5 BdwsZJwOCDFPA== Date: Fri, 06 Dec 2024 15:36:46 -0800 Subject: [PATCH 25/36] xfs: constify the xfs_sb predicates From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747257.121772.14433747039015070217.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.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 Source kernel commit: 8d939f4bd7b225d8b157b1329881d2719c0ecb29 Change the xfs_sb predicates to take a const struct xfs_sb pointer because they do not change the superblock. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/xfs_format.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index e1bfee0c3b1a8c..a24ab46aaebc7e 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -278,7 +278,7 @@ struct xfs_dsb { #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) -static inline bool xfs_sb_is_v5(struct xfs_sb *sbp) +static inline bool xfs_sb_is_v5(const struct xfs_sb *sbp) { return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; } @@ -287,12 +287,12 @@ static inline bool xfs_sb_is_v5(struct xfs_sb *sbp) * Detect a mismatched features2 field. Older kernels read/wrote * this into the wrong slot, so to be safe we keep them in sync. */ -static inline bool xfs_sb_has_mismatched_features2(struct xfs_sb *sbp) +static inline bool xfs_sb_has_mismatched_features2(const struct xfs_sb *sbp) { return sbp->sb_bad_features2 != sbp->sb_features2; } -static inline bool xfs_sb_version_hasmorebits(struct xfs_sb *sbp) +static inline bool xfs_sb_version_hasmorebits(const struct xfs_sb *sbp) { return xfs_sb_is_v5(sbp) || (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); @@ -342,8 +342,8 @@ static inline void xfs_sb_version_addprojid32(struct xfs_sb *sbp) #define XFS_SB_FEAT_COMPAT_UNKNOWN ~XFS_SB_FEAT_COMPAT_ALL static inline bool xfs_sb_has_compat_feature( - struct xfs_sb *sbp, - uint32_t feature) + const struct xfs_sb *sbp, + uint32_t feature) { return (sbp->sb_features_compat & feature) != 0; } @@ -360,8 +360,8 @@ xfs_sb_has_compat_feature( #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL static inline bool xfs_sb_has_ro_compat_feature( - struct xfs_sb *sbp, - uint32_t feature) + const struct xfs_sb *sbp, + uint32_t feature) { return (sbp->sb_features_ro_compat & feature) != 0; } @@ -387,8 +387,8 @@ xfs_sb_has_ro_compat_feature( #define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL static inline bool xfs_sb_has_incompat_feature( - struct xfs_sb *sbp, - uint32_t feature) + const struct xfs_sb *sbp, + uint32_t feature) { return (sbp->sb_features_incompat & feature) != 0; } @@ -399,8 +399,8 @@ xfs_sb_has_incompat_feature( #define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL static inline bool xfs_sb_has_incompat_log_feature( - struct xfs_sb *sbp, - uint32_t feature) + const struct xfs_sb *sbp, + uint32_t feature) { return (sbp->sb_features_log_incompat & feature) != 0; } @@ -420,7 +420,7 @@ xfs_sb_add_incompat_log_features( sbp->sb_features_log_incompat |= features; } -static inline bool xfs_sb_version_haslogxattrs(struct xfs_sb *sbp) +static inline bool xfs_sb_version_haslogxattrs(const struct xfs_sb *sbp) { return xfs_sb_is_v5(sbp) && (sbp->sb_features_log_incompat & XFS_SB_FEAT_INCOMPAT_LOG_XATTRS); From patchwork Fri Dec 6 23:37:02 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: 13897968 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 7FFEC212F87 for ; Fri, 6 Dec 2024 23:37: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=1733528223; cv=none; b=qjXgbefEDZt0BmDbyaSI1+gjQA5wrajPfZobdrGko62noeGKO2SxpUDA5NUTglJt1QyV/tSLzCvKKMrlkm/LmL9Z3NwB7D4oMYpctun9baP6roEFLFahVF7dE6r4QEepG3SwWRQQCiukvC49n14+UkNkVq2fMbbasPk9QesD9m8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528223; c=relaxed/simple; bh=cJbkPUaZrSX8ZRuS3Ka4nE1/x3YQO12vka1VZu/O9/o=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tyf/2ETQ7zHEhQgleGBmIEyQiQD2FcpANK0SRRwpIKiB4eUe6eGBnx5DSPGOKTMMJDTUE/IXXL3rwDmbN6PXClaIyHJ3yc9/aBjuNzS9mC3wk/gEmHDEIUbt0rFe6v7IN9lJ+az+AUhM1r9xBU/5Kdp6y9Wi63f0EG5Rnu0EzTI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cQPT39wx; 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="cQPT39wx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0425EC4CEE3; Fri, 6 Dec 2024 23:37:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528223; bh=cJbkPUaZrSX8ZRuS3Ka4nE1/x3YQO12vka1VZu/O9/o=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=cQPT39wxUAmnQ0fKDKOFUeTNYJXz5XTDcuv84UK9QizLEe7xShkkkZcO/yMLWNsfh jGXVuiP03ExDw6GkEfAGYx33P85ph638UESeZ1vlmcZLMTDpkjnCgPTJHYsdnIGc7g ajmJmYBqskDxJM+AJsQPDKfZxGdvyfHSJXbff6gmWWp6xmHdARKsHsjCrDl46pYOv2 LQuUkTnBCMwhodDt/LCybKjUymGmyiIAfaK6aNZjFOdUFZyOQTbBJj2Tt1p1UIgZEh OtZJtDwRDdAl6p+8eH0C7tJZxn7WERxraILRBTMb6plO4hpGgURw8PqVbeGy9vxghr qHGug4Mj4XofQ== Date: Fri, 06 Dec 2024 15:37:02 -0800 Subject: [PATCH 26/36] xfs: rename metadata inode predicates From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747272.121772.9751250500228982931.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.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 Source kernel commit: 4d272929a5258074328dae206c935634e0fd1a54 The predicate xfs_internal_inum tells us if an inumber refers to one of the inodes rooted in the superblock. Soon we're going to have internal inodes in a metadata directory tree, so this helper should be renamed to capture its limited scope. Ondisk inodes will soon have a flag to indicate that they're metadata inodes. Head off some confusion by renaming the xfs_is_metadata_inode predicate to xfs_is_internal_inode. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/libxfs_api_defs.h | 2 +- libxfs/xfs_types.c | 4 ++-- libxfs/xfs_types.h | 2 +- repair/rmap.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 483a7a9a4cbf45..92e26eebabfed8 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -199,7 +199,7 @@ #define xfs_inode_validate_cowextsize libxfs_inode_validate_cowextsize #define xfs_inode_validate_extsize libxfs_inode_validate_extsize -#define xfs_internal_inum libxfs_internal_inum +#define xfs_is_sb_inum libxfs_is_sb_inum #define xfs_iread_extents libxfs_iread_extents #define xfs_irele libxfs_irele diff --git a/libxfs/xfs_types.c b/libxfs/xfs_types.c index 0d1b86ae59d93e..a70c0395979cf8 100644 --- a/libxfs/xfs_types.c +++ b/libxfs/xfs_types.c @@ -111,7 +111,7 @@ xfs_verify_ino( /* Is this an internal inode number? */ inline bool -xfs_internal_inum( +xfs_is_sb_inum( struct xfs_mount *mp, xfs_ino_t ino) { @@ -129,7 +129,7 @@ xfs_verify_dir_ino( struct xfs_mount *mp, xfs_ino_t ino) { - if (xfs_internal_inum(mp, ino)) + if (xfs_is_sb_inum(mp, ino)) return false; return xfs_verify_ino(mp, ino); } diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index d3cb6ff3b91301..25053a66c225ed 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -230,7 +230,7 @@ bool xfs_verify_fsbext(struct xfs_mount *mp, xfs_fsblock_t fsbno, xfs_fsblock_t len); bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino); -bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino); +bool xfs_is_sb_inum(struct xfs_mount *mp, xfs_ino_t ino); bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino); bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); bool xfs_verify_rtbext(struct xfs_mount *mp, xfs_rtblock_t rtbno, diff --git a/repair/rmap.c b/repair/rmap.c index 29af74eee11831..3b998a22cee10d 100644 --- a/repair/rmap.c +++ b/repair/rmap.c @@ -814,7 +814,7 @@ rmap_shareable( return false; /* Metadata in files are never shareable */ - if (libxfs_internal_inum(mp, rmap->rm_owner)) + if (libxfs_is_sb_inum(mp, rmap->rm_owner)) return false; /* Metadata and unwritten file blocks are not shareable. */ From patchwork Fri Dec 6 23:37: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: 13897969 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 BFF911C548E for ; Fri, 6 Dec 2024 23:37:18 +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=1733528238; cv=none; b=hNz8jEV+S+90MdQqN4mwXm4UEM8H7sG19g5gDoAZB3JjZnKYgqmot2/J24vCkS8WuY5ua6WE1jgpoV0d00TklBAO49KsH5JUMlPA0MFdtNeD7W6lleiVW4S1TW7G7haisfubh6qJgqbw1ZDz8kI5NEoYMYJA87VzVHVgLbZrgIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528238; c=relaxed/simple; bh=N/BSvfpKuNZq13R66RHCZngCXChb0VPOH6h9rIQXHmI=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tX9KTIT+BTNb+d8oRAglY4CLMyWOB9GGo0QCZoZt7Pd0P+m47cQ7uLFlRNHLkEGtQGpIuAtZIIL6UH1p/xey2uYf8V/kIXC1+aiO3zMY0WJ6/sk8Tp6NRs60eQR/R++TCfrTmSyu8wXkS0R5Z67r8xBH0et64nfVjn/0LFDzbOw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FFvfumHl; 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="FFvfumHl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 971D8C4CED1; Fri, 6 Dec 2024 23:37:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528238; bh=N/BSvfpKuNZq13R66RHCZngCXChb0VPOH6h9rIQXHmI=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=FFvfumHl0xrccHnSgtt4dY1xnQIj+YL53225IUrzsGJa999ntq0izrcpLRXyxeGZe UUKcAUcswHuZvhBxHJyD/uNF8XxFA+fpzL7PtKipSQwuHO1XgGYccg8BsFzOwmL8HD fmtj4xeLczSeBgqGzJVsusq33lBnFc3mzhPovB8AkOCMxxALFD80gNwgj58OuoHEyd vs2OjVdkxUaE7mTbqZsDem2+pTBGP3xoDau4EIqkAnKpS1N3C7c7BaOHk2c/Y7Jm6X 7A9CY788wxg4nlPDxaJtnFpPpcHPfWsoplrks+JsIOPSHs9irBjG/zzymG3gyBrQY4 pNdp1qk5hAWsw== Date: Fri, 06 Dec 2024 15:37:18 -0800 Subject: [PATCH 27/36] xfs: define the on-disk format for the metadir feature From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747288.121772.8936038827895080362.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.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 Source kernel commit: 4f3d4dd1b04b2ba0bf236fbaa3c3c0c669aa5a47 Define the on-disk layout and feature flags for the metadata inode directory feature. Add a xfs_sb_version_hasmetadir for benefit of xfs_repair, which needs to know where the new end of the superblock lies. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- db/check.c | 2 - db/inode.c | 4 +- include/xfs_inode.h | 6 +++ include/xfs_mount.h | 2 + libxfs/xfs_format.h | 97 +++++++++++++++++++++++++++++++++++++++++------ libxfs/xfs_inode_buf.c | 20 +++++++--- libxfs/xfs_inode_util.c | 2 + libxfs/xfs_log_format.h | 2 - libxfs/xfs_ondisk.h | 2 - libxfs/xfs_sb.c | 10 +++++ repair/dino_chunks.c | 2 - repair/dinode.c | 12 +++--- 12 files changed, 132 insertions(+), 29 deletions(-) diff --git a/db/check.c b/db/check.c index 0a6e5c3280e1cf..fb7b6cb41a3fbf 100644 --- a/db/check.c +++ b/db/check.c @@ -2823,7 +2823,7 @@ process_inode( return; } if (dip->di_version == 1) { - nlink = be16_to_cpu(dip->di_onlink); + nlink = be16_to_cpu(dip->di_metatype); prid = 0; } else { nlink = be32_to_cpu(dip->di_nlink); diff --git a/db/inode.c b/db/inode.c index 7a5f5a0cb987aa..246febb5929aa1 100644 --- a/db/inode.c +++ b/db/inode.c @@ -90,9 +90,9 @@ const field_t inode_core_flds[] = { { "mode", FLDT_UINT16O, OI(COFF(mode)), C1, 0, TYP_NONE }, { "version", FLDT_INT8D, OI(COFF(version)), C1, 0, TYP_NONE }, { "format", FLDT_DINODE_FMT, OI(COFF(format)), C1, 0, TYP_NONE }, - { "nlinkv1", FLDT_UINT16D, OI(COFF(onlink)), inode_core_nlinkv1_count, + { "nlinkv1", FLDT_UINT16D, OI(COFF(metatype)), inode_core_nlinkv1_count, FLD_COUNT, TYP_NONE }, - { "onlink", FLDT_UINT16D, OI(COFF(onlink)), inode_core_onlink_count, + { "onlink", FLDT_UINT16D, OI(COFF(metatype)), inode_core_onlink_count, FLD_COUNT, TYP_NONE }, { "uid", FLDT_UINT32D, OI(COFF(uid)), C1, 0, TYP_NONE }, { "gid", FLDT_UINT32D, OI(COFF(gid)), C1, 0, TYP_NONE }, diff --git a/include/xfs_inode.h b/include/xfs_inode.h index f250102ff19d65..e03521bc9aaaa2 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -230,6 +230,7 @@ typedef struct xfs_inode { uint16_t i_flushiter; /* incremented on flush */ }; uint8_t i_forkoff; /* attr fork offset >> 3 */ + enum xfs_metafile_type i_metatype; /* XFS_METAFILE_* */ uint16_t i_diflags; /* XFS_DIFLAG_... */ uint64_t i_diflags2; /* XFS_DIFLAG2_... */ struct timespec64 i_crtime; /* time created */ @@ -396,6 +397,11 @@ static inline bool xfs_is_always_cow_inode(struct xfs_inode *ip) return false; } +static inline bool xfs_is_metadir_inode(const struct xfs_inode *ip) +{ + return ip->i_diflags2 & XFS_DIFLAG2_METADATA; +} + extern void libxfs_trans_inode_alloc_buf (struct xfs_trans *, struct xfs_buf *); diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 1179a80d9df94e..c7fada9e2a6d70 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -201,6 +201,7 @@ typedef struct xfs_mount { #define XFS_FEAT_NEEDSREPAIR (1ULL << 25) /* needs xfs_repair */ #define XFS_FEAT_NREXT64 (1ULL << 26) /* large extent counters */ #define XFS_FEAT_EXCHANGE_RANGE (1ULL << 27) /* exchange range */ +#define XFS_FEAT_METADIR (1ULL << 28) /* metadata directory tree */ #define __XFS_HAS_FEAT(name, NAME) \ static inline bool xfs_has_ ## name (struct xfs_mount *mp) \ @@ -246,6 +247,7 @@ __XFS_HAS_FEAT(bigtime, BIGTIME) __XFS_HAS_FEAT(needsrepair, NEEDSREPAIR) __XFS_HAS_FEAT(large_extent_counts, NREXT64) __XFS_HAS_FEAT(exchange_range, EXCHANGE_RANGE) +__XFS_HAS_FEAT(metadir, METADIR) /* Kernel mount features that we don't support */ #define __XFS_UNSUPP_FEAT(name) \ diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index a24ab46aaebc7e..616f81045921b7 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -174,6 +174,8 @@ typedef struct xfs_sb { xfs_lsn_t sb_lsn; /* last write sequence */ uuid_t sb_meta_uuid; /* metadata file system unique id */ + xfs_ino_t sb_metadirino; /* metadata directory tree root */ + /* must be padded to 64 bit alignment */ } xfs_sb_t; @@ -259,6 +261,8 @@ struct xfs_dsb { __be64 sb_lsn; /* last write sequence */ uuid_t sb_meta_uuid; /* metadata file system unique id */ + __be64 sb_metadirino; /* metadata directory tree root */ + /* must be padded to 64 bit alignment */ }; @@ -374,6 +378,7 @@ xfs_sb_has_ro_compat_feature( #define XFS_SB_FEAT_INCOMPAT_NREXT64 (1 << 5) /* large extent counters */ #define XFS_SB_FEAT_INCOMPAT_EXCHRANGE (1 << 6) /* exchangerange supported */ #define XFS_SB_FEAT_INCOMPAT_PARENT (1 << 7) /* parent pointers */ +#define XFS_SB_FEAT_INCOMPAT_METADIR (1 << 8) /* metadata dir tree */ #define XFS_SB_FEAT_INCOMPAT_ALL \ (XFS_SB_FEAT_INCOMPAT_FTYPE | \ XFS_SB_FEAT_INCOMPAT_SPINODES | \ @@ -790,6 +795,27 @@ static inline time64_t xfs_bigtime_to_unix(uint64_t ondisk_seconds) return (time64_t)ondisk_seconds - XFS_BIGTIME_EPOCH_OFFSET; } +enum xfs_metafile_type { + XFS_METAFILE_UNKNOWN, /* unknown */ + XFS_METAFILE_DIR, /* metadir directory */ + XFS_METAFILE_USRQUOTA, /* user quota */ + XFS_METAFILE_GRPQUOTA, /* group quota */ + XFS_METAFILE_PRJQUOTA, /* project quota */ + XFS_METAFILE_RTBITMAP, /* rt bitmap */ + XFS_METAFILE_RTSUMMARY, /* rt summary */ + + XFS_METAFILE_MAX +} __packed; + +#define XFS_METAFILE_TYPE_STR \ + { XFS_METAFILE_UNKNOWN, "unknown" }, \ + { XFS_METAFILE_DIR, "dir" }, \ + { XFS_METAFILE_USRQUOTA, "usrquota" }, \ + { XFS_METAFILE_GRPQUOTA, "grpquota" }, \ + { XFS_METAFILE_PRJQUOTA, "prjquota" }, \ + { XFS_METAFILE_RTBITMAP, "rtbitmap" }, \ + { XFS_METAFILE_RTSUMMARY, "rtsummary" } + /* * On-disk inode structure. * @@ -812,7 +838,7 @@ struct xfs_dinode { __be16 di_mode; /* mode and type of file */ __u8 di_version; /* inode version */ __u8 di_format; /* format of di_c data */ - __be16 di_onlink; /* old number of links to file */ + __be16 di_metatype; /* XFS_METAFILE_*; was di_onlink */ __be32 di_uid; /* owner's user id */ __be32 di_gid; /* owner's group id */ __be32 di_nlink; /* number of links to file */ @@ -1088,21 +1114,60 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) * Values for di_flags2 These start by being exposed to userspace in the upper * 16 bits of the XFS_XFLAG_s range. */ -#define XFS_DIFLAG2_DAX_BIT 0 /* use DAX for this inode */ -#define XFS_DIFLAG2_REFLINK_BIT 1 /* file's blocks may be shared */ -#define XFS_DIFLAG2_COWEXTSIZE_BIT 2 /* copy on write extent size hint */ -#define XFS_DIFLAG2_BIGTIME_BIT 3 /* big timestamps */ -#define XFS_DIFLAG2_NREXT64_BIT 4 /* large extent counters */ - -#define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT) -#define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT) -#define XFS_DIFLAG2_COWEXTSIZE (1 << XFS_DIFLAG2_COWEXTSIZE_BIT) -#define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_BIT) -#define XFS_DIFLAG2_NREXT64 (1 << XFS_DIFLAG2_NREXT64_BIT) +/* use DAX for this inode */ +#define XFS_DIFLAG2_DAX_BIT 0 + +/* file's blocks may be shared */ +#define XFS_DIFLAG2_REFLINK_BIT 1 + +/* copy on write extent size hint */ +#define XFS_DIFLAG2_COWEXTSIZE_BIT 2 + +/* big timestamps */ +#define XFS_DIFLAG2_BIGTIME_BIT 3 + +/* large extent counters */ +#define XFS_DIFLAG2_NREXT64_BIT 4 + +/* + * The inode contains filesystem metadata and can be found through the metadata + * directory tree. Metadata inodes must satisfy the following constraints: + * + * - V5 filesystem (and ftype) are enabled; + * - The only valid modes are regular files and directories; + * - The access bits must be zero; + * - DMAPI event and state masks are zero; + * - The user and group IDs must be zero; + * - The project ID can be used as a u32 annotation; + * - The immutable, sync, noatime, nodump, nodefrag flags must be set. + * - The dax flag must not be set. + * - Directories must have nosymlinks set. + * + * These requirements are chosen defensively to minimize the ability of + * userspace to read or modify the contents, should a metadata file ever + * escape to userspace. + * + * There are further constraints on the directory tree itself: + * + * - Metadata inodes must never be resolvable through the root directory; + * - They must never be accessed by userspace; + * - Metadata directory entries must have correct ftype. + * + * Superblock-rooted metadata files must have the METADATA iflag set even + * though they do not have a parent directory. + */ +#define XFS_DIFLAG2_METADATA_BIT 5 + +#define XFS_DIFLAG2_DAX (1ULL << XFS_DIFLAG2_DAX_BIT) +#define XFS_DIFLAG2_REFLINK (1ULL << XFS_DIFLAG2_REFLINK_BIT) +#define XFS_DIFLAG2_COWEXTSIZE (1ULL << XFS_DIFLAG2_COWEXTSIZE_BIT) +#define XFS_DIFLAG2_BIGTIME (1ULL << XFS_DIFLAG2_BIGTIME_BIT) +#define XFS_DIFLAG2_NREXT64 (1ULL << XFS_DIFLAG2_NREXT64_BIT) +#define XFS_DIFLAG2_METADATA (1ULL << XFS_DIFLAG2_METADATA_BIT) #define XFS_DIFLAG2_ANY \ (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE | \ - XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64) + XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64 | XFS_DIFLAG2_METADATA) static inline bool xfs_dinode_has_bigtime(const struct xfs_dinode *dip) { @@ -1117,6 +1182,12 @@ static inline bool xfs_dinode_has_large_extent_counts( (dip->di_flags2 & cpu_to_be64(XFS_DIFLAG2_NREXT64)); } +static inline bool xfs_dinode_is_metadir(const struct xfs_dinode *dip) +{ + return dip->di_version >= 3 && + (dip->di_flags2 & cpu_to_be64(XFS_DIFLAG2_METADATA)); +} + /* * Inode number format: * low inopblog bits - offset in block diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 5970ee705bc5a2..981113f6acd37a 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -206,12 +206,15 @@ xfs_inode_from_disk( * They will also be unconditionally written back to disk as v2 inodes. */ if (unlikely(from->di_version == 1)) { - set_nlink(inode, be16_to_cpu(from->di_onlink)); + /* di_metatype used to be di_onlink */ + set_nlink(inode, be16_to_cpu(from->di_metatype)); ip->i_projid = 0; } else { set_nlink(inode, be32_to_cpu(from->di_nlink)); ip->i_projid = (prid_t)be16_to_cpu(from->di_projid_hi) << 16 | be16_to_cpu(from->di_projid_lo); + if (xfs_dinode_is_metadir(from)) + ip->i_metatype = be16_to_cpu(from->di_metatype); } i_uid_write(inode, be32_to_cpu(from->di_uid)); @@ -312,7 +315,10 @@ xfs_inode_to_disk( struct inode *inode = VFS_I(ip); to->di_magic = cpu_to_be16(XFS_DINODE_MAGIC); - to->di_onlink = 0; + if (xfs_is_metadir_inode(ip)) + to->di_metatype = cpu_to_be16(ip->i_metatype); + else + to->di_metatype = 0; to->di_format = xfs_ifork_format(&ip->i_df); to->di_uid = cpu_to_be32(i_uid_read(inode)); @@ -520,8 +526,11 @@ xfs_dinode_verify( * di_nlink==0 on a V1 inode. V2/3 inodes would get written out with * di_onlink==0, so we can check that. */ - if (dip->di_version >= 2) { - if (dip->di_onlink) + if (dip->di_version == 2) { + if (dip->di_metatype) + return __this_address; + } else if (dip->di_version >= 3) { + if (!xfs_dinode_is_metadir(dip) && dip->di_metatype) return __this_address; } @@ -543,7 +552,8 @@ xfs_dinode_verify( if (dip->di_nlink) return __this_address; } else { - if (dip->di_onlink) + /* di_metatype used to be di_onlink */ + if (dip->di_metatype) return __this_address; } } diff --git a/libxfs/xfs_inode_util.c b/libxfs/xfs_inode_util.c index f9f16c7e2d0788..edc985eb9a4e45 100644 --- a/libxfs/xfs_inode_util.c +++ b/libxfs/xfs_inode_util.c @@ -221,6 +221,8 @@ xfs_inode_inherit_flags2( } if (pip->i_diflags2 & XFS_DIFLAG2_DAX) ip->i_diflags2 |= XFS_DIFLAG2_DAX; + if (xfs_is_metadir_inode(pip)) + ip->i_diflags2 |= XFS_DIFLAG2_METADATA; /* Don't let invalid cowextsize hints propagate. */ failaddr = xfs_inode_validate_cowextsize(ip->i_mount, ip->i_cowextsize, diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index 3e6682ed656b30..ace7384a275bfb 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -404,7 +404,7 @@ struct xfs_log_dinode { uint16_t di_mode; /* mode and type of file */ int8_t di_version; /* inode version */ int8_t di_format; /* format of di_c data */ - uint8_t di_pad3[2]; /* unused in v2/3 inodes */ + uint16_t di_metatype; /* metadata type, if DIFLAG2_METADATA */ uint32_t di_uid; /* owner's user id */ uint32_t di_gid; /* owner's group id */ uint32_t di_nlink; /* number of links to file */ diff --git a/libxfs/xfs_ondisk.h b/libxfs/xfs_ondisk.h index 23c133fd36f5bb..8bca86e350fdc1 100644 --- a/libxfs/xfs_ondisk.h +++ b/libxfs/xfs_ondisk.h @@ -37,7 +37,7 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_dinode, 176); XFS_CHECK_STRUCT_SIZE(struct xfs_disk_dquot, 104); XFS_CHECK_STRUCT_SIZE(struct xfs_dqblk, 136); - XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 264); + XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 272); XFS_CHECK_STRUCT_SIZE(struct xfs_dsymlink_hdr, 56); XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_key, 4); XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_rec, 16); diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 9120a3377735b0..de12edd8192e1c 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -177,6 +177,8 @@ xfs_sb_version_to_features( features |= XFS_FEAT_EXCHANGE_RANGE; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_PARENT) features |= XFS_FEAT_PARENT; + if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR) + features |= XFS_FEAT_METADIR; return features; } @@ -700,6 +702,11 @@ __xfs_sb_from_disk( /* Convert on-disk flags to in-memory flags? */ if (convert_xquota) xfs_sb_quota_from_disk(to); + + if (to->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR) + to->sb_metadirino = be64_to_cpu(from->sb_metadirino); + else + to->sb_metadirino = NULLFSINO; } void @@ -847,6 +854,9 @@ xfs_sb_to_disk( to->sb_lsn = cpu_to_be64(from->sb_lsn); if (from->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_META_UUID) uuid_copy(&to->sb_meta_uuid, &from->sb_meta_uuid); + + if (from->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR) + to->sb_metadirino = cpu_to_be64(from->sb_metadirino); } /* diff --git a/repair/dino_chunks.c b/repair/dino_chunks.c index 86e29dd9ae05eb..49d57948c7eca8 100644 --- a/repair/dino_chunks.c +++ b/repair/dino_chunks.c @@ -896,7 +896,7 @@ process_inode_chunk( set_inode_disk_nlinks(ino_rec, irec_offset, dino->di_version > 1 ? be32_to_cpu(dino->di_nlink) - : be16_to_cpu(dino->di_onlink)); + : be16_to_cpu(dino->di_metatype)); } else { set_inode_free(ino_rec, irec_offset); diff --git a/repair/dinode.c b/repair/dinode.c index ac81c487a20b8a..12a12f00672776 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -2231,20 +2231,22 @@ process_check_inode_nlink_version( int dirty = 0; /* - * if it's a version 2 inode, it should have a zero + * if it's a version 2 non-metadir inode, it should have a zero * onlink field, so clear it. */ - if (dino->di_version > 1 && dino->di_onlink != 0) { + if (dino->di_version > 1 && + !(dino->di_flags2 & cpu_to_be64(XFS_DIFLAG2_METADATA)) && + dino->di_metatype != 0) { if (!no_modify) { do_warn( _("clearing obsolete nlink field in version 2 inode %" PRIu64 ", was %d, now 0\n"), - lino, be16_to_cpu(dino->di_onlink)); - dino->di_onlink = 0; + lino, be16_to_cpu(dino->di_metatype)); + dino->di_metatype = 0; dirty = 1; } else { do_warn( _("would clear obsolete nlink field in version 2 inode %" PRIu64 ", currently %d\n"), - lino, be16_to_cpu(dino->di_onlink)); + lino, be16_to_cpu(dino->di_metatype)); } } return dirty; From patchwork Fri Dec 6 23:37:33 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: 13897970 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 594141C548E for ; Fri, 6 Dec 2024 23:37: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=1733528254; cv=none; b=ggnQbTmzAwdJfuTwkjI6JnIVFmT8tRbUfFgtkyPN/ZTtS6wUOPeiG/CCKVh0zad1KW3mpCOnfHFaySjy6Vt7N3H+heFnjlEL3jRO0xQVfI0suc6rAwim2z8uEWh/q6SnN4QagDQH5dg9wAooBrGilQsF+pgKyss3n5H9LCPES9Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528254; c=relaxed/simple; bh=9QCrWHGsZJa3B3SlkdMJlbDw/zYloxGmtzHE+XbuiB0=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D8wYN3P8MAiujry8D6cirwZ2+iMIPB7f0bEBnilwc73fddHaJg1v4o5xLmKQEt3bldKBoLpqDz8rBD1BhpVkD1hNp0EcQxcB23z4BXZV4VLH6ankk/mB1kkRadvqtPHpiCV4qAlapK0MpKs0EOqhc8Z5lmK1YnAYDbL+bNZ0wK8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dmPJiS+v; 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="dmPJiS+v" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37023C4CED1; Fri, 6 Dec 2024 23:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528254; bh=9QCrWHGsZJa3B3SlkdMJlbDw/zYloxGmtzHE+XbuiB0=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=dmPJiS+vgleclHu66cUieANv7OlIsE3xWGyDD6br6N5KMg+NF8MHFL+KpjPkWshkY Be3VKT6wRUFVwfxQ/wrGhCS50V7b2ckpUMl350oCDgkDwYRXDmbUpHupoqbyLWIStY ETt6ieOuM0U9BipuZlFzo0DltOXFfx4fX5MJhxMm0L1U90MEG4esoo8PZpJjKPzz4I eQvuHOYFd4svGEPEQEe9iOT7+DLVkHzMfpKF6/+Z+kPiTDXE/Dtdxh+Mr8YNyB2Gbu g0rUeUNELdCAl1qNDZ1qatw1AT660t6KPRLh1B/YM+lgdZ2DgrE3fF8mjrAMsu9D3b K7BIYsoZr+eYQ== Date: Fri, 06 Dec 2024 15:37:33 -0800 Subject: [PATCH 28/36] xfs: iget for metadata inodes From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747304.121772.2733366590661000896.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.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 Source kernel commit df2e495bb92c84a401b6b90c835a9d1be84a3a0f Create a xfs_trans_metafile_iget function for metadata inodes to ensure that when we try to iget a metadata file, the inode is allocated and its file mode matches the metadata file type the caller expects. Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- include/libxfs.h | 1 + include/xfs_inode.h | 5 ++++ libxfs/Makefile | 1 + libxfs/inode.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++ libxfs/libxfs_api_defs.h | 5 ++++ libxfs/xfs_metafile.h | 16 +++++++++++++ 6 files changed, 83 insertions(+) create mode 100644 libxfs/xfs_metafile.h diff --git a/include/libxfs.h b/include/libxfs.h index fe8e6584f1caca..0356bc57b956a9 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -95,6 +95,7 @@ struct iomap; #include "xfs_btree_mem.h" #include "xfs_parent.h" #include "xfs_ag_resv.h" +#include "xfs_metafile.h" #ifndef ARRAY_SIZE #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) diff --git a/include/xfs_inode.h b/include/xfs_inode.h index e03521bc9aaaa2..6f2d23987d5f8a 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -210,6 +210,11 @@ static inline struct timespec64 inode_set_ctime_current(struct inode *inode) return now; } +static inline bool inode_wrong_type(const struct inode *inode, umode_t mode) +{ + return (inode->i_mode ^ mode) & S_IFMT; +} + typedef struct xfs_inode { struct cache_node i_node; struct xfs_mount *i_mount; /* fs mount struct ptr */ diff --git a/libxfs/Makefile b/libxfs/Makefile index 470583006de69a..765c84a16408f8 100644 --- a/libxfs/Makefile +++ b/libxfs/Makefile @@ -55,6 +55,7 @@ HFILES = \ xfs_inode_buf.h \ xfs_inode_fork.h \ xfs_inode_util.h \ + xfs_metafile.h \ xfs_parent.h \ xfs_quota_defs.h \ xfs_refcount.h \ diff --git a/libxfs/inode.c b/libxfs/inode.c index 9230ad24a5cb6c..1eb0bccae48906 100644 --- a/libxfs/inode.c +++ b/libxfs/inode.c @@ -205,6 +205,61 @@ libxfs_iget( return error; } +/* + * Get a metadata inode. + * + * The metafile type must match the file mode exactly. + */ +int +libxfs_trans_metafile_iget( + struct xfs_trans *tp, + xfs_ino_t ino, + enum xfs_metafile_type metafile_type, + struct xfs_inode **ipp) +{ + struct xfs_mount *mp = tp->t_mountp; + struct xfs_inode *ip; + umode_t mode; + int error; + + error = libxfs_iget(mp, tp, ino, 0, &ip); + if (error) + return error; + + if (metafile_type == XFS_METAFILE_DIR) + mode = S_IFDIR; + else + mode = S_IFREG; + if (inode_wrong_type(VFS_I(ip), mode)) + goto bad_rele; + + *ipp = ip; + return 0; +bad_rele: + libxfs_irele(ip); + return -EFSCORRUPTED; +} + +/* Grab a metadata file if the caller doesn't already have a transaction. */ +int +libxfs_metafile_iget( + struct xfs_mount *mp, + xfs_ino_t ino, + enum xfs_metafile_type metafile_type, + struct xfs_inode **ipp) +{ + struct xfs_trans *tp; + int error; + + error = libxfs_trans_alloc_empty(mp, &tp); + if (error) + return error; + + error = libxfs_trans_metafile_iget(tp, ino, metafile_type, ipp); + libxfs_trans_cancel(tp); + return error; +} + static void libxfs_idestroy( struct xfs_inode *ip) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 92e26eebabfed8..fefae9256555a0 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -184,6 +184,7 @@ #define xfs_iext_next libxfs_iext_next #define xfs_ifork_zap_attr libxfs_ifork_zap_attr #define xfs_imap_to_bp libxfs_imap_to_bp + #define xfs_initialize_perag libxfs_initialize_perag #define xfs_initialize_perag_data libxfs_initialize_perag_data #define xfs_init_local_fork libxfs_init_local_fork @@ -208,8 +209,12 @@ #define xfs_log_calc_minimum_size libxfs_log_calc_minimum_size #define xfs_log_get_max_trans_res libxfs_log_get_max_trans_res #define xfs_log_sb libxfs_log_sb + +#define xfs_metafile_iget libxfs_metafile_iget +#define xfs_trans_metafile_iget libxfs_trans_metafile_iget #define xfs_mode_to_ftype libxfs_mode_to_ftype #define xfs_mkdir_space_res libxfs_mkdir_space_res + #define xfs_parent_addname libxfs_parent_addname #define xfs_parent_finish libxfs_parent_finish #define xfs_parent_hashval libxfs_parent_hashval diff --git a/libxfs/xfs_metafile.h b/libxfs/xfs_metafile.h new file mode 100644 index 00000000000000..60fe1890611277 --- /dev/null +++ b/libxfs/xfs_metafile.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2018-2024 Oracle. All Rights Reserved. + * Author: Darrick J. Wong + */ +#ifndef __XFS_METAFILE_H__ +#define __XFS_METAFILE_H__ + +/* Code specific to kernel/userspace; must be provided externally. */ + +int xfs_trans_metafile_iget(struct xfs_trans *tp, xfs_ino_t ino, + enum xfs_metafile_type metafile_type, struct xfs_inode **ipp); +int xfs_metafile_iget(struct xfs_mount *mp, xfs_ino_t ino, + enum xfs_metafile_type metafile_type, struct xfs_inode **ipp); + +#endif /* __XFS_METAFILE_H__ */ From patchwork Fri Dec 6 23:37: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: 13897971 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 E7FBE1C548E for ; Fri, 6 Dec 2024 23:37:49 +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=1733528270; cv=none; b=FeTq9USf44evshDhhIUnHV34MukVLL0JwYi/x44gKupn5r/UaG4Ft888a9l6M0tKhyxki7KEtpQU//jQw4FAW7KXG01IbPDOGe/yoIXXjEpomIXbiU1lqqkwRnro/QIdgB9KtuiCt0L8Y3Ew0dcWlojxjmC6LUn8vv+RsFwyc4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528270; c=relaxed/simple; bh=IZVoXHys9PUnBqz+s+/BaZfkcuuasJ7akohU6Ej+BpM=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W6syY6ln/3NlIeMhqHLntEXq8va9P4sLQjoGr6oP3LofG5n86B/JuzVIH2Ja930QmYlkZySDxBvWeKhMKUq05IVlu64v9NVLVzwRfWfS52W2NqKK+5Pairdc/QxqgsdJ3zogc36xAhF4jfxIdcIu+UjCx5iLioZqxpAN4jM/6AI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dhzs7Fpg; 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="dhzs7Fpg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1D55C4CED1; Fri, 6 Dec 2024 23:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528269; bh=IZVoXHys9PUnBqz+s+/BaZfkcuuasJ7akohU6Ej+BpM=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=dhzs7FpgA+xm2m4r4jE1E/rCmbA//gIUMsH4TWoqI8d7ghkplI+VbKC4/z6EbDIU+ GIwPBMyZPjVrNaAVO+Lga2sQAfGK12I7PycV5PpiN7Ce3kuBL+4T32lZPp79tuRz4U e9joF5kJ4D7SxBpWAAa2T+X46qp/BlSduF3ZiIiJHiWAmmqaovwZRz5Yyjg1a9yC6O T5hI71Y0PMXHlAQuon0HmqSSp5JaSBPdklOR7ChKivubgfbhPECOa/sg3J+k2tT83Y gE99HfbIF6AtXBRVlrru5g0R7jU/rMmnkM1zR3JqDTtU4yWS29rwnz9md+hQ7dO+bm mtFOpk157iiVw== Date: Fri, 06 Dec 2024 15:37:49 -0800 Subject: [PATCH 29/36] xfs: enforce metadata inode flag From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747319.121772.12003147323516221021.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.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 Source kernel commit: 7297fd0bebbd70efd12f72632a0f3ac49a8f59fe Add checks for the metadata inode flag so that we don't ever leak metadata inodes out to userspace, and we don't ever try to read a regular inode as metadata. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/xfs_inode_buf.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ libxfs/xfs_inode_buf.h | 3 ++ libxfs/xfs_metafile.h | 11 ++++++++ 3 files changed, 84 insertions(+) diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 981113f6acd37a..98482cb4948284 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -17,6 +17,7 @@ #include "xfs_ialloc.h" #include "xfs_dir2.h" #include "xfs_health.h" +#include "xfs_metafile.h" /* @@ -486,6 +487,69 @@ xfs_dinode_verify_nrext64( return NULL; } +/* + * Validate all the picky requirements we have for a file that claims to be + * filesystem metadata. + */ +xfs_failaddr_t +xfs_dinode_verify_metadir( + struct xfs_mount *mp, + struct xfs_dinode *dip, + uint16_t mode, + uint16_t flags, + uint64_t flags2) +{ + if (!xfs_has_metadir(mp)) + return __this_address; + + /* V5 filesystem only */ + if (dip->di_version < 3) + return __this_address; + + if (be16_to_cpu(dip->di_metatype) >= XFS_METAFILE_MAX) + return __this_address; + + /* V3 inode fields that are always zero */ + if ((flags2 & XFS_DIFLAG2_NREXT64) && dip->di_nrext64_pad) + return __this_address; + if (!(flags2 & XFS_DIFLAG2_NREXT64) && dip->di_flushiter) + return __this_address; + + /* Metadata files can only be directories or regular files */ + if (!S_ISDIR(mode) && !S_ISREG(mode)) + return __this_address; + + /* They must have zero access permissions */ + if (mode & 0777) + return __this_address; + + /* DMAPI event and state masks are zero */ + if (dip->di_dmevmask || dip->di_dmstate) + return __this_address; + + /* + * User and group IDs must be zero. The project ID is used for + * grouping inodes. Metadata inodes are never accounted to quotas. + */ + if (dip->di_uid || dip->di_gid) + return __this_address; + + /* Mandatory inode flags must be set */ + if (S_ISDIR(mode)) { + if ((flags & XFS_METADIR_DIFLAGS) != XFS_METADIR_DIFLAGS) + return __this_address; + } else { + if ((flags & XFS_METAFILE_DIFLAGS) != XFS_METAFILE_DIFLAGS) + return __this_address; + } + + /* dax flags2 must not be set */ + if (flags2 & XFS_DIFLAG2_DAX) + return __this_address; + + return NULL; +} + xfs_failaddr_t xfs_dinode_verify( struct xfs_mount *mp, @@ -670,6 +734,12 @@ xfs_dinode_verify( !xfs_has_bigtime(mp)) return __this_address; + if (flags2 & XFS_DIFLAG2_METADATA) { + fa = xfs_dinode_verify_metadir(mp, dip, mode, flags, flags2); + if (fa) + return fa; + } + return NULL; } diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h index 585ed5a110af4e..8d43d2641c7328 100644 --- a/libxfs/xfs_inode_buf.h +++ b/libxfs/xfs_inode_buf.h @@ -28,6 +28,9 @@ int xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from); xfs_failaddr_t xfs_dinode_verify(struct xfs_mount *mp, xfs_ino_t ino, struct xfs_dinode *dip); +xfs_failaddr_t xfs_dinode_verify_metadir(struct xfs_mount *mp, + struct xfs_dinode *dip, uint16_t mode, uint16_t flags, + uint64_t flags2); xfs_failaddr_t xfs_inode_validate_extsize(struct xfs_mount *mp, uint32_t extsize, uint16_t mode, uint16_t flags); xfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_mount *mp, diff --git a/libxfs/xfs_metafile.h b/libxfs/xfs_metafile.h index 60fe1890611277..c66b0c51b461a8 100644 --- a/libxfs/xfs_metafile.h +++ b/libxfs/xfs_metafile.h @@ -6,6 +6,17 @@ #ifndef __XFS_METAFILE_H__ #define __XFS_METAFILE_H__ +/* All metadata files must have these flags set. */ +#define XFS_METAFILE_DIFLAGS (XFS_DIFLAG_IMMUTABLE | \ + XFS_DIFLAG_SYNC | \ + XFS_DIFLAG_NOATIME | \ + XFS_DIFLAG_NODUMP | \ + XFS_DIFLAG_NODEFRAG) + +/* All metadata directories must have these flags set. */ +#define XFS_METADIR_DIFLAGS (XFS_METAFILE_DIFLAGS | \ + XFS_DIFLAG_NOSYMLINKS) + /* Code specific to kernel/userspace; must be provided externally. */ int xfs_trans_metafile_iget(struct xfs_trans *tp, xfs_ino_t ino, From patchwork Fri Dec 6 23:38:04 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: 13897972 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 8B8BF1C548E for ; Fri, 6 Dec 2024 23:38:05 +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=1733528285; cv=none; b=qqtvmDEJcEicPZtbzzeVpkbm5rd+7eHtBzGfxmOJn/xk6RT+iR5CLLCm4a+SkXSZ8pp2cVQ7MGKIn8qfCZlM0+c+aR+icAbsYjhirnUQIFP8CLQAgdujOwQryA/jU7XOioLqhzpo3LkI6TPRoihiMTPEojJ0JmYm40aP0zf21b8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528285; c=relaxed/simple; bh=/5WWOuWXk6eoQtCJEOqgNEJCfeQnOofHmSshmckkt5Q=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S8JlQ4zNeIMDkuqVzYEliD5wWvDjg220iLy11/BfOrY3XglmQz0mzFuXEUWmZ1ZqloEaeL5Q0ZOObfcBOs4QK2cdZ2LfMADAvd8EqLzr1BBHXTYhDaCUY3aFJoknAK40/12bTZu7G023RDfGeuU/Z42dgwuezXKqHC9I761yiY8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kecMrzrO; 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="kecMrzrO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63877C4CED1; Fri, 6 Dec 2024 23:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528285; bh=/5WWOuWXk6eoQtCJEOqgNEJCfeQnOofHmSshmckkt5Q=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=kecMrzrOUuIohypSJ7ksTm03LrOOcLgFjuPYtve/NR3bOmwQZBMilqZ6TC8qfpmS6 YnEcetjOSydCnm7LD5xj7Q27cuXVnGrWQAUcsvqiIBF4t+BLEUqZTfOu6MifNgddMf 4osUkhUBGbipfE7yrTgSai4+vP/tiKEGHssZAiVmAxQE33jLwkTi66s7Q4ZBhLkIon dnAGq/glZmLaIgLwCIOoMjOQfUEomLboRWdyEmIT/63faTOMfApGIOrPX+lhJsOklR IEFUh5b2wn/mQhAwyUrgL1EXhetEF1cTp63UFX39sa4SZ8ldSt6bslXakJXuJqDTNC XhgAB6eLr7f4Q== Date: Fri, 06 Dec 2024 15:38:04 -0800 Subject: [PATCH 30/36] xfs: read and write metadata inode directory tree From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747334.121772.2827186347071122552.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.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 Source kernel commit e0f091c40bf1287a122dcddd8aa4e6ad06ce441f Plumb in the bits we need to load metadata inodes from a named entry in a metadir directory, create (or hardlink) inodes into a metadir directory, create metadir directories, and flag inodes as being metadata files. Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- include/libxfs.h | 1 include/xfs_trace.h | 10 + include/xfs_trans.h | 3 libxfs/Makefile | 3 libxfs/libxfs_api_defs.h | 7 + libxfs/libxfs_priv.h | 2 libxfs/trans.c | 39 ++++ libxfs/xfs_metadir.c | 473 ++++++++++++++++++++++++++++++++++++++++++++++ libxfs/xfs_metadir.h | 47 +++++ libxfs/xfs_metafile.c | 52 +++++ libxfs/xfs_metafile.h | 4 11 files changed, 641 insertions(+) create mode 100644 libxfs/xfs_metadir.c create mode 100644 libxfs/xfs_metadir.h create mode 100644 libxfs/xfs_metafile.c diff --git a/include/libxfs.h b/include/libxfs.h index 0356bc57b956a9..348d36be192966 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -96,6 +96,7 @@ struct iomap; #include "xfs_parent.h" #include "xfs_ag_resv.h" #include "xfs_metafile.h" +#include "xfs_metadir.h" #ifndef ARRAY_SIZE #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) diff --git a/include/xfs_trace.h b/include/xfs_trace.h index de435a9d1a2a64..f3e531ef118d05 100644 --- a/include/xfs_trace.h +++ b/include/xfs_trace.h @@ -360,6 +360,16 @@ #define trace_xlog_intent_recovery_failed(...) ((void) 0) +#define trace_xfs_metadir_cancel(...) ((void) 0) +#define trace_xfs_metadir_commit(...) ((void) 0) +#define trace_xfs_metadir_create(...) ((void) 0) +#define trace_xfs_metadir_link(...) ((void) 0) +#define trace_xfs_metadir_lookup(...) ((void) 0) +#define trace_xfs_metadir_start_create(...) ((void) 0) +#define trace_xfs_metadir_start_link(...) ((void) 0) +#define trace_xfs_metadir_teardown(...) ((void) 0) +#define trace_xfs_metadir_try_create(...) ((void) 0) + #define trace_xfs_iunlink_update_bucket(...) ((void) 0) #define trace_xfs_iunlink_update_dinode(...) ((void) 0) #define trace_xfs_iunlink(...) ((void) 0) diff --git a/include/xfs_trans.h b/include/xfs_trans.h index 9bc4b1ef5e82f9..d508f8947a301c 100644 --- a/include/xfs_trans.h +++ b/include/xfs_trans.h @@ -93,6 +93,9 @@ int libxfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp, int libxfs_trans_alloc_inode(struct xfs_inode *ip, struct xfs_trans_res *resv, unsigned int dblocks, unsigned int rblocks, bool force, struct xfs_trans **tpp); +int libxfs_trans_alloc_dir(struct xfs_inode *dp, struct xfs_trans_res *resv, + struct xfs_inode *ip, unsigned int *dblocks, + struct xfs_trans **tpp, int *nospace_error); int libxfs_trans_alloc_rollable(struct xfs_mount *mp, uint blocks, struct xfs_trans **tpp); int libxfs_trans_alloc_empty(struct xfs_mount *mp, struct xfs_trans **tpp); diff --git a/libxfs/Makefile b/libxfs/Makefile index 765c84a16408f8..c8267841e77b01 100644 --- a/libxfs/Makefile +++ b/libxfs/Makefile @@ -55,6 +55,7 @@ HFILES = \ xfs_inode_buf.h \ xfs_inode_fork.h \ xfs_inode_util.h \ + xfs_metadir.h \ xfs_metafile.h \ xfs_parent.h \ xfs_quota_defs.h \ @@ -114,6 +115,8 @@ CFILES = buf_mem.c \ xfs_inode_fork.c \ xfs_inode_util.c \ xfs_ialloc_btree.c \ + xfs_metadir.c \ + xfs_metafile.c \ xfs_log_rlimit.c \ xfs_parent.c \ xfs_refcount.c \ diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index fefae9256555a0..dd163709fe07df 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -176,6 +176,7 @@ #define xfs_iallocbt_calc_size libxfs_iallocbt_calc_size #define xfs_iallocbt_maxlevels_ondisk libxfs_iallocbt_maxlevels_ondisk #define xfs_ialloc_read_agi libxfs_ialloc_read_agi +#define xfs_icreate libxfs_icreate #define xfs_idata_realloc libxfs_idata_realloc #define xfs_idestroy_fork libxfs_idestroy_fork #define xfs_iext_first libxfs_iext_first @@ -212,6 +213,11 @@ #define xfs_metafile_iget libxfs_metafile_iget #define xfs_trans_metafile_iget libxfs_trans_metafile_iget +#define xfs_metadir_link libxfs_metadir_link +#define xfs_metadir_lookup libxfs_metadir_lookup +#define xfs_metadir_start_create libxfs_metadir_start_create +#define xfs_metadir_start_link libxfs_metadir_start_link + #define xfs_mode_to_ftype libxfs_mode_to_ftype #define xfs_mkdir_space_res libxfs_mkdir_space_res @@ -285,6 +291,7 @@ #define xfs_trans_add_item libxfs_trans_add_item #define xfs_trans_alloc_empty libxfs_trans_alloc_empty #define xfs_trans_alloc libxfs_trans_alloc +#define xfs_trans_alloc_dir libxfs_trans_alloc_dir #define xfs_trans_alloc_inode libxfs_trans_alloc_inode #define xfs_trans_bdetach libxfs_trans_bdetach #define xfs_trans_bhold libxfs_trans_bhold diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 1b6bb961b7ac06..631abf266ad526 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -181,6 +181,7 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC }; #define XFS_ILOCK_SHARED 0 #define XFS_ILOCK_RTBITMAP 0 #define XFS_ILOCK_RTSUM 0 +#define XFS_IOLOCK_EXCL 0 #define XFS_STATS_INC(mp, count) do { (mp) = (mp); } while (0) #define XFS_STATS_DEC(mp, count, x) do { (mp) = (mp); } while (0) #define XFS_STATS_ADD(mp, count, x) do { (mp) = (mp); } while (0) @@ -632,6 +633,7 @@ int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip, /* xfs_inode.h */ #define xfs_iflags_set(ip, flags) do { } while (0) +#define xfs_finish_inode_setup(ip) ((void) 0) /* linux/wordpart.h */ diff --git a/libxfs/trans.c b/libxfs/trans.c index 7e36205c6a3d50..72f26591053716 100644 --- a/libxfs/trans.c +++ b/libxfs/trans.c @@ -1185,6 +1185,45 @@ libxfs_trans_alloc_inode( return 0; } +/* + * Allocate an transaction, lock and join the directory and child inodes to it, + * and reserve quota for a directory update. @resblks must point to the number + * of blocks to reserve; if not enough space is available, -ENOSPC will be + * returned. @nospace_error is always set to zero here. Userspace does not + * support reservationless creation at all, unlike the kernel. + * + * The ILOCKs will be dropped when the transaction is committed or cancelled. + * + * Caller is responsible for unlocking the inodes manually upon return + */ +int +libxfs_trans_alloc_dir( + struct xfs_inode *dp, + struct xfs_trans_res *resv, + struct xfs_inode *ip, + unsigned int *resblks, + struct xfs_trans **tpp, + int *nospace_error) +{ + struct xfs_trans *tp; + struct xfs_mount *mp = ip->i_mount; + int error; + + *nospace_error = 0; + + error = xfs_trans_alloc(mp, resv, *resblks, 0, 0, &tp); + if (error) + return error; + + xfs_lock_two_inodes(dp, XFS_ILOCK_EXCL, ip, XFS_ILOCK_EXCL); + + xfs_trans_ijoin(tp, dp, 0); + xfs_trans_ijoin(tp, ip, 0); + + *tpp = tp; + return 0; +} + /* * Try to reserve more blocks for a transaction. The single use case we * support is for offline repair -- use a transaction to gather data without diff --git a/libxfs/xfs_metadir.c b/libxfs/xfs_metadir.c new file mode 100644 index 00000000000000..b52abf12d20511 --- /dev/null +++ b/libxfs/xfs_metadir.c @@ -0,0 +1,473 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2018-2024 Oracle. All Rights Reserved. + * Author: Darrick J. Wong + */ +#include "libxfs_priv.h" +#include "xfs_fs.h" +#include "xfs_shared.h" +#include "xfs_format.h" +#include "xfs_log_format.h" +#include "xfs_trans_resv.h" +#include "xfs_bit.h" +#include "xfs_sb.h" +#include "xfs_mount.h" +#include "xfs_defer.h" +#include "xfs_trans.h" +#include "xfs_metafile.h" +#include "xfs_metadir.h" +#include "xfs_trace.h" +#include "xfs_inode.h" +#include "xfs_ialloc.h" +#include "xfs_bmap_btree.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" +#include "xfs_trans_space.h" +#include "xfs_ag.h" +#include "xfs_dir2.h" +#include "xfs_dir2_priv.h" +#include "xfs_parent.h" + +/* + * Metadata Directory Tree + * ======================= + * + * These functions provide an abstraction layer for looking up, creating, and + * deleting metadata inodes that live within a special metadata directory tree. + * + * This code does not manage the five existing metadata inodes: real time + * bitmap & summary; and the user, group, and quotas. All other metadata + * inodes must use only the xfs_meta{dir,file}_* functions. + * + * Callers wishing to create or hardlink a metadata inode must create an + * xfs_metadir_update structure, call the appropriate xfs_metadir* function, + * and then call xfs_metadir_commit or xfs_metadir_cancel to commit or cancel + * the update. Files in the metadata directory tree currently cannot be + * unlinked. + * + * When the metadir feature is enabled, all metadata inodes must have the + * "metadata" inode flag set to prevent them from being exposed to the outside + * world. + * + * Callers must take the ILOCK of any inode in the metadata directory tree to + * synchronize access to that inode. It is never necessary to take the IOLOCK + * or the MMAPLOCK since metadata inodes must not be exposed to user space. + */ + +static inline void +xfs_metadir_set_xname( + struct xfs_name *xname, + const char *path, + unsigned char ftype) +{ + xname->name = (const unsigned char *)path; + xname->len = strlen(path); + xname->type = ftype; +} + +/* + * Given a parent directory @dp and a metadata inode path component @xname, + * Look up the inode number in the directory, returning it in @ino. + * @xname.type must match the directory entry's ftype. + * + * Caller must hold ILOCK_EXCL. + */ +static inline int +xfs_metadir_lookup( + struct xfs_trans *tp, + struct xfs_inode *dp, + struct xfs_name *xname, + xfs_ino_t *ino) +{ + struct xfs_mount *mp = dp->i_mount; + struct xfs_da_args args = { + .trans = tp, + .dp = dp, + .geo = mp->m_dir_geo, + .name = xname->name, + .namelen = xname->len, + .hashval = xfs_dir2_hashname(mp, xname), + .whichfork = XFS_DATA_FORK, + .op_flags = XFS_DA_OP_OKNOENT, + .owner = dp->i_ino, + }; + int error; + + if (!S_ISDIR(VFS_I(dp)->i_mode)) + return -EFSCORRUPTED; + if (xfs_is_shutdown(mp)) + return -EIO; + + error = xfs_dir_lookup_args(&args); + if (error) + return error; + + if (!xfs_verify_ino(mp, args.inumber)) + return -EFSCORRUPTED; + if (xname->type != XFS_DIR3_FT_UNKNOWN && xname->type != args.filetype) + return -EFSCORRUPTED; + + trace_xfs_metadir_lookup(dp, xname, args.inumber); + *ino = args.inumber; + return 0; +} + +/* + * Look up and read a metadata inode from the metadata directory. If the path + * component doesn't exist, return -ENOENT. + */ +int +xfs_metadir_load( + struct xfs_trans *tp, + struct xfs_inode *dp, + const char *path, + enum xfs_metafile_type metafile_type, + struct xfs_inode **ipp) +{ + struct xfs_name xname; + xfs_ino_t ino; + int error; + + xfs_metadir_set_xname(&xname, path, XFS_DIR3_FT_UNKNOWN); + + xfs_ilock(dp, XFS_ILOCK_EXCL); + error = xfs_metadir_lookup(tp, dp, &xname, &ino); + xfs_iunlock(dp, XFS_ILOCK_EXCL); + if (error) + return error; + return xfs_trans_metafile_iget(tp, ino, metafile_type, ipp); +} + +/* + * Unlock and release resources after committing (or cancelling) a metadata + * directory tree operation. The caller retains its reference to @upd->ip + * and must release it explicitly. + */ +static inline void +xfs_metadir_teardown( + struct xfs_metadir_update *upd, + int error) +{ + trace_xfs_metadir_teardown(upd, error); + + if (upd->ppargs) { + xfs_parent_finish(upd->dp->i_mount, upd->ppargs); + upd->ppargs = NULL; + } + + if (upd->ip) { + if (upd->ip_locked) + xfs_iunlock(upd->ip, XFS_ILOCK_EXCL); + upd->ip_locked = false; + } + + if (upd->dp_locked) + xfs_iunlock(upd->dp, XFS_ILOCK_EXCL); + upd->dp_locked = false; +} + +/* + * Begin the process of creating a metadata file by allocating transactions + * and taking whatever resources we're going to need. + */ +int +xfs_metadir_start_create( + struct xfs_metadir_update *upd) +{ + struct xfs_mount *mp = upd->dp->i_mount; + int error; + + ASSERT(upd->dp != NULL); + ASSERT(upd->ip == NULL); + ASSERT(xfs_has_metadir(mp)); + ASSERT(upd->metafile_type != XFS_METAFILE_UNKNOWN); + + error = xfs_parent_start(mp, &upd->ppargs); + if (error) + return error; + + /* + * If we ever need the ability to create rt metadata files on a + * pre-metadir filesystem, we'll need to dqattach the parent here. + * Currently we assume that mkfs will create the files and quotacheck + * will account for them. + */ + + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_create, + xfs_create_space_res(mp, MAXNAMELEN), 0, 0, &upd->tp); + if (error) + goto out_teardown; + + /* + * Lock the parent directory if there is one. We can't ijoin it to + * the transaction until after the child file has been created. + */ + xfs_ilock(upd->dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT); + upd->dp_locked = true; + + trace_xfs_metadir_start_create(upd); + return 0; +out_teardown: + xfs_metadir_teardown(upd, error); + return error; +} + +/* + * Create a metadata inode with the given @mode, and insert it into the + * metadata directory tree at the given @upd->path. The path up to the final + * component must already exist. The final path component must not exist. + * + * The new metadata inode will be attached to the update structure @upd->ip, + * with the ILOCK held until the caller releases it. + * + * NOTE: This function may return a new inode to the caller even if it returns + * a negative error code. If an inode is passed back, the caller must finish + * setting up the inode before releasing it. + */ +int +xfs_metadir_create( + struct xfs_metadir_update *upd, + umode_t mode) +{ + struct xfs_icreate_args args = { + .pip = upd->dp, + .mode = mode, + }; + struct xfs_name xname; + struct xfs_dir_update du = { + .dp = upd->dp, + .name = &xname, + .ppargs = upd->ppargs, + }; + struct xfs_mount *mp = upd->dp->i_mount; + xfs_ino_t ino; + unsigned int resblks; + int error; + + xfs_assert_ilocked(upd->dp, XFS_ILOCK_EXCL); + + /* Check that the name does not already exist in the directory. */ + xfs_metadir_set_xname(&xname, upd->path, XFS_DIR3_FT_UNKNOWN); + error = xfs_metadir_lookup(upd->tp, upd->dp, &xname, &ino); + switch (error) { + case -ENOENT: + break; + case 0: + error = -EEXIST; + fallthrough; + default: + return error; + } + + /* + * A newly created regular or special file just has one directory + * entry pointing to them, but a directory also the "." entry + * pointing to itself. + */ + error = xfs_dialloc(&upd->tp, &args, &ino); + if (error) + return error; + error = xfs_icreate(upd->tp, ino, &args, &upd->ip); + if (error) + return error; + du.ip = upd->ip; + xfs_metafile_set_iflag(upd->tp, upd->ip, upd->metafile_type); + upd->ip_locked = true; + + /* + * Join the directory inode to the transaction. We do not do it + * earlier because xfs_dialloc rolls the transaction. + */ + xfs_trans_ijoin(upd->tp, upd->dp, 0); + + /* Create the entry. */ + if (S_ISDIR(args.mode)) + resblks = xfs_mkdir_space_res(mp, xname.len); + else + resblks = xfs_create_space_res(mp, xname.len); + xname.type = xfs_mode_to_ftype(args.mode); + + trace_xfs_metadir_try_create(upd); + + error = xfs_dir_create_child(upd->tp, resblks, &du); + if (error) + return error; + + /* Metadir files are not accounted to quota. */ + + trace_xfs_metadir_create(upd); + + return 0; +} + +#ifndef __KERNEL__ +/* + * Begin the process of linking a metadata file by allocating transactions + * and locking whatever resources we're going to need. + */ +int +xfs_metadir_start_link( + struct xfs_metadir_update *upd) +{ + struct xfs_mount *mp = upd->dp->i_mount; + unsigned int resblks; + int nospace_error = 0; + int error; + + ASSERT(upd->dp != NULL); + ASSERT(upd->ip != NULL); + ASSERT(xfs_has_metadir(mp)); + + error = xfs_parent_start(mp, &upd->ppargs); + if (error) + return error; + + resblks = xfs_link_space_res(mp, MAXNAMELEN); + error = xfs_trans_alloc_dir(upd->dp, &M_RES(mp)->tr_link, upd->ip, + &resblks, &upd->tp, &nospace_error); + if (error) + goto out_teardown; + if (!resblks) { + /* We don't allow reservationless updates. */ + xfs_trans_cancel(upd->tp); + upd->tp = NULL; + xfs_iunlock(upd->dp, XFS_ILOCK_EXCL); + xfs_iunlock(upd->ip, XFS_ILOCK_EXCL); + error = nospace_error; + goto out_teardown; + } + + upd->dp_locked = true; + upd->ip_locked = true; + + trace_xfs_metadir_start_link(upd); + return 0; +out_teardown: + xfs_metadir_teardown(upd, error); + return error; +} + +/* + * Link the metadata directory given by @path to the inode @upd->ip. + * The path (up to the final component) must already exist, but the final + * component must not already exist. + */ +int +xfs_metadir_link( + struct xfs_metadir_update *upd) +{ + struct xfs_name xname; + struct xfs_dir_update du = { + .dp = upd->dp, + .name = &xname, + .ip = upd->ip, + .ppargs = upd->ppargs, + }; + struct xfs_mount *mp = upd->dp->i_mount; + xfs_ino_t ino; + unsigned int resblks; + int error; + + xfs_assert_ilocked(upd->dp, XFS_ILOCK_EXCL); + xfs_assert_ilocked(upd->ip, XFS_ILOCK_EXCL); + + /* Look up the name in the current directory. */ + xfs_metadir_set_xname(&xname, upd->path, + xfs_mode_to_ftype(VFS_I(upd->ip)->i_mode)); + error = xfs_metadir_lookup(upd->tp, upd->dp, &xname, &ino); + switch (error) { + case -ENOENT: + break; + case 0: + error = -EEXIST; + fallthrough; + default: + return error; + } + + resblks = xfs_link_space_res(mp, xname.len); + error = xfs_dir_add_child(upd->tp, resblks, &du); + if (error) + return error; + + trace_xfs_metadir_link(upd); + + return 0; +} +#endif /* ! __KERNEL__ */ + +/* Commit a metadir update and unlock/drop all resources. */ +int +xfs_metadir_commit( + struct xfs_metadir_update *upd) +{ + int error; + + trace_xfs_metadir_commit(upd); + + error = xfs_trans_commit(upd->tp); + upd->tp = NULL; + + xfs_metadir_teardown(upd, error); + return error; +} + +/* Cancel a metadir update and unlock/drop all resources. */ +void +xfs_metadir_cancel( + struct xfs_metadir_update *upd, + int error) +{ + trace_xfs_metadir_cancel(upd); + + xfs_trans_cancel(upd->tp); + upd->tp = NULL; + + xfs_metadir_teardown(upd, error); +} + +/* Create a metadata for the last component of the path. */ +int +xfs_metadir_mkdir( + struct xfs_inode *dp, + const char *path, + struct xfs_inode **ipp) +{ + struct xfs_metadir_update upd = { + .dp = dp, + .path = path, + .metafile_type = XFS_METAFILE_DIR, + }; + int error; + + if (xfs_is_shutdown(dp->i_mount)) + return -EIO; + + /* Allocate a transaction to create the last directory. */ + error = xfs_metadir_start_create(&upd); + if (error) + return error; + + /* Create the subdirectory and take our reference. */ + error = xfs_metadir_create(&upd, S_IFDIR); + if (error) + goto out_cancel; + + error = xfs_metadir_commit(&upd); + if (error) + goto out_irele; + + xfs_finish_inode_setup(upd.ip); + *ipp = upd.ip; + return 0; + +out_cancel: + xfs_metadir_cancel(&upd, error); +out_irele: + /* Have to finish setting up the inode to ensure it's deleted. */ + if (upd.ip) { + xfs_finish_inode_setup(upd.ip); + xfs_irele(upd.ip); + } + return error; +} diff --git a/libxfs/xfs_metadir.h b/libxfs/xfs_metadir.h new file mode 100644 index 00000000000000..bfecac7d3d1472 --- /dev/null +++ b/libxfs/xfs_metadir.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2018-2024 Oracle. All Rights Reserved. + * Author: Darrick J. Wong + */ +#ifndef __XFS_METADIR_H__ +#define __XFS_METADIR_H__ + +/* Cleanup widget for metadata inode creation and deletion. */ +struct xfs_metadir_update { + /* Parent directory */ + struct xfs_inode *dp; + + /* Path to metadata file */ + const char *path; + + /* Parent pointer update context */ + struct xfs_parent_args *ppargs; + + /* Child metadata file */ + struct xfs_inode *ip; + + struct xfs_trans *tp; + + enum xfs_metafile_type metafile_type; + + unsigned int dp_locked:1; + unsigned int ip_locked:1; +}; + +int xfs_metadir_load(struct xfs_trans *tp, struct xfs_inode *dp, + const char *path, enum xfs_metafile_type metafile_type, + struct xfs_inode **ipp); + +int xfs_metadir_start_create(struct xfs_metadir_update *upd); +int xfs_metadir_create(struct xfs_metadir_update *upd, umode_t mode); + +int xfs_metadir_start_link(struct xfs_metadir_update *upd); +int xfs_metadir_link(struct xfs_metadir_update *upd); + +int xfs_metadir_commit(struct xfs_metadir_update *upd); +void xfs_metadir_cancel(struct xfs_metadir_update *upd, int error); + +int xfs_metadir_mkdir(struct xfs_inode *dp, const char *path, + struct xfs_inode **ipp); + +#endif /* __XFS_METADIR_H__ */ diff --git a/libxfs/xfs_metafile.c b/libxfs/xfs_metafile.c new file mode 100644 index 00000000000000..3bd9493373115a --- /dev/null +++ b/libxfs/xfs_metafile.c @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2018-2024 Oracle. All Rights Reserved. + * Author: Darrick J. Wong + */ +#include "libxfs_priv.h" +#include "xfs_fs.h" +#include "xfs_shared.h" +#include "xfs_format.h" +#include "xfs_log_format.h" +#include "xfs_trans_resv.h" +#include "xfs_bit.h" +#include "xfs_sb.h" +#include "xfs_mount.h" +#include "xfs_defer.h" +#include "xfs_trans.h" +#include "xfs_metafile.h" +#include "xfs_trace.h" +#include "xfs_inode.h" + +/* Set up an inode to be recognized as a metadata directory inode. */ +void +xfs_metafile_set_iflag( + struct xfs_trans *tp, + struct xfs_inode *ip, + enum xfs_metafile_type metafile_type) +{ + VFS_I(ip)->i_mode &= ~0777; + VFS_I(ip)->i_uid = GLOBAL_ROOT_UID; + VFS_I(ip)->i_gid = GLOBAL_ROOT_GID; + if (S_ISDIR(VFS_I(ip)->i_mode)) + ip->i_diflags |= XFS_METADIR_DIFLAGS; + else + ip->i_diflags |= XFS_METAFILE_DIFLAGS; + ip->i_diflags2 &= ~XFS_DIFLAG2_DAX; + ip->i_diflags2 |= XFS_DIFLAG2_METADATA; + ip->i_metatype = metafile_type; + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); +} + +/* Clear the metadata directory inode flag. */ +void +xfs_metafile_clear_iflag( + struct xfs_trans *tp, + struct xfs_inode *ip) +{ + ASSERT(xfs_is_metadir_inode(ip)); + ASSERT(VFS_I(ip)->i_nlink == 0); + + ip->i_diflags2 &= ~XFS_DIFLAG2_METADATA; + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); +} diff --git a/libxfs/xfs_metafile.h b/libxfs/xfs_metafile.h index c66b0c51b461a8..acec400123db05 100644 --- a/libxfs/xfs_metafile.h +++ b/libxfs/xfs_metafile.h @@ -17,6 +17,10 @@ #define XFS_METADIR_DIFLAGS (XFS_METAFILE_DIFLAGS | \ XFS_DIFLAG_NOSYMLINKS) +void xfs_metafile_set_iflag(struct xfs_trans *tp, struct xfs_inode *ip, + enum xfs_metafile_type metafile_type); +void xfs_metafile_clear_iflag(struct xfs_trans *tp, struct xfs_inode *ip); + /* Code specific to kernel/userspace; must be provided externally. */ int xfs_trans_metafile_iget(struct xfs_trans *tp, xfs_ino_t ino, From patchwork Fri Dec 6 23:38:20 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: 13897973 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 332231C548E for ; Fri, 6 Dec 2024 23:38: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=1733528301; cv=none; b=RiV7pyDSNAlgJDMsgznYH7WLqdlxbm2+faBdNx+BhB+t+vRh29UKgwWBoIvfKoUL/e5TZ4ps1PVUQpe3FcbAobXFpaTw/L1xnRLDCg15xg84JGjuD5qpJLsc6ymbRVnWKq+ajU7258Qyvlq8yv46TtsETc0avmFspF7ezgLgzpI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528301; c=relaxed/simple; bh=oxjh7kBLjtEhobK1FPbM45oYdkoYPhXqz8TCDXlHHPI=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YsQJ/uggTBEiMipWVZRjuDmeM7RHyQrOHAK3WzCSZwR+yiclEh5gvhd2YVx8sK7DCSYgtseZXb8KE1iHOmXAYky5o6mYIzXSVc6WgZMgiHOVPtzfWVY0RPhD2Xp2kRdk08Z99LsfDsG8ZeBAsd+Z3nqIxC7ZWkCFbxYchkaqtpM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=G/8N++31; 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="G/8N++31" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05D3AC4CED1; Fri, 6 Dec 2024 23:38:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528301; bh=oxjh7kBLjtEhobK1FPbM45oYdkoYPhXqz8TCDXlHHPI=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=G/8N++31Gdg9U6QGpy4wTwsrb6IMd2EQxcvjRU/4l6pIY8Qhq7aEmeCFB6KvQSpYc xiPlgEt5dFQ/06DE8C+p5qnTO1gP/xcRCGXGISRF+NI1sVBEXEgn3zoP2sazLJiOAp c/4SQfErpGRpUYiPiYAE/mcmv5fz/DsMYijIXGyVYBCf+6Ua56dAqy1PaFYlxcIXzi S2UtTwNwBVWSRJ0ZidhDbenvNMbNZVS9kuObfLRB52+WUvVS3tADkPQMRXn9ZT+w08 P/j9t9TtPUiOt5gesiF0/fz6hNz4GOCPKTZDFfIWzGCkD87NIhm/gxtQm5+FG+h6uG Qv4jRzQMCWR6Q== Date: Fri, 06 Dec 2024 15:38:20 -0800 Subject: [PATCH 31/36] xfs: disable the agi rotor for metadata inodes From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747349.121772.12239653896060824999.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.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 Source kernel commit: 8651b410ae781cc607159c51dbb0b317b23543b1 Ideally, we'd put all the metadata inodes in one place if we could, so that the metadata all stay reasonably close together instead of spreading out over the disk. Furthermore, if the log is internal we'd probably prefer to keep the metadata near the log. Therefore, disable AGI rotoring for metadata inode allocations. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/xfs_ialloc.c | 58 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 055eff477faceb..2575447f92dfbb 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -1836,6 +1836,40 @@ xfs_dialloc_try_ag( return error; } +/* + * Pick an AG for the new inode. + * + * Directories, symlinks, and regular files frequently allocate at least one + * block, so factor that potential expansion when we examine whether an AG has + * enough space for file creation. Try to keep metadata files all in the same + * AG. + */ +static inline xfs_agnumber_t +xfs_dialloc_pick_ag( + struct xfs_mount *mp, + struct xfs_inode *dp, + umode_t mode) +{ + xfs_agnumber_t start_agno; + + if (!dp) + return 0; + if (xfs_is_metadir_inode(dp)) { + if (mp->m_sb.sb_logstart) + return XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart); + return 0; + } + + if (S_ISDIR(mode)) + return (atomic_inc_return(&mp->m_agirotor) - 1) % mp->m_maxagi; + + start_agno = XFS_INO_TO_AGNO(mp, dp->i_ino); + if (start_agno >= mp->m_maxagi) + start_agno = 0; + + return start_agno; +} + /* * Allocate an on-disk inode. * @@ -1851,31 +1885,19 @@ xfs_dialloc( xfs_ino_t *new_ino) { struct xfs_mount *mp = (*tpp)->t_mountp; + struct xfs_perag *pag; + struct xfs_ino_geometry *igeo = M_IGEO(mp); + xfs_ino_t ino = NULLFSINO; xfs_ino_t parent = args->pip ? args->pip->i_ino : 0; - umode_t mode = args->mode & S_IFMT; xfs_agnumber_t agno; - int error = 0; xfs_agnumber_t start_agno; - struct xfs_perag *pag; - struct xfs_ino_geometry *igeo = M_IGEO(mp); + umode_t mode = args->mode & S_IFMT; bool ok_alloc = true; bool low_space = false; int flags; - xfs_ino_t ino = NULLFSINO; + int error = 0; - /* - * Directories, symlinks, and regular files frequently allocate at least - * one block, so factor that potential expansion when we examine whether - * an AG has enough space for file creation. - */ - if (S_ISDIR(mode)) - start_agno = (atomic_inc_return(&mp->m_agirotor) - 1) % - mp->m_maxagi; - else { - start_agno = XFS_INO_TO_AGNO(mp, parent); - if (start_agno >= mp->m_maxagi) - start_agno = 0; - } + start_agno = xfs_dialloc_pick_ag(mp, args->pip, mode); /* * If we have already hit the ceiling of inode blocks then clear From patchwork Fri Dec 6 23:38:36 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: 13897974 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 C7F4A1C548E for ; Fri, 6 Dec 2024 23:38:36 +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=1733528316; cv=none; b=epLbVgfYvRCzSFOPYHrWURhh6RBjHolHTTXwFrV0iEMmQm9bQjCA15foWv5plQVimKoL68393DSLz9wOUGzIZxIajRadl5dm/L8b9G8o82IfX+NdU0R32BVVuVvsusxKcZp2PFj5ms0QkIS83SXoOAazRgWaXf2F0qItYA6ZFdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528316; c=relaxed/simple; bh=dIwngUAllLCIFo9fuvFGhs/Z4uqBhX4bjwnojaYl6aQ=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bLu6BM0+gU1jigCmcYIOVJJRmgaGBuw94LMh4PL0tvgCIPipcrABrNz9U93O3XSQ0S4VgiJ5atiJGEQF4z2l8BjZui3svUZX5mTKbM6TQYO9Qh0xE0Ode/iK3v4L07+PnCzyC8HAQay/0ZD63B1WQizW0ARcR/iy4tlZisw98V8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nzACcqBC; 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="nzACcqBC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DB8FC4CED1; Fri, 6 Dec 2024 23:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528316; bh=dIwngUAllLCIFo9fuvFGhs/Z4uqBhX4bjwnojaYl6aQ=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=nzACcqBCwLet8VXSDFMUVYChSh3ALTQFLNdDrlYeZbsmaI5264iNOIzov8vwEw8Sz g9y4fzRY/oVTquLFg2nbqN9YdF4WPhM8/6aoPH6qR4yDBh+XgIfqSJ2FWtjoosaFYW Iy73RAU9zVBhe/HIl4k6EsyNtwv7WUS2/Xzw1K2VZj2mAmJmTlDK1ujF5hrRb1PbRg d3DZhCW0BaM/dL4tVc4483OJKLqYkNqPMB2UaXu0ND+cmNy+6mbrUcse8AcS6hftBD wTFy1DPOY/su1tQ9bzG6O9VPq3/QOFmqj3xERLZuErjTSwhJMWg89GqOwJKgApdqs5 GsqNzatiG+oXA== Date: Fri, 06 Dec 2024 15:38:36 -0800 Subject: [PATCH 32/36] xfs: advertise metadata directory feature From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747365.121772.15504972794584218787.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.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 Source kernel commit: 688828d8f8cdf8b1b917de938a1ce86a93fdbba9 Advertise the existence of the metadata directory feature; this will be used by scrub to decide if it needs to scan the metadir too. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/xfs_fs.h | 1 + libxfs/xfs_sb.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h index 860284064c5aa9..a42c1a33691c0f 100644 --- a/libxfs/xfs_fs.h +++ b/libxfs/xfs_fs.h @@ -242,6 +242,7 @@ typedef struct xfs_fsop_resblks { #define XFS_FSOP_GEOM_FLAGS_NREXT64 (1 << 23) /* large extent counters */ #define XFS_FSOP_GEOM_FLAGS_EXCHANGE_RANGE (1 << 24) /* exchange range */ #define XFS_FSOP_GEOM_FLAGS_PARENT (1 << 25) /* linux parent pointers */ +#define XFS_FSOP_GEOM_FLAGS_METADIR (1 << 26) /* metadata directories */ /* * Minimum and maximum sizes need for growth checks. diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index de12edd8192e1c..4ca57d592be8fa 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -1306,6 +1306,8 @@ xfs_fs_geometry( geo->flags |= XFS_FSOP_GEOM_FLAGS_NREXT64; if (xfs_has_exchange_range(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_EXCHANGE_RANGE; + if (xfs_has_metadir(mp)) + geo->flags |= XFS_FSOP_GEOM_FLAGS_METADIR; geo->rtsectsize = sbp->sb_blocksize; geo->dirblocksize = xfs_dir2_dirblock_bytes(sbp); From patchwork Fri Dec 6 23:38:52 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: 13897975 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 09D0721506D for ; Fri, 6 Dec 2024 23:38:52 +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=1733528333; cv=none; b=cbP/FDIpvL0L0swltPeW1Gj14DQX3fFHuUyCLEbi/d1Yqk0xTGd0IgQ6phQFPbqIFzXZ2Z9k9/ydAJsAMc56CUW9ReOzO9NCIZC9G2Gb6t/LCvQnr+kt5/Y2dUNSd18nYwv3xmJGiQdvDqv6LvErJMFr7h7fFr//4IRRD+4i75I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528333; c=relaxed/simple; bh=dE/gX7IIpQslD7Lf/wffy5xYW2sN7a4gHVTSELyN468=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=us6TqFR/ONkEbjCTqoURy0NIBISn3NxqVyNyJyTIW6SyszsFqjzo6Hnjhs/xxrsvzPen6dKuFdF9QCaPAsGf8BRGynO8u0CYwAsaCGEtNkFBhaQYy0LKndzgeqqoLkDr3XNd7XFLMl48vDsOiZk6D8ab2Phw82VtzHRTSv2XbS4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Qw6eERvN; 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="Qw6eERvN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70AD0C4CEDF; Fri, 6 Dec 2024 23:38:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528332; bh=dE/gX7IIpQslD7Lf/wffy5xYW2sN7a4gHVTSELyN468=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Qw6eERvNLAXoBvo0qo+9sv1H6sfISysYQuchNtlv08Df/TfqxWVIbbuvA0LhRAhmG TrYcPINmsMGtu5uEJrnrgoFGzOTyjUcK6x3zyFQW2hR/oNVUjTqkiBVBJSDflpPlZo sOq7I+MJxb/QsgfazWWoBJw3ziA6zlO5X6KBm9CJzYOj7nAkC/CZ9xYy+Rqc28eBds X3pIrqifvLWcnZA0c232/w3hsturjpjJYaZL8BvBuCaZYlpY9ieeuKsqEamBlrbD8J HsgxxiceuNAL1fEbXe+BJn1sevfLtEkjPE9/dMUSvnx6lwiQ34D/In06QdyOuabm33 ZkOpQz2c9R/FA== Date: Fri, 06 Dec 2024 15:38:52 -0800 Subject: [PATCH 33/36] xfs: allow bulkstat to return metadata directories From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747380.121772.12137566266343094869.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.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 Source kernel commit: df866c538ff098baa210b407b822818a415a6e7e Allow the V5 bulkstat ioctl to return information about metadata directory files so that xfs_scrub can find and scrub them, since they are otherwise ordinary directories. (Metadata files of course require per-file scrub code and hence do not need exposure.) Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/xfs_fs.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h index a42c1a33691c0f..499bea4ea8067f 100644 --- a/libxfs/xfs_fs.h +++ b/libxfs/xfs_fs.h @@ -490,9 +490,17 @@ struct xfs_bulk_ireq { */ #define XFS_BULK_IREQ_NREXT64 (1U << 2) +/* + * Allow bulkstat to return information about metadata directories. This + * enables xfs_scrub to find them for scanning, as they are otherwise ordinary + * directories. + */ +#define XFS_BULK_IREQ_METADIR (1U << 3) + #define XFS_BULK_IREQ_FLAGS_ALL (XFS_BULK_IREQ_AGNO | \ XFS_BULK_IREQ_SPECIAL | \ - XFS_BULK_IREQ_NREXT64) + XFS_BULK_IREQ_NREXT64 | \ + XFS_BULK_IREQ_METADIR) /* Operate on the root directory inode. */ #define XFS_BULK_IREQ_SPECIAL_ROOT (1) From patchwork Fri Dec 6 23:39:07 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: 13897984 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 967F1213E97 for ; Fri, 6 Dec 2024 23:39:08 +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=1733528348; cv=none; b=u9++nuUA+5BspTns87BRmvMY48mo05WSn0T+PgkV4iXzCxsqPMvu0W0kKGXko+fDmFmYvYg1sWf2QpCxKePIbINBuRGc+namxhp5zAHFyXud1+kSt4ZPIMeTAVkmYcbfW7Mf42xtqaqjXKcAPntodlQhMGOgrsNPidkEV4xqzYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528348; c=relaxed/simple; bh=f1H0S3LmJiS7L2YE6t0iHQa9jIj5Qqej1nlZUUaehSQ=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Yetj/YSjwadkNoLfz4fTjAPOfyJ3DBof0WBvQcZWvJTxNFPvKmf3TG0QAqk0HgC337Gy/WS8ZxsByZuglpVqntA8ajEUN6PGgxgptrfHxrsLiKz4RhNpwVnpwzLzFxUPLNx6o5l29+4ltCtDCXigzVoNLJiBKsBZMM77fBxKVWo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dOjARFYT; 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="dOjARFYT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21B84C4CED1; Fri, 6 Dec 2024 23:39:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528348; bh=f1H0S3LmJiS7L2YE6t0iHQa9jIj5Qqej1nlZUUaehSQ=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=dOjARFYTgZVKv/bTssnQ4SK4xtmBI9ggmBpx/ZsWuWFj4pJ0Av4d3TOEzVuKSJsSj WbvQzOpqshyAHHUSmioD0dOdG8vcXPlxg+5SUiIPma3CK1slO3D9BEk2ijcuA7P8uO 4YT8GZtaECQycnf19yYLoPwclYMMxM0+UH2jR0O/ZDqiPxduIAK0jHhcGCogyLiiVx 7fWu57PSCo12JeYdwhcuw46bWUuaO4CPWEO4EXUiBMXe0slkzDA5AsOLH4WbN/i8BS FCGQkj/kDPYti3j/wDXpwZcEwornfabq/hf2zt47hJqwHjJ7lY6muq4nk6O+GEFpZc ebMAdYpRXc9zQ== Date: Fri, 06 Dec 2024 15:39:07 -0800 Subject: [PATCH 34/36] xfs: adjust xfs_bmap_add_attrfork for metadir From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747396.121772.4712174044501346925.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.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 Source kernel commit: 61b6bdb30a4bee1f3417081aedfe9e346538f897 Online repair might use the xfs_bmap_add_attrfork to repair a file in the metadata directory tree if (say) the metadata file lacks the correct parent pointers. In that case, it is not correct to check that the file is dqattached -- metadata files must be not have /any/ dquot attached at all. Adjust the assertions appropriately. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/xfs_attr.c | 5 ++++- libxfs/xfs_bmap.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 150aaddf7f9fed..7567014abbe7f0 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1003,7 +1003,10 @@ xfs_attr_add_fork( unsigned int blks; /* space reservation */ int error; /* error return value */ - ASSERT(!XFS_NOT_DQATTACHED(mp, ip)); + if (xfs_is_metadir_inode(ip)) + ASSERT(XFS_IS_DQDETACHED(ip)); + else + ASSERT(!XFS_NOT_DQATTACHED(mp, ip)); blks = XFS_ADDAFORK_SPACE_RES(mp); diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 13cd4faa492838..99d53f9383a49a 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -1036,7 +1036,10 @@ xfs_bmap_add_attrfork( int error; /* error return value */ xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); - ASSERT(!XFS_NOT_DQATTACHED(mp, ip)); + if (xfs_is_metadir_inode(ip)) + ASSERT(XFS_IS_DQDETACHED(ip)); + else + ASSERT(!XFS_NOT_DQATTACHED(mp, ip)); ASSERT(!xfs_inode_has_attr_fork(ip)); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); From patchwork Fri Dec 6 23:39:23 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: 13897985 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 35367206279 for ; Fri, 6 Dec 2024 23:39:23 +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=1733528364; cv=none; b=kCssQlY+qm8GNNpl87Qwp0dnYAmSvDg7Q+3fACyBJ/P/2cAPPH9lqUYN1ovrndRkwFrEal0aH9N6V+JI5rgQZ/qVt0jRimOxwxDTwptVtRRrqACpW56P2+X8Og3L2a6E5mwXVJ8vXKAhy1kAZ3EaGkjrEZ3cwZ9SNwNbo2RFWk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528364; c=relaxed/simple; bh=8GziOFrpJtbtbGbmS4wIvJOHzjFxAwwKRHrXlIc7FNw=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ib66CdxRUWXRtZsX/jpAFe0Jny8jibdPoNA4PH65sm5DA3gzKA870pWDCaMC9EAqlpxmbT8HI8ErI+UOyiCh0wSmwNX4sJ6z5tCpY9v5Dm+Lr4gHlRGYybX14WBORSwDrxJVOJNVfR75/pUGMu1E4pEVdD0oe5+hyvlZyKy9BNw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QDt0Kq6s; 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="QDt0Kq6s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B000CC4CED1; Fri, 6 Dec 2024 23:39:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528363; bh=8GziOFrpJtbtbGbmS4wIvJOHzjFxAwwKRHrXlIc7FNw=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=QDt0Kq6sc71of09ojYX8pCUuR87wuNSZTtqXwV/GaajHMCS+LchTTwsOZaOYIRhAR AXMXynquhMQs9UA/TaHfNotYNZqdrmkbnlRQxJYD2TL8F8uuLq8EAoxEmQM0MC61R4 +SZ3xUzaWcQ8c5pTggkqMofcNJcFCpP6pt6rLHjjPmWf4pj4B7sSkqBoJ3QlI7QItL JFNdNr2X46U10XXaFl048Iqh/oWtOdexhs4ErKaZVPGaXGGnbDpPZm4UDm6tWfdQrW mMCrqtif3IhdJEptMCHJ7mA8Uz9limVDpNhLpVaFL4BjjdbqEixfMB8yqfYsU81ncW nsCe52uYbNNXQ== Date: Fri, 06 Dec 2024 15:39:23 -0800 Subject: [PATCH 35/36] xfs: record health problems with the metadata directory From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747410.121772.11231744611869127789.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.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 Source kernel commit: be42fc1393d66024eb6415c92f45fab5d1878c3e Make a report to the health monitoring subsystem any time we encounter something in the metadata directory tree that looks like corruption. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/xfs_fs.h | 1 + libxfs/xfs_health.h | 4 +++- libxfs/xfs_metadir.c | 13 ++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h index 499bea4ea8067f..b05e6fb1470351 100644 --- a/libxfs/xfs_fs.h +++ b/libxfs/xfs_fs.h @@ -198,6 +198,7 @@ struct xfs_fsop_geom { #define XFS_FSOP_GEOM_SICK_RT_SUMMARY (1 << 5) /* realtime summary */ #define XFS_FSOP_GEOM_SICK_QUOTACHECK (1 << 6) /* quota counts */ #define XFS_FSOP_GEOM_SICK_NLINKS (1 << 7) /* inode link counts */ +#define XFS_FSOP_GEOM_SICK_METADIR (1 << 8) /* metadata directory */ /* Output for XFS_FS_COUNTS */ typedef struct xfs_fsop_counts { diff --git a/libxfs/xfs_health.h b/libxfs/xfs_health.h index 13301420a2f670..f90e8dfc050000 100644 --- a/libxfs/xfs_health.h +++ b/libxfs/xfs_health.h @@ -62,6 +62,7 @@ struct xfs_da_args; #define XFS_SICK_FS_PQUOTA (1 << 3) /* project quota */ #define XFS_SICK_FS_QUOTACHECK (1 << 4) /* quota counts */ #define XFS_SICK_FS_NLINKS (1 << 5) /* inode link counts */ +#define XFS_SICK_FS_METADIR (1 << 6) /* metadata directory tree */ /* Observable health issues for realtime volume metadata. */ #define XFS_SICK_RT_BITMAP (1 << 0) /* realtime bitmap */ @@ -105,7 +106,8 @@ struct xfs_da_args; XFS_SICK_FS_GQUOTA | \ XFS_SICK_FS_PQUOTA | \ XFS_SICK_FS_QUOTACHECK | \ - XFS_SICK_FS_NLINKS) + XFS_SICK_FS_NLINKS | \ + XFS_SICK_FS_METADIR) #define XFS_SICK_RT_PRIMARY (XFS_SICK_RT_BITMAP | \ XFS_SICK_RT_SUMMARY) diff --git a/libxfs/xfs_metadir.c b/libxfs/xfs_metadir.c index b52abf12d20511..b5f05925e73a4e 100644 --- a/libxfs/xfs_metadir.c +++ b/libxfs/xfs_metadir.c @@ -27,6 +27,7 @@ #include "xfs_dir2.h" #include "xfs_dir2_priv.h" #include "xfs_parent.h" +#include "xfs_health.h" /* * Metadata Directory Tree @@ -93,8 +94,10 @@ xfs_metadir_lookup( }; int error; - if (!S_ISDIR(VFS_I(dp)->i_mode)) + if (!S_ISDIR(VFS_I(dp)->i_mode)) { + xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR); return -EFSCORRUPTED; + } if (xfs_is_shutdown(mp)) return -EIO; @@ -102,10 +105,14 @@ xfs_metadir_lookup( if (error) return error; - if (!xfs_verify_ino(mp, args.inumber)) + if (!xfs_verify_ino(mp, args.inumber)) { + xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR); return -EFSCORRUPTED; - if (xname->type != XFS_DIR3_FT_UNKNOWN && xname->type != args.filetype) + } + if (xname->type != XFS_DIR3_FT_UNKNOWN && xname->type != args.filetype) { + xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR); return -EFSCORRUPTED; + } trace_xfs_metadir_lookup(dp, xname, args.inumber); *ino = args.inumber; From patchwork Fri Dec 6 23:39: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: 13897986 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 DA20B1FA172 for ; Fri, 6 Dec 2024 23:39:39 +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=1733528379; cv=none; b=Tc6OGNsOKpIt+68e675KYbHVa1XZ287wlTU2hJhJquk5nL8WFHLzZIBbxlHMdo9PAfOEg/tpSZKcIcvvmGf9bJrd2LcOyUyUNZflS6c6+UN7CDuNbKUEB6A+7pnOgMOzqrQLWoH8DXp4VjErC2Y2SJFnEjAZiV34Aw9dwWjDANk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733528379; c=relaxed/simple; bh=XYEdP597n1D74NX5g9WtpTlQGZCdmx8TmnMroa+Dd9I=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J/sgb9ImngEjlx4qVKekN8ppKqyZD0y5zAnbUGQAjZZZBt0Lc7PxbJCemfkEj6SYuI2LDemVEhbhZ9jGbGTCMeTjVv3zn4RlhBRmTuKMvF02efA64sW6hho3C2PW8wrWxUbuy5ieSij9RlBwOJ7v+XRm5EDoaPLRm/Vy/wxcDVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pE3pxqy8; 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="pE3pxqy8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5815AC4CED1; Fri, 6 Dec 2024 23:39:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733528379; bh=XYEdP597n1D74NX5g9WtpTlQGZCdmx8TmnMroa+Dd9I=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=pE3pxqy8H6VXFEx1Ig5xzmxKKaotm7wJdMqlA1MjXdL0COqE+HqYck3UEla54jT6g 8mbKXv0aVYr1ZaL5h8lZwHbhNqxTs5XclGgnkbCivtVc0spRbkO/S2Kkozapl+lsVL fzlYCFKvO7T0j/EwnBM2ournkvntf/loD8wMbAAc1bkkrR7X2TXZ8uIY0B4M+yK2GA AltfgbtQV3aM/IGM9M0qmQMPcWgfAn9ieUJ/3ZyR7WXO6WwWn6uGON5STnTRIRU0Rn TBKKY9BEfWE2r1tr6Nyp7pH4zH3yi04qmItu6GrMyqHpX5lVWWLVE6DlDsXMLI142O 80KL18ypF3E6Q== Date: Fri, 06 Dec 2024 15:39:38 -0800 Subject: [PATCH 36/36] xfs: check metadata directory file path connectivity From: "Darrick J. Wong" To: aalbersh@kernel.org, djwong@kernel.org Cc: hch@lst.de, hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173352747425.121772.5629402600312137149.stgit@frogsfrogsfrogs> In-Reply-To: <173352746825.121772.11414387759505707402.stgit@frogsfrogsfrogs> References: <173352746825.121772.11414387759505707402.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 Source kernel commit: b3c03efa5972f084e40104307dbe432359279cf2 Create a new scrubber type that checks that well known metadata directory paths are connected to the metadata inode that the incore structures think is in use. For example, check that "/quota/user" in the metadata directory tree actually points to mp->m_quotainfo->qi_uquotaip->i_ino. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/xfs_fs.h | 13 ++++++++++++- libxfs/xfs_health.h | 4 +++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h index b05e6fb1470351..faa38a7d1eb019 100644 --- a/libxfs/xfs_fs.h +++ b/libxfs/xfs_fs.h @@ -199,6 +199,7 @@ struct xfs_fsop_geom { #define XFS_FSOP_GEOM_SICK_QUOTACHECK (1 << 6) /* quota counts */ #define XFS_FSOP_GEOM_SICK_NLINKS (1 << 7) /* inode link counts */ #define XFS_FSOP_GEOM_SICK_METADIR (1 << 8) /* metadata directory */ +#define XFS_FSOP_GEOM_SICK_METAPATH (1 << 9) /* metadir tree path */ /* Output for XFS_FS_COUNTS */ typedef struct xfs_fsop_counts { @@ -732,9 +733,10 @@ struct xfs_scrub_metadata { #define XFS_SCRUB_TYPE_NLINKS 26 /* inode link counts */ #define XFS_SCRUB_TYPE_HEALTHY 27 /* everything checked out ok */ #define XFS_SCRUB_TYPE_DIRTREE 28 /* directory tree structure */ +#define XFS_SCRUB_TYPE_METAPATH 29 /* metadata directory tree paths */ /* Number of scrub subcommands. */ -#define XFS_SCRUB_TYPE_NR 29 +#define XFS_SCRUB_TYPE_NR 30 /* * This special type code only applies to the vectored scrub implementation. @@ -812,6 +814,15 @@ struct xfs_scrub_vec_head { #define XFS_SCRUB_VEC_FLAGS_ALL (0) +/* + * i: sm_ino values for XFS_SCRUB_TYPE_METAPATH to select a metadata file for + * path checking. + */ +#define XFS_SCRUB_METAPATH_PROBE (0) /* do we have a metapath scrubber? */ + +/* Number of metapath sm_ino values */ +#define XFS_SCRUB_METAPATH_NR (1) + /* * ioctl limits */ diff --git a/libxfs/xfs_health.h b/libxfs/xfs_health.h index f90e8dfc050000..a23df94319e5fb 100644 --- a/libxfs/xfs_health.h +++ b/libxfs/xfs_health.h @@ -63,6 +63,7 @@ struct xfs_da_args; #define XFS_SICK_FS_QUOTACHECK (1 << 4) /* quota counts */ #define XFS_SICK_FS_NLINKS (1 << 5) /* inode link counts */ #define XFS_SICK_FS_METADIR (1 << 6) /* metadata directory tree */ +#define XFS_SICK_FS_METAPATH (1 << 7) /* metadata directory tree path */ /* Observable health issues for realtime volume metadata. */ #define XFS_SICK_RT_BITMAP (1 << 0) /* realtime bitmap */ @@ -107,7 +108,8 @@ struct xfs_da_args; XFS_SICK_FS_PQUOTA | \ XFS_SICK_FS_QUOTACHECK | \ XFS_SICK_FS_NLINKS | \ - XFS_SICK_FS_METADIR) + XFS_SICK_FS_METADIR | \ + XFS_SICK_FS_METAPATH) #define XFS_SICK_RT_PRIMARY (XFS_SICK_RT_BITMAP | \ XFS_SICK_RT_SUMMARY)