From patchwork Sat Jan 14 12:57:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Xiang X-Patchwork-Id: 43749 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp279400wrn; Sat, 14 Jan 2023 05:17:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXu5C6VWoSelU0Cghwz9vzwykWbJLM/emdOUd54nI1mZstsOH5I64mHoM2k+rrX9ySbaV2q6 X-Received: by 2002:a17:906:6bc6:b0:86d:f370:19ab with SMTP id t6-20020a1709066bc600b0086df37019abmr920563ejs.5.1673702257197; Sat, 14 Jan 2023 05:17:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673702257; cv=none; d=google.com; s=arc-20160816; b=Z2dzWLzD3vNSKaUZvTuBQa9e4BLbtC0HbGvgCSJAcFXHACY7MZQ/whyCIF+WM1VXYR 8Dd70FlBqyuHLTnUBLo33SswtVLsCjpv625kxZvzFQSWf3AW307WFX0f2S5H6kZxBSid 8JSEqrEIJmUP3FrZKnuDGArmIJs6qyE0RpcJymyHD5Y8VBIvD/2L3QkJa/I920IytvgE Xqu/infuKv1oGQHP9W4kFxCeDryJ/a03XXNntg9Nf4IEjKAlNFjrpaUToSjyXq1wGwS3 ENwL9jIKXX8xVH3vc5HbN35CoYptHnN+Z7Sl5SaCuhxlQAJPFqVdGeJfkRswP78xOzF2 3uOA== 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=lpXVxyZWgvEnk4Iq6F1nMwD2g+6WKKNyec+xFan2pSE=; b=fhNx3R/DTNOkinJOEI4ht7FN87stiAS2porowCEKfHZObi7IlMTuKNiaUjI0AKq4ro jmwBIOf/37AZ0u3H0fDu3KgxIi1bhTbls/B8aJCu0iedP4g1UA+KZC07UJsuHgmeOgsh T2VYaTOBwXGcgl5xGMqzMrn714NYsp8ymPfPGaplgMd05SC0AGyjNxAafkp1YeHzVXh/ 7TWq8Mm7v9gfEjJ6ru+stlWv17QCfQGSgK4/CiEKYsc2xxAS4RCbJQWwaWXmgZqiLKKD KCdTNFn/R0IGJtcXgW44IkfiY4+/UtXBaJc0jfhqO0+BhGMwNbVTJAVp/VcOGO9DDXhP d9XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MAHizgaA; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xf9-20020a17090731c900b0084d0b4b4fdbsi25612845ejb.555.2023.01.14.05.17.13; Sat, 14 Jan 2023 05:17:37 -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=@kernel.org header.s=k20201202 header.b=MAHizgaA; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229566AbjANM6M (ORCPT + 99 others); Sat, 14 Jan 2023 07:58:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbjANM6L (ORCPT ); Sat, 14 Jan 2023 07:58:11 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C08BE8A51 for ; Sat, 14 Jan 2023 04:58:09 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4AFE16091F for ; Sat, 14 Jan 2023 12:58:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF333C433EF; Sat, 14 Jan 2023 12:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673701088; bh=vD+R0I/+XGCpx3ixVZETPZPrWFSY/wd9ViAO+3HiKA8=; h=From:To:Cc:Subject:Date:From; b=MAHizgaAGK4UjLpHpTuBL8u+ujeeQm9FMSmRsrz56wUUmzBwUfH2Cygm+YE34KrYE Rj+cJSq4bF3xbzP0liu1AGzpZYyTIXI80E3V6J0jAx3GwwVke/p04tXpOb+up96g5H wt15siRsXSXn75N00mAIJ9EUxaMTp1eVIu7zLRKfLnQcHfjoKttiXxarSR4CWvOgIF ZadcO3HLTkFV1ePRtPDffVgxHqojiAlC3ANy62KoDe4zcNhAzJHLlVv/QD7uNeT21X hTne/2fnf/A5C72M5B/IEC3yh2Q8j6fCp2aRtEGaUDX8MuRz6IHEWlJDXlNCvV11jm YWuRN1rTQqqPg== From: Gao Xiang To: linux-erofs@lists.ozlabs.org, Chao Yu , Yue Hu , Jingbo Xu Cc: LKML , Gao Xiang Subject: [PATCH 1/2] erofs: get rid of debug_one_dentry() Date: Sat, 14 Jan 2023 20:57:45 +0800 Message-Id: <20230114125746.399253-1-xiang@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755004018489816468?= X-GMAIL-MSGID: =?utf-8?q?1755004018489816468?= From: Gao Xiang Since erofsdump is available, no need to keep this debugging functionality at all. Also drop a useless comment since it's the VFS behavior. Signed-off-by: Gao Xiang Reviewed-by: Jingbo Xu Reviewed-by: Yue Hu Reviewed-by: Chao Yu --- fs/erofs/dir.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/fs/erofs/dir.c b/fs/erofs/dir.c index ecf28f66b97d..6970b09b8307 100644 --- a/fs/erofs/dir.c +++ b/fs/erofs/dir.c @@ -6,21 +6,6 @@ */ #include "internal.h" -static void debug_one_dentry(unsigned char d_type, const char *de_name, - unsigned int de_namelen) -{ -#ifdef CONFIG_EROFS_FS_DEBUG - /* since the on-disk name could not have the trailing '\0' */ - unsigned char dbg_namebuf[EROFS_NAME_LEN + 1]; - - memcpy(dbg_namebuf, de_name, de_namelen); - dbg_namebuf[de_namelen] = '\0'; - - erofs_dbg("found dirent %s de_len %u d_type %d", dbg_namebuf, - de_namelen, d_type); -#endif -} - static int erofs_fill_dentries(struct inode *dir, struct dir_context *ctx, void *dentry_blk, struct erofs_dirent *de, unsigned int nameoff, unsigned int maxsize) @@ -52,10 +37,8 @@ static int erofs_fill_dentries(struct inode *dir, struct dir_context *ctx, return -EFSCORRUPTED; } - debug_one_dentry(d_type, de_name, de_namelen); if (!dir_emit(ctx, de_name, de_namelen, le64_to_cpu(de->nid), d_type)) - /* stopped by some reason */ return 1; ++de; ctx->pos += sizeof(struct erofs_dirent); From patchwork Sat Jan 14 12:57:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Xiang X-Patchwork-Id: 43748 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp277700wrn; Sat, 14 Jan 2023 05:12:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXtWPHUAPinNz1heFkiLwdr4aQo0Gmc6nTgtO7yRR/5BsGRum3wJkB5ChSdFwu1MBv6u+4BD X-Received: by 2002:a62:84c9:0:b0:581:1f4b:d1e5 with SMTP id k192-20020a6284c9000000b005811f4bd1e5mr68128871pfd.12.1673701976878; Sat, 14 Jan 2023 05:12:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673701976; cv=none; d=google.com; s=arc-20160816; b=lFXOVk2wY23CY5ej+jcW0xDOMdxpAZ3ElpKEBAI+4t6S2TTNjPx9PK1/bVulVcMgRX gtbNsYc9e1hQjMVgc9AItMIGZwIduBtOgdaRCeqVkuc/vnYixTWlU4glAmAV0uiS9HJj fltoVIapLt2Xj0L/X0XS75O5hSlxaa9aYZDzm4h6fAVu3ytt+Z9b72wfXG9NDVkZJfBz oZ1KsW7qu/o/q17uAvWvr84qKhoj+Ux3CsByXwwUMr4+/SLNMLzHweu6NXzWCfPZq4TK TUmgwApz+SQ1aJqt3Y8Tdrf9UIi+C8i09kPLWtXki92tfEJ6hIJVHyX9PKe8E9EStPeV Ho8A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KcWo6Kwj04fiuHP8et0jUcJ5ogmx8xfBOFgUq9bnMfg=; b=EeY/l77wx/GT8jswDKrHg/ePFXn7XkNra6IJa5WryecyauwTfsE+/br9DaxWGFrmdq afjeJ1YKC6gCfc0BOyPJ5eyAA8k7exaa2eWZp9tZppAodZuc6ItY8QqqkBeHYkcjLwDo bzASDr8VLjoiEGqFDL1X37MfuloxUF+1IxL8ZC/tOKwgGbDJv+1OTj1b9fkYu/J7Rjec A2QvcbF72/YasXF1s64xzIZ589WeUrsuFZc/9JZO/hFGraGEqRwdc4mJfxKlLLTD1+RN Su+N501m44CbjzuahYwxUPqaUoXPqiTAReHM6lGeuH3H/ATAFc8U1dzEL1vv+tdyKRjT 0l6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P8kcW9Fa; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020a056a0022c200b0058bc7462962si2228071pfj.80.2023.01.14.05.12.42; Sat, 14 Jan 2023 05:12:56 -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=@kernel.org header.s=k20201202 header.b=P8kcW9Fa; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229652AbjANM6Y (ORCPT + 99 others); Sat, 14 Jan 2023 07:58:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbjANM6U (ORCPT ); Sat, 14 Jan 2023 07:58:20 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41D3B8A6F for ; Sat, 14 Jan 2023 04:58:19 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 45730CE062B for ; Sat, 14 Jan 2023 12:58:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19278C433D2; Sat, 14 Jan 2023 12:58:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673701095; bh=/LYB2TwpC+HPUPWYl+FMF4k9ra4MQtGSeEtXZo29/rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P8kcW9Fa7n9kWGIFVlbyX6iV4O5zELbms8nkLKF2tQyKUM1Vu5TjzGIhkTV1qCq9+ mhXACSG1qlEA8Hohi6zp2X82+DVdu8rXW+pjAygfPPw2VT4jfgVwZFWLR7efrp++AV dPwPVREG1FA+PNvKEcf4pmF3cE4uQl8uC0nKFgI3WZ57Qc74Z56kLpctVtzNBn54TW kmHKdLWx4PW0TCEV+ZJoSd71wzJomb/hkMGeN9NB2mrOMUaxpOpgn3kZu9wcRpz2PY xrg1kEJTc/UR6bBE5+kWYrHvgdskqh6Yjx4IpB/0MRt7Ka7eLKSSA7wW0vp4xdJGJB br5+8C0kfToIQ== From: Gao Xiang To: linux-erofs@lists.ozlabs.org, Chao Yu , Yue Hu , Jingbo Xu Cc: LKML , Gao Xiang Subject: [PATCH 2/2] erofs: simplify iloc() Date: Sat, 14 Jan 2023 20:57:46 +0800 Message-Id: <20230114125746.399253-2-xiang@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230114125746.399253-1-xiang@kernel.org> References: <20230114125746.399253-1-xiang@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755003724021499405?= X-GMAIL-MSGID: =?utf-8?q?1755003724021499405?= From: Gao Xiang Actually we could pass in inodes directly to clean up all callers. Also rename iloc() as erofs_iloc(). Signed-off-by: Gao Xiang --- fs/erofs/data.c | 9 +++------ fs/erofs/inode.c | 2 +- fs/erofs/internal.h | 16 +++++++++------- fs/erofs/xattr.c | 20 +++++++------------- fs/erofs/zmap.c | 13 +++++-------- 5 files changed, 25 insertions(+), 35 deletions(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index f57f921683d7..2713257ee718 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -91,11 +91,8 @@ static int erofs_map_blocks_flatmode(struct inode *inode, map->m_pa = blknr_to_addr(vi->raw_blkaddr) + map->m_la; map->m_plen = blknr_to_addr(lastblk) - offset; } else if (tailendpacking) { - /* 2 - inode inline B: inode, [xattrs], inline last blk... */ - struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); - - map->m_pa = iloc(sbi, vi->nid) + vi->inode_isize + - vi->xattr_isize + erofs_blkoff(map->m_la); + map->m_pa = erofs_iloc(inode) + vi->inode_isize + + vi->xattr_isize + erofs_blkoff(offset); map->m_plen = inode->i_size - offset; /* inline data should be located in the same meta block */ @@ -150,7 +147,7 @@ int erofs_map_blocks(struct inode *inode, unit = EROFS_BLOCK_MAP_ENTRY_SIZE; /* block map */ chunknr = map->m_la >> vi->chunkbits; - pos = ALIGN(iloc(EROFS_SB(sb), vi->nid) + vi->inode_isize + + pos = ALIGN(erofs_iloc(inode) + vi->inode_isize + vi->xattr_isize, unit) + unit * chunknr; kaddr = erofs_read_metabuf(&buf, sb, erofs_blknr(pos), EROFS_KMAP); diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c index 57328691582e..d7e87d41f7bf 100644 --- a/fs/erofs/inode.c +++ b/fs/erofs/inode.c @@ -14,7 +14,7 @@ static void *erofs_read_inode(struct erofs_buf *buf, struct super_block *sb = inode->i_sb; struct erofs_sb_info *sbi = EROFS_SB(sb); struct erofs_inode *vi = EROFS_I(inode); - const erofs_off_t inode_loc = iloc(sbi, vi->nid); + const erofs_off_t inode_loc = erofs_iloc(inode); erofs_blk_t blkaddr, nblks = 0; void *kaddr; diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index b4cc40fa3803..b7291691be68 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -270,11 +270,6 @@ struct erofs_buf { #define erofs_blkoff(addr) ((addr) % EROFS_BLKSIZ) #define blknr_to_addr(nr) ((erofs_off_t)(nr) * EROFS_BLKSIZ) -static inline erofs_off_t iloc(struct erofs_sb_info *sbi, erofs_nid_t nid) -{ - return blknr_to_addr(sbi->meta_blkaddr) + (nid << sbi->islotbits); -} - #define EROFS_FEATURE_FUNCS(name, compat, feature) \ static inline bool erofs_sb_has_##name(struct erofs_sb_info *sbi) \ { \ @@ -339,8 +334,15 @@ struct erofs_inode { struct inode vfs_inode; }; -#define EROFS_I(ptr) \ - container_of(ptr, struct erofs_inode, vfs_inode) +#define EROFS_I(ptr) container_of(ptr, struct erofs_inode, vfs_inode) + +static inline erofs_off_t erofs_iloc(struct inode *inode) +{ + struct erofs_sb_info *sbi = EROFS_I_SB(sbi); + + return blknr_to_addr(sbi->meta_blkaddr) + + (EROFS_I(nid) << sbi->islotbits); +} static inline unsigned long erofs_inode_datablocks(struct inode *inode) { diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c index a62fb8a3318a..60729b1220b6 100644 --- a/fs/erofs/xattr.c +++ b/fs/erofs/xattr.c @@ -22,8 +22,7 @@ static int init_inode_xattrs(struct inode *inode) struct xattr_iter it; unsigned int i; struct erofs_xattr_ibody_header *ih; - struct super_block *sb; - struct erofs_sb_info *sbi; + struct super_block *sb = inode->i_sb; int ret = 0; /* the most case is that xattrs of this inode are initialized. */ @@ -52,15 +51,14 @@ static int init_inode_xattrs(struct inode *inode) * undefined right now (maybe use later with some new sb feature). */ if (vi->xattr_isize == sizeof(struct erofs_xattr_ibody_header)) { - erofs_err(inode->i_sb, + erofs_err(sb, "xattr_isize %d of nid %llu is not supported yet", vi->xattr_isize, vi->nid); ret = -EOPNOTSUPP; goto out_unlock; } else if (vi->xattr_isize < sizeof(struct erofs_xattr_ibody_header)) { if (vi->xattr_isize) { - erofs_err(inode->i_sb, - "bogus xattr ibody @ nid %llu", vi->nid); + erofs_err(sb, "bogus xattr ibody @ nid %llu", vi->nid); DBG_BUGON(1); ret = -EFSCORRUPTED; goto out_unlock; /* xattr ondisk layout error */ @@ -69,11 +67,9 @@ static int init_inode_xattrs(struct inode *inode) goto out_unlock; } - sb = inode->i_sb; - sbi = EROFS_SB(sb); it.buf = __EROFS_BUF_INITIALIZER; - it.blkaddr = erofs_blknr(iloc(sbi, vi->nid) + vi->inode_isize); - it.ofs = erofs_blkoff(iloc(sbi, vi->nid) + vi->inode_isize); + it.blkaddr = erofs_blknr(erofs_iloc(inode) + vi->inode_isize); + it.ofs = erofs_blkoff(erofs_iloc(inode) + vi->inode_isize); /* read in shared xattr array (non-atomic, see kmalloc below) */ it.kaddr = erofs_read_metabuf(&it.buf, sb, it.blkaddr, EROFS_KMAP); @@ -159,7 +155,6 @@ static int inline_xattr_iter_begin(struct xattr_iter *it, struct inode *inode) { struct erofs_inode *const vi = EROFS_I(inode); - struct erofs_sb_info *const sbi = EROFS_SB(inode->i_sb); unsigned int xattr_header_sz, inline_xattr_ofs; xattr_header_sz = inlinexattr_header_size(inode); @@ -170,9 +165,8 @@ static int inline_xattr_iter_begin(struct xattr_iter *it, inline_xattr_ofs = vi->inode_isize + xattr_header_sz; - it->blkaddr = erofs_blknr(iloc(sbi, vi->nid) + inline_xattr_ofs); - it->ofs = erofs_blkoff(iloc(sbi, vi->nid) + inline_xattr_ofs); - + it->blkaddr = erofs_blknr(erofs_iloc(inode) + inline_xattr_ofs); + it->ofs = erofs_blkoff(erofs_iloc(inode) + inline_xattr_ofs); it->kaddr = erofs_read_metabuf(&it->buf, inode->i_sb, it->blkaddr, EROFS_KMAP); if (IS_ERR(it->kaddr)) diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c index 98fb90b9af71..3aeffc762b2f 100644 --- a/fs/erofs/zmap.c +++ b/fs/erofs/zmap.c @@ -55,8 +55,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode) if (test_bit(EROFS_I_Z_INITED_BIT, &vi->flags)) goto out_unlock; - pos = ALIGN(iloc(EROFS_SB(sb), vi->nid) + vi->inode_isize + - vi->xattr_isize, 8); + pos = ALIGN(erofs_iloc(inode) + vi->inode_isize + vi->xattr_isize, 8); kaddr = erofs_read_metabuf(&buf, sb, erofs_blknr(pos), EROFS_KMAP); if (IS_ERR(kaddr)) { err = PTR_ERR(kaddr); @@ -169,10 +168,9 @@ static int legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m, { struct inode *const inode = m->inode; struct erofs_inode *const vi = EROFS_I(inode); - const erofs_off_t ibase = iloc(EROFS_I_SB(inode), vi->nid); const erofs_off_t pos = - Z_EROFS_VLE_LEGACY_INDEX_ALIGN(ibase + vi->inode_isize + - vi->xattr_isize) + + Z_EROFS_VLE_LEGACY_INDEX_ALIGN(erofs_iloc(inode) + + vi->inode_isize + vi->xattr_isize) + lcn * sizeof(struct z_erofs_vle_decompressed_index); struct z_erofs_vle_decompressed_index *di; unsigned int advise, type; @@ -372,9 +370,8 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m, struct inode *const inode = m->inode; struct erofs_inode *const vi = EROFS_I(inode); const unsigned int lclusterbits = vi->z_logical_clusterbits; - const erofs_off_t ebase = ALIGN(iloc(EROFS_I_SB(inode), vi->nid) + - vi->inode_isize + vi->xattr_isize, 8) + - sizeof(struct z_erofs_map_header); + const erofs_off_t ebase = sizeof(struct z_erofs_map_header) + + ALIGN(erofs_iloc(inode) + vi->inode_isize + vi->xattr_isize, 8); const unsigned int totalidx = DIV_ROUND_UP(inode->i_size, EROFS_BLKSIZ); unsigned int compacted_4b_initial, compacted_2b; unsigned int amortizedshift;