From patchwork Thu Oct 31 23:18: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: 13858462 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 79B231E1A37 for ; Thu, 31 Oct 2024 23:18: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=1730416685; cv=none; b=Ki4Cuz6Xv2RMzOT8LydNoiUDCUoh4vIcIcZpW0aOoHU9cJEuGlryt0XlkMLN8LCoU5d3sO0/Ploj6l/dZb+G9zCjrpF+LV1ADlxyEyW6gkAWiYWSeiJcOD8qhtrJvnVdBgOlUmWSW9VkrqWcilnAFUVQcf2dGrrgKmd0Dt/9444= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730416685; c=relaxed/simple; bh=gljjXFH81UV8Kku1UmvWTGlfcPv4duH1tPlozJDvJC4=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kzhoDYYK007+GXnqKmWYTahQMKaIK3f1rWNcquXblDmtsMotRX0Kwoswj0MjuXobcokIA56Tg99i0fD540LMqe6AokelugQZB0yWA60hJ5vs12wYNYVOGUNjo6PcalW6FRROIcA41axCQCcYcdzMzBgCl/euzlRNg9jjdqtWMWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ciDgH8UK; 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="ciDgH8UK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C19BC4CEC3; Thu, 31 Oct 2024 23:18:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730416685; bh=gljjXFH81UV8Kku1UmvWTGlfcPv4duH1tPlozJDvJC4=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ciDgH8UKDJ6Qgp0Vl5psVvIXFoP0ozJX1hYZRhlqMinlOy+2Vg8TB/g6YHe2sYtVy bzcK97uDz4fwdhWAM2l8cC9INqEGo8SWjKtwgXLAzZgRaE9EgtvBWxbPuUJUXaxdfe EqXES/3EqNQia7Sn2O9JZGWhpqdJfi/6bhYGx79ULl6i9l0GIC7y0W0Iqer4WbWck4 o9K6eYL3qPt03udhSlJhjCH7ccGPEAXTaWy9ro4JB/zwCa2S8guqiq/+8IKfmrVQOk pMDyNOxBgLsS3BugQuuQjs4QUGx+WDvMyON4uRipwlhSKXztbjUQNpM51WNGwGuZIx 2sxWWaLSc9NpA== Date: Thu, 31 Oct 2024 16:18:04 -0700 Subject: [PATCH 36/41] xfs: call xfs_bmap_exact_minlen_extent_alloc from xfs_bmap_btalloc From: "Darrick J. Wong" To: djwong@kernel.org, aalbersh@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <173041566467.962545.14625825074524844035.stgit@frogsfrogsfrogs> In-Reply-To: <173041565874.962545.15559186670255081566.stgit@frogsfrogsfrogs> References: <173041565874.962545.15559186670255081566.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: 405ee87c6938f67e6ab62a3f8f85b3c60a093886 xfs_bmap_exact_minlen_extent_alloc duplicates the args setup in xfs_bmap_btalloc. Switch to call it from xfs_bmap_btalloc after doing the basic setup. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Carlos Maiolino --- libxfs/xfs_bmap.c | 61 +++++++++++------------------------------------------ 1 file changed, 13 insertions(+), 48 deletions(-) diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 3c4922424f3fd0..02f26854c53cfe 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -3473,28 +3473,17 @@ xfs_bmap_process_allocated_extent( static int xfs_bmap_exact_minlen_extent_alloc( - struct xfs_bmalloca *ap) + struct xfs_bmalloca *ap, + struct xfs_alloc_arg *args) { - struct xfs_mount *mp = ap->ip->i_mount; - struct xfs_alloc_arg args = { .tp = ap->tp, .mp = mp }; - xfs_fileoff_t orig_offset; - xfs_extlen_t orig_length; - int error; - - ASSERT(ap->length); - if (ap->minlen != 1) { - ap->blkno = NULLFSBLOCK; - ap->length = 0; + args->fsbno = NULLFSBLOCK; return 0; } - orig_offset = ap->offset; - orig_length = ap->length; - - args.alloc_minlen_only = 1; - - xfs_bmap_compute_alignments(ap, &args); + args->alloc_minlen_only = 1; + args->minlen = args->maxlen = ap->minlen; + args->total = ap->total; /* * Unlike the longest extent available in an AG, we don't track @@ -3504,33 +3493,9 @@ xfs_bmap_exact_minlen_extent_alloc( * we need not be concerned about a drop in performance in * "debug only" code paths. */ - ap->blkno = XFS_AGB_TO_FSB(mp, 0, 0); + ap->blkno = XFS_AGB_TO_FSB(ap->ip->i_mount, 0, 0); - args.oinfo = XFS_RMAP_OINFO_SKIP_UPDATE; - args.minlen = args.maxlen = ap->minlen; - args.total = ap->total; - - args.alignment = 1; - args.minalignslop = 0; - - args.minleft = ap->minleft; - args.wasdel = ap->wasdel; - args.resv = XFS_AG_RESV_NONE; - args.datatype = ap->datatype; - - error = xfs_alloc_vextent_first_ag(&args, ap->blkno); - if (error) - return error; - - if (args.fsbno != NULLFSBLOCK) { - xfs_bmap_process_allocated_extent(ap, &args, orig_offset, - orig_length); - } else { - ap->blkno = NULLFSBLOCK; - ap->length = 0; - } - - return 0; + return xfs_alloc_vextent_first_ag(args, ap->blkno); } /* @@ -3789,8 +3754,11 @@ xfs_bmap_btalloc( /* Trim the allocation back to the maximum an AG can fit. */ args.maxlen = min(ap->length, mp->m_ag_max_usable); - if ((ap->datatype & XFS_ALLOC_USERDATA) && - xfs_inode_is_filestream(ap->ip)) + if (unlikely(XFS_TEST_ERROR(false, mp, + XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT))) + error = xfs_bmap_exact_minlen_extent_alloc(ap, &args); + else if ((ap->datatype & XFS_ALLOC_USERDATA) && + xfs_inode_is_filestream(ap->ip)) error = xfs_bmap_btalloc_filestreams(ap, &args, stripe_align); else error = xfs_bmap_btalloc_best_length(ap, &args, stripe_align); @@ -4205,9 +4173,6 @@ xfs_bmapi_allocate( 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)