Message ID | 20221026165133.2563946-1-kbusch@meta.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp379841wru; Wed, 26 Oct 2022 09:58:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM43adRCbbz/J6csUrepKW5Vr18An2A1PTZJiFq0+Qgh0sPaFo7Wg8arCosEpraPOjtEwF8V X-Received: by 2002:a17:902:8542:b0:179:eb8d:f41d with SMTP id d2-20020a170902854200b00179eb8df41dmr43781179plo.62.1666803495920; Wed, 26 Oct 2022 09:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666803495; cv=none; d=google.com; s=arc-20160816; b=Dfm7F0mQWDyrGkB1ShtZSLYcLu2a7BWAsHzcVf841WzlComPQAUkQWCLn2qWeYR+Ka wUvV24mli4gMj+0fZWqDwX5JuW1/E5Py3COQ8rg+liPU6cP59h+tPOWARkvRmK+14XiZ xIi3q0QPudyqJr1yWG12JJ34SILKxuZodI6neR6ZnM5UziHDZD8NVX/qOtk+JpgSBOy/ WI/sMfqze5ZEnKr7vblwg29BnwqxVlOs/vMb+szWqmd/wcVh5RrVEqbLV64k64ISjhiN kLm7Tgzvha30h1FFD0RszclbwQSEAukDFey6BQzI9j6JfdR/ynZ/wsG0ZRiGeV2sZFyX 2UVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=yweTIcEEup4K70R2eq07Kp6EbZy543M8HDS4MaHQouE=; b=kHSffpoWyPFE5EqpZ43DHzR1q/N0Q7ch7HPwRleCyt1uLTiFrCP1bGyCqS6lGZLGkt 9YZq9nS8iqqSSROgDl4DwpNt6pB84LW6ImPJqp2d2aXvJmovUBzS/S19bUMk3kUPsbOy sCiHukkKxa/t2nrpuslfpBOeY8pTHz75cfu7QTzfbGyEj+T3PlL45S7piOkPz/MiTiU3 BtfHGhz9hARl99D2FunF+uOoH4nxtqUZOvFlxksI7iAD8g8rnLX3Xs3k/C7aJoNrdrvO y+REIXpTsn3IRwSxmj1zTd0h3bj+sa0T6HRX8UVdnAxGHNhys/txbizSqm4+c1JPaPNX bIQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@meta.com header.s=s2048-2021-q4 header.b=KeqUX9C6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=meta.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t184-20020a635fc1000000b0046aeabd6548si4013768pgb.104.2022.10.26.09.58.02; Wed, 26 Oct 2022 09:58:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@meta.com header.s=s2048-2021-q4 header.b=KeqUX9C6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=meta.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233905AbiJZQwH (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Wed, 26 Oct 2022 12:52:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233536AbiJZQwE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 26 Oct 2022 12:52:04 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E21ED5AA04 for <linux-kernel@vger.kernel.org>; Wed, 26 Oct 2022 09:52:03 -0700 (PDT) Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29QFxccJ031022 for <linux-kernel@vger.kernel.org>; Wed, 26 Oct 2022 09:52:03 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=s2048-2021-q4; bh=yweTIcEEup4K70R2eq07Kp6EbZy543M8HDS4MaHQouE=; b=KeqUX9C6evJ19CNbkIyX//kFQ00xpDB38KH+ya2Mr46EC9xid+R9Iyq/WJq/bRXP7Wmv nDNsjRYgZoBPj+EuhQjTWXQsKGUTf5DZ41wlCK9YNhyemfbzFNFRexRHod11QnxjHrIB KP6itgP7A9mfGsff/hc8vbbNkuiRVMDeJjQp88b2iSRKSoadkEgrh3JfbKz/HV68M3Kg UQMQe9Qy3FPqXgxRVxYGBliC8Sn85ZBfjaVvGln3mr1oHM/JfjPBnUXyK1wQ/H9SsD7a cI1f30DSA2q95nwQN+rHl2R/QHhbvtM+HPXTBHhYiUKogJA2fFJ1UmGFLbDYChuMDgxN Ww== Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3ke5sncgsx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for <linux-kernel@vger.kernel.org>; Wed, 26 Oct 2022 09:52:03 -0700 Received: from twshared13927.24.frc3.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:11d::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 26 Oct 2022 09:52:02 -0700 Received: by devbig007.nao1.facebook.com (Postfix, from userid 544533) id 5F861A4B1E3F; Wed, 26 Oct 2022 09:51:53 -0700 (PDT) From: Keith Busch <kbusch@meta.com> To: <linux-fsdevel@vger.kernel.org> CC: <linux-kernel@vger.kernel.org>, <hch@lst.de>, <djwong@kernel.org>, <bvanassche@acm.org>, Keith Busch <kbusch@kernel.org> Subject: [PATCH] iomap: directly use logical block size Date: Wed, 26 Oct 2022 09:51:33 -0700 Message-ID: <20221026165133.2563946-1-kbusch@meta.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-ORIG-GUID: 2wTcft4Q44mXu-rQ9bMYRVmULB6mduX7 X-Proofpoint-GUID: 2wTcft4Q44mXu-rQ9bMYRVmULB6mduX7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_07,2022-10-26_01,2022-06-22_01 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747770142073878410?= X-GMAIL-MSGID: =?utf-8?q?1747770142073878410?= |
Series |
iomap: directly use logical block size
|
|
Commit Message
Keith Busch
Oct. 26, 2022, 4:51 p.m. UTC
From: Keith Busch <kbusch@kernel.org> Don't transform the logical block size to a bit shift only to shift it back to the original block size. Just use the size. Signed-off-by: Keith Busch <kbusch@kernel.org> --- fs/iomap/direct-io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 10/26/2022 9:51 AM, Keith Busch wrote: > From: Keith Busch <kbusch@kernel.org> > > Don't transform the logical block size to a bit shift only to shift it > back to the original block size. Just use the size. > > Signed-off-by: Keith Busch <kbusch@kernel.org> > --- we should also change any other callers like this. Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> -ck
On Wed, Oct 26, 2022 at 09:51:33AM -0700, Keith Busch wrote: > From: Keith Busch <kbusch@kernel.org> > > Don't transform the logical block size to a bit shift only to shift it > back to the original block size. Just use the size. > > Signed-off-by: Keith Busch <kbusch@kernel.org> > --- > fs/iomap/direct-io.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c > index 4eb559a16c9e..503b97e5a115 100644 > --- a/fs/iomap/direct-io.c > +++ b/fs/iomap/direct-io.c > @@ -240,7 +240,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, > { > const struct iomap *iomap = &iter->iomap; > struct inode *inode = iter->inode; > - unsigned int blkbits = blksize_bits(bdev_logical_block_size(iomap->bdev)); > + unsigned int blksz = bdev_logical_block_size(iomap->bdev); /me looks at what blksize_bits does (assumes block size > 256) and rolls his eyes. Regardless, this looks correct to me, so Reviewed-by: Darrick J. Wong <djwong@kernel.org> --D > unsigned int fs_block_size = i_blocksize(inode), pad; > loff_t length = iomap_length(iter); > loff_t pos = iter->pos; > @@ -252,7 +252,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, > size_t copied = 0; > size_t orig_count; > > - if ((pos | length) & ((1 << blkbits) - 1) || > + if ((pos | length) & (blksz - 1) || > !bdev_iter_is_aligned(iomap->bdev, dio->submit.iter)) > return -EINVAL; > > -- > 2.30.2 >
On 10/26/22 09:51, Keith Busch wrote: > From: Keith Busch <kbusch@kernel.org> > > Don't transform the logical block size to a bit shift only to shift it > back to the original block size. Just use the size. > > Signed-off-by: Keith Busch <kbusch@kernel.org> > --- > fs/iomap/direct-io.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c > index 4eb559a16c9e..503b97e5a115 100644 > --- a/fs/iomap/direct-io.c > +++ b/fs/iomap/direct-io.c > @@ -240,7 +240,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, > { > const struct iomap *iomap = &iter->iomap; > struct inode *inode = iter->inode; > - unsigned int blkbits = blksize_bits(bdev_logical_block_size(iomap->bdev)); > + unsigned int blksz = bdev_logical_block_size(iomap->bdev); > unsigned int fs_block_size = i_blocksize(inode), pad; > loff_t length = iomap_length(iter); > loff_t pos = iter->pos; > @@ -252,7 +252,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, > size_t copied = 0; > size_t orig_count; > > - if ((pos | length) & ((1 << blkbits) - 1) || > + if ((pos | length) & (blksz - 1) || > !bdev_iter_is_aligned(iomap->bdev, dio->submit.iter)) > return -EINVAL; Reviewed-by: Bart Van Assche <bvanassche@acm.org>
On Wed, Oct 26, 2022 at 09:51:33AM -0700, Keith Busch wrote: > From: Keith Busch <kbusch@kernel.org> > > Don't transform the logical block size to a bit shift only to shift it > back to the original block size. Just use the size. This looks reasonable. But given that the blksz variable is only used once, why not open code the bdev_logical_block_size in the conditional?
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 4eb559a16c9e..503b97e5a115 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -240,7 +240,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, { const struct iomap *iomap = &iter->iomap; struct inode *inode = iter->inode; - unsigned int blkbits = blksize_bits(bdev_logical_block_size(iomap->bdev)); + unsigned int blksz = bdev_logical_block_size(iomap->bdev); unsigned int fs_block_size = i_blocksize(inode), pad; loff_t length = iomap_length(iter); loff_t pos = iter->pos; @@ -252,7 +252,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, size_t copied = 0; size_t orig_count; - if ((pos | length) & ((1 << blkbits) - 1) || + if ((pos | length) & (blksz - 1) || !bdev_iter_is_aligned(iomap->bdev, dio->submit.iter)) return -EINVAL;