Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp912282rdf; Tue, 21 Nov 2023 23:29:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWU6zw3lhGTi3A3t2Y/p8uk/RHrCp8EV4UFlVnKvvVFo/ZIyJBSJvHyoWiSXhxrozMzbM8 X-Received: by 2002:a17:902:db02:b0:1cc:482c:bc54 with SMTP id m2-20020a170902db0200b001cc482cbc54mr1745931plx.48.1700638153617; Tue, 21 Nov 2023 23:29:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700638153; cv=none; d=google.com; s=arc-20160816; b=yisaQ4oEV00RqqUBRIEPB/R3rYgKgtXcEuXQcB6jSASBkt2+ew8XmeA4FTUkfGR7lA FYQw+uJQEKSmFSgIK68Nvjlk6r9o+sAMnKoMIrf5RhIrQRjXaq2ylBhx6JtWdrGME9NE R1kMvOX59pUOzdocZzAOBKLv70XyUUK0ZZxU/R3zjS6KsMnnoSWoR+6GiiDu1O//rwHE bgaUy+PawOgegotAf001n7XyzTHVh0L1h0df+/hKKxeUuruJm9/twA2fjM82332kq2KN mIK5HomqH9p8QFnDE64CDQB4ogTz6rFiUovpvVlnpcxtW8Khf3n2pXuOv+VNzwseT9OO G/dA== 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=xKzadQBp86OPkvjkpX1NPj8LtoV9+7VhbqtkMJ7c0p8=; fh=UYZ16plG818q2QhvqtnEN6ieY6S+xg7EzzDgjDIXUNw=; b=y1XV2avwOyCAVj5fNyMHAixd4Nk2TwlsB9JC3fC83D/3JNk6qoO0mKt/nL80Y6/HNk fGX5o7CLDmxsUUapYvPLaFGWviIl4qO8UQ3gRD7JfaC4vERLZFvb0Aky/utGAp+uQ24r IZ99tQAkVbhAqinnrGcMwt+uKaRHfYQAV7xkNrPcR+b9v6Mv++zkP5O0mPzkoBerA2ex ooz+dSDEdKDAoPsmnxUar1VWM4HpQxp4PaXM0vLRBapOVm7MK6xymSHL3RL6vJBvc7Y2 dB8j+W89vAzPL34q1JPXPX1B9+dvdR5YVzm5P/Y+aEtHhReaZsYs81LKjndtT4PeowTE 5hBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=R6YRWtxa; 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 e9-20020a170902d38900b001c9c3f327e1si11894594pld.191.2023.11.21.23.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 23:29:13 -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=R6YRWtxa; 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 33147803B704; Tue, 21 Nov 2023 23:29:11 -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 S230161AbjKVH3E (ORCPT + 99 others); Wed, 22 Nov 2023 02:29:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230062AbjKVH3D (ORCPT ); Wed, 22 Nov 2023 02:29:03 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F469D1; Tue, 21 Nov 2023 23:28:59 -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=xKzadQBp86OPkvjkpX1NPj8LtoV9+7VhbqtkMJ7c0p8=; b=R6YRWtxaLw6jG2S3GfiNe5UL1W 19YrMm3BTQIFpje67cz9XGp2xu4KuwhFCVHLKcNW2+0JoczOf/E8SKNVh5osjmP34/iXSvALyTC82 OkXvMx5oCWyGdg8JPzbGfB40hjvB7m0gJNPgFMzY2VlSP8ZC2B4eY2V3vD1lJMrNl2qR1juBD73Si cNtjziHq1vutkQd2+v0taG733jkz2D8q7Et5FUwa0YdwWe1ASzGoVkn2/7j0YcVA/JQJfSwGHWamy qhtwVIRX6jaRKN0iZ/3Obpbc+oS9n3xHzMp3jmHjRQJQQ0QIS5wZEoOjF5+X78OgOHMDwIdUIT752 eZZU8d+A==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1r5hfM-000uPI-0t; Wed, 22 Nov 2023 07:28:56 +0000 Date: Tue, 21 Nov 2023 23:28:56 -0800 From: Christoph Hellwig To: Yu Kuai Cc: ming.lei@redhat.com, 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: <20231122103103.1104589-3-yukuai1@huaweicloud.com> 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]); Tue, 21 Nov 2023 23:29:11 -0800 (PST) > + if (partno && bdev_flagged(disk->part0, BD_FLAG_HAS_SUBMIT_BIO)) > + bdev_set_flag(bdev, BD_FLAG_HAS_SUBMIT_BIO); > else > + bdev_clear_flag(bdev, BD_FLAG_HAS_SUBMIT_BIO); While the block layer has a bit of history of using wrappers for testing, setting and clearing flags, I have to say I always find them rather confusing when reading the code. > +#define BD_FLAG_READ_ONLY 0 /* read-only-policy */ I know this is copied from the existing field, but can you expand it a bit? > +#define BD_FLAG_WRITE_HOLDER 1 > +#define BD_FLAG_HAS_SUBMIT_BIO 2 > +#define BD_FLAG_MAKE_IT_FAIL 3 And also write comments for these. > + > struct block_device { > sector_t bd_start_sect; > sector_t bd_nr_sectors; > @@ -44,10 +49,8 @@ struct block_device { > struct request_queue * bd_queue; > struct disk_stats __percpu *bd_stats; > unsigned long bd_stamp; > - bool bd_read_only; /* read-only policy */ > + unsigned short bd_flags; I suspect you really need an unsigned long and atomic bit ops here. Even a lock would probably not work on alpha as it could affect the other fields in the same 32-bit alignment.