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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 980DEC55178 for ; Thu, 29 Oct 2020 10:15:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26C7A20791 for ; Thu, 29 Oct 2020 10:15:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BkdUv33z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726345AbgJ2KPE (ORCPT ); Thu, 29 Oct 2020 06:15:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726076AbgJ2KPE (ORCPT ); Thu, 29 Oct 2020 06:15:04 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77EEBC0613D2 for ; Thu, 29 Oct 2020 03:15:04 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id y14so1921107pfp.13 for ; Thu, 29 Oct 2020 03:15:04 -0700 (PDT) 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=KLF4cb64GJbiHT8LOjTkxd0TAULr04LwRnmVPjbD1QY=; b=BkdUv33zmtByv67Y9Fw5wm4sDaT53AZyfUGh8qWN8v4W3etbEorE7dZULVZN9sxKJJ MgtbiZ2T2V/EDYVodu+JoV2TmFyGmxp6vIl84YyZ1LCKmCEyV6/4/93oAjlrKFm5MnVQ VUWHD/1Bu0d6kG9hRsemXYxanGcbG2UBEEn+7/1EMfinFPBziMPJLxHB3Y6Qbu5l6B5k EoD7mhpR5Oq4iFYCiOdjLPKSCFXK/6YYC+4W/n/9wIdk14bh5E5Fzuu7TywAZvKJMO/3 wPW/OQN3ZwSfnwc0VKIVgP81E/1cWi654FJZlI1qZUVi6eW8TALyeH8A7pbqSHB1Em3F RIRw== 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=KLF4cb64GJbiHT8LOjTkxd0TAULr04LwRnmVPjbD1QY=; b=pZoSaH6Izx12RPn8JhgfJyFzqaMUMjfDQtoHcJ3wfnZHAyABjR9nqkOHXDLG/nydsr NOScQAbn/dk4cIRz0JYvCimYsAkJMZT9NfZUEdGpQq86ygwBAfOaO3jNpTf2YG7JUxyY 4YNleBKF2K3I41O7muUcWVHQpKFMbTD/RU//TjfOx73f2lO7gN7orE5MKs+mc9Is+lUB T5poAARJyicONalS9TgYh2i+kD1VM+0o8Araa8oAmKnuIgmk76qWZtOVXhdsLYjiPet0 9AqYmWFUqnldAK896mbgEo1xqgxorqR5mRi9PxeTbZ2SGjYuCyl+XYj3yPtinEN0lGNu QYcg== X-Gm-Message-State: AOAM530xM+IG0+zv5YD8BuRp/X9o2sbfcx+ImcOAGIsM3keW/XhRgeAb q//OeMBJcnD/hhb9FW7flLYyKNeekqM= X-Google-Smtp-Source: ABdhPJx7NG+KfnIJQ/4CLtlE2LxsVpCqveCX5r8RgmQIemPAVGtwRGQAkQxuYuOqTB1e4ucW+D6uUA== X-Received: by 2002:a17:90a:6683:: with SMTP id m3mr3730493pjj.225.1603966503667; Thu, 29 Oct 2020 03:15:03 -0700 (PDT) Received: from localhost.localdomain ([122.179.67.57]) by smtp.gmail.com with ESMTPSA id s9sm2488073pfh.67.2020.10.29.03.15.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 03:15:03 -0700 (PDT) From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , darrick.wong@oracle.com, david@fromorbit.com, hch@infradead.org, allison.henderson@oracle.com Subject: [PATCH V8 13/14] xfs: Process allocated extent in a separate function Date: Thu, 29 Oct 2020 15:43:47 +0530 Message-Id: <20201029101348.4442-14-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201029101348.4442-1-chandanrlinux@gmail.com> References: <20201029101348.4442-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 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 935f2d506748..88db23afc51c 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3509,6 +3509,48 @@ xfs_bmap_compute_alignments( } } +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 */ @@ -3701,36 +3743,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.28.0