Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4469183rdb; Fri, 15 Sep 2023 03:18:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMnbT+Esg/ElzR+uILh4kM84caOz3fACKhsrU7G/c7g1JJjEYbgZEPVXpkYhqg9yLmWTVI X-Received: by 2002:a05:6358:91a6:b0:141:3a1:1877 with SMTP id j38-20020a05635891a600b0014103a11877mr1539201rwa.14.1694773131072; Fri, 15 Sep 2023 03:18:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694773131; cv=none; d=google.com; s=arc-20160816; b=T29f1AgNoNT4jhLZsEA7tArnt2l+1XNpXiHiaHb8W883848xclIWrMPp918weUJAtM CIayMAr4KMRA8QqpYG+yCbPH21S2B3na646OFoynpd/t6KgKvJZwTyLhl8sziAixvgdP 32LYPBjINrSjgxaMfPTxMigFJQm05U03WmeAl4OeFtwiSsdsjkOCTW5tZy4vS5fsTx07 c9vByCHBNONKd87fMfGhISWkI21fIej6llX6uBz7tJ3MMl8u8K+ARW7X3VbJ+Sob4SC8 /vWuMGikwwveehnDEuQapdOwS28Bcbw1MfJJv//24JmxYF9H6PLj49xffYORAoFLDDTR Z88w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date; bh=brhjJ4v0XYZnt0/Y5RmJlYt+vmLaAsfRXFZ0TwZ0elY=; fh=TEFLw8ITaVe0/YZcfxDHprHdbD565THHKebSs1PlwiU=; b=N9fF62On3nzCHNLVEptdwOkEYBwxuRtk3+2Xpr0QHGizkbePo1Ii4WVGCOqT8ZcSYp O703+D81wS3b1cCXsSTxM2wbccQMaeYXuNf6kFxlhYS9YZyhygEGeStIT0rlMwY8Fc5N OSykcF86f3Ohl/iwBv9GQRkV76bfMvQq/u8i2Y1Ee9yP/8WAXgZGXJef9/rhWypcgVdf jou8OP90FARzyu2+upqNv6cvCnnThdhIAOn0BSKpQtl3gOC6A++NL38ZDK9Xsrsj6AeN 5lRLPOWMUO6ohOvyhF4U8dLovZgkV7H0o5kzLvedkUiVKO6kqnzIzl65LkS0Cso/yg3c TOQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id bs62-20020a632841000000b0057808b558cesi2024181pgb.124.2023.09.15.03.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 03:18:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 6397881B0CDD; Fri, 15 Sep 2023 03:05:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234102AbjIOKFP (ORCPT + 99 others); Fri, 15 Sep 2023 06:05:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234096AbjIOKFN (ORCPT ); Fri, 15 Sep 2023 06:05:13 -0400 Received: from andre.telenet-ops.be (andre.telenet-ops.be [IPv6:2a02:1800:120:4::f00:15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BE4810E6 for ; Fri, 15 Sep 2023 03:03:26 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed40:7135:da8b:ba1d:1a7c]) by andre.telenet-ops.be with bizsmtp id mA3P2A00J3q21w701A3P7m; Fri, 15 Sep 2023 12:03:25 +0200 Received: from geert (helo=localhost) by ramsan.of.borg with local-esmtp (Exim 4.95) (envelope-from ) id 1qh5fX-003lP0-Gz; Fri, 15 Sep 2023 12:03:23 +0200 Date: Fri, 15 Sep 2023 12:03:23 +0200 (CEST) From: Geert Uytterhoeven To: David Sterba cc: Johannes Thumshirn , Chris Mason , Josef Bacik , David Sterba , Christoph Hellwig , Naohiro Aota , Qu Wenruo , Damien Le Moal , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v9 03/11] btrfs: add support for inserting raid stripe extents In-Reply-To: <20230914180701.GB20408@twin.jikos.cz> Message-ID: References: <20230914-raid-stripe-tree-v9-0-15d423829637@wdc.com> <20230914-raid-stripe-tree-v9-3-15d423829637@wdc.com> <20230914180701.GB20408@twin.jikos.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Spam-Status: No, score=-0.8 required=5.0 tests=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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 15 Sep 2023 03:05:31 -0700 (PDT) Hi David, On Thu, 14 Sep 2023, David Sterba wrote: > On Thu, Sep 14, 2023 at 09:06:58AM -0700, Johannes Thumshirn wrote: >> Add support for inserting stripe extents into the raid stripe tree on >> completion of every write that needs an extra logical-to-physical >> translation when using RAID. >> >> Inserting the stripe extents happens after the data I/O has completed, >> this is done to a) support zone-append and b) rule out the possibility of >> a RAID-write-hole. >> >> Signed-off-by: Johannes Thumshirn >> --- /dev/null >> +++ b/fs/btrfs/raid-stripe-tree.c >> +static int btrfs_insert_striped_mirrored_raid_extents( >> + struct btrfs_trans_handle *trans, >> + struct btrfs_ordered_extent *ordered, >> + u64 map_type) >> +{ >> + 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; > > This will probably warn due to u64/u32 division. Worse, it causes link failures in linux-next, as e.g. reported by noreply@ellerman.id.au: ERROR: modpost: "__udivdi3" [fs/btrfs/btrfs.ko] undefined! So despite being aware of the issue, you still queued it? The use of "int" for almost all variables is also a red flag: - list_count_nodes() returns size_t, - btrfs_bg_flags_to_raid_index() returns an enum. - btrfs_raid_array[index].sub_stripes is u8, - The result of the division may not fit in 32-bit. Thanks for fixing, soon! ;-) Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds