Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp1060049rdf; Wed, 22 Nov 2023 04:48:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IGOAZ4WDaSLo4jzCq+GH8zdFwmJuanntAjlcY1gOmrAGEuylnN1SWiCrBS06Tp798FfoxnD X-Received: by 2002:a05:6a20:7d93:b0:180:e2b8:3b0e with SMTP id v19-20020a056a207d9300b00180e2b83b0emr2256751pzj.50.1700657292867; Wed, 22 Nov 2023 04:48:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700657292; cv=none; d=google.com; s=arc-20160816; b=jqDNAspfLRoiFDJZCdv+NHQc9zn/3QxKtVnRKY9cFYslzJgaYkLXmZ4Ur0yG5GiEmF oNEaWIfwcj2JUv3aCcHkNWshxx84mgGw31ioT8ckDDM2wD4h08/SkUJmKtIx41GbjEWd 9+GMRM+w0ByVKKonKtGD6/UuWPh1f0wNJW+LdQUA4hGbkrGu8Yv70HywRsIq/8bLQgty vX0U66rYb9ryCxYH6HbaFgFlFR7dK4hlt+6dfxEQczInwXE7WQVqcMQadbDFwQEgR+zv RtlHwZwVcI7xFrxVeqjHKSA8Sjgv0zlZx1uw5PXnRkftmgym3mb7SmwKbygTYHMNGCX4 V3QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/lJjJofj7oNx1tsDn6G0hMP38tInZAYQWY3bOgST5Os=; fh=pdrz9pMzRxXRsEfkPMQMOkzwqdTTXkIQqo5S3UnXMrg=; b=lsIp6GgtwRq/9UBouGPTflgOMMdn80y0AnOSHQOMZxe82kkrZrNwdUCcjOrutxUX9x S/856yDQrgDGxRvq8IKrHIhSaIFyGrF98J99d85aA0Jr1R0VZAYE0PcmzrnBnFViUuvO ZF7i3N0d/wc1pnWv+XYJud4Z22N9Arypa3hq/07inhSFpzFzXuu5MeixDBj1oB9rQcZr a74OMBsM8mtsTOe7DW2Ah7JM+wPcWrF2hjudQnGYO7rSXpFi4ny1+amNtCqyLyWqx03E 909UVVBns7CmmR0U6+Ins7jNv55PRhgkqnRzSp1PyXqIfDnpcmDeEeY8RYVlCnNJA+3j Jmwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=qxZN1SnO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id w28-20020a63161c000000b00584ca25959csi12392434pgl.540.2023.11.22.04.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 04:48:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=qxZN1SnO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 4026D81CA3E6; Wed, 22 Nov 2023 04:48:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343685AbjKVMsB (ORCPT + 99 others); Wed, 22 Nov 2023 07:48:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234981AbjKVMsA (ORCPT ); Wed, 22 Nov 2023 07:48:00 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3FDED8; Wed, 22 Nov 2023 04:47:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=/lJjJofj7oNx1tsDn6G0hMP38tInZAYQWY3bOgST5Os=; b=qxZN1SnOPNClHqFezkQCZQ/Rqa pwvqtIgipYYwuLG4w4DXTwRA6S9MMqR2uvMFW3Gf4kqjZ7xVfouTzchMBs+fZg5d3Od+HztJxYxkS jnv2gEQIbjnSgs3lsgkfLRa2YA/uHbmUrBnMrvnMwvdn8aVi72COnshOnLZ9jS0w9qt+ZPVTwl0Tc GvRfpZ1/g8sqOJB+Lda3fLPrj/zPoZiyIx3IrmsjihFoDY2M/8aUooyGvU3C1GtWyBZ7JJwRNppZf NrIxAZlZUGX0n2FHNjfe1pa4estJTHovJ2NSFRLDStS8E3q3yyZBZgt3Iarz4OEePPD1ulv3RnOu/ iT8r6zvg==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1r5mdz-001qmi-2z; Wed, 22 Nov 2023 12:47:51 +0000 Date: Wed, 22 Nov 2023 04:47:51 -0800 From: Christoph Hellwig To: Ming Lei Cc: Christoph Hellwig , Yu Kuai , axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: Re: [PATCH v3 2/3] block: introduce new field bd_flags in block_device Message-ID: References: <20231122103103.1104589-1-yukuai1@huaweicloud.com> <20231122103103.1104589-3-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Wed, 22 Nov 2023 04:48:10 -0800 (PST) On Wed, Nov 22, 2023 at 04:19:40PM +0800, Ming Lei wrote: > On Tue, Nov 21, 2023 at 11:53:17PM -0800, Christoph Hellwig wrote: > > On Wed, Nov 22, 2023 at 03:45:24PM +0800, Ming Lei wrote: > > > All the existed 'bool' flags are not atomic RW, so I think it isn't > > > necessary to define 'bd_flags' as 'unsigned long' for replacing them. > > > > So because the old code wasn't correct we'll never bother? The new > > flag and the new placement certainly make this more critical as well. > > Can you explain why the old code was wrong? > > 1) ->bd_read_only and ->bd_make_it_fail > > - set from userspace interface(ioctl or sysfs) > - check in IO code path > > so changing it into atomic bit doesn't make difference from user > viewpoint. > > 2) ->bd_write_holder > > disk->open_mutex is held for read & write this flag > > 3) ->bd_has_submit_bio > > This flag is setup as oneshot before adding disk, and check in FS io code > path. On architectures that can't do byte-level atomics all three can corrupt each other, and even worse bd_partno. Granted that is only alpha these days IIRC, but it's still buggy.