Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3650296pxu; Tue, 8 Dec 2020 18:44:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwv9wXtcZsoJkNmQlyfbPjdsrh9fD235y0QZeVXdo/JwucONNNEy+inibA8WHo1qav4pPgC X-Received: by 2002:a17:907:720e:: with SMTP id dr14mr269299ejc.303.1607481893851; Tue, 08 Dec 2020 18:44:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1607481893; cv=pass; d=google.com; s=arc-20160816; b=ZbA/kgLHCtKPbhksFgLSQg/TpPNUzzBbNkrwa/yFZOmoPiHRKR+QZAzzjcqObwGkif IpBstyZV2E9ZMMttRGHXcJckhXqBXYZm3FMx2LCP7m2zm326deInflNV4B/qHN+jtm6K 71nNYeJRl/otG7UG2T7+b09m807kuuengGzBhsmWUJlsJFA2vb9MWhS8h23NTK2WHzpy Fs5vt9t4b3PnPjyEzxIZLRT1aEOn+9zPN+66MtlOb0CH9FxcJ7fmwrHAuhm2X3yqSHIs pvznNrL0PKPi6eW3JO+PbtqoI+nk4A4fu1SwHQnJtXCr6J0CtLYAm3lYXOvr1jQHyndC YkWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=AMxXvGBy2MWXqsETDuiVKEL/Re0aGOm0lekuBhQnTEo=; b=c2HJaHU1HyAu6TbYCBfpLVSm9Sjic02fvHW1FtO65uSsLgYTZIv9Ov8KWLCeVRFmWd rof0MH/euKkW+5Ja+JDD9d8FLrDljv6lwspEFCrX+BNE3PGNV48horzXBJLddv7AEPwk i+Dvmgj1KYC2t7zZwdF40Zx7LDN0KIYe5h/AiVh6nowfZvoIkOEYVHbV44oLw8cmp+S2 I4kFInLldnuI36FQ9hqiH9A3N0swJq+o5cKsTgLamAj79vIapf1AanPnjwACZWuLBNfX lpuemm9adKuedExNmLaVoJgWPEf0CXxKsIOUd1tYAP20bQkFoKPX02BHtz80/K+08uTW ai3w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oppoglobal.onmicrosoft.com header.s=selector1-oppoglobal-onmicrosoft-com header.b="r3HejG/B"; arc=pass (i=1 spf=pass spfdomain=oppo.com dkim=pass dkdomain=oppo.com dmarc=pass fromdomain=oppo.com); 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=fail (p=NONE sp=NONE dis=NONE) header.from=oppo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o24si92369edz.608.2020.12.08.18.44.26; Tue, 08 Dec 2020 18:44:53 -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=@oppoglobal.onmicrosoft.com header.s=selector1-oppoglobal-onmicrosoft-com header.b="r3HejG/B"; arc=pass (i=1 spf=pass spfdomain=oppo.com dkim=pass dkdomain=oppo.com dmarc=pass fromdomain=oppo.com); 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=fail (p=NONE sp=NONE dis=NONE) header.from=oppo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726843AbgLICl0 (ORCPT + 99 others); Tue, 8 Dec 2020 21:41:26 -0500 Received: from mail-eopbgr1300087.outbound.protection.outlook.com ([40.107.130.87]:38880 "EHLO APC01-HK2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726604AbgLIClT (ORCPT ); Tue, 8 Dec 2020 21:41:19 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lZKhLrxO/IFVolIJ8sZlBToxGNvOd2Hol6yJaUrRhb861yqJJ1SWbosyano1tW/4wxmaBvr6zgSFxOjUgXwXRfS2zl40Sl1jnaHF1XkflrtBCTfLmgD5BoLxNvAJqUdh3s9Ad3PYaJCasjYYCL1sLXc9SbZGTqlfzznZmtSjN7MDi2UwBU7qR+69m4yGB8Ghk4XpOEgOm8vsktd+f9Pu7hM72KoMWdyn3qmyn4TBzJULk8bco+l1+ZsTJJKG9iF2DryOcdfHgSdsoCl1EA3Gbxp9lzqPjtOuMAvbgxdflom37irOpR1ovJtXmI99e1fwdpgb0sGnKA/F2HeCOReeJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AMxXvGBy2MWXqsETDuiVKEL/Re0aGOm0lekuBhQnTEo=; b=Qq0Kr5fQMUdGhovJSg9L261k2sHTLyn/q5L7yPpiuVcsaIgumbDmMN5UFIwdOuvBP1PUR5qTegtp6wurwXXjiKH7V7t0HDW30oPgyRJCOdtKDBc372PT0WP1SkFW4JgrspgVLsP/dsRWJHZqLgxB+wRsUkMtsYd+iFMA+nt0BR6O3B55GSu1O/e0Ut5icEpOyCSTzE8T4gHl45U0gY9fW6XQ9O9UneYchC/0mSqiqG3dSC6qlmCwCtXORhp9wRpr0L8jpWxRUr/phTrbfxcC03ymPPuxtI9aRxnVX5qbfobueZfYCjR9YSE6UBoj9q2MGzDXdqKTRLlSQOJxTLZmHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oppo.com; dmarc=pass action=none header.from=oppo.com; dkim=pass header.d=oppo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppoglobal.onmicrosoft.com; s=selector1-oppoglobal-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AMxXvGBy2MWXqsETDuiVKEL/Re0aGOm0lekuBhQnTEo=; b=r3HejG/BqV6ywKMLAt9zIWtCUoCVIBPTkjIpAs61FkFPbNO4YTPk/7C3NDMtWWzF0jkysnf/qB5hS89P83mr2PuUcykb9Zp8FHotb0nmUXkl7/QVzaVDpqJ0Shl31pxgprAw3PNQT7seoxw0l5yOK8vqROiHU8umbz3piEo8M6k= Authentication-Results: lists.ozlabs.org; dkim=none (message not signed) header.d=none;lists.ozlabs.org; dmarc=none action=none header.from=oppo.com; Received: from SG2PR02MB4108.apcprd02.prod.outlook.com (2603:1096:4:96::19) by SG2PR02MB2461.apcprd02.prod.outlook.com (2603:1096:3:1d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12; Wed, 9 Dec 2020 02:39:42 +0000 Received: from SG2PR02MB4108.apcprd02.prod.outlook.com ([fe80::dcd:13c1:2191:feb7]) by SG2PR02MB4108.apcprd02.prod.outlook.com ([fe80::dcd:13c1:2191:feb7%7]) with mapi id 15.20.3654.012; Wed, 9 Dec 2020 02:39:42 +0000 From: Huang Jianan To: linux-erofs@lists.ozlabs.org Cc: huangjianan@oppo.com, guoweichao@oppo.com, zhangshiming@oppo.com, linux-kernel@vger.kernel.org Subject: [PATCH v4] erofs: avoid using generic_block_bmap Date: Wed, 9 Dec 2020 10:39:30 +0800 Message-Id: <20201209023930.15554-1-huangjianan@oppo.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [58.252.5.72] X-ClientProxiedBy: HK2PR04CA0088.apcprd04.prod.outlook.com (2603:1096:202:15::32) To SG2PR02MB4108.apcprd02.prod.outlook.com (2603:1096:4:96::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (58.252.5.72) by HK2PR04CA0088.apcprd04.prod.outlook.com (2603:1096:202:15::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Wed, 9 Dec 2020 02:39:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ee02ae2-80fb-4aa6-9e8a-08d89bebaeb3 X-MS-TrafficTypeDiagnostic: SG2PR02MB2461: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:525; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: haN0CUqS0dZNJ46+tAr+aA5y4WB/YUne4cGMrg7R0wGMWjBVRwBTRqLDiq5sbv/YdDzZjpZX5oY77+kACxnaZjgteTKXRK4r8FTVEuhcDlZPDnYiOPdRgPrhU9S6L/9Lqs/BHYXqOVi0l6Uf372OUKpI68KWlB/yEnqSJAYMYDu04JQqzxr51KFwZKRA4J2Aw5A6hrKpzhEd3+IokeG9lTdsqOQASyCFJa44o2N+sXVUz606WNGRP2roOH55crXp/tCykYwe10m8/aDq1FKxudRvczs8VKEIo4oCslVmB2nq8sggBul/YudXLQfoaQBqOhu2ESJH9sPY1lI7eGbdKE5CyxC84EBHibF4Bi8K0USUh0IGn1c+5YwNulzZVf7lluGLB7oAkzTucoe3y63tdvy32zfpayNcy7JZiXV3WKgPt8+y+p2ha1TgycT/qMxtNBGadiJWs03QGa7xC225vQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SG2PR02MB4108.apcprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(366004)(346002)(34490700003)(508600001)(86362001)(36756003)(5660300002)(956004)(8676002)(8936002)(2616005)(1076003)(69590400008)(6666004)(16526019)(6506007)(52116002)(2906002)(83380400001)(6916009)(6486002)(66946007)(66556008)(66476007)(6512007)(4326008)(186003)(26005)(11606006)(41533002);DIR:OUT;SFP:1101; X-MS-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edpMbxdZpnwRifd2IQj15wDLd1jCGbMc7sw8Gcyux06?= =?us-ascii?Q?Kevt41aKU94C5Q85uHfTwq3kDExGBdBUzHbXLpSOEBZkSyx4qY+QRHFFj9Iz?= =?us-ascii?Q?KD0o7fUvqRhW0OIGl2kvtj7ldpf0B6P3EC7Jn/CodBQ=3D?= X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-AuthSource: SG2PR02MB4108.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2020 02:39:42.2162 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-Network-Message-Id: 7ee02ae2-80fb-4aa6-9e8a-08d89bebaeb3 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QLK65YAX5i8bP3wTHDkHtkayf2VUJjPuLZdgq9FLoTID45wLjOHcRKmxeKXVz5nHo3xjMcep7nCpKx0qbrb/bw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR02MB2461 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; 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; + 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); + +out: + return blknr; } /* for uncompressed (aligned) files and raw access for other files */ -- 2.25.1