Message ID | 20230306075527.1338-1-zbestahu@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1712460wrd; Sun, 5 Mar 2023 23:58:12 -0800 (PST) X-Google-Smtp-Source: AK7set90jC8EpEdzAOOF0MOyI3vGIJrCKOLKEBhHr0SQjK1st/tuPFmn3q8wyraf+AwS10xO8FpD X-Received: by 2002:a17:90a:2c2:b0:233:f3c2:a86d with SMTP id d2-20020a17090a02c200b00233f3c2a86dmr10218015pjd.47.1678089492312; Sun, 05 Mar 2023 23:58:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678089492; cv=none; d=google.com; s=arc-20160816; b=BV9NC0VsKB1RK1De29ipr8mjohMC3qrZ/yT+Rl+gC98T828baP0V9KpU87Pn7kB8FY /5kQ/ejlfPreskd/EnXNPpJtGr5Yx+G1rmDRzEJ5Kk1ciB2Msa2nQqj0GOrzKoBI3bdE +lWXX3cl4wNE3MjNVxAfk5ACJqi0MijVM3vyBFG8QatiJt6/+gqwkb/42+JpVntcrtNf +B7cp3jiE/l7guPEH6977jc3kmScovD7O4Hcy/dCuNKTEjwP653daY+PAS/E0vepXSUw q0t2ez9R4diUwgnKKg/vLJ51KTBIo9HMFaJAFGr+ZoaKqOOPAQh1ddZd77MsZcVPgyOq IOXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=DXM+F0nCeNTp6Op2aBBfKjMUtWoANY5Axbyzod0a2dk=; b=rf4xUNVlLFSft4x+ugtdEZ7C80gFi7QkaTwnR0g11RJe0528yFprrcvYLMOJJcgC4k GP2yS52Pp/a9ouZVWxYq7oSx5bc7EfPTV0P5qpPbCcLbgChH5q+Il6etlkBcKOE+k6Uy EPhnNfpd/Tc+jXS0ySNaHb6EpEJoalg5qPDFOVplQXin3u3f0AoNDkhBnhoaq/ixF1tb qBE1qO2fSutC7VYnNIUV8bvUoliyqDPdfsAVYlmE1DhXyd51L42UsO2DFHVgQP/SX8hl Y9eHaQG/lSmPmpXNbYexXnGi6oYMXZUqXBBgeillVZwGT08Kn6VEjH46wUF1wj2MOmKH F5oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="JuHi9hM/"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm18-20020a656e92000000b00503a2b23520si8308500pgb.690.2023.03.05.23.57.59; Sun, 05 Mar 2023 23:58:12 -0800 (PST) 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=@gmail.com header.s=20210112 header.b="JuHi9hM/"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229707AbjCFHz7 (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 6 Mar 2023 02:55:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbjCFHz5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 6 Mar 2023 02:55:57 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D75518151 for <linux-kernel@vger.kernel.org>; Sun, 5 Mar 2023 23:55:56 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id cp7-20020a17090afb8700b0023756229427so12341393pjb.1 for <linux-kernel@vger.kernel.org>; Sun, 05 Mar 2023 23:55:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678089356; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DXM+F0nCeNTp6Op2aBBfKjMUtWoANY5Axbyzod0a2dk=; b=JuHi9hM/KWhW1Mri//QAde/70PgU9JOPU4yDSh9qWdIQdD8fzQGWUiePB8OSSZAnV1 zT9kyW1GwWMvvo/Zr8C5c0mst/Ch8s3CljIrPvOkGexctWW/m/vJ12+TSDPlSE6at6N1 MnCrM1NAjW1I2sDCEgFV9bM66E2nTCR0K8SqwYPDCxba5DUcuMmnYrTpMGqa+WUOLqm1 dHZxYY6KvpB0Ox486ldWbITM5Cb3E+O5AW7d9DLzcnA5671fRdlB24bn2Sl2PMQo/KnW iW/1iOojHqoQg7k0yafD8+jSiwgMK0zgRTcQ3ja7w8ajdG0b7u6H/Ey7Z0SvWEJWExzt DHJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678089356; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DXM+F0nCeNTp6Op2aBBfKjMUtWoANY5Axbyzod0a2dk=; b=299ovpMpk4A2TZABvG5KCRoIQI+MUeTlATkRmuLRW7zKMmM+9GrFNM4riUCGwUJW5Z mtds8KVCrvnc+Rll/iRHbNSq8qu7sECf6bdv11SW05LC9hNMc1x2CeWKFVi3+aG48QlJ nKbTLCIh2/+YoNq9suCAEso+S4+x+R9NW0r4OorEbi/ZK+KrgEVH8VaJVyOKQ1TWiDf4 no0J+dR6sWM70EWyFsFIQ/Y1qTfn93AyhzG+16g2XVBbvAHi2xyCkqvA9tBujFrjeUEH 4IPq7sj6v9DQq4qJREc91fab5RBVMWjQQzBJqOc9vMmwuZx5t7y0my69vIZyxEmuLFPh nVLQ== X-Gm-Message-State: AO0yUKUHjfkgtlvSfA1DAh2AWFgs96cNe6CDh9olx3ALAYkMwZ6jUK53 1+mtj0XZUtGvnP8GqUaV3Fc= X-Received: by 2002:a17:90b:3b85:b0:234:8c58:c325 with SMTP id pc5-20020a17090b3b8500b002348c58c325mr10160476pjb.31.1678089355951; Sun, 05 Mar 2023 23:55:55 -0800 (PST) Received: from localhost.localdomain ([156.236.96.165]) by smtp.gmail.com with ESMTPSA id e8-20020a17090ac20800b0022be36be19asm5383079pjt.53.2023.03.05.23.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Mar 2023 23:55:55 -0800 (PST) From: Yue Hu <zbestahu@gmail.com> To: xiang@kernel.org, chao@kernel.org, jefflexu@linux.alibaba.com, linux-erofs@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, huyue2@coolpad.com, zhangwen@coolpad.com Subject: [PATCH] erofs: use wrapper i_blocksize() in erofs_file_read_iter() Date: Mon, 6 Mar 2023 15:55:27 +0800 Message-Id: <20230306075527.1338-1-zbestahu@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1759604367632845015?= X-GMAIL-MSGID: =?utf-8?q?1759604367632845015?= |
Series |
erofs: use wrapper i_blocksize() in erofs_file_read_iter()
|
|
Commit Message
Yue Hu
March 6, 2023, 7:55 a.m. UTC
From: Yue Hu <huyue2@coolpad.com> linux/fs.h has a wrapper for this operation. Signed-off-by: Yue Hu <huyue2@coolpad.com> --- fs/erofs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 2023/3/6 15:55, Yue Hu wrote: > From: Yue Hu <huyue2@coolpad.com> > > linux/fs.h has a wrapper for this operation. > > Signed-off-by: Yue Hu <huyue2@coolpad.com> Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Thanks, Gao Xiang > --- > fs/erofs/data.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/erofs/data.c b/fs/erofs/data.c > index 5bd0c956a142..7e8baf56faa5 100644 > --- a/fs/erofs/data.c > +++ b/fs/erofs/data.c > @@ -380,7 +380,7 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) > if (bdev) > blksize_mask = bdev_logical_block_size(bdev) - 1; > else > - blksize_mask = (1 << inode->i_blkbits) - 1; > + blksize_mask = i_blocksize(inode) - 1; > > if ((iocb->ki_pos | iov_iter_count(to) | > iov_iter_alignment(to)) & blksize_mask)
> @@ -380,7 +380,7 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) > if (bdev) > blksize_mask = bdev_logical_block_size(bdev) - 1; > else > - blksize_mask = (1 << inode->i_blkbits) - 1; > + blksize_mask = i_blocksize(inode) - 1; Since the mask is to be obtained here, is it more appropriate to use GENMASK(inode->i_blkbits - 1, 0)? Thx, Yangtao
On 3/9/23 3:15 PM, Yangtao Li wrote: >> @@ -380,7 +380,7 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) >> if (bdev) >> blksize_mask = bdev_logical_block_size(bdev) - 1; >> else >> - blksize_mask = (1 << inode->i_blkbits) - 1; >> + blksize_mask = i_blocksize(inode) - 1; > > Since the mask is to be obtained here, is it more appropriate to use GENMASK(inode->i_blkbits - 1, 0)? FYI it seems that GENMASK macro is widely used in driver and arch code base, while it's rarely used in fs, except for f2fs.
On Thu, 9 Mar 2023 15:15:15 +0800 Yangtao Li <frank.li@vivo.com> wrote: > > @@ -380,7 +380,7 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) > > if (bdev) > > blksize_mask = bdev_logical_block_size(bdev) - 1; > > else > > - blksize_mask = (1 << inode->i_blkbits) - 1; > > + blksize_mask = i_blocksize(inode) - 1; > > Since the mask is to be obtained here, is it more appropriate to use GENMASK(inode->i_blkbits - 1, 0)? It should be another change independently to this patch. rt? > > Thx, > Yangtao
> FYI it seems that GENMASK macro is widely used in driver and arch code base, while it's rarely used in fs, except for f2fs.
I think the following usage can be changed to bitmap api, just like in f2fs?
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=c4ca1f7164734a1baf40d4ff1552172a07d4fc4d
fs/erofs/fscache.c:135: unsigned long flags = 1 << NETFS_SREQ_ONDEMAND;
fs/erofs/internal.h:250:#define SECTORS_PER_BLOCK (1 << SECTORS_PER_BLOCK)
fs/erofs/internal.h:252:#define EROFS_BLKSIZ (1 << LOG_BLOCK_SIZE)
fs/erofs/internal.h:354: return (value >> bit) & ((1 << bits) - 1);
fs/erofs/zmap.c:66: ((1 << Z_EROFS_VLE_DI_CLUSTER_TYPE_BITS) - 1);
fs/erofs/zmap.c:69: m->clusterofs = 1 << vi->z_logical_clusterbits;
fs/erofs/zmap.c:114: const unsigned int lomask = (1 << lclusterbits) - 1;
fs/erofs/zmap.c:141: const unsigned int lomask = (1 << lclusterbits) - 1;
fs/erofs/zmap.c:147: if (1 << amortizedshift == 4)
fs/erofs/zmap.c:149: else if (1 << amortizedshift == 2 && lclusterbits == 12)
fs/erofs/zmap.c:169: m->clusterofs = 1 << lclusterbits;
fs/erofs/zmap.c:291: pos += lcn * (1 << amortizedshift);
fs/erofs/zmap.c:409: m->compressedblks = 1 << (lclusterbits - LOG_BLOCK_SIZE);
fs/erofs/zmap.c:457: m->clusterofs != 1 << lclusterbits);
fs/erofs/zmap.c:497: endoff = ofs & ((1 << lclusterbits) - 1);
fs/erofs/erofs_fs.h:120: ((1 << (EROFS_I_DATALAYOUT_BIT + EROFS_I_DATALAYOUT_BITS)) - 1)
fs/erofs/erofs_fs.h:279:#define Z_EROFS_ALL_COMPR_ALGS ((1 << Z_EROFS_COMPRESSION_MAX) - 1)
fs/erofs/erofs_fs.h:377:#define Z_EROFS_VLE_DI_PARTIAL_REF (1 << 15)
fs/erofs/erofs_fs.h:384:#define Z_EROFS_VLE_DI_D0_CBLKCNT (1 << 11)
fs/erofs/erofs_fs.h:427: .h_clusterbits = 1 << Z_EROFS_FRAGMENT_INODE_BIT
fs/erofs/data.c:379: blksize_mask = (1 << inode->i_blkbits) - 1;
fs/erofs/zdata.c:133:#define Z_EROFS_PAGE_EIO (1 << 30)
Thx,
Yangtao
On 2023/3/9 15:37, Yue Hu wrote: > On Thu, 9 Mar 2023 15:15:15 +0800 > Yangtao Li <frank.li@vivo.com> wrote: > >>> @@ -380,7 +380,7 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) >>> if (bdev) >>> blksize_mask = bdev_logical_block_size(bdev) - 1; >>> else >>> - blksize_mask = (1 << inode->i_blkbits) - 1; >>> + blksize_mask = i_blocksize(inode) - 1; >> >> Since the mask is to be obtained here, is it more appropriate to use GENMASK(inode->i_blkbits - 1, 0)? > > It should be another change independently to this patch. rt? I'd suggest that keep to use (i_blocksize(inode) - 1) here, for example: https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git/tree/fs/gfs2/bmap.c#n963 Thanks, Gao Xiang > >> >> Thx, >> Yangtao
On 2023/3/9 15:42, Yangtao Li wrote: >> FYI it seems that GENMASK macro is widely used in driver and arch code base, while it's rarely used in fs, except for f2fs. > > I think the following usage can be changed to bitmap api, just like in f2fs? > https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=c4ca1f7164734a1baf40d4ff1552172a07d4fc4d > > fs/erofs/fscache.c:135: unsigned long flags = 1 << NETFS_SREQ_ONDEMAND; > fs/erofs/internal.h:250:#define SECTORS_PER_BLOCK (1 << SECTORS_PER_BLOCK) > fs/erofs/internal.h:252:#define EROFS_BLKSIZ (1 << LOG_BLOCK_SIZE) > fs/erofs/internal.h:354: return (value >> bit) & ((1 << bits) - 1); > fs/erofs/zmap.c:66: ((1 << Z_EROFS_VLE_DI_CLUSTER_TYPE_BITS) - 1); > fs/erofs/zmap.c:69: m->clusterofs = 1 << vi->z_logical_clusterbits; > fs/erofs/zmap.c:114: const unsigned int lomask = (1 << lclusterbits) - 1; > fs/erofs/zmap.c:141: const unsigned int lomask = (1 << lclusterbits) - 1; > fs/erofs/zmap.c:147: if (1 << amortizedshift == 4) > fs/erofs/zmap.c:149: else if (1 << amortizedshift == 2 && lclusterbits == 12) > fs/erofs/zmap.c:169: m->clusterofs = 1 << lclusterbits; > fs/erofs/zmap.c:291: pos += lcn * (1 << amortizedshift); > fs/erofs/zmap.c:409: m->compressedblks = 1 << (lclusterbits - LOG_BLOCK_SIZE); > fs/erofs/zmap.c:457: m->clusterofs != 1 << lclusterbits); > fs/erofs/zmap.c:497: endoff = ofs & ((1 << lclusterbits) - 1); > fs/erofs/erofs_fs.h:120: ((1 << (EROFS_I_DATALAYOUT_BIT + EROFS_I_DATALAYOUT_BITS)) - 1) > fs/erofs/erofs_fs.h:279:#define Z_EROFS_ALL_COMPR_ALGS ((1 << Z_EROFS_COMPRESSION_MAX) - 1) > fs/erofs/erofs_fs.h:377:#define Z_EROFS_VLE_DI_PARTIAL_REF (1 << 15) > fs/erofs/erofs_fs.h:384:#define Z_EROFS_VLE_DI_D0_CBLKCNT (1 << 11) > fs/erofs/erofs_fs.h:427: .h_clusterbits = 1 << Z_EROFS_FRAGMENT_INODE_BIT > fs/erofs/data.c:379: blksize_mask = (1 << inode->i_blkbits) - 1; > fs/erofs/zdata.c:133:#define Z_EROFS_PAGE_EIO (1 << 30) > Is there some benefit to use these? BIT(1) vs 1 << 1? also almost all filesystems rarely use such APIs honestly. Thanks, Gao Xiang > Thx, > Yangtao
On 2023/3/6 15:55, Yue Hu wrote: > From: Yue Hu <huyue2@coolpad.com> > > linux/fs.h has a wrapper for this operation. > > Signed-off-by: Yue Hu <huyue2@coolpad.com> Reviewed-by: Chao Yu <chao@kernel.org> Thanks,
diff --git a/fs/erofs/data.c b/fs/erofs/data.c index 5bd0c956a142..7e8baf56faa5 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -380,7 +380,7 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) if (bdev) blksize_mask = bdev_logical_block_size(bdev) - 1; else - blksize_mask = (1 << inode->i_blkbits) - 1; + blksize_mask = i_blocksize(inode) - 1; if ((iocb->ki_pos | iov_iter_count(to) | iov_iter_alignment(to)) & blksize_mask)