From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B26E3C433FE for ; Wed, 9 Dec 2020 10:09:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E9A923A22 for ; Wed, 9 Dec 2020 10:09:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729738AbgLIKJ1 (ORCPT ); Wed, 9 Dec 2020 05:09:27 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:8970 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728631AbgLIKJ1 (ORCPT ); Wed, 9 Dec 2020 05:09:27 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4CrXmz5MJYzhnbT; Wed, 9 Dec 2020 18:08:19 +0800 (CST) Received: from [10.136.114.67] (10.136.114.67) by smtp.huawei.com (10.3.19.204) with Microsoft SMTP Server (TLS) id 14.3.487.0; Wed, 9 Dec 2020 18:08:42 +0800 Subject: Re: [PATCH v4] erofs: avoid using generic_block_bmap To: Huang Jianan , CC: , , References: <20201209023930.15554-1-huangjianan@oppo.com> From: Chao Yu Message-ID: <23527fc2-811b-321e-10f1-cb5b50affdbb@huawei.com> Date: Wed, 9 Dec 2020 18:08:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20201209023930.15554-1-huangjianan@oppo.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.136.114.67] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/12/9 10:39, Huang Jianan wrote: > iblock indicates the number of i_blkbits-sized blocks rather than > sectors. > > In addition, considering buffer_head limits mapped size to 32-bits, > should avoid using generic_block_bmap. > > Fixes: 9da681e017a3 ("staging: erofs: support bmap") > Signed-off-by: Huang Jianan > Signed-off-by: Guo Weichao > --- > fs/erofs/data.c | 30 ++++++++++-------------------- > 1 file changed, 10 insertions(+), 20 deletions(-) > > diff --git a/fs/erofs/data.c b/fs/erofs/data.c > index 347be146884c..d6ea0a216b57 100644 > --- a/fs/erofs/data.c > +++ b/fs/erofs/data.c > @@ -312,36 +312,26 @@ static void erofs_raw_access_readahead(struct readahead_control *rac) > submit_bio(bio); > } > > -static int erofs_get_block(struct inode *inode, sector_t iblock, > - struct buffer_head *bh, int create) > -{ > - struct erofs_map_blocks map = { > - .m_la = iblock << 9, > - }; > - int err; > - > - err = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW); > - if (err) > - return err; > - > - if (map.m_flags & EROFS_MAP_MAPPED) > - bh->b_blocknr = erofs_blknr(map.m_pa); > - > - return err; > -} > - > static sector_t erofs_bmap(struct address_space *mapping, sector_t block) > { > struct inode *inode = mapping->host; > + struct erofs_map_blocks map = { > + .m_la = blknr_to_addr(block), > + }; > + sector_t blknr = 0; It could be removed? > > if (EROFS_I(inode)->datalayout == EROFS_INODE_FLAT_INLINE) { > erofs_blk_t blks = i_size_read(inode) >> LOG_BLOCK_SIZE; > > if (block >> LOG_SECTORS_PER_BLOCK >= blks) > - return 0; return 0; > + goto out; > } > > - return generic_block_bmap(mapping, block, erofs_get_block); > + if (!erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW)) > + blknr = erofs_blknr(map.m_pa); return erofs_blknr(map.m_pa); > + > +out: > + return blknr; return 0; Anyway, LGTM. Reviewed-by: Chao Yu Thanks, > } > > /* for uncompressed (aligned) files and raw access for other files */ >