linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] f2fs: rename logical_to_blk and blk_to_logical
@ 2020-11-26  2:24 Jaegeuk Kim
  2020-11-26  2:24 ` [PATCH 2/4] f2fs: use new conversion functions between blks and bytes Jaegeuk Kim
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Jaegeuk Kim @ 2020-11-26  2:24 UTC (permalink / raw)
  To: linux-kernel, kernel-team; +Cc: Jaegeuk Kim

This patch renames two functions like below having u64.
 - logical_to_blk to bytes_to_blks
 - blk_to_logical to blks_to_bytes

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/data.c | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index be4da52604ed..a8612c6f40ab 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1808,14 +1808,14 @@ static int get_data_block_bmap(struct inode *inode, sector_t iblock,
 						NO_CHECK_TYPE, create);
 }
 
-static inline sector_t logical_to_blk(struct inode *inode, loff_t offset)
+static inline u64 bytes_to_blks(struct inode *inode, u64 bytes)
 {
-	return (offset >> inode->i_blkbits);
+	return (bytes >> inode->i_blkbits);
 }
 
-static inline loff_t blk_to_logical(struct inode *inode, sector_t blk)
+static inline u64 blks_to_bytes(struct inode *inode, u64 blks)
 {
-	return (blk << inode->i_blkbits);
+	return (blks << inode->i_blkbits);
 }
 
 static int f2fs_xattr_fiemap(struct inode *inode,
@@ -1843,7 +1843,7 @@ static int f2fs_xattr_fiemap(struct inode *inode,
 			return err;
 		}
 
-		phys = (__u64)blk_to_logical(inode, ni.blk_addr);
+		phys = blks_to_bytes(inode, ni.blk_addr);
 		offset = offsetof(struct f2fs_inode, i_addr) +
 					sizeof(__le32) * (DEF_ADDRS_PER_INODE -
 					get_inline_xattr_addrs(inode));
@@ -1875,7 +1875,7 @@ static int f2fs_xattr_fiemap(struct inode *inode,
 			return err;
 		}
 
-		phys = (__u64)blk_to_logical(inode, ni.blk_addr);
+		phys = blks_to_bytes(inode, ni.blk_addr);
 		len = inode->i_sb->s_blocksize;
 
 		f2fs_put_page(page, 1);
@@ -1945,18 +1945,18 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 			goto out;
 	}
 
-	if (logical_to_blk(inode, len) == 0)
-		len = blk_to_logical(inode, 1);
+	if (bytes_to_blks(inode, len) == 0)
+		len = blks_to_bytes(inode, 1);
 
-	start_blk = logical_to_blk(inode, start);
-	last_blk = logical_to_blk(inode, start + len - 1);
+	start_blk = bytes_to_blks(inode, start);
+	last_blk = bytes_to_blks(inode, start + len - 1);
 
 next:
 	memset(&map_bh, 0, sizeof(struct buffer_head));
 	map_bh.b_size = len;
 
 	if (compr_cluster)
-		map_bh.b_size = blk_to_logical(inode, cluster_size - 1);
+		map_bh.b_size = blks_to_bytes(inode, cluster_size - 1);
 
 	ret = get_data_block(inode, start_blk, &map_bh, 0,
 					F2FS_GET_BLOCK_FIEMAP, &next_pgofs);
@@ -1967,7 +1967,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 	if (!buffer_mapped(&map_bh)) {
 		start_blk = next_pgofs;
 
-		if (blk_to_logical(inode, start_blk) < blk_to_logical(inode,
+		if (blks_to_bytes(inode, start_blk) < blks_to_bytes(inode,
 						max_inode_blocks(inode)))
 			goto prep_next;
 
@@ -1993,9 +1993,9 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		compr_cluster = false;
 
 
-		logical = blk_to_logical(inode, start_blk - 1);
-		phys = blk_to_logical(inode, map_bh.b_blocknr);
-		size = blk_to_logical(inode, cluster_size);
+		logical = blks_to_bytes(inode, start_blk - 1);
+		phys = blks_to_bytes(inode, map_bh.b_blocknr);
+		size = blks_to_bytes(inode, cluster_size);
 
 		flags |= FIEMAP_EXTENT_ENCODED;
 
@@ -2013,14 +2013,14 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		goto prep_next;
 	}
 
-	logical = blk_to_logical(inode, start_blk);
-	phys = blk_to_logical(inode, map_bh.b_blocknr);
+	logical = blks_to_bytes(inode, start_blk);
+	phys = blks_to_bytes(inode, map_bh.b_blocknr);
 	size = map_bh.b_size;
 	flags = 0;
 	if (buffer_unwritten(&map_bh))
 		flags = FIEMAP_EXTENT_UNWRITTEN;
 
-	start_blk += logical_to_blk(inode, size);
+	start_blk += bytes_to_blks(inode, size);
 
 prep_next:
 	cond_resched();
@@ -3903,7 +3903,7 @@ static int check_swap_activate_fast(struct swap_info_struct *sis,
 	 * to be very smart.
 	 */
 	cur_lblock = 0;
-	last_lblock = logical_to_blk(inode, i_size_read(inode));
+	last_lblock = bytes_to_blks(inode, i_size_read(inode));
 	len = i_size_read(inode);
 
 	while (cur_lblock <= last_lblock && cur_lblock < sis->max) {
@@ -3925,7 +3925,7 @@ static int check_swap_activate_fast(struct swap_info_struct *sis,
 			goto err_out;
 
 		pblock = map_bh.b_blocknr;
-		nr_pblocks = logical_to_blk(inode, map_bh.b_size);
+		nr_pblocks = bytes_to_blks(inode, map_bh.b_size);
 
 		if (cur_lblock + nr_pblocks >= sis->max)
 			nr_pblocks = sis->max - cur_lblock;
-- 
2.29.2.454.gaff20da3a2-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/4] f2fs: use new conversion functions between blks and bytes
  2020-11-26  2:24 [PATCH 1/4] f2fs: rename logical_to_blk and blk_to_logical Jaegeuk Kim
@ 2020-11-26  2:24 ` Jaegeuk Kim
  2020-12-01  4:09   ` Jaegeuk Kim
  2020-11-26  2:24 ` [PATCH 3/4] f2fs: fix wrong block count instead of bytes Jaegeuk Kim
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Jaegeuk Kim @ 2020-11-26  2:24 UTC (permalink / raw)
  To: linux-kernel, kernel-team; +Cc: Jaegeuk Kim

This patch cleans up blks and bytes conversions.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/data.c | 46 +++++++++++++++++++++-------------------------
 1 file changed, 21 insertions(+), 25 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index a8612c6f40ab..a84e5bc09337 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1750,6 +1750,16 @@ bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len)
 	return true;
 }
 
+static inline u64 bytes_to_blks(struct inode *inode, u64 bytes)
+{
+	return (bytes >> inode->i_blkbits);
+}
+
+static inline u64 blks_to_bytes(struct inode *inode, u64 blks)
+{
+	return (blks << inode->i_blkbits);
+}
+
 static int __get_data_block(struct inode *inode, sector_t iblock,
 			struct buffer_head *bh, int create, int flag,
 			pgoff_t *next_pgofs, int seg_type, bool may_write)
@@ -1758,7 +1768,7 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
 	int err;
 
 	map.m_lblk = iblock;
-	map.m_len = bh->b_size >> inode->i_blkbits;
+	map.m_len = bytes_to_blks(inode, bh->b_size);
 	map.m_next_pgofs = next_pgofs;
 	map.m_next_extent = NULL;
 	map.m_seg_type = seg_type;
@@ -1768,7 +1778,7 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
 	if (!err) {
 		map_bh(bh, inode->i_sb, map.m_pblk);
 		bh->b_state = (bh->b_state & ~F2FS_MAP_FLAGS) | map.m_flags;
-		bh->b_size = (u64)map.m_len << inode->i_blkbits;
+		bh->b_size = blks_to_bytes(inode, map.m_len);
 	}
 	return err;
 }
@@ -1808,16 +1818,6 @@ static int get_data_block_bmap(struct inode *inode, sector_t iblock,
 						NO_CHECK_TYPE, create);
 }
 
-static inline u64 bytes_to_blks(struct inode *inode, u64 bytes)
-{
-	return (bytes >> inode->i_blkbits);
-}
-
-static inline u64 blks_to_bytes(struct inode *inode, u64 blks)
-{
-	return (blks << inode->i_blkbits);
-}
-
 static int f2fs_xattr_fiemap(struct inode *inode,
 				struct fiemap_extent_info *fieinfo)
 {
@@ -2053,8 +2053,7 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page,
 					bool is_readahead)
 {
 	struct bio *bio = *bio_ret;
-	const unsigned blkbits = inode->i_blkbits;
-	const unsigned blocksize = 1 << blkbits;
+	const unsigned blocksize = blks_to_bytes(inode, 1);
 	sector_t block_in_file;
 	sector_t last_block;
 	sector_t last_block_in_file;
@@ -2063,8 +2062,8 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page,
 
 	block_in_file = (sector_t)page_index(page);
 	last_block = block_in_file + nr_pages;
-	last_block_in_file = (f2fs_readpage_limit(inode) + blocksize - 1) >>
-							blkbits;
+	last_block_in_file = bytes_to_blks(inode,
+			f2fs_readpage_limit(inode) + blocksize - 1);
 	if (last_block > last_block_in_file)
 		last_block = last_block_in_file;
 
@@ -2177,16 +2176,15 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
 	struct bio *bio = *bio_ret;
 	unsigned int start_idx = cc->cluster_idx << cc->log_cluster_size;
 	sector_t last_block_in_file;
-	const unsigned blkbits = inode->i_blkbits;
-	const unsigned blocksize = 1 << blkbits;
+	const unsigned blocksize = blks_to_bytes(inode, 1);
 	struct decompress_io_ctx *dic = NULL;
 	int i;
 	int ret = 0;
 
 	f2fs_bug_on(sbi, f2fs_cluster_is_empty(cc));
 
-	last_block_in_file = (f2fs_readpage_limit(inode) +
-					blocksize - 1) >> blkbits;
+	last_block_in_file = bytes_to_blks(inode,
+			f2fs_readpage_limit(inode) + blocksize - 1);
 
 	/* get rid of pages beyond EOF */
 	for (i = 0; i < cc->cluster_size; i++) {
@@ -3968,7 +3966,6 @@ static int check_swap_activate(struct swap_info_struct *sis,
 	struct inode *inode = mapping->host;
 	unsigned blocks_per_page;
 	unsigned long page_no;
-	unsigned blkbits;
 	sector_t probe_block;
 	sector_t last_block;
 	sector_t lowest_block = -1;
@@ -3979,8 +3976,7 @@ static int check_swap_activate(struct swap_info_struct *sis,
 	if (PAGE_SIZE == F2FS_BLKSIZE)
 		return check_swap_activate_fast(sis, swap_file, span);
 
-	blkbits = inode->i_blkbits;
-	blocks_per_page = PAGE_SIZE >> blkbits;
+	blocks_per_page = bytes_to_blks(inode, PAGE_SIZE);
 
 	/*
 	 * Map all the blocks into the extent list.  This code doesn't try
@@ -3988,7 +3984,7 @@ static int check_swap_activate(struct swap_info_struct *sis,
 	 */
 	probe_block = 0;
 	page_no = 0;
-	last_block = i_size_read(inode) >> blkbits;
+	last_block = bytes_to_blks(inode, i_size_read(inode));
 	while ((probe_block + blocks_per_page) <= last_block &&
 			page_no < sis->max) {
 		unsigned block_in_page;
@@ -4028,7 +4024,7 @@ static int check_swap_activate(struct swap_info_struct *sis,
 			}
 		}
 
-		first_block >>= (PAGE_SHIFT - blkbits);
+		first_block >>= (PAGE_SHIFT - inode->i_blkbits);
 		if (page_no) {	/* exclude the header page */
 			if (first_block < lowest_block)
 				lowest_block = first_block;
-- 
2.29.2.454.gaff20da3a2-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/4] f2fs: fix wrong block count instead of bytes
  2020-11-26  2:24 [PATCH 1/4] f2fs: rename logical_to_blk and blk_to_logical Jaegeuk Kim
  2020-11-26  2:24 ` [PATCH 2/4] f2fs: use new conversion functions between blks and bytes Jaegeuk Kim
@ 2020-11-26  2:24 ` Jaegeuk Kim
  2020-12-01  4:09   ` Jaegeuk Kim
  2020-11-26  2:24 ` [PATCH 4/4] f2fs: remove buffer_head which has 32bits limit Jaegeuk Kim
  2020-12-01  4:09 ` [PATCH 1/4] f2fs: rename logical_to_blk and blk_to_logical Jaegeuk Kim
  3 siblings, 1 reply; 12+ messages in thread
From: Jaegeuk Kim @ 2020-11-26  2:24 UTC (permalink / raw)
  To: linux-kernel, kernel-team; +Cc: Jaegeuk Kim

We should convert cur_lblock, a block count, to bytes for len.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/data.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index a84e5bc09337..e49c14ccfafe 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3893,7 +3893,7 @@ static int check_swap_activate_fast(struct swap_info_struct *sis,
 	sector_t highest_pblock = 0;
 	int nr_extents = 0;
 	unsigned long nr_pblocks;
-	unsigned long len;
+	u64 len;
 	int ret;
 
 	/*
@@ -3911,7 +3911,7 @@ static int check_swap_activate_fast(struct swap_info_struct *sis,
 		cond_resched();
 
 		memset(&map_bh, 0, sizeof(struct buffer_head));
-		map_bh.b_size = len - cur_lblock;
+		map_bh.b_size = len - blks_to_bytes(inode, cur_lblock);
 
 		ret = get_data_block(inode, cur_lblock, &map_bh, 0,
 					F2FS_GET_BLOCK_FIEMAP, &next_pgofs);
-- 
2.29.2.454.gaff20da3a2-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/4] f2fs: remove buffer_head which has 32bits limit
  2020-11-26  2:24 [PATCH 1/4] f2fs: rename logical_to_blk and blk_to_logical Jaegeuk Kim
  2020-11-26  2:24 ` [PATCH 2/4] f2fs: use new conversion functions between blks and bytes Jaegeuk Kim
  2020-11-26  2:24 ` [PATCH 3/4] f2fs: fix wrong block count instead of bytes Jaegeuk Kim
@ 2020-11-26  2:24 ` Jaegeuk Kim
  2020-12-01  4:09   ` Jaegeuk Kim
  2020-12-01  4:09 ` [PATCH 1/4] f2fs: rename logical_to_blk and blk_to_logical Jaegeuk Kim
  3 siblings, 1 reply; 12+ messages in thread
From: Jaegeuk Kim @ 2020-11-26  2:24 UTC (permalink / raw)
  To: linux-kernel, kernel-team; +Cc: Jaegeuk Kim, Light Hsieh

This patch removes buffer_head dependency when getting block addresses.
Light reported there's a 32bit issue in f2fs_fiemap where map_bh.b_size is
32bits while len is 64bits given by user. This will give wrong length to
f2fs_map_block.

Reported-by: Light Hsieh <Light.Hsieh@mediatek.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/data.c | 76 ++++++++++++++++++++++----------------------------
 1 file changed, 34 insertions(+), 42 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index e49c14ccfafe..bfe0d787c9e6 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1783,15 +1783,6 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
 	return err;
 }
 
-static int get_data_block(struct inode *inode, sector_t iblock,
-			struct buffer_head *bh_result, int create, int flag,
-			pgoff_t *next_pgofs)
-{
-	return __get_data_block(inode, iblock, bh_result, create,
-							flag, next_pgofs,
-							NO_CHECK_TYPE, create);
-}
-
 static int get_data_block_dio_write(struct inode *inode, sector_t iblock,
 			struct buffer_head *bh_result, int create)
 {
@@ -1810,14 +1801,6 @@ static int get_data_block_dio(struct inode *inode, sector_t iblock,
 				false);
 }
 
-static int get_data_block_bmap(struct inode *inode, sector_t iblock,
-			struct buffer_head *bh_result, int create)
-{
-	return __get_data_block(inode, iblock, bh_result, create,
-						F2FS_GET_BLOCK_BMAP, NULL,
-						NO_CHECK_TYPE, create);
-}
-
 static int f2fs_xattr_fiemap(struct inode *inode,
 				struct fiemap_extent_info *fieinfo)
 {
@@ -1913,7 +1896,7 @@ static loff_t max_inode_blocks(struct inode *inode)
 int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		u64 start, u64 len)
 {
-	struct buffer_head map_bh;
+	struct f2fs_map_blocks map;
 	sector_t start_blk, last_blk;
 	pgoff_t next_pgofs;
 	u64 logical = 0, phys = 0, size = 0;
@@ -1952,19 +1935,21 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 	last_blk = bytes_to_blks(inode, start + len - 1);
 
 next:
-	memset(&map_bh, 0, sizeof(struct buffer_head));
-	map_bh.b_size = len;
+	memset(&map, 0, sizeof(map));
+	map.m_lblk = start_blk;
+	map.m_len = bytes_to_blks(inode, len);
+	map.m_next_pgofs = &next_pgofs;
+	map.m_seg_type = NO_CHECK_TYPE;
 
 	if (compr_cluster)
-		map_bh.b_size = blks_to_bytes(inode, cluster_size - 1);
+		map.m_len = cluster_size - 1;
 
-	ret = get_data_block(inode, start_blk, &map_bh, 0,
-					F2FS_GET_BLOCK_FIEMAP, &next_pgofs);
+	ret = f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_FIEMAP);
 	if (ret)
 		goto out;
 
 	/* HOLE */
-	if (!buffer_mapped(&map_bh)) {
+	if (!(map.m_flags & F2FS_MAP_FLAGS)) {
 		start_blk = next_pgofs;
 
 		if (blks_to_bytes(inode, start_blk) < blks_to_bytes(inode,
@@ -1994,7 +1979,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 
 
 		logical = blks_to_bytes(inode, start_blk - 1);
-		phys = blks_to_bytes(inode, map_bh.b_blocknr);
+		phys = blks_to_bytes(inode, map.m_pblk);
 		size = blks_to_bytes(inode, cluster_size);
 
 		flags |= FIEMAP_EXTENT_ENCODED;
@@ -2007,17 +1992,17 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		goto prep_next;
 	}
 
-	if (map_bh.b_blocknr == COMPRESS_ADDR) {
+	if (map.m_pblk == COMPRESS_ADDR) {
 		compr_cluster = true;
 		start_blk++;
 		goto prep_next;
 	}
 
 	logical = blks_to_bytes(inode, start_blk);
-	phys = blks_to_bytes(inode, map_bh.b_blocknr);
-	size = map_bh.b_size;
+	phys = blks_to_bytes(inode, map.m_pblk);
+	size = blks_to_bytes(inode, map.m_len);
 	flags = 0;
-	if (buffer_unwritten(&map_bh))
+	if (map.m_flags & F2FS_MAP_UNWRITTEN)
 		flags = FIEMAP_EXTENT_UNWRITTEN;
 
 	start_blk += bytes_to_blks(inode, size);
@@ -3797,9 +3782,6 @@ static sector_t f2fs_bmap_compress(struct inode *inode, sector_t block)
 static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
 {
 	struct inode *inode = mapping->host;
-	struct buffer_head tmp = {
-		.b_size = i_blocksize(inode),
-	};
 	sector_t blknr = 0;
 
 	if (f2fs_has_inline_data(inode))
@@ -3816,8 +3798,16 @@ static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
 	if (f2fs_compressed_file(inode)) {
 		blknr = f2fs_bmap_compress(inode, block);
 	} else {
-		if (!get_data_block_bmap(inode, block, &tmp, 0))
-			blknr = tmp.b_blocknr;
+		struct f2fs_map_blocks map;
+
+		memset(&map, 0, sizeof(map));
+		map.m_lblk = block;
+		map.m_len = 1;
+		map.m_next_pgofs = NULL;
+		map.m_seg_type = NO_CHECK_TYPE;
+
+		if (!f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_BMAP))
+			blknr = map.m_pblk;
 	}
 out:
 	trace_f2fs_bmap(inode, block, blknr);
@@ -3905,25 +3895,27 @@ static int check_swap_activate_fast(struct swap_info_struct *sis,
 	len = i_size_read(inode);
 
 	while (cur_lblock <= last_lblock && cur_lblock < sis->max) {
-		struct buffer_head map_bh;
+		struct f2fs_map_blocks map;
 		pgoff_t next_pgofs;
 
 		cond_resched();
 
-		memset(&map_bh, 0, sizeof(struct buffer_head));
-		map_bh.b_size = len - blks_to_bytes(inode, cur_lblock);
+		memset(&map, 0, sizeof(map));
+		map.m_lblk = cur_lblock;
+		map.m_len = bytes_to_blks(inode, len) - cur_lblock;
+		map.m_next_pgofs = &next_pgofs;
+		map.m_seg_type = NO_CHECK_TYPE;
 
-		ret = get_data_block(inode, cur_lblock, &map_bh, 0,
-					F2FS_GET_BLOCK_FIEMAP, &next_pgofs);
+		ret = f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_FIEMAP);
 		if (ret)
 			goto err_out;
 
 		/* hole */
-		if (!buffer_mapped(&map_bh))
+		if (!(map.m_flags & F2FS_MAP_FLAGS))
 			goto err_out;
 
-		pblock = map_bh.b_blocknr;
-		nr_pblocks = bytes_to_blks(inode, map_bh.b_size);
+		pblock = map.m_pblk;
+		nr_pblocks = map.m_len;
 
 		if (cur_lblock + nr_pblocks >= sis->max)
 			nr_pblocks = sis->max - cur_lblock;
-- 
2.29.2.454.gaff20da3a2-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/4] f2fs: rename logical_to_blk and blk_to_logical
  2020-11-26  2:24 [PATCH 1/4] f2fs: rename logical_to_blk and blk_to_logical Jaegeuk Kim
                   ` (2 preceding siblings ...)
  2020-11-26  2:24 ` [PATCH 4/4] f2fs: remove buffer_head which has 32bits limit Jaegeuk Kim
@ 2020-12-01  4:09 ` Jaegeuk Kim
  2020-12-01  8:55   ` [f2fs-dev] " Chao Yu
  3 siblings, 1 reply; 12+ messages in thread
From: Jaegeuk Kim @ 2020-12-01  4:09 UTC (permalink / raw)
  To: linux-kernel, kernel-team; +Cc: Linux F2FS Dev Mailing List

Forgot to add f2fs mailing list.

On 11/25, Jaegeuk Kim wrote:
> This patch renames two functions like below having u64.
>  - logical_to_blk to bytes_to_blks
>  - blk_to_logical to blks_to_bytes
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/data.c | 40 ++++++++++++++++++++--------------------
>  1 file changed, 20 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index be4da52604ed..a8612c6f40ab 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1808,14 +1808,14 @@ static int get_data_block_bmap(struct inode *inode, sector_t iblock,
>  						NO_CHECK_TYPE, create);
>  }
>  
> -static inline sector_t logical_to_blk(struct inode *inode, loff_t offset)
> +static inline u64 bytes_to_blks(struct inode *inode, u64 bytes)
>  {
> -	return (offset >> inode->i_blkbits);
> +	return (bytes >> inode->i_blkbits);
>  }
>  
> -static inline loff_t blk_to_logical(struct inode *inode, sector_t blk)
> +static inline u64 blks_to_bytes(struct inode *inode, u64 blks)
>  {
> -	return (blk << inode->i_blkbits);
> +	return (blks << inode->i_blkbits);
>  }
>  
>  static int f2fs_xattr_fiemap(struct inode *inode,
> @@ -1843,7 +1843,7 @@ static int f2fs_xattr_fiemap(struct inode *inode,
>  			return err;
>  		}
>  
> -		phys = (__u64)blk_to_logical(inode, ni.blk_addr);
> +		phys = blks_to_bytes(inode, ni.blk_addr);
>  		offset = offsetof(struct f2fs_inode, i_addr) +
>  					sizeof(__le32) * (DEF_ADDRS_PER_INODE -
>  					get_inline_xattr_addrs(inode));
> @@ -1875,7 +1875,7 @@ static int f2fs_xattr_fiemap(struct inode *inode,
>  			return err;
>  		}
>  
> -		phys = (__u64)blk_to_logical(inode, ni.blk_addr);
> +		phys = blks_to_bytes(inode, ni.blk_addr);
>  		len = inode->i_sb->s_blocksize;
>  
>  		f2fs_put_page(page, 1);
> @@ -1945,18 +1945,18 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>  			goto out;
>  	}
>  
> -	if (logical_to_blk(inode, len) == 0)
> -		len = blk_to_logical(inode, 1);
> +	if (bytes_to_blks(inode, len) == 0)
> +		len = blks_to_bytes(inode, 1);
>  
> -	start_blk = logical_to_blk(inode, start);
> -	last_blk = logical_to_blk(inode, start + len - 1);
> +	start_blk = bytes_to_blks(inode, start);
> +	last_blk = bytes_to_blks(inode, start + len - 1);
>  
>  next:
>  	memset(&map_bh, 0, sizeof(struct buffer_head));
>  	map_bh.b_size = len;
>  
>  	if (compr_cluster)
> -		map_bh.b_size = blk_to_logical(inode, cluster_size - 1);
> +		map_bh.b_size = blks_to_bytes(inode, cluster_size - 1);
>  
>  	ret = get_data_block(inode, start_blk, &map_bh, 0,
>  					F2FS_GET_BLOCK_FIEMAP, &next_pgofs);
> @@ -1967,7 +1967,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>  	if (!buffer_mapped(&map_bh)) {
>  		start_blk = next_pgofs;
>  
> -		if (blk_to_logical(inode, start_blk) < blk_to_logical(inode,
> +		if (blks_to_bytes(inode, start_blk) < blks_to_bytes(inode,
>  						max_inode_blocks(inode)))
>  			goto prep_next;
>  
> @@ -1993,9 +1993,9 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>  		compr_cluster = false;
>  
>  
> -		logical = blk_to_logical(inode, start_blk - 1);
> -		phys = blk_to_logical(inode, map_bh.b_blocknr);
> -		size = blk_to_logical(inode, cluster_size);
> +		logical = blks_to_bytes(inode, start_blk - 1);
> +		phys = blks_to_bytes(inode, map_bh.b_blocknr);
> +		size = blks_to_bytes(inode, cluster_size);
>  
>  		flags |= FIEMAP_EXTENT_ENCODED;
>  
> @@ -2013,14 +2013,14 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>  		goto prep_next;
>  	}
>  
> -	logical = blk_to_logical(inode, start_blk);
> -	phys = blk_to_logical(inode, map_bh.b_blocknr);
> +	logical = blks_to_bytes(inode, start_blk);
> +	phys = blks_to_bytes(inode, map_bh.b_blocknr);
>  	size = map_bh.b_size;
>  	flags = 0;
>  	if (buffer_unwritten(&map_bh))
>  		flags = FIEMAP_EXTENT_UNWRITTEN;
>  
> -	start_blk += logical_to_blk(inode, size);
> +	start_blk += bytes_to_blks(inode, size);
>  
>  prep_next:
>  	cond_resched();
> @@ -3903,7 +3903,7 @@ static int check_swap_activate_fast(struct swap_info_struct *sis,
>  	 * to be very smart.
>  	 */
>  	cur_lblock = 0;
> -	last_lblock = logical_to_blk(inode, i_size_read(inode));
> +	last_lblock = bytes_to_blks(inode, i_size_read(inode));
>  	len = i_size_read(inode);
>  
>  	while (cur_lblock <= last_lblock && cur_lblock < sis->max) {
> @@ -3925,7 +3925,7 @@ static int check_swap_activate_fast(struct swap_info_struct *sis,
>  			goto err_out;
>  
>  		pblock = map_bh.b_blocknr;
> -		nr_pblocks = logical_to_blk(inode, map_bh.b_size);
> +		nr_pblocks = bytes_to_blks(inode, map_bh.b_size);
>  
>  		if (cur_lblock + nr_pblocks >= sis->max)
>  			nr_pblocks = sis->max - cur_lblock;
> -- 
> 2.29.2.454.gaff20da3a2-goog

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/4] f2fs: remove buffer_head which has 32bits limit
  2020-11-26  2:24 ` [PATCH 4/4] f2fs: remove buffer_head which has 32bits limit Jaegeuk Kim
@ 2020-12-01  4:09   ` Jaegeuk Kim
  2020-12-02  1:47     ` [f2fs-dev] " Chao Yu
  0 siblings, 1 reply; 12+ messages in thread
From: Jaegeuk Kim @ 2020-12-01  4:09 UTC (permalink / raw)
  To: linux-kernel, kernel-team; +Cc: Linux F2FS Dev Mailing List, Light Hsieh

On 11/25, Jaegeuk Kim wrote:
> This patch removes buffer_head dependency when getting block addresses.
> Light reported there's a 32bit issue in f2fs_fiemap where map_bh.b_size is
> 32bits while len is 64bits given by user. This will give wrong length to
> f2fs_map_block.
> 
> Reported-by: Light Hsieh <Light.Hsieh@mediatek.com>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/data.c | 76 ++++++++++++++++++++++----------------------------
>  1 file changed, 34 insertions(+), 42 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index e49c14ccfafe..bfe0d787c9e6 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1783,15 +1783,6 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
>  	return err;
>  }
>  
> -static int get_data_block(struct inode *inode, sector_t iblock,
> -			struct buffer_head *bh_result, int create, int flag,
> -			pgoff_t *next_pgofs)
> -{
> -	return __get_data_block(inode, iblock, bh_result, create,
> -							flag, next_pgofs,
> -							NO_CHECK_TYPE, create);
> -}
> -
>  static int get_data_block_dio_write(struct inode *inode, sector_t iblock,
>  			struct buffer_head *bh_result, int create)
>  {
> @@ -1810,14 +1801,6 @@ static int get_data_block_dio(struct inode *inode, sector_t iblock,
>  				false);
>  }
>  
> -static int get_data_block_bmap(struct inode *inode, sector_t iblock,
> -			struct buffer_head *bh_result, int create)
> -{
> -	return __get_data_block(inode, iblock, bh_result, create,
> -						F2FS_GET_BLOCK_BMAP, NULL,
> -						NO_CHECK_TYPE, create);
> -}
> -
>  static int f2fs_xattr_fiemap(struct inode *inode,
>  				struct fiemap_extent_info *fieinfo)
>  {
> @@ -1913,7 +1896,7 @@ static loff_t max_inode_blocks(struct inode *inode)
>  int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>  		u64 start, u64 len)
>  {
> -	struct buffer_head map_bh;
> +	struct f2fs_map_blocks map;
>  	sector_t start_blk, last_blk;
>  	pgoff_t next_pgofs;
>  	u64 logical = 0, phys = 0, size = 0;
> @@ -1952,19 +1935,21 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>  	last_blk = bytes_to_blks(inode, start + len - 1);
>  
>  next:
> -	memset(&map_bh, 0, sizeof(struct buffer_head));
> -	map_bh.b_size = len;
> +	memset(&map, 0, sizeof(map));
> +	map.m_lblk = start_blk;
> +	map.m_len = bytes_to_blks(inode, len);
> +	map.m_next_pgofs = &next_pgofs;
> +	map.m_seg_type = NO_CHECK_TYPE;
>  
>  	if (compr_cluster)
> -		map_bh.b_size = blks_to_bytes(inode, cluster_size - 1);
> +		map.m_len = cluster_size - 1;
>  
> -	ret = get_data_block(inode, start_blk, &map_bh, 0,
> -					F2FS_GET_BLOCK_FIEMAP, &next_pgofs);
> +	ret = f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_FIEMAP);
>  	if (ret)
>  		goto out;
>  
>  	/* HOLE */
> -	if (!buffer_mapped(&map_bh)) {
> +	if (!(map.m_flags & F2FS_MAP_FLAGS)) {
>  		start_blk = next_pgofs;
>  
>  		if (blks_to_bytes(inode, start_blk) < blks_to_bytes(inode,
> @@ -1994,7 +1979,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>  
>  
>  		logical = blks_to_bytes(inode, start_blk - 1);
> -		phys = blks_to_bytes(inode, map_bh.b_blocknr);
> +		phys = blks_to_bytes(inode, map.m_pblk);
>  		size = blks_to_bytes(inode, cluster_size);
>  
>  		flags |= FIEMAP_EXTENT_ENCODED;
> @@ -2007,17 +1992,17 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>  		goto prep_next;
>  	}
>  
> -	if (map_bh.b_blocknr == COMPRESS_ADDR) {
> +	if (map.m_pblk == COMPRESS_ADDR) {
>  		compr_cluster = true;
>  		start_blk++;
>  		goto prep_next;
>  	}
>  
>  	logical = blks_to_bytes(inode, start_blk);
> -	phys = blks_to_bytes(inode, map_bh.b_blocknr);
> -	size = map_bh.b_size;
> +	phys = blks_to_bytes(inode, map.m_pblk);
> +	size = blks_to_bytes(inode, map.m_len);
>  	flags = 0;
> -	if (buffer_unwritten(&map_bh))
> +	if (map.m_flags & F2FS_MAP_UNWRITTEN)
>  		flags = FIEMAP_EXTENT_UNWRITTEN;
>  
>  	start_blk += bytes_to_blks(inode, size);
> @@ -3797,9 +3782,6 @@ static sector_t f2fs_bmap_compress(struct inode *inode, sector_t block)
>  static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
>  {
>  	struct inode *inode = mapping->host;
> -	struct buffer_head tmp = {
> -		.b_size = i_blocksize(inode),
> -	};
>  	sector_t blknr = 0;
>  
>  	if (f2fs_has_inline_data(inode))
> @@ -3816,8 +3798,16 @@ static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
>  	if (f2fs_compressed_file(inode)) {
>  		blknr = f2fs_bmap_compress(inode, block);
>  	} else {
> -		if (!get_data_block_bmap(inode, block, &tmp, 0))
> -			blknr = tmp.b_blocknr;
> +		struct f2fs_map_blocks map;
> +
> +		memset(&map, 0, sizeof(map));
> +		map.m_lblk = block;
> +		map.m_len = 1;
> +		map.m_next_pgofs = NULL;
> +		map.m_seg_type = NO_CHECK_TYPE;
> +
> +		if (!f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_BMAP))
> +			blknr = map.m_pblk;
>  	}
>  out:
>  	trace_f2fs_bmap(inode, block, blknr);
> @@ -3905,25 +3895,27 @@ static int check_swap_activate_fast(struct swap_info_struct *sis,
>  	len = i_size_read(inode);
>  
>  	while (cur_lblock <= last_lblock && cur_lblock < sis->max) {
> -		struct buffer_head map_bh;
> +		struct f2fs_map_blocks map;
>  		pgoff_t next_pgofs;
>  
>  		cond_resched();
>  
> -		memset(&map_bh, 0, sizeof(struct buffer_head));
> -		map_bh.b_size = len - blks_to_bytes(inode, cur_lblock);
> +		memset(&map, 0, sizeof(map));
> +		map.m_lblk = cur_lblock;
> +		map.m_len = bytes_to_blks(inode, len) - cur_lblock;
> +		map.m_next_pgofs = &next_pgofs;
> +		map.m_seg_type = NO_CHECK_TYPE;
>  
> -		ret = get_data_block(inode, cur_lblock, &map_bh, 0,
> -					F2FS_GET_BLOCK_FIEMAP, &next_pgofs);
> +		ret = f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_FIEMAP);
>  		if (ret)
>  			goto err_out;
>  
>  		/* hole */
> -		if (!buffer_mapped(&map_bh))
> +		if (!(map.m_flags & F2FS_MAP_FLAGS))
>  			goto err_out;
>  
> -		pblock = map_bh.b_blocknr;
> -		nr_pblocks = bytes_to_blks(inode, map_bh.b_size);
> +		pblock = map.m_pblk;
> +		nr_pblocks = map.m_len;
>  
>  		if (cur_lblock + nr_pblocks >= sis->max)
>  			nr_pblocks = sis->max - cur_lblock;
> -- 
> 2.29.2.454.gaff20da3a2-goog

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/4] f2fs: fix wrong block count instead of bytes
  2020-11-26  2:24 ` [PATCH 3/4] f2fs: fix wrong block count instead of bytes Jaegeuk Kim
@ 2020-12-01  4:09   ` Jaegeuk Kim
  2020-12-01  9:03     ` [f2fs-dev] " Chao Yu
  0 siblings, 1 reply; 12+ messages in thread
From: Jaegeuk Kim @ 2020-12-01  4:09 UTC (permalink / raw)
  To: linux-kernel, kernel-team; +Cc: Linux F2FS Dev Mailing List

On 11/25, Jaegeuk Kim wrote:
> We should convert cur_lblock, a block count, to bytes for len.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/data.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index a84e5bc09337..e49c14ccfafe 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -3893,7 +3893,7 @@ static int check_swap_activate_fast(struct swap_info_struct *sis,
>  	sector_t highest_pblock = 0;
>  	int nr_extents = 0;
>  	unsigned long nr_pblocks;
> -	unsigned long len;
> +	u64 len;
>  	int ret;
>  
>  	/*
> @@ -3911,7 +3911,7 @@ static int check_swap_activate_fast(struct swap_info_struct *sis,
>  		cond_resched();
>  
>  		memset(&map_bh, 0, sizeof(struct buffer_head));
> -		map_bh.b_size = len - cur_lblock;
> +		map_bh.b_size = len - blks_to_bytes(inode, cur_lblock);
>  
>  		ret = get_data_block(inode, cur_lblock, &map_bh, 0,
>  					F2FS_GET_BLOCK_FIEMAP, &next_pgofs);
> -- 
> 2.29.2.454.gaff20da3a2-goog

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/4] f2fs: use new conversion functions between blks and bytes
  2020-11-26  2:24 ` [PATCH 2/4] f2fs: use new conversion functions between blks and bytes Jaegeuk Kim
@ 2020-12-01  4:09   ` Jaegeuk Kim
  2020-12-01  9:00     ` [f2fs-dev] " Chao Yu
  0 siblings, 1 reply; 12+ messages in thread
From: Jaegeuk Kim @ 2020-12-01  4:09 UTC (permalink / raw)
  To: linux-kernel, kernel-team; +Cc: Linux F2FS Dev Mailing List

On 11/25, Jaegeuk Kim wrote:
> This patch cleans up blks and bytes conversions.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/data.c | 46 +++++++++++++++++++++-------------------------
>  1 file changed, 21 insertions(+), 25 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index a8612c6f40ab..a84e5bc09337 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1750,6 +1750,16 @@ bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len)
>  	return true;
>  }
>  
> +static inline u64 bytes_to_blks(struct inode *inode, u64 bytes)
> +{
> +	return (bytes >> inode->i_blkbits);
> +}
> +
> +static inline u64 blks_to_bytes(struct inode *inode, u64 blks)
> +{
> +	return (blks << inode->i_blkbits);
> +}
> +
>  static int __get_data_block(struct inode *inode, sector_t iblock,
>  			struct buffer_head *bh, int create, int flag,
>  			pgoff_t *next_pgofs, int seg_type, bool may_write)
> @@ -1758,7 +1768,7 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
>  	int err;
>  
>  	map.m_lblk = iblock;
> -	map.m_len = bh->b_size >> inode->i_blkbits;
> +	map.m_len = bytes_to_blks(inode, bh->b_size);
>  	map.m_next_pgofs = next_pgofs;
>  	map.m_next_extent = NULL;
>  	map.m_seg_type = seg_type;
> @@ -1768,7 +1778,7 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
>  	if (!err) {
>  		map_bh(bh, inode->i_sb, map.m_pblk);
>  		bh->b_state = (bh->b_state & ~F2FS_MAP_FLAGS) | map.m_flags;
> -		bh->b_size = (u64)map.m_len << inode->i_blkbits;
> +		bh->b_size = blks_to_bytes(inode, map.m_len);
>  	}
>  	return err;
>  }
> @@ -1808,16 +1818,6 @@ static int get_data_block_bmap(struct inode *inode, sector_t iblock,
>  						NO_CHECK_TYPE, create);
>  }
>  
> -static inline u64 bytes_to_blks(struct inode *inode, u64 bytes)
> -{
> -	return (bytes >> inode->i_blkbits);
> -}
> -
> -static inline u64 blks_to_bytes(struct inode *inode, u64 blks)
> -{
> -	return (blks << inode->i_blkbits);
> -}
> -
>  static int f2fs_xattr_fiemap(struct inode *inode,
>  				struct fiemap_extent_info *fieinfo)
>  {
> @@ -2053,8 +2053,7 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page,
>  					bool is_readahead)
>  {
>  	struct bio *bio = *bio_ret;
> -	const unsigned blkbits = inode->i_blkbits;
> -	const unsigned blocksize = 1 << blkbits;
> +	const unsigned blocksize = blks_to_bytes(inode, 1);
>  	sector_t block_in_file;
>  	sector_t last_block;
>  	sector_t last_block_in_file;
> @@ -2063,8 +2062,8 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page,
>  
>  	block_in_file = (sector_t)page_index(page);
>  	last_block = block_in_file + nr_pages;
> -	last_block_in_file = (f2fs_readpage_limit(inode) + blocksize - 1) >>
> -							blkbits;
> +	last_block_in_file = bytes_to_blks(inode,
> +			f2fs_readpage_limit(inode) + blocksize - 1);
>  	if (last_block > last_block_in_file)
>  		last_block = last_block_in_file;
>  
> @@ -2177,16 +2176,15 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
>  	struct bio *bio = *bio_ret;
>  	unsigned int start_idx = cc->cluster_idx << cc->log_cluster_size;
>  	sector_t last_block_in_file;
> -	const unsigned blkbits = inode->i_blkbits;
> -	const unsigned blocksize = 1 << blkbits;
> +	const unsigned blocksize = blks_to_bytes(inode, 1);
>  	struct decompress_io_ctx *dic = NULL;
>  	int i;
>  	int ret = 0;
>  
>  	f2fs_bug_on(sbi, f2fs_cluster_is_empty(cc));
>  
> -	last_block_in_file = (f2fs_readpage_limit(inode) +
> -					blocksize - 1) >> blkbits;
> +	last_block_in_file = bytes_to_blks(inode,
> +			f2fs_readpage_limit(inode) + blocksize - 1);
>  
>  	/* get rid of pages beyond EOF */
>  	for (i = 0; i < cc->cluster_size; i++) {
> @@ -3968,7 +3966,6 @@ static int check_swap_activate(struct swap_info_struct *sis,
>  	struct inode *inode = mapping->host;
>  	unsigned blocks_per_page;
>  	unsigned long page_no;
> -	unsigned blkbits;
>  	sector_t probe_block;
>  	sector_t last_block;
>  	sector_t lowest_block = -1;
> @@ -3979,8 +3976,7 @@ static int check_swap_activate(struct swap_info_struct *sis,
>  	if (PAGE_SIZE == F2FS_BLKSIZE)
>  		return check_swap_activate_fast(sis, swap_file, span);
>  
> -	blkbits = inode->i_blkbits;
> -	blocks_per_page = PAGE_SIZE >> blkbits;
> +	blocks_per_page = bytes_to_blks(inode, PAGE_SIZE);
>  
>  	/*
>  	 * Map all the blocks into the extent list.  This code doesn't try
> @@ -3988,7 +3984,7 @@ static int check_swap_activate(struct swap_info_struct *sis,
>  	 */
>  	probe_block = 0;
>  	page_no = 0;
> -	last_block = i_size_read(inode) >> blkbits;
> +	last_block = bytes_to_blks(inode, i_size_read(inode));
>  	while ((probe_block + blocks_per_page) <= last_block &&
>  			page_no < sis->max) {
>  		unsigned block_in_page;
> @@ -4028,7 +4024,7 @@ static int check_swap_activate(struct swap_info_struct *sis,
>  			}
>  		}
>  
> -		first_block >>= (PAGE_SHIFT - blkbits);
> +		first_block >>= (PAGE_SHIFT - inode->i_blkbits);
>  		if (page_no) {	/* exclude the header page */
>  			if (first_block < lowest_block)
>  				lowest_block = first_block;
> -- 
> 2.29.2.454.gaff20da3a2-goog

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [f2fs-dev] [PATCH 1/4] f2fs: rename logical_to_blk and blk_to_logical
  2020-12-01  4:09 ` [PATCH 1/4] f2fs: rename logical_to_blk and blk_to_logical Jaegeuk Kim
@ 2020-12-01  8:55   ` Chao Yu
  0 siblings, 0 replies; 12+ messages in thread
From: Chao Yu @ 2020-12-01  8:55 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, kernel-team; +Cc: Linux F2FS Dev Mailing List

On 2020/12/1 12:09, Jaegeuk Kim wrote:
> Forgot to add f2fs mailing list.
> 
> On 11/25, Jaegeuk Kim wrote:
>> This patch renames two functions like below having u64.
>>   - logical_to_blk to bytes_to_blks
>>   - blk_to_logical to blks_to_bytes
>>
>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [f2fs-dev] [PATCH 2/4] f2fs: use new conversion functions between blks and bytes
  2020-12-01  4:09   ` Jaegeuk Kim
@ 2020-12-01  9:00     ` Chao Yu
  0 siblings, 0 replies; 12+ messages in thread
From: Chao Yu @ 2020-12-01  9:00 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, kernel-team; +Cc: Linux F2FS Dev Mailing List

On 2020/12/1 12:09, Jaegeuk Kim wrote:
> On 11/25, Jaegeuk Kim wrote:
>> This patch cleans up blks and bytes conversions.
>>
>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [f2fs-dev] [PATCH 3/4] f2fs: fix wrong block count instead of bytes
  2020-12-01  4:09   ` Jaegeuk Kim
@ 2020-12-01  9:03     ` Chao Yu
  0 siblings, 0 replies; 12+ messages in thread
From: Chao Yu @ 2020-12-01  9:03 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, kernel-team; +Cc: Linux F2FS Dev Mailing List

On 2020/12/1 12:09, Jaegeuk Kim wrote:
> On 11/25, Jaegeuk Kim wrote:
>> We should convert cur_lblock, a block count, to bytes for len.
>>
>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Fixes: af4b6b8edf6a ("f2fs: introduce check_swap_activate_fast()")

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [f2fs-dev] [PATCH 4/4] f2fs: remove buffer_head which has 32bits limit
  2020-12-01  4:09   ` Jaegeuk Kim
@ 2020-12-02  1:47     ` Chao Yu
  0 siblings, 0 replies; 12+ messages in thread
From: Chao Yu @ 2020-12-02  1:47 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, kernel-team
  Cc: Light Hsieh, Linux F2FS Dev Mailing List

On 2020/12/1 12:09, Jaegeuk Kim wrote:
> On 11/25, Jaegeuk Kim wrote:
>> This patch removes buffer_head dependency when getting block addresses.
>> Light reported there's a 32bit issue in f2fs_fiemap where map_bh.b_size is
>> 32bits while len is 64bits given by user. This will give wrong length to
>> f2fs_map_block.
>>
>> Reported-by: Light Hsieh <Light.Hsieh@mediatek.com>
>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-12-02  1:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-26  2:24 [PATCH 1/4] f2fs: rename logical_to_blk and blk_to_logical Jaegeuk Kim
2020-11-26  2:24 ` [PATCH 2/4] f2fs: use new conversion functions between blks and bytes Jaegeuk Kim
2020-12-01  4:09   ` Jaegeuk Kim
2020-12-01  9:00     ` [f2fs-dev] " Chao Yu
2020-11-26  2:24 ` [PATCH 3/4] f2fs: fix wrong block count instead of bytes Jaegeuk Kim
2020-12-01  4:09   ` Jaegeuk Kim
2020-12-01  9:03     ` [f2fs-dev] " Chao Yu
2020-11-26  2:24 ` [PATCH 4/4] f2fs: remove buffer_head which has 32bits limit Jaegeuk Kim
2020-12-01  4:09   ` Jaegeuk Kim
2020-12-02  1:47     ` [f2fs-dev] " Chao Yu
2020-12-01  4:09 ` [PATCH 1/4] f2fs: rename logical_to_blk and blk_to_logical Jaegeuk Kim
2020-12-01  8:55   ` [f2fs-dev] " Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).