Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2212233rdb; Mon, 20 Nov 2023 05:25:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/ePAL5UfIv9O6LUeYOUNtCm7ddJUqZChR4gcLFNkf9vRalPOWFCfjAQtZJy7ifwNJ/uhy X-Received: by 2002:a05:6a21:788e:b0:187:4118:c0ee with SMTP id bf14-20020a056a21788e00b001874118c0eemr9897121pzc.46.1700486711043; Mon, 20 Nov 2023 05:25:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700486711; cv=none; d=google.com; s=arc-20160816; b=LiRUpdf1H774hBb/MEr/6cLVC+lA1rwyhJeBXgciXLkJ3qnUc86pzCJa1cG5/iK+1k rlXbZQhjlvMxh9xzKReZSBrH63J+rPLiQG/3uCCE5wUgOctMrHU0VwTF4JuTA4v43ZnR nKQtEUF/8C7r84LR+tv3dMOBCNE+WB6OZOek1br51WkcJ8ju6fYqphY41JDUDokf0G18 tJiuhx+ZWWDHuFypJDHPlRyJ6MZyBmOckvAquuo4Sa6gHaA9omONaa1orQbRO9I2CU0N qtKAsHGSmhCmDQW2+/p94gJfuDfCXyR6Zfkqnc25L0IQSckScVWDH46cE9rUIMYlxNjy OEqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=4hjAmKH3FAmGdFmnORyrpY8yLZaloEvEMnGFQNsf13E=; fh=AC18sRYWtWlffYAZ+MQvgd/wWCW2Fn4he/HJwhdW3OQ=; b=qqYKMmcZ/YNDUTLAfdsFGvzvn+/w9y51fog8z2UqNypTWI09j7xxhs4h0SjPe6L95O Vc4JqwQmxAWDldNTXmXpUMYT//yNKjFnnPORizSb8AFAGfuU7nKc0/VIbsDcHae2OAm3 CRJwr5I2kYQM0vtp6m/eiJxDEotP9lRCJNFPjAuz7d7u9HZm3D7FOZu2jH5JbvVG1T/X YijUx0O0f+h4o/Jz709OBw3L7Fjk6Tf1LJkF/JNrIpL8tqEGoBhOsEoBBrhAZ3a7BLeZ L6adUwWpiPwGONcjof054HgY0p6Eas5Pn5KsCG71wvAdQQIb4piM9pH07j9rBSDxyis/ xUgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id w22-20020a63c116000000b005b9602a7badsi8354538pgf.688.2023.11.20.05.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 05:25:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 55A97807AC62; Mon, 20 Nov 2023 05:25:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232538AbjKTNYW (ORCPT + 99 others); Mon, 20 Nov 2023 08:24:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232984AbjKTNYN (ORCPT ); Mon, 20 Nov 2023 08:24:13 -0500 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8312131; Mon, 20 Nov 2023 05:24:08 -0800 (PST) Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4SYpBB2lMMz4f3knr; Mon, 20 Nov 2023 21:24:02 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id EC84E1A02CA; Mon, 20 Nov 2023 21:24:03 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP1 (Coremail) with SMTP id cCh0CgA3iA7yXVtlJWLJBQ--.22273S3; Mon, 20 Nov 2023 21:24:03 +0800 (CST) Subject: Re: [PATCH 1/2] block: introduce new field flags in block_device To: Hannes Reinecke , Yu Kuai , axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, Ming Lei , "yukuai (C)" References: <20231120093847.2228127-1-yukuai1@huaweicloud.com> <20231120093847.2228127-2-yukuai1@huaweicloud.com> From: Yu Kuai Message-ID: <1338945e-5033-3bb2-0480-7c6767bf0848@huaweicloud.com> Date: Mon, 20 Nov 2023 21:24:02 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgA3iA7yXVtlJWLJBQ--.22273S3 X-Coremail-Antispam: 1UD129KBjvJXoWxAFWxGw1xXF17Zw18CrWUtwb_yoW5Gr1Dpr ykJFy5WrWUGrn5Wr4xJr1UJFyrXw48t3W8Gryaya42yr4UJr1Yqr18Xry0gF17Ar4xJF47 Xr1UJrWkZFyUGrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkC14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcVAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCYjI0SjxkI62AI1cAE67vI Y487MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI 0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y 0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxV WUJVW8JwCI42IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8 JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUoOJ5UU UUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-Spam-Status: No, score=-4.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 20 Nov 2023 05:25:08 -0800 (PST) Hi, 在 2023/11/20 18:45, Hannes Reinecke 写道: > On 11/20/23 10:38, Yu Kuai wrote: >> From: Yu Kuai >> >> There are multiple switches in struct block_device, use seperate bool >> fields for them is not gracefully. Add a new field flags and replace >> swithes to a bit, there are no functional changes, and preapre to add >> a new switch in the next patch. >> >> Signed-off-by: Yu Kuai >> --- >>   block/bdev.c              | 15 ++++++++------- >>   block/blk-core.c          |  7 ++++--- >>   block/genhd.c             |  8 +++++--- >>   block/ioctl.c             |  2 +- >>   include/linux/blk_types.h | 12 ++++++------ >>   include/linux/blkdev.h    |  5 +++-- >>   6 files changed, 27 insertions(+), 22 deletions(-) >> >> diff --git a/block/bdev.c b/block/bdev.c >> index fc8d28d77495..cb849bcf61ae 100644 >> --- a/block/bdev.c >> +++ b/block/bdev.c >> @@ -408,10 +408,10 @@ struct block_device *bdev_alloc(struct gendisk >> *disk, u8 partno) >>       bdev->bd_partno = partno; >>       bdev->bd_inode = inode; >>       bdev->bd_queue = disk->queue; >> -    if (partno) >> -        bdev->bd_has_submit_bio = disk->part0->bd_has_submit_bio; >> +    if (partno && test_bit(BD_FLAG_HAS_SUBMIT_BIO, &disk->part0->flags)) >> +        set_bit(BD_FLAG_HAS_SUBMIT_BIO, &bdev->flags); >>       else >> -        bdev->bd_has_submit_bio = false; >> +        clear_bit(BD_FLAG_HAS_SUBMIT_BIO, &bdev->flags); >>       bdev->bd_stats = alloc_percpu(struct disk_stats); >>       if (!bdev->bd_stats) { >>           iput(inode); > > Couldn't you achieve the very same result by using > 'READ_ONCE()/WRITE_ONCE()' and keep the structure as-is? Yes, remove this patch and add a new bool field in the next patch can work as well, the idea here is replace multiple fields with a single flag, and just use the flag in next patch. If people thinks add a new bool field is better, I'll follow that. Thanks, Kuai > > Cheers, > > Hannes-- > Dr. Hannes Reinecke                   Kernel Storage Architect > hare@suse.de                              +49 911 74053 688 > SUSE Software Solutions Germany GmbH, Frankenstr. 146, 90461 Nürnberg > Managing Directors: I. Totev, A. McDonald, W. Knoblich > (HRB 36809, AG Nürnberg) > > . >