From patchwork Tue Jan 26 06:32:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12045699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF316C433DB for ; Tue, 26 Jan 2021 06:37:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FAA722B3F for ; Tue, 26 Jan 2021 06:37:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388499AbhAZGh3 (ORCPT ); Tue, 26 Jan 2021 01:37:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731473AbhAZGgD (ORCPT ); Tue, 26 Jan 2021 01:36:03 -0500 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CC06C0617AA for ; Mon, 25 Jan 2021 22:33:28 -0800 (PST) Received: by mail-pf1-x42e.google.com with SMTP id u67so9916843pfb.3 for ; Mon, 25 Jan 2021 22:33:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YAgcMDOb0KJIXAxPprgHhIeraWJAIcFboADzdy2olkU=; b=InlrxKEzOmg1LEf4Eu/047Kugg+FnGN1gFnqbxOMUX/TX1Xv/660iVIJzBcIKAv97J lLtQZr3yvPLhwkBbH4NucC/BnzAMfGhjDBGnjOp9taKKysZg7atM9ObvckPdBhlFU75B BxtyKmLNK2TgjW9J5/L89iFjRInQB/Dm/qc+TURZyQYhayOCYaKp9M8cZJ/gGX2OHE+x gSjJC49FYRRM5FYPL6mweH7NehQAIe7WCvyhYJteWsi0f57RsxTGjZf29M9NSAduOGW4 KtsBtdP0Ql+eRAEo10/D7NtyG3FFbyi6nOcOpL3nz2SAxyr1aWa2wmIe2yyNli+6q+OM /qWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YAgcMDOb0KJIXAxPprgHhIeraWJAIcFboADzdy2olkU=; b=G2W/8uVkSUAcen9LJlqwaFlOo3yNJuzaoYMK5niHQPn5Ifrh0qr1kJ7PDtvUdncv9e zqVHYUozJGH3v0gqgY3g3H1tip5FGPAa+4W5QoKkOzT6iurL608BG/J+Rk2XS+g6JOZZ aaplDwA7nzc0tqJ0fgD/6D7rs9uLRUDhcJrvaMCsJT+fIbD3XKBW12ex5p7YJWb0gl2E K+UsLjsjDRAFsb+bjpeAxgS6KKWWYgrYuzTPaWkW+KF39mRU5L3WM5UW0Yjw1tH2oUUf unrJS2ysvH51hlzkw1VDkcSSplGbTeOKs9ETZxvvMT0E4w+IIYG6Gy6Is4sBt0kc0dAB mksg== X-Gm-Message-State: AOAM533RuD9GW7wcPHTi0Boex/EgLQqaOU/xPMwiJ0mojc+P8DzUQGru MebI1zPxGtOERuBh5DSK0CxOM2kb7Ys= X-Google-Smtp-Source: ABdhPJyAuIOryGmVZ9zqf+qkoqYDfWdFs2zpC1IzX/cO7IR0YaHkz4gFj/3AUiHC57JXw4PNL7MNdA== X-Received: by 2002:a63:4443:: with SMTP id t3mr4300102pgk.297.1611642807665; Mon, 25 Jan 2021 22:33:27 -0800 (PST) Received: from localhost.localdomain ([122.167.33.191]) by smtp.gmail.com with ESMTPSA id w21sm17296578pff.220.2021.01.25.22.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 22:33:27 -0800 (PST) From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, hch@lst.de, allison.henderson@oracle.com, "Darrick J . Wong" Subject: [PATCH V15 15/16] xfs: Process allocated extent in a separate function Date: Tue, 26 Jan 2021 12:02:31 +0530 Message-Id: <20210126063232.3648053-16-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210126063232.3648053-1-chandanrlinux@gmail.com> References: <20210126063232.3648053-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit moves over the code in xfs_bmap_btalloc() which is responsible for processing an allocated extent to a new function. Apart from xfs_bmap_btalloc(), the new function will be invoked by another function introduced in a future commit. Reviewed-by: Allison Henderson Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_bmap.c | 74 ++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index a0e8968e473d..ee2c0a4295c6 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3510,6 +3510,48 @@ xfs_bmap_compute_alignments( return stripe_align; } +static void +xfs_bmap_process_allocated_extent( + struct xfs_bmalloca *ap, + struct xfs_alloc_arg *args, + xfs_fileoff_t orig_offset, + xfs_extlen_t orig_length) +{ + int nullfb; + + nullfb = ap->tp->t_firstblock == NULLFSBLOCK; + + /* + * check the allocation happened at the same or higher AG than + * the first block that was allocated. + */ + ASSERT(nullfb || + XFS_FSB_TO_AGNO(args->mp, ap->tp->t_firstblock) <= + XFS_FSB_TO_AGNO(args->mp, args->fsbno)); + + ap->blkno = args->fsbno; + if (nullfb) + ap->tp->t_firstblock = args->fsbno; + ap->length = args->len; + /* + * If the extent size hint is active, we tried to round the + * caller's allocation request offset down to extsz and the + * length up to another extsz boundary. If we found a free + * extent we mapped it in starting at this new offset. If the + * newly mapped space isn't long enough to cover any of the + * range of offsets that was originally requested, move the + * mapping up so that we can fill as much of the caller's + * original request as possible. Free space is apparently + * very fragmented so we're unlikely to be able to satisfy the + * hints anyway. + */ + if (ap->length <= orig_length) + ap->offset = orig_offset; + else if (ap->offset + ap->length < orig_offset + orig_length) + ap->offset = orig_offset + orig_length - ap->length; + xfs_bmap_btalloc_accounting(ap, args); +} + STATIC int xfs_bmap_btalloc( struct xfs_bmalloca *ap) /* bmap alloc argument struct */ @@ -3702,36 +3744,10 @@ xfs_bmap_btalloc( return error; ap->tp->t_flags |= XFS_TRANS_LOWMODE; } + if (args.fsbno != NULLFSBLOCK) { - /* - * check the allocation happened at the same or higher AG than - * the first block that was allocated. - */ - ASSERT(ap->tp->t_firstblock == NULLFSBLOCK || - XFS_FSB_TO_AGNO(mp, ap->tp->t_firstblock) <= - XFS_FSB_TO_AGNO(mp, args.fsbno)); - - ap->blkno = args.fsbno; - if (ap->tp->t_firstblock == NULLFSBLOCK) - ap->tp->t_firstblock = args.fsbno; - ap->length = args.len; - /* - * If the extent size hint is active, we tried to round the - * caller's allocation request offset down to extsz and the - * length up to another extsz boundary. If we found a free - * extent we mapped it in starting at this new offset. If the - * newly mapped space isn't long enough to cover any of the - * range of offsets that was originally requested, move the - * mapping up so that we can fill as much of the caller's - * original request as possible. Free space is apparently - * very fragmented so we're unlikely to be able to satisfy the - * hints anyway. - */ - if (ap->length <= orig_length) - ap->offset = orig_offset; - else if (ap->offset + ap->length < orig_offset + orig_length) - ap->offset = orig_offset + orig_length - ap->length; - xfs_bmap_btalloc_accounting(ap, &args); + xfs_bmap_process_allocated_extent(ap, &args, orig_offset, + orig_length); } else { ap->blkno = NULLFSBLOCK; ap->length = 0;