From patchwork Mon Oct 21 22:07: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: 13844771 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 ABCD41E2839 for ; Mon, 21 Oct 2024 22:07:48 +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=1729548468; cv=none; b=IpAVVF0mDyuqc4A4LE9YUmtSlCDyzTih1vwchzSN+UK1MQY9AqfEgHxrQ+5ojlxpSBq6U29JAduHQe3Og51kCwNA9gf/4IMXt9tF3OvmF9bxkFM6R+1wBh5vJwqGogyba3//z6kjO3aPPlgbsUshhbm2R9AQSRf6w6rPrFqQpLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729548468; c=relaxed/simple; bh=i6gmFKAHib8GzGEajsTQd9oJCZtEooSS4SIJarCB+vQ=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LUO6rhgi60ugPJSzGyTAxtWWji8FAIHRWIXQcp4564osru43cyDZ4fB26WzWm/8pOi0xNPYZXxoyGXCSsPvH8W+8OuMGrZGlbQH+t1fyK5GG3W9lAmyF6WxvyX8yaeHVg+RB8YMlLnkM+3OZq7Z6XjcoKTQMi0NsxBfe/UL2T5M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=G6U0v6RH; 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="G6U0v6RH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E021C4CEE4; Mon, 21 Oct 2024 22:07:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729548468; bh=i6gmFKAHib8GzGEajsTQd9oJCZtEooSS4SIJarCB+vQ=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=G6U0v6RHxdnt5qaOHtLq9F2sslLy/jaPRrk1a+jVZQKtyFWBeI98EMyACqig32oNQ psW/lzMKn3SXkbr8wJbNQ1VcTm99lsHJgZnBGiy8g5j1UqG1ZMUBMZqMw+DPOy1x0t x6WRNSfbsBzuSRBDYsktOIsdO2Rw1jVGB32sALCvWkxBpTjz4N1L1zBbfyOh7zrC5Q HA+tM/C2U1F+NV8UA2RQIqGz5x5MNuE8dKsPkTpNGT4+JkaK7HJUFvXT7SlWHwX38f Zre2aGJwkBHo2skSrd6cXzC0W6pkkzxEo87QmrnfUgNFHrQsc0iXBl78AKtfsDOBpT /OK8R0TkA5Xzw== Date: Mon, 21 Oct 2024 15:07:47 -0700 Subject: [PATCH 34/37] xfs: fold xfs_bmap_alloc_userdata into xfs_bmapi_allocate From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org, aalbersh@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <172954783985.34558.1097911190499766488.stgit@frogsfrogsfrogs> In-Reply-To: <172954783428.34558.6301509765231998083.stgit@frogsfrogsfrogs> References: <172954783428.34558.6301509765231998083.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: 865469cd41bce2b04bef9539cbf70676878bc8df Userdata and metadata allocations end up in the same allocation helpers. Remove the separate xfs_bmap_alloc_userdata function to make this more clear. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Carlos Maiolino --- libxfs/xfs_bmap.c | 73 ++++++++++++++++++++--------------------------------- 1 file changed, 28 insertions(+), 45 deletions(-) diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index c014325a5d7d9c..af493836ecc7ea 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -4170,43 +4170,6 @@ xfs_bmapi_reserve_delalloc( return error; } -static int -xfs_bmap_alloc_userdata( - struct xfs_bmalloca *bma) -{ - struct xfs_mount *mp = bma->ip->i_mount; - int whichfork = xfs_bmapi_whichfork(bma->flags); - int error; - - /* - * Set the data type being allocated. For the data fork, the first data - * in the file is treated differently to all other allocations. For the - * attribute fork, we only need to ensure the allocated range is not on - * the busy list. - */ - bma->datatype = XFS_ALLOC_NOBUSY; - if (whichfork == XFS_DATA_FORK || whichfork == XFS_COW_FORK) { - bma->datatype |= XFS_ALLOC_USERDATA; - if (bma->offset == 0) - bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA; - - if (mp->m_dalign && bma->length >= mp->m_dalign) { - error = xfs_bmap_isaeof(bma, whichfork); - if (error) - return error; - } - - if (XFS_IS_REALTIME_INODE(bma->ip)) - return xfs_bmap_rtalloc(bma); - } - - if (unlikely(XFS_TEST_ERROR(false, mp, - XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT))) - return xfs_bmap_exact_minlen_extent_alloc(bma); - - return xfs_bmap_btalloc(bma); -} - static int xfs_bmapi_allocate( struct xfs_bmalloca *bma) @@ -4224,15 +4187,35 @@ xfs_bmapi_allocate( else bma->minlen = 1; - if (bma->flags & XFS_BMAPI_METADATA) { - if (unlikely(XFS_TEST_ERROR(false, mp, - XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT))) - error = xfs_bmap_exact_minlen_extent_alloc(bma); - else - error = xfs_bmap_btalloc(bma); - } else { - error = xfs_bmap_alloc_userdata(bma); + if (!(bma->flags & XFS_BMAPI_METADATA)) { + /* + * For the data and COW fork, the first data in the file is + * treated differently to all other allocations. For the + * attribute fork, we only need to ensure the allocated range + * is not on the busy list. + */ + bma->datatype = XFS_ALLOC_NOBUSY; + if (whichfork == XFS_DATA_FORK || whichfork == XFS_COW_FORK) { + bma->datatype |= XFS_ALLOC_USERDATA; + if (bma->offset == 0) + bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA; + + if (mp->m_dalign && bma->length >= mp->m_dalign) { + error = xfs_bmap_isaeof(bma, whichfork); + if (error) + return error; + } + } } + + if ((bma->datatype & XFS_ALLOC_USERDATA) && + XFS_IS_REALTIME_INODE(bma->ip)) + error = xfs_bmap_rtalloc(bma); + else if (unlikely(XFS_TEST_ERROR(false, mp, + XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT))) + error = xfs_bmap_exact_minlen_extent_alloc(bma); + else + error = xfs_bmap_btalloc(bma); if (error) return error; if (bma->blkno == NULLFSBLOCK)