Message ID | 20230406064400.2917-1-wuchi.zero@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp821527vqo; Wed, 5 Apr 2023 23:54:31 -0700 (PDT) X-Google-Smtp-Source: AKy350Y+e8v9c4OELAiPrjlGJIBaY4v/luRP/7m2ylQeLAjzfpR5qPFN+X2azg26+J42ZS4nfgsB X-Received: by 2002:a17:903:234a:b0:19d:f7e:9864 with SMTP id c10-20020a170903234a00b0019d0f7e9864mr12236403plh.57.1680764070826; Wed, 05 Apr 2023 23:54:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680764070; cv=none; d=google.com; s=arc-20160816; b=dgzbg1QjrbawcW9lJVUQ1vUAAXP+oFmieEC3uzRlyjW/NVSJ+BAkjBRx8dn/5d9WDT d9oLXcpdBRX7emqn4iGhIDuLuGteN/+bafw7N24uAZq7BwFzGG3/2U4IxawqVHDOskn5 MtWjE19MpFjv4K55ZhHXSiBR4D8QbiwBE66inGDIm9UMg9M0d8m5T8G9Qn+uFxZGfs/y rBrmR6hoyCYN/w53/3PXZuzCD7R9UovcNHcaiOtEWXIu9Egti7nDnrAON7X5tMp612k+ FzzVA6GjFRRNkB0QV/rFzbhBiMxO9ouNjq2mNdW5u3H7eBiz2T5s/5wikjhjQOhVhGaJ scVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=+XBnQxjP2ylYL48AsMsqJUUlZkp52VkN+BigcNo4SiQ=; b=R7bKaSGKpLXQ4t19Z3sBDBoFL3CTIKYMNL02FbrBkhowZp9XMJFT2XzMhAmPGb8Q+U b/ic7b/CpA+Lv9S4jwC3dHqzMtmiO1YLb8VlmVkDkaEPpNOPhfESay+B7HZ6NjE8rP9X rVbz70bievmd4BHKafVVa7UsKYCS8dGJ0A0dDG9FKYM9FYjhPGrUktPls8PEBUoszbhP 1V+A8NMWEynCvfn+wO2fNshNgqvwRYlCP817gP2BdDKUP/k8HEA1f+fcctGh6/l4qotC U/Y8X9YtRBTETVoqLriiUPlZlfwuTz9+Mwy3759d8nAEZB4gFsNWt391VrSJ4EWN5LVq oyOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="dx/VJIgP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t6-20020a654086000000b00507249cdefasi588652pgp.155.2023.04.05.23.54.18; Wed, 05 Apr 2023 23:54:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="dx/VJIgP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235577AbjDFGoK (ORCPT <rfc822;lkml4gm@gmail.com> + 99 others); Thu, 6 Apr 2023 02:44:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235269AbjDFGoI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 6 Apr 2023 02:44:08 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71AEB6581; Wed, 5 Apr 2023 23:44:06 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id f22so32555980plr.0; Wed, 05 Apr 2023 23:44:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680763446; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+XBnQxjP2ylYL48AsMsqJUUlZkp52VkN+BigcNo4SiQ=; b=dx/VJIgP0dFPwE+hAodDjLSlhr9c9dcTApIXN+gKo1mgNohBB3II2KivA6IEyDZLqx TA6TDO6Q1TJMUHN6FB+qLuc7ucYJbcJiyfUNSwxYFk/pIr5LqAbTm94O1RMxKlph73CT 8Dj4NJuOiySxYXRSK9SDEKPP7XgVTx3imOC41xbkX/5JkQL2MkFzyB5ITDzW/OhoFkno AJKbP0XSs6NVjQDqLxHVmf9+Q3HYLSnuRSosRQBccfXJAk53zoLgTbWbLQ+6PpfT20Q7 z2xgvtLDGqeMOEXEo0QM2RCJQBG7U3tYgyqYfcU6rF+TMQbQI9zyN83Obyp3Yn5bNZdz hnqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680763446; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+XBnQxjP2ylYL48AsMsqJUUlZkp52VkN+BigcNo4SiQ=; b=g/nxLy2lXAUMyMWLw07NEeyGUbTqXG5+ILcHnDjxsM/IewzNlqrdhThUTjk+ay0rOo 6mOl2RKZS3tzkaJeoZ5zj7MJYe/fTKAaGvJNot1gDOqUxjaXCX9YBfQ+IcxyEvUrqiTi eWAnqWhGPO77YN+uGTM6rNXgoxdcWyDutAd6bZqeR62TFiOX7iX/mZBzHUFd38c/vL8c HLA/I5gJV31NiulizMKLahDEfTbACSg4/fqCKF0eNfA1q5FmIl6JPjhDipYG+btE1fJy 9/qnumuYxzuOQRcBQgp9+UodgTovWm2rFQddq9SE7GzTsiynFuEbFDtN5jPwqGQJ85PJ lcKg== X-Gm-Message-State: AAQBX9cGFx9kRoF1n0rZlA+TtXfdbJlcGZfui2hzVKkVdPctESm9xUJk KklqLMJaIPIffGuIV5DPZzo= X-Received: by 2002:a17:903:1205:b0:19f:36b1:c35 with SMTP id l5-20020a170903120500b0019f36b10c35mr10603846plh.64.1680763445834; Wed, 05 Apr 2023 23:44:05 -0700 (PDT) Received: from C02FG34WMD6R.bytedance.net ([61.213.176.12]) by smtp.gmail.com with ESMTPSA id iw3-20020a170903044300b0019a74841c9bsm614436plb.192.2023.04.05.23.44.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 23:44:05 -0700 (PDT) From: wuchi <wuchi.zero@gmail.com> To: tytso@mit.edu, adilger.kernel@dilger.ca, ojaswin@linux.ibm.com, ritesh.list@gmail.com, David.Laight@aculab.com Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] ext4: simplify 32bit calculation of lblk Date: Thu, 6 Apr 2023 14:44:00 +0800 Message-Id: <20230406064400.2917-1-wuchi.zero@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762408866355015375?= X-GMAIL-MSGID: =?utf-8?q?1762408866355015375?= |
Series |
[v2] ext4: simplify 32bit calculation of lblk
|
|
Commit Message
wuchi
April 6, 2023, 6:44 a.m. UTC
commit <ad4fb9cafe100a> (ext4: fix 32bit overflow in ext4_ext_find_goal())
uses value compare to fix 32bit overflow. The resion is that
(block - ext_block) will overflow and cast u32 to u64.
eg: -1(u32) cast to 0xffffffff(u64) which wasn't correct here.
Remove the brackets will solve it simply.
Suggested-by: David Laight <David.Laight@aculab.com>
Signed-off-by: wuchi <wuchi.zero@gmail.com>
---
fs/ext4/extents.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 3559ea6b0781..254d380ff46e 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -237,10 +237,7 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode, ext4_fsblk_t ext_pblk = ext4_ext_pblock(ex); ext4_lblk_t ext_block = le32_to_cpu(ex->ee_block); - if (block > ext_block) - return ext_pblk + (block - ext_block); - else - return ext_pblk - (ext_block - block); + return ext_pblk + block - ext_block; } /* it looks like index is empty;