From mboxrd@z Thu Jan 1 00:00:00 1970 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.7 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 1573FC433DB for ; Sun, 10 Jan 2021 03:31:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E109122A99 for ; Sun, 10 Jan 2021 03:31:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726481AbhAJDbS (ORCPT ); Sat, 9 Jan 2021 22:31:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726267AbhAJDbS (ORCPT ); Sat, 9 Jan 2021 22:31:18 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B67D2C0617BB for ; Sat, 9 Jan 2021 19:30:17 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id v19so10294633pgj.12 for ; Sat, 09 Jan 2021 19:30:17 -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=9P5ZxB5U8FlibcHn25BfII6i6eHF++h7Z1D7nnaozPM=; b=Dhk5enHRxvqTgD4IeP4tezQbLNEtDg8LnpPqHfwD6VoUMR4dIaT3/6U309ftQlfgOk zfBWtkEIYwhAp84ev8q8yFe7RbtZFc/Mfuhicd/6m4wDU2U4GTqIt30jXvYec1L8FNSy MKImcMUswgUqWhqp/TCwB728lPb+F6V/TyZCAaoQs8RSDT0zR/DukfGFvFspJUrUR0Yi qMpo+hEvuOuvuFcDNUVhfPcQh0ywJU5zdgzSnhrat3EG8sR9LLXZUWNP7tgkEI8XU9Ne ggX80QKdFCOyB9oFBuZoxvf/ES9yzMxeFjpnSKoq8ASKn5xNBdKe3XjdjWKt45+JwdKd YWTQ== 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=9P5ZxB5U8FlibcHn25BfII6i6eHF++h7Z1D7nnaozPM=; b=ddm9Ec94XHhzfeK437jGX4pq6k5HkA5RcfVKba9Heo4wW2vtRYt9tko08LJhMaaWe9 0vPJOmyn9fy8azH/uO+JduWT2B9lmEQ+0xQ5MIyxj/J69j1yV6Hiu3ObLZU6HZ/lFJo+ M9sehISFwtyky3/F063LCgUsnQc8jBI1nTvCup2wU6oxlJOQhhH8YKgdqNJdCwO7uD6w FOT5YMm9RgE0YXJaR4y6WXNYicSSKbfA/BjTjqjnsfUjiGTpI1tCoU7scl4r3UC89evU IQUFYnGfSBXu8uiZk93xTk8zKm0Ez1kgkkJXBfmXQGLhOSzAhtYBUepL+91srei2lG9q Ffvg== X-Gm-Message-State: AOAM531CofRb3A0pW4VBOs5cWlmuiUjoxOuhDgokp6nCe5fW0SPOOz1X ii0V141gVJxrpctnahS3WzqkObW88D9lkQ== X-Google-Smtp-Source: ABdhPJwYg4ctbH+jk09lu47/HoTFMPiONI3kIxqDo0P5aWuviah4xP8ZMEQ6hQishd48KVXJ6gKu6Q== X-Received: by 2002:a65:430b:: with SMTP id j11mr13677050pgq.130.1610249417189; Sat, 09 Jan 2021 19:30:17 -0800 (PST) Received: from localhost.localdomain ([122.179.92.100]) by smtp.gmail.com with ESMTPSA id x6sm14079861pfq.57.2021.01.09.19.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jan 2021 19:30:16 -0800 (PST) From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , darrick.wong@oracle.com, djwong@kernel.org, hch@lst.de, allison.henderson@oracle.com Subject: [PATCH V13 15/16] xfs: Process allocated extent in a separate function Date: Sun, 10 Jan 2021 08:59:27 +0530 Message-Id: <20210110032928.3120861-16-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210110032928.3120861-1-chandanrlinux@gmail.com> References: <20210110032928.3120861-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 ff4ca6c456c3..19b5a516cb30 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; -- 2.29.2