Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4931307iob; Mon, 9 May 2022 05:08:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzYJCXektuuVx3zthhFPknBdC+LaLEXNwkBf5i2p5DXIZBzz5ZIeluLuaOZsQIoBmhjbBs X-Received: by 2002:a17:902:d4c2:b0:15e:abd0:926f with SMTP id o2-20020a170902d4c200b0015eabd0926fmr16161134plg.129.1652098097392; Mon, 09 May 2022 05:08:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652098097; cv=none; d=google.com; s=arc-20160816; b=eKiOSPmJR2GZTvnf652PzrB6bBMkB/YcHy/AFwqVrrcVB7fKf+FU4j5aJDFqbtyEA/ R0LRGhl3IssopUeIOY0W9cWlRkm4MvAiBfnZ6tA5W2lNq5VQaWkelia7q36+Vszp8Z4r EjnmOe5GYpUzrKOgbgoX/yMbyVh32iV+RfE0DH+syTS+37mTVR0gNq8LAN6yTnu6kzht dkVDnlBpEmMXHE1ivWCHL0MTY724R2k5PNHuFAORhhsqmk+9AXAz/JeFHIKqB7fZLXS7 FifhgD2aNeCJ+FEgn6+wGap9qRm6fEegaWwQJaJC8tQFSiKL+QHkrJWkwmb/ccPPLHek 2SFg== 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 :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature :wdcironportexception:ironport-sdr:ironport-sdr:dkim-signature; bh=R7p++eFkOmpFxyhEfVZjPFTiO7RXQjBryk+5g+fzIW4=; b=QrmqfNSCvjV6Zq3a4T17+m8gQxQRpy+wu2xsbrj4MGpBx3XlX3ZrMPYOz+d7yKvnT1 JMoYu6nDmpo5yJDNdzSXDO5uiPRnMyO/RW6npL27Ni5KvdN7W4ytCZXJUWvHg2pu3KBD eJELOI17s46/EUA+9kqZ54cEcYT9yck6qWJV0kjU5DNE455Uy743Ufx7X+kVaAP3LQ0C 9sDqirnlG+8c399D75G1nqLEBwTLj3rEIUPQ4QsEZlQy62w6e+KkZM/tSiNg+xhvHTIC 3yGpmjijPsjTO4qOESWxL6/qo3nx1drCO3Jl/JmODcqRnF5R3WuhYU0mEn+liVVk0hWE yYdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=CA2+t0av; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b="E/S7+ftC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x11-20020a17090a8a8b00b001dcaebe4c87si14008148pjn.34.2022.05.09.05.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 05:08:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=CA2+t0av; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b="E/S7+ftC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=opensource.wdc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DDEFE1DFDA1; Mon, 9 May 2022 04:32:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232849AbiEILgW (ORCPT + 99 others); Mon, 9 May 2022 07:36:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232114AbiEILgD (ORCPT ); Mon, 9 May 2022 07:36:03 -0400 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A63171DE56E for ; Mon, 9 May 2022 04:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1652095930; x=1683631930; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=v0lVI0gmiUvzoNmI5a0guGMpgDZX+uKFFD4KLqB/fQU=; b=CA2+t0avAnITT5MNseqitpiLsf/TgdwP4pQJj9r9feebQes73Q3iK5iD /EUakjrzIdM5sueaDZ7YXMuaaJhke6b/Exgshe40Ceu4pQAcunFkcjeUm FKhA2O9N2M2gRUL4FNPSaczi7RZVlbeUlEW924OeUkFb2D34pl1/Ibire ddoTjjdt/tpWys4vqz2zRWQztPJC2EvfpolbbOvTR+K1nc2mPX77iuiVg wvqGRTctOmaX4rXegdTYx95FC4OE6UEva+pD7Ao9rNYxNs/kLRocAOoim QQUXL0F2SAqYYW8LdrTU0IXUTDe0n4lhzw2dPHQ0Ug/0ok8Iov0QMPd6L A==; X-IronPort-AV: E=Sophos;i="5.91,211,1647273600"; d="scan'208";a="200733502" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 09 May 2022 19:32:09 +0800 IronPort-SDR: OYoxTPElI/N9nyV1TVqEoaLGCH9dlkiws3xf/LosMXJik3uGKW6efzch8cDxryfLdXfCOUBlM4 vQVZkOSS5ep6brfomhJM1cRDFMmHG9A2sepw1s/n6oYdYp4MjKmPIcFpet96rHbsZXFyVksU1e K0u2RV8mmRWMbFEL8a+Qp94V64OrYrj4JhVRojPn8lcgCL/Pw8rM48cvWEW6pOjzcFusLzdtYg TbhoONlDIVZkFXN3/GCdprGLd1c26qkdj+9ao9SW7wqT4MuQmU0QkJUeF57qTn6/l1I57gd4t5 3YMe7GSDX8yvmUCg4c9AmI3k Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 09 May 2022 04:02:13 -0700 IronPort-SDR: d8PfF+UF7oZF9tNAHT0SP0G9aqIQLAkb3Y8ZbpngkuC0xffh9aDIuz3LECMyBmCujsxUdWumxb rAuqXBqTCOglt39VzKnZXgmhkt66oBfk8ieFpBe64p989RwH/RKxPDqqjojZjKJY9OYacxSbQU DIivcsIIH9cbti4LsCAhe6s6Z0xK1TpraT2hRDeXsSxBI8oFFg1pLlGjuvhjyZgC/I2XkLrATn lOobGcl9gTElTbvguUqFVDhxLWgf0xmPrn5Pv+PITay1bpAoROAFOh+zfZa5vfZIYFRiFIhkDs /h4= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 09 May 2022 04:32:07 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4KxfCW0tdGz1SHwl for ; Mon, 9 May 2022 04:32:07 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :in-reply-to:organization:from:references:to:content-language :subject:user-agent:mime-version:date:message-id; s=dkim; t= 1652095926; x=1654687927; bh=v0lVI0gmiUvzoNmI5a0guGMpgDZX+uKFFD4 KLqB/fQU=; b=E/S7+ftCKDojRwdfWfMiCt2FBFS6P6O4vQv9CY0mSrWKcOA/TUZ cINZhwkUJYr2VgFPHiRT6KCIT63B1UNrpbQrpHSC1d6EEDVjfyCzgGRo25Yk+Mak ke234L+h8WlpCNwP12dZFkUA1RUzY8bhjo/4g7dLD/EYNiArXQLxsSKwun2bK3Ud 0wdN4f58GNZYl3Y6Xy2a/6WnwZ19GsujmmSXyN8pGC3Pw9VYMxpmDi/CSROhi8Gv ZaE8OWsdQY3K0YdfRMnjbNkDESbv3xgPsyP35A+xnGM6iDPATqr5gNEjatknRWB9 QJziNpUStccPtJO2rPx1Sa+x/ad4k2zfTDw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ZaClWmvwbvBZ for ; Mon, 9 May 2022 04:32:06 -0700 (PDT) Received: from [192.168.10.49] (unknown [10.225.164.111]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4KxfCM384lz1Rvlc; Mon, 9 May 2022 04:31:59 -0700 (PDT) Message-ID: <9eb00b42-ca5b-c94e-319d-a0e102b99f02@opensource.wdc.com> Date: Mon, 9 May 2022 20:31:57 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v3 10/11] null_blk: allow non power of 2 zoned devices Content-Language: en-US To: Pankaj Raghav , jaegeuk@kernel.org, hare@suse.de, dsterba@suse.com, axboe@kernel.dk, hch@lst.de, snitzer@kernel.org Cc: Chris Mason , Josef Bacik , bvanassche@acm.org, linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com, Jens Axboe , gost.dev@samsung.com, jonathan.derrick@linux.dev, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, dm-devel@redhat.com, Naohiro Aota , linux-kernel@vger.kernel.org, Johannes Thumshirn , Sagi Grimberg , Alasdair Kergon , linux-block@vger.kernel.org, Chaitanya Kulkarni , Keith Busch , linux-btrfs@vger.kernel.org, Luis Chamberlain References: <20220506081105.29134-1-p.raghav@samsung.com> <20220506081105.29134-11-p.raghav@samsung.com> <39a80347-af70-8af0-024a-52f92e27a14a@opensource.wdc.com> From: Damien Le Moal Organization: Western Digital Research In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/05/09 20:06, Pankaj Raghav wrote: > >>> diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c >>> index 5cb4c92cd..ed9a58201 100644 >>> --- a/drivers/block/null_blk/main.c >>> +++ b/drivers/block/null_blk/main.c >>> @@ -1929,9 +1929,8 @@ static int null_validate_conf(struct nullb_device *dev) >>> if (dev->queue_mode == NULL_Q_BIO) >>> dev->mbps = 0; >>> >>> - if (dev->zoned && >>> - (!dev->zone_size || !is_power_of_2(dev->zone_size))) { >>> - pr_err("zone_size must be power-of-two\n"); >>> + if (dev->zoned && !dev->zone_size) { >>> + pr_err("zone_size must not be zero\n"); >> >> May be a simpler phrasing would be better: >> >> pr_err("Invalid zero zone size\n"); >> > Ack. I will change this in the next rev. >>> return -EINVAL; >>> } >>> >>> diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c >>> index dae54dd1a..00c34e65e 100644 >>> --- a/drivers/block/null_blk/zoned.c >>> +++ b/drivers/block/null_blk/zoned.c >>> @@ -13,7 +13,10 @@ static inline sector_t mb_to_sects(unsigned long mb) >>> >>> static inline unsigned int null_zone_no(struct nullb_device *dev, sector_t sect) >>> { >>> - return sect >> ilog2(dev->zone_size_sects); >>> + if (is_power_of_2(dev->zone_size_sects)) >>> + return sect >> ilog2(dev->zone_size_sects); >> >> As a separate patch, I think we should really have ilog2(dev->zone_size_sects) >> as a dev field to avoid doing this ilog2 for every call.. >> > I don't think that is possible because `zone_size_sects` can also be non > po2. But when it is we can optimize that. All we need is add a "zone_size_sect_shift" field that is initialized when zone_size_sects is set when the device is created. Then, you can have code like: if (dev->zone_size_sect_shift)) return sect >> dev->zone_size_sect_shift; Which avoids both is_power_of_2() and ilog2() calls for every IO. -- Damien Le Moal Western Digital Research