Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1569215rdb; Wed, 20 Sep 2023 12:55:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEL8fjjzvcFeE8Wxsc8WDrDB7+M1/cRI4bsCAKaJaxdUDVGDLp/Y7E+UF/jBjQXMbsiI4iD X-Received: by 2002:a05:6a20:144c:b0:13e:90aa:8c8b with SMTP id a12-20020a056a20144c00b0013e90aa8c8bmr5209863pzi.4.1695239734003; Wed, 20 Sep 2023 12:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695239733; cv=none; d=google.com; s=arc-20160816; b=M4sMusrLV1weWK6IxN6/dzK8RVPvyBxdJmaLZuYihFkXILyCF+QRlOpGtP2cLv3fkm DXUPmgXctkK8gq3X+6KAZ1aH6pxGKp90fgfFa8eN8+PZRW70u2F2xehWBfgk5oERciYq M8DS1ecKQ0tuIPsvkyjn93ak/ttEPzFIkVrzuTdhj07PbftuSmx+zoqCXq2cJqf9A1tg ApnyFOLEeDrAOtOGiqzHyTA3Ve1wbgab4t62Sy3o481RkNJgvzQ8omzkfLSCQdg/XCDn PybApG+NbrDrr11ClwaDs96Dfl0pBvHnjVwed0qGZpS3lZidHrr72aXXmlHjuotpw/Ff 0fMg== 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-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=qGHbOYY7FsnjaS3nEMPoYfjC2fCOhS5YY3UGPdYWWqA=; fh=n0VfwU14tfXTWFHpWQ7LQEOn1uDhMXSRNYv3HpqCLJ4=; b=MY8+xZb35BZYFiZnuvOqANSy2+ymemQH91NGNQJnkHpT6UScAueQ51skdHHTSNQJ4H lUzNc0CzZu6m7jaGtrEK9O+VUfSD//hgWIVuEKJtEfrRNzuTgJr4OHSTeMz8Qu0J4hTV aZwo5ayO4JZ+TH7SpisP01lr9dCXSqCT77KWfXXKntQXdTo5znbCGXqvvUnxa2514Zvt MdfzoPm01BDfncCzOz1wVjnDkhBdu5m17WGXNcwFnaJkGUOrosB6mUfuAQIfxxqoinxV k5v8OlYr8v70yCEtUOX9WwIJ4mUtYg2ErxybK7zRJiHexfvBnUKUUBl95aq92/UUgNHH jLxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=eUEUXDPJ; dkim=neutral (no key) header.i=@suse.cz header.b=f87QlHrO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id p4-20020a639504000000b0055e607f1e99si2590421pgd.882.2023.09.20.12.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 12:55:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=eUEUXDPJ; dkim=neutral (no key) header.i=@suse.cz header.b=f87QlHrO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 63203809E20E; Wed, 20 Sep 2023 08:41:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236704AbjITPks (ORCPT + 99 others); Wed, 20 Sep 2023 11:40:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236627AbjITPkq (ORCPT ); Wed, 20 Sep 2023 11:40:46 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA309D9; Wed, 20 Sep 2023 08:40:38 -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 8093122008; Wed, 20 Sep 2023 15:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1695224437; 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: in-reply-to:in-reply-to:references:references; bh=qGHbOYY7FsnjaS3nEMPoYfjC2fCOhS5YY3UGPdYWWqA=; b=eUEUXDPJpfeyk0v2ba1gL0uQKM+jaVmIO63x8U5ylhQzfXlh8sClPT8caUaVp1Okm1lvDH vkSmEXH5KFJtIEIx5rkx3XuwqyJRvNxg5RHjnl+ynx4ocAGvtvLd7bIi9mQqVlzBub0ivQ XKWoywhL5PGOnZrOHiQu3M8EEHa9P6w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1695224437; 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: in-reply-to:in-reply-to:references:references; bh=qGHbOYY7FsnjaS3nEMPoYfjC2fCOhS5YY3UGPdYWWqA=; b=f87QlHrOYk6ACyn7nYXDy+EjkZ/aqwGw6soUlxxliaVK2q1+VSJYLg0A7BWUvXuhR2zpl3 gypAKvtw9+KA7uBw== 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 37275132C7; Wed, 20 Sep 2023 15:40:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id waTIDHUSC2XXTAAAMHmgww (envelope-from ); Wed, 20 Sep 2023 15:40:37 +0000 Date: Wed, 20 Sep 2023 17:34:03 +0200 From: David Sterba To: Qu Wenruo Cc: dsterba@suse.cz, Johannes Thumshirn , 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: <20230920153403.GD2268@twin.jikos.cz> Reply-To: dsterba@suse.cz References: <20230918-rst-updates-v1-0-17686dc06859@wdc.com> <20230918-rst-updates-v1-1-17686dc06859@wdc.com> <20230918162448.GI2747@suse.cz> <20230919135810.GT2747@twin.jikos.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 20 Sep 2023 08:41:22 -0700 (PDT) On Wed, Sep 20, 2023 at 07:20:49AM +0930, Qu Wenruo wrote: > >>>>> 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. > >> > >> In fact, we already have an check in btrfs_validate_super(), if the > >> num_devices is over 1<<31, we would reject the fs. > > > > No, it's just a warning in that case. > > We can make it a proper reject. > > > > >> I think we should be safe to further reduce the threshold. > >> > >> U16_MAX sounds a valid and sane value to me. > >> If no rejection I can send out a patch for this. > >> > >> And later change internal rw_devices/num_devices to u16. > > > > U16 does not make sense here, it's not a native int type on many > > architectures and generates awkward assembly code. We use it in > > justified cases where it's saving space in structures that are allocated > > thousand times. The arbitrary limit 65536 is probably sane but not > > much different than 1<<31, practically not hit and was useful to > > note fuzzed superblocks. > > OK, we can make it unsigned int (mostly u32) for fs_info::*_devices, but > still do extra limits on things like device add to limit it to U16_MAX. > > Would this be a better solution? > At least it would still half the width while keep it native to most (if > not all) archs. I don't see much point changing it from u64, it copies the on-disk type, we validate the value on input, then use it as an int type. There are not even theoretical problems stemming from the type width. With the validations in place we don't need to add any artificial limits to the number of devices, like we don't add such limitations elsewhere if not necessary.