Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9087558pxu; Mon, 28 Dec 2020 06:19:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTtBprA6BImgcqvQWZZlzS/52h6YwnEXaye7NFH//W8TU8JKQ5TAPlREjTH2VhFzE4D34j X-Received: by 2002:a17:907:4243:: with SMTP id np3mr41298838ejb.212.1609165187293; Mon, 28 Dec 2020 06:19:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165187; cv=none; d=google.com; s=arc-20160816; b=MmK2/Q/l6egPrmzaY/zrdT5w4szYeEPpog/oC1RNecm6Q2WwDlDZKGSq92FJM9o7Bp BJx6csite/DEEML2znC1Nc+CfUnpdguLWAdanySHVf071bJav3lAMsxo5EwEIyV2dZHm GkUJEhOONhCj6DQ5gAofD116zxq/qoCmKAF31ZNxpJQkGiYiOQmlzNHt4l27gMidIa5u tPoWCOzJddCPLMJN1jhPBPmz5n5+8aDqXK9TYPL/CnEEkZUdDIeB0hmMYiIDEh2sUvcX kpX+3R4xef9cA0j2B/xhnFqH4E/mqwLrXk0A2k4CB6usC6QLA7tLs7BmxQHmUzS72rR6 DFOg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aF0yvunt3CjiWRRgmGdXCqU5bxW7Th727f5g/G9xNg4=; b=UHXx51WOJXLr3BD6fxcwxBCa1XxOcHD45EHOvn9NU2Lh1eRAU0AqjinJk09F9qKGdM E5hEVHvTQ3MWNHkeqcu39M/jQcmwj7nif/8CL6Qx+6fQZaW2ntKKeordKQWD7fu5Bk9R P5XBBBAWZF2P1Tt1UytiMAllk8tR27MZregrpdf5V1BDLyOIg1ww2roIhBcSWMJp3sGL BfheB5JyOyofcIkTTFYBpwSt+8TKtf3mtFsWJUgn9Pdome3mS/hD/Hhkg6Pg8Vnl+vMG PIvBqj14YgSfu1y9GZCDcHMBWZ0vzO/otbz3DcvIdD1vqLPZXnsRF13EBUicUAp5jNyS 5e5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="MJS8d1/b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o11si19017204ejg.118.2020.12.28.06.19.24; Mon, 28 Dec 2020 06:19:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="MJS8d1/b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2501891AbgL1ORf (ORCPT + 99 others); Mon, 28 Dec 2020 09:17:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:52136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2501881AbgL1ORe (ORCPT ); Mon, 28 Dec 2020 09:17:34 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 27E59207B2; Mon, 28 Dec 2020 14:17:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165038; bh=+ckL7sCwj843aPBGGz7Zq03vrwFIHW76lI/94Rcm2x8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MJS8d1/bjjUDbxPpTFXx2kCuV6I8fQjG7U4FJBl1oLMomD3E2s8ARs19L39XndTVn 54A1IjG2ZFXQ3kpD5ion1raoVuEspX6+l39ULrDggAVue5aU1BEdxI/7vZbU1+OX8n 88aAbmQBcKzBVSRbmhe1AsYpUoRLBLd5sXTfKKpY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Yu , Gao Xiang , Huang Jianan , Guo Weichao , Sasha Levin Subject: [PATCH 5.10 389/717] erofs: avoid using generic_block_bmap Date: Mon, 28 Dec 2020 13:46:27 +0100 Message-Id: <20201228125039.642500610@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huang Jianan [ Upstream commit d8b3df8b1048405e73558b88cba2adf29490d468 ] Surprisingly, `block' in sector_t indicates the number of i_blkbits-sized blocks rather than sectors for bmap. In addition, considering buffer_head limits mapped size to 32-bits, should avoid using generic_block_bmap. Link: https://lore.kernel.org/r/20201209115740.18802-1-huangjianan@oppo.com Fixes: 9da681e017a3 ("staging: erofs: support bmap") Reviewed-by: Chao Yu Reviewed-by: Gao Xiang Signed-off-by: Huang Jianan Signed-off-by: Guo Weichao [ Gao Xiang: slightly update the commit message description. ] Signed-off-by: Gao Xiang Signed-off-by: Sasha Levin --- fs/erofs/data.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index 347be146884c3..ea4f693bee224 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -312,27 +312,12 @@ 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), + }; if (EROFS_I(inode)->datalayout == EROFS_INODE_FLAT_INLINE) { erofs_blk_t blks = i_size_read(inode) >> LOG_BLOCK_SIZE; @@ -341,7 +326,10 @@ static sector_t erofs_bmap(struct address_space *mapping, sector_t block) return 0; } - return generic_block_bmap(mapping, block, erofs_get_block); + if (!erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW)) + return erofs_blknr(map.m_pa); + + return 0; } /* for uncompressed (aligned) files and raw access for other files */ -- 2.27.0