From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) (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 5E80B20C029 for ; Thu, 12 Mar 2026 16:45:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.9.28.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773333926; cv=none; b=YEr+Oma4+JuOf7DK4TGoJGvWa1lOAjoyCz8BFzdCEkVlKUBMGIvnK035prdYSzL3H48MvhQt0H2dLDlOPiWmPtgWWFhX4bWZ+3WDT79uH8yqgXJ+MS0rbGhzFieEJCxtdbN3K/ilhngJMLRsswDlvKRN+PmNwfTwgpgRcbW4TIc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773333926; c=relaxed/simple; bh=SoR0bYqqNr17DsRa4VjxM3HZFFRJZw1lex1FhQZHRYU=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=qbAaN8N0sl0R3Cur3FQGa5yRTaLUCfkgAZdz4prme6lDhkLucsL71VHoFeeB0xI3n4S6jhMwEoWsTrBKf0zHuVsjFIVgnqe+cC8tlJN8U5VX05T6YVDQCKYNAblxNsjnyTDtd0TDCY/wfh9I33i3zbZQ8c/g/j/7zshADeyQUcc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mit.edu; spf=pass smtp.mailfrom=mit.edu; dkim=pass (2048-bit key) header.d=mit.edu header.i=@mit.edu header.b=gPdxbSxn; arc=none smtp.client-ip=18.9.28.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mit.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mit.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mit.edu header.i=@mit.edu header.b="gPdxbSxn" Received: from macsyma.thunk.org (pool-173-48-82-98.bstnma.fios.verizon.net [173.48.82.98]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 62CGj9Sf029112 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Mar 2026 12:45:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1773333911; bh=SZZmxmfR1k76FpE/PVCaMb7XKHYbqAPafdqg93xNU6M=; h=Date:From:Subject:Message-ID:MIME-Version:Content-Type; b=gPdxbSxn/k2FN+F0JTXuQh9vkH+myG2QoHVgRSOYXjOfdIl8Q3aKKADx9A3ists5l mlOSGAu4PXNuvUg33be6hH6O3nB/6VGrPWbRb9bIQ5i++emYPmwPi0QtjLoHJuifGE Wa5TgVUKn1/14eALV+o21c4iWHUILcIVeOWJ4eWyfL4Xf0pl3Mvb/II1ZOjq5n7+4Q R3P2bzeehh5YQRWGqq0nn3Vuv4Uhds8OQMA9/q7mMoIGpzov89q6nURtuUTQxWIh/S /1cKdq9ZSS+zvp1rgvV+OwiiyBN9aUpuBR+dRDhiGTS91D75lS4TROWsynZm50194l ZUBb0QV5hpsaA== Received: by macsyma.thunk.org (Postfix, from userid 15806) id 313F95D11D3B; Thu, 12 Mar 2026 12:45:09 -0400 (EDT) Date: Thu, 12 Mar 2026 12:45:09 -0400 From: "Theodore Tso" To: Linux Kernel Developers List Cc: Sasha Levin , Jonathan Corbet Subject: How should we handle using AI for reviewing commits? Message-ID: <20260312164509.GB4689@macsyma-wired.lan> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="pp1dqafV+sS0xgVv" Content-Disposition: inline --pp1dqafV+sS0xgVv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline We recently used an AI review bot while applying an LTS backport to an internal kernel tree at $WORK. While doing the review, it flagged a set of concerns which resulted in my creating a patch[1] to address the issues that it found in the kernel commit. [1] https://lore.kernel.org/all/20260310122806.1277631-1-tytso@mit.edu/ In this commit there is no LLM generated output in the code, but there *is* LLM generated output in the commit description, since I quoted the concerns raised by the LLM. Per the our new coding-assistants process document[2], "When AI tools contribute to kernel development, proper attribution helps track the evolving role of AI in the development process. Contributions should include an Assisted-by tag..." [2] https://www.kernel.org/doc/html/latest/process/coding-assistants.html When I was considering whether I should add something like: Assisted-by: Gemini:Gemini-3.1-Pro [TOOL] There was a couple of things that came to mind. First, should we make some kind of distintion between exactly how the AI tool assisted in the development of the commit? There's a big difference between using an AI assistant to find a potential issue, to an AI assistant which created new code out of whole cloth, with a spectrum of changes in between. Given that the stated code was to "track the evolving role of AI", it occured to me that perhaps we should add some indication about exactly what was the nature of assistance that was provided. The second observation that I had was that example set of tools for [TOOL] was "specialized analysis tools": coccinelle, sparse, smatch, clang-tidy. I assume the intent was if an AI bot started using tools like sparse, coccinelle, as an agent?w If there is a set of LLM prompts which has a name, would that also be appropriate for TOOL? Chris Mason's repo has a fairly non-descriptive name, "review-prompts", but in the future when companies start making their internal review prompts public, some of them may have more evocative names that might be more unique and more marketing friendly. :-) - Ted --pp1dqafV+sS0xgVv Content-Type: message/rfc822 Content-Disposition: inline Return-path: Envelope-to: mit@thunk.org Delivery-date: Tue, 10 Mar 2026 12:28:20 +0000 Received: from exchange-forwarding-3.mit.edu ([18.7.62.33]) by imap.thunk.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vzwCC-0002D5-0J for mit@thunk.org; Tue, 10 Mar 2026 12:28:20 +0000 Received: from mailhub-dmz-4.mit.edu (MAILHUB-DMZ-4.MIT.EDU [18.7.62.38]) by exchange-forwarding-3.mit.edu (8.14.7/8.12.4) with ESMTP id 62ACSGtv012425 for ; Tue, 10 Mar 2026 08:28:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1773145698; bh=0tuRckjV7VXF4FxDrS0YxUqr6sqNgghmyE2YFnA7WzM=; h=From:Subject:Date:Message-ID:MIME-Version:Content-Type; b=gmGla3v9Dg//9ijgpLye3Rd+b5ssPu4l6MiyJsHe0uQLcSp/pHZZlW52aoygpYmWY 8SqpmSuXfv2pcBDyK9adywUAzDcabgsxReTXsLk8z2LILXc5KkW0NXgeGrQGan/KeR zhbA0RU1apHhKWDn0+C6Lk8Pi9DO8IxDIDZpro7jm06G72xibe5dBD5Dxb3+sKLsT6 QofNw2n55tg9N/qmvwfrzDOZZ2+DO9Rv0SS5wuAqQV/UtsxUrSEc1DW5IiJ2VUN1cg PwyzjKGfmRGY2tWB5dO0en6l4J2tB+I7PejLO0LNaxI65DzVPhV2z4jZrFLuG3sjCZ IE0uJ+MnUlOyQ== Received: from mailhub-dmz-4.mit.edu (mailhub-dmz-4.mit.edu [127.0.0.1]) by mailhub-dmz-4.mit.edu (8.14.7/8.9.2) with ESMTP id 62ACSGHa030733 for ; Tue, 10 Mar 2026 08:28:17 -0400 Received: (from mdefang@localhost) by mailhub-dmz-4.mit.edu (8.14.7/8.13.8/Submit) id 62ACSFGr030725 for tytso@exchange-forwarding.mit.edu; Tue, 10 Mar 2026 08:28:15 -0400 Received: from BL2PR08CU001.outbound.protection.outlook.com (mail-bl2pr08cu00100.outbound.protection.outlook.com [40.93.4.8]) by MAILHUB-DMZ-4.MIT.EDU (envelope-sender ) (MIMEDefang) with ESMTP id 62ACSE8e030716 for ; Tue, 10 Mar 2026 08:28:15 -0400 Received: from MN2PR11CA0025.namprd11.prod.outlook.com (2603:10b6:208:23b::30) by CY3PR01MB9342.prod.exchangelabs.com (2603:10b6:930:103::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9700.11; Tue, 10 Mar 2026 12:28:11 +0000 Received: from BL6PEPF0001AB72.namprd02.prod.outlook.com (2603:10b6:208:23b:cafe::32) by MN2PR11CA0025.outlook.office365.com (2603:10b6:208:23b::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.25 via Frontend Transport; Tue, 10 Mar 2026 12:27:50 +0000 Authentication-Results: spf=pass (sender IP is 18.9.28.11) smtp.mailfrom=mit.edu; dkim=pass (signature was verified) header.d=mit.edu;dmarc=pass action=none header.from=mit.edu;compauth=pass reason=100 Received-SPF: Pass (protection.outlook.com: domain of mit.edu designates 18.9.28.11 as permitted sender) receiver=protection.outlook.com; client-ip=18.9.28.11; helo=outgoing.mit.edu; pr=C Received: from outgoing.mit.edu (18.9.28.11) by BL6PEPF0001AB72.mail.protection.outlook.com (10.167.242.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.18 via Frontend Transport; Tue, 10 Mar 2026 12:28:10 +0000 Received: from trampoline.thunk.org (pool-173-48-117-133.bstnma.fios.verizon.net [173.48.117.133]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 62ACS8WG022651 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Mar 2026 08:28:09 -0400 Received: by trampoline.thunk.org (Postfix, from userid 15806) id 3A5062E00D6; Tue, 10 Mar 2026 08:28:08 -0400 (EDT) From: "Theodore Ts'o" To: Ext4 Developers List Cc: "Theodore Ts'o" , Jan Kara Date: Tue, 10 Mar 2026 08:28:06 -0400 Message-ID: <20260310122806.1277631-1-tytso@mit.edu> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-EOPTenantAttributedMessage: 64afd9ba-0ecf-4acf-bc36-935f6235ba8b:0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB72:EE_|CY3PR01MB9342:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: f7654546-2e26-4d97-ae67-08de7ea07dfd X-MS-Exchange-AtpMessageProperties: SA|SL X-MIT-ForwardedCount: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?+cahnPZsadYg75GFMkVGkD3k8orlyDMYbb3HJbEMFUm0p3fpi4m3pSjbEAES?= =?us-ascii?Q?yDEdYrkK/WtykUrCzoCNowhaO2b4QyZTbOj/P7sOo9O4GZTR3gHf5RYweZcE?= =?us-ascii?Q?poqzCP6htEV97ETNOqlE0rF4CSGeduTF0B/9iHAj/mCMm/hD6ectD9hgyqjg?= =?us-ascii?Q?wxUBJZqrmn+YzQYyTqFbdhHV0vTnTfopM5DBzaeZhSAgENIMfm/n3x1UeVRZ?= =?us-ascii?Q?bQBSYEzt9+BfC0sBzA3lrc9H6PsJfT3B+A9h6nrp1ehrOX3P4NI9TPWtb7Mo?= =?us-ascii?Q?pvUTIM0m6uA+z6IWu3FkxPLMqxRPcaHObW2KANnooZoYzvI9hotiw9c8TnwC?= =?us-ascii?Q?dNnIPVX14Qn/z360OzPGIEiCAVohIbCqlSuiLgJe6ogfnojSaPoiADOdQcCx?= =?us-ascii?Q?FVKtdPUKzAx9sD4lSzHTkbEu/9+cDrRA3zpYoVMaQUX8xsn1EkQyYpNCAXvE?= =?us-ascii?Q?4COYI7IFMwhLcXztxY97vBG1zzuTN9u7KindIyW3IM6bE63dQe//EQaIjPt5?= =?us-ascii?Q?LV/+niml/7p44ZyWQKi0wLDdD/H6jmLCy1/WUywN4knxDFs0G64/JQgx7Gdq?= =?us-ascii?Q?ODYT/WLOFzu8YKF/zN5ZF2KRJPz/nvcwbW9lt92euCdj89Vgy6JN49r0x/v5?= =?us-ascii?Q?Ge7zOjRVAospCRzsaQbyEdpX8kzBs5jZidZ2W53cIOI1uNf+DCzoGXt8ICqA?= =?us-ascii?Q?KmUWRMw3pTgJe5juIOoYx8fFsK+zQJFkrxHxHL7M40R8WYAseakaN/QvozqT?= =?us-ascii?Q?wSclUeu3uJ/5LEkj2/41mB7TK1mNTxHA8OJs/ADQpgRoetYtvW5I3RsEvdtb?= =?us-ascii?Q?86vIQN/fikJg4RxGcQRZ9aWRWoRFVjDABy4hVhmkr90K3lW+KTUowxaYuk/f?= =?us-ascii?Q?59/o1dAuwB//xR2EKL5Qc8PBKX98srT2FzVR389I8GhengKwywsyOXJH4Tjy?= =?us-ascii?Q?9lCPafm7CPWAqBWGo+zhm9ADByO19lDTIBq4BLpQMZlfmEri2DXKqfbPh9xm?= =?us-ascii?Q?YgrJEzganJ4NeTIj5pxxw+gQw0R6ivuDJajSjmrdkICkcKr6OH3xYclhfU0X?= =?us-ascii?Q?tGPk0rmerHeb9+aQaDhhPxHZ+i3m49z3+1ia34b1jpCQX2/+l0+hAv/XUaT4?= =?us-ascii?Q?eMEDRX+uimdSM0F/+of/k4fqMVXVW/TAQuOxno08nDY/KhMHlsJeEDogN8mu?= =?us-ascii?Q?7e6rLTLcqPCwYURQNCZBDtAUjWHaHmG1+xf4LzJ4IGtlkLhYFiPXgTSZ0hxO?= =?us-ascii?Q?7vucwdVFTcfKvOtYfzhu63fi++XmxOkPDl5XiO7saarajsarEE2xJ41s4x3F?= =?us-ascii?Q?2AUCW329rDruvXE4wnCXeiBt/DyeR3dTlL6l0JhFYxdsXVyPYJd1t/MIkM5r?= =?us-ascii?Q?5Xd+n6PoMQoMQxiTioZCrE39NsqTJ39KB3bIvKyaE4fYh7FQt/jxzsUEJ+nu?= =?us-ascii?Q?eKzaBpHXJxQClK51DbDNMkuZea9k6jjs4YLQdFNn6n7CPWgFQDTSd2OAE4wC?= =?us-ascii?Q?7n2CbpI2d54jPgZ3GCgwlx8mEqSl6MhutgB00Sg/pU1NWK3wYv6gIedeUCfx?= =?us-ascii?Q?vEBKfZUPS5wu2uObHpBQ7MgCGNns1GhQEN/CcDErPU2ZFWz/VsM+lh0ClKlH?= =?us-ascii?Q?ZPZb8rN2jmAU+R37EJDGKdbR8sQxgtKaqcB+k7HSS83xerc/Ie8ixAsKb6Lg?= =?us-ascii?Q?EM29yKV7enundiQ2XbxGS9WY3rEp3E77dJUh1ZCPfomhEUOyJNEmiKCLy/QI?= =?us-ascii?Q?ItlLucIE/s/xGUDo7Pihtu8X+qXYPO4=3D?= X-Forefront-Antispam-Report: CIP:18.9.28.11;CTRY:US;LANG:en;SCL:-1;SRV:;IPV:CAL;SFV:SKN;H:outgoing.mit.edu;PTR:outgoing-auth-1.mit.edu;CAT:NONE;SFS:(13230040);DIR:INB; X-Exchange-RoutingPolicyChecked: QOtLRaJPl/uhbt2USQoRknuWvOUzCRi44ONmlsewWoy5eTha5cCMJIfPoftX9MIQb40xzM3GG0F2npSw2DhbCJQqHs2NYNVtysEZiO/bhK/Q0j0Ln1PUfqUZ686gKxwvfeH+8D0/RWfnjBTJVma4z8+7Nt7InFUFUuBsd7ARSQjPouDuwxQjGvRPa2O4Xpn748fe6PQOBU534kagvvhK+spdVZfQDxOJHCyoOi2lLvnyRVV+TIb9bK1X1p23Yz88w7jgvirsjU4EdUSPiJVgYnZJ9SsEHEZmxi6pr3DV7AuIvieRKdp4/sA8x8dgjTiqV6xXjZgdO4AZUdh0wkemUw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: bqpnFBJbYPguG//o42IUTMMK9Bj0DRl9Fi7R+EqSmuqjpsyKSia2HpyGR4uctClYebVB7MCJKmYY9/tpQ0qiR9/+UDB6ZYQoCjdaqDNpjw9QvonrzdhF4IUQMiZ53noLbYElg/EkYSZL0eAHYPjatEniqQuyILN6UYu3hD67NbpePYHfTlZFunYdys3B9RAaJA1VWf3YzZDQwCd7YvEPJwRbQqx2cZPAk7GkxUCqEZDAhfaNWkh/A4prfsJkXDQ04FpngGwczi82eApuVLf0sBDEKwqCkxJrvKrryjDNTG7ZHxPEGwgydmFj32XS6Y7KZyKMUgj6r7gp6clpekjAam+iycwI5H27aJha5LUnfChEtL3Ye9HHsWpTwzFcZq3YrDBc6ACVu5B4pBzlayGg9Nd0KTUWnmFPtrVgrfXprrgrsLMqYyo/pfFrqz/E4HuAW26dO+kH9A0iRhR4HlTU0xcqwLwnFJBuJDZIyjzyEnMozIAaLjtNlQpWb3meM740p0WGyQSsUAAS/IdXb4fC0G90z0TSdEsmYsTjG0Sj6M9Ul7IaOOIYA8e1IjJmhKzEWcA7sNRYiRHAkPdDazl+gAR3evqHyfvAUGC0bGkllFOuRldNea/p56QdBXJdRgQN X-OriginatorOrg: mit.edu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2026 12:28:10.5180 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7654546-2e26-4d97-ae67-08de7ea07dfd X-MS-Exchange-CrossTenant-Id: 64afd9ba-0ecf-4acf-bc36-935f6235ba8b X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB72.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY3PR01MB9342 X-MS-Exchange-CrossPremises-OriginalClientIPAddress: 18.9.28.11 X-MS-Exchange-CrossPremises-TransportTrafficType: Email X-MS-Exchange-CrossPremises-AuthSource: BL6PEPF0001AB72.namprd02.prod.outlook.com X-MS-Exchange-CrossPremises-AuthAs: Anonymous X-MS-Exchange-CrossPremises-SCL: -1 X-MS-Exchange-CrossPremises-Antispam-ScanContext: DIR:Incoming;SFV:NSPM;SKIP:0; X-MS-Exchange-CrossPremises-Processed-By-Journaling: Journal Agent X-OrganizationHeadersPreserved: CY3PR01MB9342.prod.exchangelabs.com X-SA-Exim-Connect-IP: 18.7.62.33 X-SA-Exim-Mail-From: tytso@mit.edu X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on imap.thunk.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 Subject: [RFC PATCH] ext4: handle wraparound when searching for blocks for indirect mapped blocks X-SA-Exim-Version: 4.2.1 (built Wed, 06 Jul 2022 17:58:28 +0000) X-SA-Exim-Scanned: Yes (on imap.thunk.org) Commit 4865c768b563 ("ext4: always allocate blocks only from groups inode can use") restricts what blocks will be allocated for indirect block based files to block numbers that fit within 32-bit block numbers. However, when using a review bot running on the latest Gemini LLM to check this commit when backporting into an LTS based kernel, it raised the following concerns: If ac->ac_g_ex.fe_group is >= ngroups (for instance, if the goal group was populated via stream allocation from s_mb_last_groups), then start will be >= ngroups. Does this allow allocating blocks beyond the 32-bit limit for indirect block mapped files? The commit message mentions that ext4_mb_scan_groups_linear() takes care to not select unsupported groups. However, its loop uses group = *start, and the very first iteration will call ext4_mb_scan_group() with this unsupported group because next_linear_group() is only called at the end of the iteration. Also, in the optimized scanning paths like ext4_mb_scan_groups_p2_aligned(), start is passed into ext4_mb_scan_groups_xa_range(). If start >= ngroups, will this trigger the WARN_ON_ONCE(end > ngroups || start >= end) because end is set to ngroups? Furthermore, after wrapping around, end will be set to the original start which is > ngroups, triggering the warning a second time. Should this code clamp start to < ngroups before scanning? After reviewing the code paths involved and considering the LLM review, I believe that while it is unlikely, it is possible that how commit 4865c768b563 added ext4_get_allocation_groups_count() doesn't completely address all of the possible situtions that might show up when using indirect-mapped files and allocating blocks on a file system with more than 2**32 blocks. So this commit adds some safety checks and wrap around logic to some functions if the multiblock allocator: ext4_mb_scan_groups_xa_range(), ext4_mb_scan_groups_best_avail(), ext4_mb_scan_groups_p2_aligned(), and ext4_mb_scan_groups(). Fixes: 4865c768b563 ("ext4: always allocate blocks only from groups inode can use") Signed-off-by: Theodore Ts'o Cc: Jan Kara --- fs/ext4/mballoc.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 20e9fdaf4301..454d5a1b4803 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -915,13 +915,17 @@ static int ext4_mb_scan_groups_xa_range(struct ext4_allocation_context *ac, struct ext4_sb_info *sbi = EXT4_SB(sb); enum criteria cr = ac->ac_criteria; ext4_group_t ngroups = ext4_get_allocation_groups_count(ac); - unsigned long group = start; + unsigned long group, end_range; struct ext4_group_info *grp; - if (WARN_ON_ONCE(end > ngroups || start >= end)) - return 0; - - xa_for_each_range(xa, group, grp, start, end - 1) { + if (start >= ngroups) + start = 0; + group = start; +wrap_around: + end_range = end; + if (end_range > ngroups) + end_range = ngroups; + xa_for_each_range(xa, group, grp, start, end_range - 1) { int err; if (sbi->s_mb_stats) @@ -933,7 +937,11 @@ static int ext4_mb_scan_groups_xa_range(struct ext4_allocation_context *ac, cond_resched(); } - + if (start) { + end = start; + start = 0; + goto wrap_around; + } return 0; } @@ -967,6 +975,8 @@ static int ext4_mb_scan_groups_p2_aligned(struct ext4_allocation_context *ac, start = group; end = ext4_get_allocation_groups_count(ac); + if (start >= end) + return 0; wrap_around: for (i = ac->ac_2order; i < MB_NUM_ORDERS(ac->ac_sb); i++) { ret = ext4_mb_scan_groups_largest_free_order_range(ac, i, @@ -1099,6 +1109,8 @@ static int ext4_mb_scan_groups_best_avail(struct ext4_allocation_context *ac, start = group; end = ext4_get_allocation_groups_count(ac); + if (start >= end) + start = 0; wrap_around: for (i = order; i >= min_order; i--) { int frag_order; @@ -1199,6 +1211,8 @@ static int ext4_mb_scan_groups(struct ext4_allocation_context *ac) /* searching for the right group start from the goal value specified */ start = ac->ac_g_ex.fe_group; + if (start >= ngroups) + start = 0; ac->ac_prefetch_grp = start; ac->ac_prefetch_nr = 0; -- 2.51.0 --pp1dqafV+sS0xgVv--