All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huang Jianan <huangjianan@oppo.com>
To: linux-erofs@lists.ozlabs.org
Cc: guoweichao@oppo.com, zhangshiming@oppo.com
Subject: [PATCH v2] erofs: fix wrong address in erofs_get_block
Date: Tue,  8 Dec 2020 17:31:33 +0800	[thread overview]
Message-ID: <20201208093133.5865-1-huangjianan@oppo.com> (raw)

iblock indicates the number of i_blkbits-sized blocks rather than
sectors, fix it.

If the data has a disk mapping, map_bh should be used to read the
correct data from the device.

Fixes: 9da681e017a3 ("staging: erofs: support bmap")
Signed-off-by: Huang Jianan <huangjianan@oppo.com>
Signed-off-by: Guo Weichao <guoweichao@oppo.com>
---
 fs/erofs/data.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 347be146884c..aad3fb68d6c8 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -316,7 +316,7 @@ 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,
+		.m_la = blknr_to_addr(iblock),
 	};
 	int err;
 
@@ -325,7 +325,7 @@ static int erofs_get_block(struct inode *inode, sector_t iblock,
 		return err;
 
 	if (map.m_flags & EROFS_MAP_MAPPED)
-		bh->b_blocknr = erofs_blknr(map.m_pa);
+		map_bh(bh, inode->i_sb, erofs_blknr(map.m_pa));
 
 	return err;
 }
-- 
2.25.1


             reply	other threads:[~2020-12-08  9:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08  9:31 Huang Jianan [this message]
2020-12-08  9:48 ` [PATCH v2] erofs: fix wrong address in erofs_get_block Chao Yu
2020-12-08 10:35   ` Gao Xiang
2020-12-08 13:09     ` Huang Jianan
2020-12-08 13:07   ` Huang Jianan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201208093133.5865-1-huangjianan@oppo.com \
    --to=huangjianan@oppo.com \
    --cc=guoweichao@oppo.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=zhangshiming@oppo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.