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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1151C433F5 for ; Tue, 14 Dec 2021 08:47:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229771AbhLNIrk (ORCPT ); Tue, 14 Dec 2021 03:47:40 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:24052 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbhLNIrj (ORCPT ); Tue, 14 Dec 2021 03:47:39 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1BE7Av5F004564; Tue, 14 Dec 2021 08:47:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=RxIJuZTknzy3oLkftFh/6d0+fWkJRPebTRecJNM+ri8=; b=hMYhMZ4nboZlsykZW2nDWeGnXx07AycLh6ddlk+Utr5+BrzyJlD4Gn2BJmbuAYC0SEz3 C2t07ytvk051aJTJ/3RK5Ac9XBuYT9M6Zjum9OoGbotvwrOdnGroXYFbcAPVcnyw1urK JSbHxhiJiIglEf99/g5mH+fl8AWSCXx6lvYnA9uWr1sWuk5Fi6lp0gqKa5ty6IZxcb8Z suLGoegGqQwu0M8hIgX8J0FqnO2a0rqAhViCameF+Rb2jsHkN/fdQq3m+H4liUbjqdcy I5S1FgAjLfRvmWC6tsAfBaYhnA2YfvqXcv4EyxqRduJYkkhawojpGU6FSmRNviA8FUce 3g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3cx3mru5x4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Dec 2021 08:47:36 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1BE8f5CL107700; Tue, 14 Dec 2021 08:47:35 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2173.outbound.protection.outlook.com [104.47.57.173]) by userp3020.oracle.com with ESMTP id 3cvnepm0rp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Dec 2021 08:47:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KS6uzNABzWhWRGhvl1mXuGn/H9gHeed/F77AkBi9K/qViMj64M/ZzTqVofcJDc+d5e5IjXoKbZwf34zE51E/vPS+L9A1GFcpvYyBkctcQsC8eal7wzJGjTpflD69CzPiF7mM6RcYqDqbafQzNHEz5/Sq0pCpwJ6ZGEo84nksnGW42on4dxXmHwtlAmcIK6a4042pmPWhsAia9p6BXN8OJ3OPZUwkhKnsq3Cxw7y+vj0JmbVfvmR4nv8GeMX3gOBqXTBo2bXJjq0+XV0GItql4kJyePB7pvsvrFyEQPQ09zgIPoHMPUz0r7wNSzWeL3s6mM474JoWOJwo18PKeIyVBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RxIJuZTknzy3oLkftFh/6d0+fWkJRPebTRecJNM+ri8=; b=OUgC/9iH+58JE3+e4WaMpdVD1TXpo1tIPw173Ckcm5pX2haqwr5GefkZjhgrKatjlhHwEBFBgRUyvIVk6bqSJa9uJFeyDy+qvcN5D0APaiy0FvINyNHEI1fby5jxbgZkLQVUNB/ElDsybsTJnF+PFVnRwZxRxiXdJy0B+GmYZgjb9mIBdBIlikGg81RW0pUB90iP3nn2Hz7uxl/I/pzk4653Xq9odbmgaONa6Bpmy5KZXs+hiXnsqs263kkJTX3aaxuN9nWkCDjnYclKLHFm9vyg2lkEQqYYt5IpCwR/EP4gmYsZ5ahRK7/XrQsn4cFStSR9pSguuMAp/heIExp04A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RxIJuZTknzy3oLkftFh/6d0+fWkJRPebTRecJNM+ri8=; b=krtvCjOtV5CA3y6x6I+uXJ6ltjbhMnD8Za6LMFTRozPbplPoBvymISjD3AYhpQmDRJuzPS1GlJVLf7QhB2lWcFOgwAKVe/nYZVIZTJZzxcKdq7nswj7aYgdQJTRoowFHrUFOvG6jEeq3r2SzNBweDtD5mSdewXGkL+rMZvOfwfY= Received: from SA2PR10MB4587.namprd10.prod.outlook.com (2603:10b6:806:114::12) by SN6PR10MB3054.namprd10.prod.outlook.com (2603:10b6:805:d1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.17; Tue, 14 Dec 2021 08:47:32 +0000 Received: from SA2PR10MB4587.namprd10.prod.outlook.com ([fe80::75ca:e478:6788:d21d]) by SA2PR10MB4587.namprd10.prod.outlook.com ([fe80::75ca:e478:6788:d21d%6]) with mapi id 15.20.4778.018; Tue, 14 Dec 2021 08:47:32 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, david@fromorbit.com Subject: [PATCH V4 16/16] xfs: Define max extent length based on on-disk format definition Date: Tue, 14 Dec 2021 14:15:19 +0530 Message-Id: <20211214084519.759272-17-chandan.babu@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211214084519.759272-1-chandan.babu@oracle.com> References: <20211214084519.759272-1-chandan.babu@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MA1PR0101CA0052.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::14) To SA2PR10MB4587.namprd10.prod.outlook.com (2603:10b6:806:114::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 851f470e-658b-4cec-6de0-08d9bede5e3d X-MS-TrafficTypeDiagnostic: SN6PR10MB3054:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1332; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XS+1vcljs7xc8z69nYnrAB3vXPIDDMwvq0T6OS+BgWh58aKpd5Umng3DI9rFhwCNcPVFrRXEaOVZjQicNkwCyo5YUSfnWrZuoX80QQ45f+rrXuyRjy6UFt+spIF0uSR7CyAPniXhDxfxlRpp8ytVY6gP3XELMgBafbdFNFvNXhkLiReB4jPIMgNuZbamCcoTnteMbJ/zOsjtSP2cOv0FK4YGiYaudCFSa24kg4rUL2CfY9ZOwwxrV2aCyNrlySLns5eMl2BqycfyJApt5zf0hrGFBIqybbm3xzKiLv0mPu4zD8jFeQ1u0wGqyNnEGiLgtsvrOuck9XYrZ3tKWK+wiNaq+bwAalVz6uofHAwqTHFebU31Dmx7In/sEi2E67NOAzFxNY88ZiScc7Zv6RhRe9AvjisNJBrB/re5FJeMU7JdT4zIl+C14tkhrmfaMcqdztKs74CC2nyDnSVVGhW9DOL2uYwOZJePGd9c0md888SrKr4KimL9G3DSWrUCgR6WNXKXXC7ArxrPxFqCwx/pSIsczysxODXecs4a/pl2PM6y9j2WHYVJSoEn4i9iSKoJMLcGJAxYmS2bRfqDLkcNKlEf9Y6xvkGesTvAYiqq19S3OnKYaFvaj5E/aJxZxjlHEkx2EIuzEU42Q2RU3CaAdW464QlsFaz2G6FLvw/Qt8FL/Vaus6qd93m3g2tLw6guB5eFd/zGuxwfuFX3zLRjZA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA2PR10MB4587.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(8936002)(8676002)(30864003)(66556008)(66476007)(6486002)(316002)(6916009)(6512007)(186003)(5660300002)(2906002)(36756003)(83380400001)(26005)(66946007)(2616005)(6666004)(1076003)(4326008)(6506007)(508600001)(52116002)(38350700002)(86362001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?POHKH2wZc1LUQ8X8aMqQtjmoUVkPEzYc0zDd17Xqt+l9f5nVy81v+erqeGj5?= =?us-ascii?Q?KvDzrCw1/tAiR7S2X7qLXNwi8enHm8MmBfQrQ6mE+JGaoV3Hg4BWldjbfWkF?= =?us-ascii?Q?H3ZtVw4SRvx9sDujUGCsPigf8cKny9o5n1TMB6pcF1w2SCAC62wSFsVAMJ9S?= =?us-ascii?Q?YfLr9MCCAwMzmGMdeJ00D94WsghQSdPmJNVzLntvb7q1szVQofHEdYX0t8LD?= =?us-ascii?Q?EXtbPZB2zv4J2yXwNKrOgGcdsclmo4nm/gG2v2dnwEn1w6JSaM2n+7fSsAP9?= =?us-ascii?Q?q5rK4NSPAO6B7Sczwxt5mB4tsEXjOMQh4gzo2wZU2zKLyAXSs69mUv18cakY?= =?us-ascii?Q?r82A6TBWSZp62XAzil/13xqJiaP/VvdTyhDpvy2iBlTPn/JLA91Mdwhf9ier?= =?us-ascii?Q?LsE4gm2EEImbV6cAh60e61napBwqWC8Ycr+o1srQl041FqjrNO9OvVltAbmf?= =?us-ascii?Q?ktNZZwUqW9Sh5KAX455HZNNh4iJBiwxQ8m/KmuULeWKFPq5mWGZyBXg3ajV4?= =?us-ascii?Q?V9zyudXGVvPDVHJssjSot2yD7KgRE4fE/r/QlGIKohqGyKPqjYX7In9cs1Qk?= =?us-ascii?Q?wmwdjA2GKLdfmMG12vdqB1n9eOZHgDh0DxgCBQAP5gNt7lSRnIuQ+yHWNLfs?= =?us-ascii?Q?dsEaBYbGr8JGQmI/e1Nk+2J6DGSmgu1WmO8Ddvv4xkunfZ3+W37vtWs3RSZr?= =?us-ascii?Q?Q14mhu/8ioIVqVVJDSrElgFUINGP/D6BIlM+LLvWasXxw/vhRxFPtNbWfGSW?= =?us-ascii?Q?iJ2EWrW4rIpHGeFYqm1HJ47qpCwTM8VIRyJElPfEGrB460BoYBjZ29wHbSMO?= =?us-ascii?Q?3ClvNoYIXBRXouFW8to+4ixvNnfxe70TrTw9wQje0aGnYGRX0ri+yef84YE4?= =?us-ascii?Q?UNOzVzxz1Odimlen/+8uAKrZtGfu26eLSxdSBrMepvw3732OPfOhwzPEnuu7?= =?us-ascii?Q?pn/ASGhbzY1/1fa4NEmeBSsvXM1bp1v60c9jAOIu8Vc+bSJpd72Pzs8kz/gI?= =?us-ascii?Q?l3S9ZVPq23BDdx9XZC+7MBv4W1wLUH7RE9y8O+oBQl/UjvSKot6Q4NYPfcoS?= =?us-ascii?Q?nKSaSqVgaMHt6HZQ/q2bdPesP+hZ/FmHJ51XdsOu2y3crztubHnMRuak6SPR?= =?us-ascii?Q?M4DEZpIuqGWFtJXk4D6MRbCO5nvJ9CmPUzgko0Z7VhCwnb5O1ezifRAiCgbY?= =?us-ascii?Q?LtnuMZcnCNX0cV1Bu4emNvF1Dfdf7u9aJ7ea2CVLoPv+tz0C1Gi2ngyEYeEG?= =?us-ascii?Q?sbFQvpk1NS7ASXkZIPSWJxevgVGPi17LhbIe1HNSvvSPrWtTN+5+moUW6PBU?= =?us-ascii?Q?qY8cKx7C4SMVHT3/G2vy+3RsD453Am2UFLqMGoRVWWb1XmUTbsY6ZqNo9AFw?= =?us-ascii?Q?2kNSfsSODEynZDp7UvG9z3AyOq72PB2PFzz8T7aTn4qh14WoxyReFgKhqd2B?= =?us-ascii?Q?3gC2ezL1IolbPGYIsFQjM82nfWwLndhxm+UFo2ITVNUy7Iz0EpNv6kuquFDy?= =?us-ascii?Q?4Z0WvcWWnByTsbTw2/MP+dF0FxbO8SkwmojxlKVOSVU9neZST8fh0/qfa5Gl?= =?us-ascii?Q?5eurcDhrQ/XGQD29j+TmJXuPPOALu8R3AkEYSDptUZXIukyAHJ5/JoO1wOHp?= =?us-ascii?Q?u8gDg3kIpdZIjGwAtHqHob0=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 851f470e-658b-4cec-6de0-08d9bede5e3d X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4587.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2021 08:47:32.7257 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DQQfTT94fKtgwuGG+sfko7Khz0o/TeVDZkYDxP2sDi5q5OG87/pWtzrY1j/hiZZwhwfXool4Up9qDmnELtD4jQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB3054 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10197 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 malwarescore=0 bulkscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112140049 X-Proofpoint-ORIG-GUID: GSAG0yJgoj3ySSHdlZy3QxjKjRIDxBmN X-Proofpoint-GUID: GSAG0yJgoj3ySSHdlZy3QxjKjRIDxBmN Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The maximum extent length depends on maximum block count that can be stored in a BMBT record. Hence this commit defines MAXEXTLEN based on BMBT_BLOCKCOUNT_BITLEN. While at it, the commit also renames MAXEXTLEN to XFS_MAX_BMBT_EXTLEN. Suggested-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_alloc.c | 2 +- fs/xfs/libxfs/xfs_bmap.c | 57 +++++++++++++++++----------------- fs/xfs/libxfs/xfs_format.h | 21 +++++++------ fs/xfs/libxfs/xfs_inode_buf.c | 4 +-- fs/xfs/libxfs/xfs_trans_resv.c | 11 ++++--- fs/xfs/scrub/bmap.c | 2 +- fs/xfs/xfs_bmap_util.c | 14 +++++---- fs/xfs/xfs_iomap.c | 28 ++++++++--------- 8 files changed, 72 insertions(+), 67 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 353e53b892e6..3f9b9cbfef43 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -2493,7 +2493,7 @@ __xfs_free_extent_later( ASSERT(bno != NULLFSBLOCK); ASSERT(len > 0); - ASSERT(len <= MAXEXTLEN); + ASSERT(len <= XFS_MAX_BMBT_EXTLEN); ASSERT(!isnullstartblock(bno)); agno = XFS_FSB_TO_AGNO(mp, bno); agbno = XFS_FSB_TO_AGBNO(mp, bno); diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 0ce58e4a9c44..9c3da7a916df 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -1449,7 +1449,7 @@ xfs_bmap_add_extent_delay_real( LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && LEFT.br_state == new->br_state && - LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN) + LEFT.br_blockcount + new->br_blockcount <= XFS_MAX_BMBT_EXTLEN) state |= BMAP_LEFT_CONTIG; /* @@ -1467,13 +1467,13 @@ xfs_bmap_add_extent_delay_real( new_endoff == RIGHT.br_startoff && new->br_startblock + new->br_blockcount == RIGHT.br_startblock && new->br_state == RIGHT.br_state && - new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN && + new->br_blockcount + RIGHT.br_blockcount <= XFS_MAX_BMBT_EXTLEN && ((state & (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING)) != (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING) || LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount - <= MAXEXTLEN)) + <= XFS_MAX_BMBT_EXTLEN)) state |= BMAP_RIGHT_CONTIG; error = 0; @@ -1997,7 +1997,7 @@ xfs_bmap_add_extent_unwritten_real( LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && LEFT.br_state == new->br_state && - LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN) + LEFT.br_blockcount + new->br_blockcount <= XFS_MAX_BMBT_EXTLEN) state |= BMAP_LEFT_CONTIG; /* @@ -2015,13 +2015,13 @@ xfs_bmap_add_extent_unwritten_real( new_endoff == RIGHT.br_startoff && new->br_startblock + new->br_blockcount == RIGHT.br_startblock && new->br_state == RIGHT.br_state && - new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN && + new->br_blockcount + RIGHT.br_blockcount <= XFS_MAX_BMBT_EXTLEN && ((state & (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING)) != (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING) || LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount - <= MAXEXTLEN)) + <= XFS_MAX_BMBT_EXTLEN)) state |= BMAP_RIGHT_CONTIG; /* @@ -2507,15 +2507,15 @@ xfs_bmap_add_extent_hole_delay( */ if ((state & BMAP_LEFT_VALID) && (state & BMAP_LEFT_DELAY) && left.br_startoff + left.br_blockcount == new->br_startoff && - left.br_blockcount + new->br_blockcount <= MAXEXTLEN) + left.br_blockcount + new->br_blockcount <= XFS_MAX_BMBT_EXTLEN) state |= BMAP_LEFT_CONTIG; if ((state & BMAP_RIGHT_VALID) && (state & BMAP_RIGHT_DELAY) && new->br_startoff + new->br_blockcount == right.br_startoff && - new->br_blockcount + right.br_blockcount <= MAXEXTLEN && + new->br_blockcount + right.br_blockcount <= XFS_MAX_BMBT_EXTLEN && (!(state & BMAP_LEFT_CONTIG) || (left.br_blockcount + new->br_blockcount + - right.br_blockcount <= MAXEXTLEN))) + right.br_blockcount <= XFS_MAX_BMBT_EXTLEN))) state |= BMAP_RIGHT_CONTIG; /* @@ -2658,17 +2658,17 @@ xfs_bmap_add_extent_hole_real( left.br_startoff + left.br_blockcount == new->br_startoff && left.br_startblock + left.br_blockcount == new->br_startblock && left.br_state == new->br_state && - left.br_blockcount + new->br_blockcount <= MAXEXTLEN) + left.br_blockcount + new->br_blockcount <= XFS_MAX_BMBT_EXTLEN) state |= BMAP_LEFT_CONTIG; if ((state & BMAP_RIGHT_VALID) && !(state & BMAP_RIGHT_DELAY) && new->br_startoff + new->br_blockcount == right.br_startoff && new->br_startblock + new->br_blockcount == right.br_startblock && new->br_state == right.br_state && - new->br_blockcount + right.br_blockcount <= MAXEXTLEN && + new->br_blockcount + right.br_blockcount <= XFS_MAX_BMBT_EXTLEN && (!(state & BMAP_LEFT_CONTIG) || left.br_blockcount + new->br_blockcount + - right.br_blockcount <= MAXEXTLEN)) + right.br_blockcount <= XFS_MAX_BMBT_EXTLEN)) state |= BMAP_RIGHT_CONTIG; error = 0; @@ -2903,15 +2903,15 @@ xfs_bmap_extsize_align( /* * For large extent hint sizes, the aligned extent might be larger than - * MAXEXTLEN. In that case, reduce the size by an extsz so that it pulls - * the length back under MAXEXTLEN. The outer allocation loops handle - * short allocation just fine, so it is safe to do this. We only want to - * do it when we are forced to, though, because it means more allocation - * operations are required. + * XFS_BMBT_MAX_EXTLEN. In that case, reduce the size by an extsz so + * that it pulls the length back under XFS_BMBT_MAX_EXTLEN. The outer + * allocation loops handle short allocation just fine, so it is safe to + * do this. We only want to do it when we are forced to, though, because + * it means more allocation operations are required. */ - while (align_alen > MAXEXTLEN) + while (align_alen > XFS_MAX_BMBT_EXTLEN) align_alen -= extsz; - ASSERT(align_alen <= MAXEXTLEN); + ASSERT(align_alen <= XFS_MAX_BMBT_EXTLEN); /* * If the previous block overlaps with this proposed allocation @@ -3001,9 +3001,9 @@ xfs_bmap_extsize_align( return -EINVAL; } else { ASSERT(orig_off >= align_off); - /* see MAXEXTLEN handling above */ + /* see XFS_BMBT_MAX_EXTLEN handling above */ ASSERT(orig_end <= align_off + align_alen || - align_alen + extsz > MAXEXTLEN); + align_alen + extsz > XFS_MAX_BMBT_EXTLEN); } #ifdef DEBUG @@ -3968,7 +3968,7 @@ xfs_bmapi_reserve_delalloc( * Cap the alloc length. Keep track of prealloc so we know whether to * tag the inode before we return. */ - alen = XFS_FILBLKS_MIN(len + prealloc, MAXEXTLEN); + alen = XFS_FILBLKS_MIN(len + prealloc, XFS_MAX_BMBT_EXTLEN); if (!eof) alen = XFS_FILBLKS_MIN(alen, got->br_startoff - aoff); if (prealloc && alen >= len) @@ -4101,7 +4101,7 @@ xfs_bmapi_allocate( if (!xfs_iext_peek_prev_extent(ifp, &bma->icur, &bma->prev)) bma->prev.br_startoff = NULLFILEOFF; } else { - bma->length = XFS_FILBLKS_MIN(bma->length, MAXEXTLEN); + bma->length = XFS_FILBLKS_MIN(bma->length, XFS_MAX_BMBT_EXTLEN); if (!bma->eof) bma->length = XFS_FILBLKS_MIN(bma->length, bma->got.br_startoff - bma->offset); @@ -4421,8 +4421,8 @@ xfs_bmapi_write( * xfs_extlen_t and therefore 32 bits. Hence we have to * check for 32-bit overflows and handle them here. */ - if (len > (xfs_filblks_t)MAXEXTLEN) - bma.length = MAXEXTLEN; + if (len > (xfs_filblks_t)XFS_MAX_BMBT_EXTLEN) + bma.length = XFS_MAX_BMBT_EXTLEN; else bma.length = len; @@ -4557,7 +4557,8 @@ xfs_bmapi_convert_delalloc( bma.ip = ip; bma.wasdel = true; bma.offset = bma.got.br_startoff; - bma.length = max_t(xfs_filblks_t, bma.got.br_blockcount, MAXEXTLEN); + bma.length = max_t(xfs_filblks_t, bma.got.br_blockcount, + XFS_MAX_BMBT_EXTLEN); bma.minleft = xfs_bmapi_minleft(tp, ip, whichfork); /* @@ -4638,7 +4639,7 @@ xfs_bmapi_remap( ifp = XFS_IFORK_PTR(ip, whichfork); ASSERT(len > 0); - ASSERT(len <= (xfs_filblks_t)MAXEXTLEN); + ASSERT(len <= (xfs_filblks_t)XFS_MAX_BMBT_EXTLEN); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); ASSERT(!(flags & ~(XFS_BMAPI_ATTRFORK | XFS_BMAPI_PREALLOC | XFS_BMAPI_NORMAP))); @@ -5638,7 +5639,7 @@ xfs_bmse_can_merge( if ((left->br_startoff + left->br_blockcount != startoff) || (left->br_startblock + left->br_blockcount != got->br_startblock) || (left->br_state != got->br_state) || - (left->br_blockcount + got->br_blockcount > MAXEXTLEN)) + (left->br_blockcount + got->br_blockcount > XFS_MAX_BMBT_EXTLEN)) return false; return true; diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 3183f78fe7a3..dd5cffe63be3 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -885,15 +885,6 @@ enum xfs_dinode_fmt { { XFS_DINODE_FMT_BTREE, "btree" }, \ { XFS_DINODE_FMT_UUID, "uuid" } -/* - * Max values for extlen, extnum, aextnum. - */ -#define MAXEXTLEN ((xfs_extlen_t)0x1fffff) /* 21 bits */ -#define XFS_MAX_EXTCNT_DATA_FORK ((xfs_extnum_t)0xffffffffffff) /* Unsigned 48-bits */ -#define XFS_MAX_EXTCNT_ATTR_FORK ((xfs_aextnum_t)0xffffffff) /* Unsigned 32-bits */ -#define XFS_MAX_EXTCNT_DATA_FORK_OLD ((xfs_extnum_t)0x7fffffff) /* Signed 32-bits */ -#define XFS_MAX_EXTCNT_ATTR_FORK_OLD ((xfs_aextnum_t)0x7fff) /* Signed 16-bits */ - /* * Inode minimum and maximum sizes. */ @@ -1623,7 +1614,17 @@ typedef struct xfs_bmdr_block { #define BMBT_BLOCKCOUNT_BITLEN 21 #define BMBT_STARTOFF_MASK ((1ULL << BMBT_STARTOFF_BITLEN) - 1) -#define BMBT_BLOCKCOUNT_MASK ((1ULL << BMBT_BLOCKCOUNT_BITLEN) - 1) + +/* + * Max values for extlen and disk inode's extent counters. + */ +#define XFS_MAX_BMBT_EXTLEN ((xfs_extlen_t)(1ULL << BMBT_BLOCKCOUNT_BITLEN) - 1) +#define XFS_MAX_EXTCNT_DATA_FORK ((xfs_extnum_t)0xffffffffffff) /* Unsigned 48-bits */ +#define XFS_MAX_EXTCNT_ATTR_FORK ((xfs_aextnum_t)0xffffffff) /* Unsigned 32-bits */ +#define XFS_MAX_EXTCNT_DATA_FORK_OLD ((xfs_extnum_t)0x7fffffff) /* Signed 32-bits */ +#define XFS_MAX_EXTCNT_ATTR_FORK_OLD ((xfs_aextnum_t)0x7fff) /* Signed 16-bits */ + +#define BMBT_BLOCKCOUNT_MASK XFS_MAX_BMBT_EXTLEN /* * bmbt records have a file offset (block) field that is 54 bits wide, so this diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index b8e4e1f69989..780bad03d953 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -691,7 +691,7 @@ xfs_inode_validate_extsize( if (extsize_bytes % blocksize_bytes) return __this_address; - if (extsize > MAXEXTLEN) + if (extsize > XFS_MAX_BMBT_EXTLEN) return __this_address; if (!rt_flag && extsize > mp->m_sb.sb_agblocks / 2) @@ -748,7 +748,7 @@ xfs_inode_validate_cowextsize( if (cowextsize_bytes % mp->m_sb.sb_blocksize) return __this_address; - if (cowextsize > MAXEXTLEN) + if (cowextsize > XFS_MAX_BMBT_EXTLEN) return __this_address; if (cowextsize > mp->m_sb.sb_agblocks / 2) diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index 6f83d9b306ee..19313021fb99 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c @@ -199,8 +199,8 @@ xfs_calc_inode_chunk_res( /* * Per-extent log reservation for the btree changes involved in freeing or * allocating a realtime extent. We have to be able to log as many rtbitmap - * blocks as needed to mark inuse MAXEXTLEN blocks' worth of realtime extents, - * as well as the realtime summary block. + * blocks as needed to mark inuse XFS_BMBT_MAX_EXTLEN blocks' worth of realtime + * extents, as well as the realtime summary block. */ static unsigned int xfs_rtalloc_log_count( @@ -210,7 +210,7 @@ xfs_rtalloc_log_count( unsigned int blksz = XFS_FSB_TO_B(mp, 1); unsigned int rtbmp_bytes; - rtbmp_bytes = (MAXEXTLEN / mp->m_sb.sb_rextsize) / NBBY; + rtbmp_bytes = (XFS_MAX_BMBT_EXTLEN / mp->m_sb.sb_rextsize) / NBBY; return (howmany(rtbmp_bytes, blksz) + 1) * num_ops; } @@ -247,7 +247,7 @@ xfs_rtalloc_log_count( * the inode's bmap btree: max depth * block size * the agfs of the ags from which the extents are allocated: 2 * sector * the superblock free block counter: sector size - * the realtime bitmap: ((MAXEXTLEN / rtextsize) / NBBY) bytes + * the realtime bitmap: ((XFS_BMBT_MAX_EXTLEN / rtextsize) / NBBY) bytes * the realtime summary: 1 block * the allocation btrees: 2 trees * (2 * max depth - 1) * block size * And the bmap_finish transaction can free bmap blocks in a join (t3): @@ -299,7 +299,8 @@ xfs_calc_write_reservation( * the agf for each of the ags: 2 * sector size * the agfl for each of the ags: 2 * sector size * the super block to reflect the freed blocks: sector size - * the realtime bitmap: 2 exts * ((MAXEXTLEN / rtextsize) / NBBY) bytes + * the realtime bitmap: 2 exts * ((XFS_BMBT_MAX_EXTLEN / rtextsize) / NBBY) + * bytes * the realtime summary: 2 exts * 1 block * worst case split in allocation btrees per extent assuming 2 extents: * 2 exts * 2 trees * (2 * max depth - 1) * block size diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c index a4cbbc346f60..c357593e0a02 100644 --- a/fs/xfs/scrub/bmap.c +++ b/fs/xfs/scrub/bmap.c @@ -350,7 +350,7 @@ xchk_bmap_iextent( irec->br_startoff); /* Make sure the extent points to a valid place. */ - if (irec->br_blockcount > MAXEXTLEN) + if (irec->br_blockcount > XFS_MAX_BMBT_EXTLEN) xchk_fblock_set_corrupt(info->sc, info->whichfork, irec->br_startoff); if (info->is_rt && diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 73a36b7be3bd..36cde254dedd 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -119,14 +119,14 @@ xfs_bmap_rtalloc( */ ralen = ap->length / mp->m_sb.sb_rextsize; /* - * If the old value was close enough to MAXEXTLEN that + * If the old value was close enough to XFS_BMBT_MAX_EXTLEN that * we rounded up to it, cut it back so it's valid again. * Note that if it's a really large request (bigger than - * MAXEXTLEN), we don't hear about that number, and can't + * XFS_BMBT_MAX_EXTLEN), we don't hear about that number, and can't * adjust the starting point to match it. */ - if (ralen * mp->m_sb.sb_rextsize >= MAXEXTLEN) - ralen = MAXEXTLEN / mp->m_sb.sb_rextsize; + if (ralen * mp->m_sb.sb_rextsize >= XFS_MAX_BMBT_EXTLEN) + ralen = XFS_MAX_BMBT_EXTLEN / mp->m_sb.sb_rextsize; /* * Lock out modifications to both the RT bitmap and summary inodes @@ -840,9 +840,11 @@ xfs_alloc_file_space( * count, hence we need to limit the number of blocks we are * trying to reserve to avoid an overflow. We can't allocate * more than @nimaps extents, and an extent is limited on disk - * to MAXEXTLEN (21 bits), so use that to enforce the limit. + * to XFS_BMBT_MAX_EXTLEN (21 bits), so use that to enforce the + * limit. */ - resblks = min_t(xfs_fileoff_t, (e - s), (MAXEXTLEN * nimaps)); + resblks = min_t(xfs_fileoff_t, (e - s), + (XFS_MAX_BMBT_EXTLEN * nimaps)); if (unlikely(rt)) { dblocks = XFS_DIOSTRAT_SPACE_RES(mp, 0); rblocks = resblks; diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 093758440ad5..6835adc8d62f 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -395,7 +395,7 @@ xfs_iomap_prealloc_size( */ plen = prev.br_blockcount; while (xfs_iext_prev_extent(ifp, &ncur, &got)) { - if (plen > MAXEXTLEN / 2 || + if (plen > XFS_MAX_BMBT_EXTLEN / 2 || isnullstartblock(got.br_startblock) || got.br_startoff + got.br_blockcount != prev.br_startoff || got.br_startblock + got.br_blockcount != prev.br_startblock) @@ -407,23 +407,23 @@ xfs_iomap_prealloc_size( /* * If the size of the extents is greater than half the maximum extent * length, then use the current offset as the basis. This ensures that - * for large files the preallocation size always extends to MAXEXTLEN - * rather than falling short due to things like stripe unit/width - * alignment of real extents. + * for large files the preallocation size always extends to + * XFS_BMBT_MAX_EXTLEN rather than falling short due to things like stripe + * unit/width alignment of real extents. */ alloc_blocks = plen * 2; - if (alloc_blocks > MAXEXTLEN) + if (alloc_blocks > XFS_MAX_BMBT_EXTLEN) alloc_blocks = XFS_B_TO_FSB(mp, offset); qblocks = alloc_blocks; /* - * MAXEXTLEN is not a power of two value but we round the prealloc down - * to the nearest power of two value after throttling. To prevent the - * round down from unconditionally reducing the maximum supported - * prealloc size, we round up first, apply appropriate throttling, - * round down and cap the value to MAXEXTLEN. + * XFS_BMBT_MAX_EXTLEN is not a power of two value but we round the prealloc + * down to the nearest power of two value after throttling. To prevent + * the round down from unconditionally reducing the maximum supported + * prealloc size, we round up first, apply appropriate throttling, round + * down and cap the value to XFS_BMBT_MAX_EXTLEN. */ - alloc_blocks = XFS_FILEOFF_MIN(roundup_pow_of_two(MAXEXTLEN), + alloc_blocks = XFS_FILEOFF_MIN(roundup_pow_of_two(XFS_MAX_BMBT_EXTLEN), alloc_blocks); freesp = percpu_counter_read_positive(&mp->m_fdblocks); @@ -471,14 +471,14 @@ xfs_iomap_prealloc_size( */ if (alloc_blocks) alloc_blocks = rounddown_pow_of_two(alloc_blocks); - if (alloc_blocks > MAXEXTLEN) - alloc_blocks = MAXEXTLEN; + if (alloc_blocks > XFS_MAX_BMBT_EXTLEN) + alloc_blocks = XFS_MAX_BMBT_EXTLEN; /* * If we are still trying to allocate more space than is * available, squash the prealloc hard. This can happen if we * have a large file on a small filesystem and the above - * lowspace thresholds are smaller than MAXEXTLEN. + * lowspace thresholds are smaller than XFS_BMBT_MAX_EXTLEN. */ while (alloc_blocks && alloc_blocks >= freesp) alloc_blocks >>= 4; -- 2.30.2