Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp918445rdf; Tue, 21 Nov 2023 23:47:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWUya2CGwn8fhtFk06TqsYBOUiKDxzBLgMNFVPaAvVjpip0sycTV7C0+af9ZXWs3CI3juK X-Received: by 2002:a05:6a20:8ca6:b0:18a:d7a8:5e5a with SMTP id k38-20020a056a208ca600b0018ad7a85e5amr1478173pzh.58.1700639242154; Tue, 21 Nov 2023 23:47:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700639242; cv=none; d=google.com; s=arc-20160816; b=YvuOqjGdj8Y1e1yh+Zl4ap+s1N1IkcAdXuQR9LdpcUWzlKltwRKOxJmX/fI5CvK0Iu Ynxowssr3iv3r3p9OQuD2iT4vc/Pd1C0EmGWK5UNsJZtxIHe3lehKNBipsW/orSyVswx jaaSmqTSZe+5+TxXZaZuq5nRlxAXiBM20GAKNVssbXrwUWo3D57e9epMtGiXL1TwkXg1 N+EVoayC9JjAyByRkA1sOAGMN9q/OgTWA4gWBl6Ui9vT89Jh2joh2PPLANIkCBeTOHgn ZApoOVCzoPDWNm5FiYPsus9CB41X37VFt+YMLUaQug3aIdf001D98WQSeMQpj2SmkOQY zYsw== 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=jTGOOSKEq2M9Q7E6uQFEx6Kxv1A8e9evjKXYaodJf9c=; fh=2+37wnsYfbqDmMaw6l0SemXKjfRlbprXZEyTyAU6X3k=; b=nQcc+rPoXyYcAoS/o4G5BVKU0rU3FY1T4ZSWRoy6Enby82gKs5D9h1dT4wNXeLWGUA 1paZ+1X+VXO7zWOiVcgWPr/XaHfdgMp9iOY4DzW3ErRymskDcWVZ4R3/3Dj6rM1DjMoH GchMuMwETI2nlUZl/oZtF+QlEyS2xWrbcqPmOmxLhJVqri1r377jWGnAAWFtuxzqd8vH UWy9f2t5yTmP6WnzN74qDnoR7r54VJ9ZDmjLic6FBH8+HDbLxFcHyZOQZiYP+BqSKADe kvllK8H2TCxTOpU7bSIb5iIiKLl5dL10RI7OScF4d4lllRi9cWGWUiC04eFGTg3YfGhx yWoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fuDfCiod; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id q11-20020a17090a9f4b00b00285150b2f9asi965569pjv.180.2023.11.21.23.47.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 23:47:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fuDfCiod; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 9BA7D80C47AB; Tue, 21 Nov 2023 23:45:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230113AbjKVHpo (ORCPT + 99 others); Wed, 22 Nov 2023 02:45:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229931AbjKVHpn (ORCPT ); Wed, 22 Nov 2023 02:45:43 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8A6C197 for ; Tue, 21 Nov 2023 23:45:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700639138; h=from:from:reply-to:subject:subject: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=jTGOOSKEq2M9Q7E6uQFEx6Kxv1A8e9evjKXYaodJf9c=; b=fuDfCiodXAofXvsRSVjGucwJWNjsQCBN8/GCIE0rq6ztvRUKcC7SgxuwiCQW2CqlHPG6TD npe/OtnN2O1mNlIdEwIXZUeq5Slez66t3moF/o3tAVu+6+U6SYaa6/MwxAZbGYbb4DDQCd 3Kfb7MfB8LqLKDUCp+ck01uXfYSh7uM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-518-d6584vmDO0Wf2Ns6rQrEnw-1; Wed, 22 Nov 2023 02:45:34 -0500 X-MC-Unique: d6584vmDO0Wf2Ns6rQrEnw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BA5FE89C666; Wed, 22 Nov 2023 07:45:33 +0000 (UTC) Received: from fedora (unknown [10.72.120.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09A8640C6EB9; Wed, 22 Nov 2023 07:45:28 +0000 (UTC) Date: Wed, 22 Nov 2023 15:45:24 +0800 From: Ming Lei To: Christoph Hellwig Cc: 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-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,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 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]); Tue, 21 Nov 2023 23:45:57 -0800 (PST) On Tue, Nov 21, 2023 at 11:28:56PM -0800, Christoph Hellwig wrote: > > + 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. 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. Thanks, Ming