Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp299257rdb; Mon, 18 Sep 2023 15:57:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjkesnisIFRJWk2XryWTQeEqBqvQUAnAvlGhwKtbDpJm/DJYwB6/D9RxJipKfJ10pnoDdG X-Received: by 2002:a05:6a20:1608:b0:159:c918:1016 with SMTP id l8-20020a056a20160800b00159c9181016mr10591529pzj.49.1695077833366; Mon, 18 Sep 2023 15:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695077833; cv=none; d=google.com; s=arc-20160816; b=uAW8R/zUmm7/mtgwYvjJgKmteohh9Ix0mqQj5ymZ9V7Dbf/k8L7OoCgjQRgKtn8Ld3 eQAykQg2WYU6vBibwZfmpra2zfhLqeul0yi4sC0qwWDc/QQyd/OuMdsCg7SlrjXnIsHd Q5P0m0vWXl6R6vnMVmBLuH7hce4DUj2NLzf8NP9K9zLYlD/nmkGdwJxpp17605rb4YhP 7KCFgU/Okt/FlXAuBgRAFRPltDLsz0UnSkoPa3IxJWhAb7FdbzkJNII8NePQ80eWdLNP 6yNvnUfm9/wamRW+p13VapIVYrMWTLUGDUZ4Z/nuXTuGB+NtoisuXSvBUNalU8NZj2XC ZVlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature:dkim-signature; bh=CKKkFp5ehkDbafP9C6xC6+RnxQLBq56KlrfWbgn4bDc=; fh=e/dspWiDpGrJnyhyMeXVGZwmj8DdEPOiqxfeEbyfLiQ=; b=I2z1o9kjto/HZX+oqBpuZFWs/yYYkUVJcghmYNbIyISfOd0tV6nA+sR0yo557cj0VV twp1bNZ4koF2bbShlVDpcqCkUSLC9ZGPfxKLgbh3DrOhx+36pjnoXrAEwqpwC9RSVW5H +Nji8rEn08wAWeOijbNg6M727dZ1ybRv2zK52PJCDNGueL4zqUtpGrTtMMcIJOVFQuvx leU3WjKTy+4SgZZ4ai1h5mnQtxbAm3ThJz9dAOWm/eY4hsNn3Prvu4teY7lwFTD6D0Bp pdy9f1IA6lIgwOvoJ5tNtQqzL3CviOB83VSni7llAiBknHDZK+3MEBe2SK34M1EOmxsg FG3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=tDvhyJuR; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id fp7-20020a056a00608700b0069023e4bcb4si8473014pfb.114.2023.09.18.15.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 15:57:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=tDvhyJuR; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 43E0F825172E; Mon, 18 Sep 2023 09:37:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230348AbjIRQhB (ORCPT + 99 others); Mon, 18 Sep 2023 12:37:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbjIRQgr (ORCPT ); Mon, 18 Sep 2023 12:36:47 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F5935BB1; Mon, 18 Sep 2023 09:31:25 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9DD0921E9F; Mon, 18 Sep 2023 16:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1695054684; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CKKkFp5ehkDbafP9C6xC6+RnxQLBq56KlrfWbgn4bDc=; b=tDvhyJuRfPgtwJ5cySbTm2NKjjLgu6TBS2xtOvRpKQLIPFPZti4DA9Y+PJBv8Tj2otuMS5 x+YAmvtGYMmGSUx4iOpmAQAUHkPO5D6r3bN2dnr+HSf429pLyShuPBf8Jhvq5wnFHpLsCk DZldf6REW2y/HbQ7tdbSmHU6VZamGmY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1695054684; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CKKkFp5ehkDbafP9C6xC6+RnxQLBq56KlrfWbgn4bDc=; b=RR/l4CyGLrE/f12m1t3yPOG+q1Fkz6r6UJ6/406poOPtdoW6hld9gGCFQ+ENPp4kO6IfJu xdtl/hUDnbI4MBBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 685C013480; Mon, 18 Sep 2023 16:31:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id pd9uGFx7CGXffAAAMHmgww (envelope-from ); Mon, 18 Sep 2023 16:31:24 +0000 Date: Mon, 18 Sep 2023 18:24:48 +0200 From: David Sterba To: Johannes Thumshirn Cc: Geert Uytterhoeven , Chris Mason , Josef Bacik , David Sterba , Qu Wenru , "linux-btrfs@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/4] btrfs: fix 64bit division in btrfs_insert_striped_mirrored_raid_extents Message-ID: <20230918162448.GI2747@suse.cz> Reply-To: dsterba@suse.cz References: <20230918-rst-updates-v1-0-17686dc06859@wdc.com> <20230918-rst-updates-v1-1-17686dc06859@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 18 Sep 2023 09:37:06 -0700 (PDT) On Mon, Sep 18, 2023 at 03:03:10PM +0000, Johannes Thumshirn wrote: > On 18.09.23 16:19, Geert Uytterhoeven wrote: > > Hi Johannes, > > > > On Mon, Sep 18, 2023 at 4:14 PM Johannes Thumshirn > > wrote: > >> Fix modpost error due to 64bit division on 32bit systems in > >> btrfs_insert_striped_mirrored_raid_extents. > >> > >> Cc: Geert Uytterhoeven > >> Signed-off-by: Johannes Thumshirn > > > > Thanks for your patch! > > > >> --- a/fs/btrfs/raid-stripe-tree.c > >> +++ b/fs/btrfs/raid-stripe-tree.c > >> @@ -148,10 +148,10 @@ static int btrfs_insert_striped_mirrored_raid_extents( > >> { > >> struct btrfs_io_context *bioc; > >> struct btrfs_io_context *rbioc; > >> - const int nstripes = list_count_nodes(&ordered->bioc_list); > >> - const int index = btrfs_bg_flags_to_raid_index(map_type); > >> - const int substripes = btrfs_raid_array[index].sub_stripes; > >> - const int max_stripes = trans->fs_info->fs_devices->rw_devices / substripes; > >> + const size_t nstripes = list_count_nodes(&ordered->bioc_list); > >> + const enum btrfs_raid_types index = btrfs_bg_flags_to_raid_index(map_type); > >> + const u8 substripes = btrfs_raid_array[index].sub_stripes; > >> + const int max_stripes = div_u64(trans->fs_info->fs_devices->rw_devices, substripes); > > > > What if the quotient does not fit in a signed 32-bit value? > > Then you've bought a lot of HDDs ;-) > > Jokes aside, yes this is theoretically correct. Dave can you fix > max_stripes up to be u64 when applying? I think we can keep it int, or unsigned int if needed, we can't hit such huge values for rw_devices. The 'theoretically' would fit for a machine with infinite resources, otherwise the maximum number of devices I'd expect is a few thousand.