Commit cd8fc522 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jaegeuk Kim

f2fs: remove the create argument to f2fs_map_blocks

The create argument is always identicaly to map->m_may_create, so use
that consistently.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent ffdeab71
...@@ -1477,8 +1477,7 @@ int f2fs_get_block_locked(struct dnode_of_data *dn, pgoff_t index) ...@@ -1477,8 +1477,7 @@ int f2fs_get_block_locked(struct dnode_of_data *dn, pgoff_t index)
* maps continuous logical blocks to physical blocks, and return such * maps continuous logical blocks to physical blocks, and return such
* info via f2fs_map_blocks structure. * info via f2fs_map_blocks structure.
*/ */
int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag)
int create, int flag)
{ {
unsigned int maxblocks = map->m_len; unsigned int maxblocks = map->m_len;
struct dnode_of_data dn; struct dnode_of_data dn;
...@@ -1507,38 +1506,31 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, ...@@ -1507,38 +1506,31 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
pgofs = (pgoff_t)map->m_lblk; pgofs = (pgoff_t)map->m_lblk;
end = pgofs + maxblocks; end = pgofs + maxblocks;
if (!create && f2fs_lookup_read_extent_cache(inode, pgofs, &ei)) { if (map->m_may_create ||
if (f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_DIO && !f2fs_lookup_read_extent_cache(inode, pgofs, &ei))
map->m_may_create) goto next_dnode;
goto next_dnode;
map->m_pblk = ei.blk + pgofs - ei.fofs; /* Found the map in read extent cache */
map->m_len = min((pgoff_t)maxblocks, ei.fofs + ei.len - pgofs); map->m_pblk = ei.blk + pgofs - ei.fofs;
map->m_flags = F2FS_MAP_MAPPED; map->m_len = min((pgoff_t)maxblocks, ei.fofs + ei.len - pgofs);
if (map->m_next_extent) map->m_flags = F2FS_MAP_MAPPED;
*map->m_next_extent = pgofs + map->m_len; if (map->m_next_extent)
*map->m_next_extent = pgofs + map->m_len;
/* for hardware encryption, but to avoid potential issue in future */ /* for hardware encryption, but to avoid potential issue in future */
if (flag == F2FS_GET_BLOCK_DIO) if (flag == F2FS_GET_BLOCK_DIO)
f2fs_wait_on_block_writeback_range(inode, f2fs_wait_on_block_writeback_range(inode,
map->m_pblk, map->m_len); map->m_pblk, map->m_len);
if (map->m_multidev_dio) { if (map->m_multidev_dio) {
block_t blk_addr = map->m_pblk; bidx = f2fs_target_device_index(sbi, map->m_pblk);
bidx = f2fs_target_device_index(sbi, map->m_pblk);
map->m_bdev = FDEV(bidx).bdev; map->m_bdev = FDEV(bidx).bdev;
map->m_pblk -= FDEV(bidx).start_blk; map->m_pblk -= FDEV(bidx).start_blk;
map->m_len = min(map->m_len, map->m_len = min(map->m_len,
FDEV(bidx).end_blk + 1 - map->m_pblk); FDEV(bidx).end_blk + 1 - map->m_pblk);
if (map->m_may_create)
f2fs_update_device_state(sbi, inode->i_ino,
blk_addr, map->m_len);
}
goto out;
} }
goto out;
next_dnode: next_dnode:
if (map->m_may_create) if (map->m_may_create)
...@@ -1602,7 +1594,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, ...@@ -1602,7 +1594,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
set_inode_flag(inode, FI_APPEND_WRITE); set_inode_flag(inode, FI_APPEND_WRITE);
} }
} else { } else {
if (create) { if (map->m_may_create) {
if (unlikely(f2fs_cp_error(sbi))) { if (unlikely(f2fs_cp_error(sbi))) {
err = -EIO; err = -EIO;
goto sync_out; goto sync_out;
...@@ -1776,7 +1768,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, ...@@ -1776,7 +1768,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
f2fs_balance_fs(sbi, dn.node_changed); f2fs_balance_fs(sbi, dn.node_changed);
} }
out: out:
trace_f2fs_map_blocks(inode, map, create, flag, err); trace_f2fs_map_blocks(inode, map, flag, err);
return err; return err;
} }
...@@ -1798,7 +1790,7 @@ bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) ...@@ -1798,7 +1790,7 @@ bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len)
while (map.m_lblk < last_lblk) { while (map.m_lblk < last_lblk) {
map.m_len = last_lblk - map.m_lblk; map.m_len = last_lblk - map.m_lblk;
err = f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_DEFAULT); err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_DEFAULT);
if (err || map.m_len == 0) if (err || map.m_len == 0)
return false; return false;
map.m_lblk += map.m_len; map.m_lblk += map.m_len;
...@@ -1972,7 +1964,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ...@@ -1972,7 +1964,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
map.m_len = cluster_size - count_in_cluster; map.m_len = cluster_size - count_in_cluster;
} }
ret = f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_FIEMAP); ret = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_FIEMAP);
if (ret) if (ret)
goto out; goto out;
...@@ -2105,7 +2097,7 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, ...@@ -2105,7 +2097,7 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page,
map->m_lblk = block_in_file; map->m_lblk = block_in_file;
map->m_len = last_block - block_in_file; map->m_len = last_block - block_in_file;
ret = f2fs_map_blocks(inode, map, 0, F2FS_GET_BLOCK_DEFAULT); ret = f2fs_map_blocks(inode, map, F2FS_GET_BLOCK_DEFAULT);
if (ret) if (ret)
goto out; goto out;
got_it: got_it:
...@@ -3807,7 +3799,7 @@ static sector_t f2fs_bmap(struct address_space *mapping, sector_t block) ...@@ -3807,7 +3799,7 @@ static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
map.m_next_pgofs = NULL; map.m_next_pgofs = NULL;
map.m_seg_type = NO_CHECK_TYPE; map.m_seg_type = NO_CHECK_TYPE;
if (!f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_BMAP)) if (!f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_BMAP))
blknr = map.m_pblk; blknr = map.m_pblk;
} }
out: out:
...@@ -3915,7 +3907,7 @@ static int check_swap_activate(struct swap_info_struct *sis, ...@@ -3915,7 +3907,7 @@ static int check_swap_activate(struct swap_info_struct *sis,
map.m_seg_type = NO_CHECK_TYPE; map.m_seg_type = NO_CHECK_TYPE;
map.m_may_create = false; map.m_may_create = false;
ret = f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_FIEMAP); ret = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_FIEMAP);
if (ret) if (ret)
goto out; goto out;
...@@ -4140,8 +4132,7 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, ...@@ -4140,8 +4132,7 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
if (flags & IOMAP_WRITE) if (flags & IOMAP_WRITE)
map.m_may_create = true; map.m_may_create = true;
err = f2fs_map_blocks(inode, &map, flags & IOMAP_WRITE, err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_DIO);
F2FS_GET_BLOCK_DIO);
if (err) if (err)
return err; return err;
......
...@@ -3811,8 +3811,7 @@ struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index, ...@@ -3811,8 +3811,7 @@ struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index,
struct page *f2fs_get_new_data_page(struct inode *inode, struct page *f2fs_get_new_data_page(struct inode *inode,
struct page *ipage, pgoff_t index, bool new_i_size); struct page *ipage, pgoff_t index, bool new_i_size);
int f2fs_do_write_data_page(struct f2fs_io_info *fio); int f2fs_do_write_data_page(struct f2fs_io_info *fio);
int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag);
int create, int flag);
int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
u64 start, u64 len); u64 start, u64 len);
int f2fs_encrypt_one_page(struct f2fs_io_info *fio); int f2fs_encrypt_one_page(struct f2fs_io_info *fio);
......
...@@ -1743,7 +1743,7 @@ static int expand_inode_data(struct inode *inode, loff_t offset, ...@@ -1743,7 +1743,7 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
f2fs_unlock_op(sbi); f2fs_unlock_op(sbi);
map.m_seg_type = CURSEG_COLD_DATA_PINNED; map.m_seg_type = CURSEG_COLD_DATA_PINNED;
err = f2fs_map_blocks(inode, &map, 1, F2FS_GET_BLOCK_PRE_DIO); err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_PRE_DIO);
file_dont_truncate(inode); file_dont_truncate(inode);
f2fs_up_write(&sbi->pin_sem); f2fs_up_write(&sbi->pin_sem);
...@@ -1756,7 +1756,7 @@ static int expand_inode_data(struct inode *inode, loff_t offset, ...@@ -1756,7 +1756,7 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
map.m_len = expanded; map.m_len = expanded;
} else { } else {
err = f2fs_map_blocks(inode, &map, 1, F2FS_GET_BLOCK_PRE_AIO); err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_PRE_AIO);
expanded = map.m_len; expanded = map.m_len;
} }
out_err: out_err:
...@@ -2604,7 +2604,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, ...@@ -2604,7 +2604,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
*/ */
while (map.m_lblk < pg_end) { while (map.m_lblk < pg_end) {
map.m_len = pg_end - map.m_lblk; map.m_len = pg_end - map.m_lblk;
err = f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_DEFAULT); err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_DEFAULT);
if (err) if (err)
goto out; goto out;
...@@ -2651,7 +2651,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, ...@@ -2651,7 +2651,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
do_map: do_map:
map.m_len = pg_end - map.m_lblk; map.m_len = pg_end - map.m_lblk;
err = f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_DEFAULT); err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_DEFAULT);
if (err) if (err)
goto clear_out; goto clear_out;
...@@ -3225,7 +3225,7 @@ int f2fs_precache_extents(struct inode *inode) ...@@ -3225,7 +3225,7 @@ int f2fs_precache_extents(struct inode *inode)
map.m_len = end - map.m_lblk; map.m_len = end - map.m_lblk;
f2fs_down_write(&fi->i_gc_rwsem[WRITE]); f2fs_down_write(&fi->i_gc_rwsem[WRITE]);
err = f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_PRECACHE); err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_PRECACHE);
f2fs_up_write(&fi->i_gc_rwsem[WRITE]); f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
if (err) if (err)
return err; return err;
...@@ -4464,7 +4464,7 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter, ...@@ -4464,7 +4464,7 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter,
flag = F2FS_GET_BLOCK_PRE_AIO; flag = F2FS_GET_BLOCK_PRE_AIO;
} }
ret = f2fs_map_blocks(inode, &map, 1, flag); ret = f2fs_map_blocks(inode, &map, flag);
/* -ENOSPC|-EDQUOT are fine to report the number of allocated blocks. */ /* -ENOSPC|-EDQUOT are fine to report the number of allocated blocks. */
if (ret < 0 && !((ret == -ENOSPC || ret == -EDQUOT) && map.m_len > 0)) if (ret < 0 && !((ret == -ENOSPC || ret == -EDQUOT) && map.m_len > 0))
return ret; return ret;
......
...@@ -569,10 +569,10 @@ TRACE_EVENT(f2fs_file_write_iter, ...@@ -569,10 +569,10 @@ TRACE_EVENT(f2fs_file_write_iter,
); );
TRACE_EVENT(f2fs_map_blocks, TRACE_EVENT(f2fs_map_blocks,
TP_PROTO(struct inode *inode, struct f2fs_map_blocks *map, TP_PROTO(struct inode *inode, struct f2fs_map_blocks *map, int flag,
int create, int flag, int ret), int ret),
TP_ARGS(inode, map, create, flag, ret), TP_ARGS(inode, map, flag, ret),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(dev_t, dev) __field(dev_t, dev)
...@@ -584,7 +584,6 @@ TRACE_EVENT(f2fs_map_blocks, ...@@ -584,7 +584,6 @@ TRACE_EVENT(f2fs_map_blocks,
__field(int, m_seg_type) __field(int, m_seg_type)
__field(bool, m_may_create) __field(bool, m_may_create)
__field(bool, m_multidev_dio) __field(bool, m_multidev_dio)
__field(int, create)
__field(int, flag) __field(int, flag)
__field(int, ret) __field(int, ret)
), ),
...@@ -599,7 +598,6 @@ TRACE_EVENT(f2fs_map_blocks, ...@@ -599,7 +598,6 @@ TRACE_EVENT(f2fs_map_blocks,
__entry->m_seg_type = map->m_seg_type; __entry->m_seg_type = map->m_seg_type;
__entry->m_may_create = map->m_may_create; __entry->m_may_create = map->m_may_create;
__entry->m_multidev_dio = map->m_multidev_dio; __entry->m_multidev_dio = map->m_multidev_dio;
__entry->create = create;
__entry->flag = flag; __entry->flag = flag;
__entry->ret = ret; __entry->ret = ret;
), ),
...@@ -607,7 +605,7 @@ TRACE_EVENT(f2fs_map_blocks, ...@@ -607,7 +605,7 @@ TRACE_EVENT(f2fs_map_blocks,
TP_printk("dev = (%d,%d), ino = %lu, file offset = %llu, " TP_printk("dev = (%d,%d), ino = %lu, file offset = %llu, "
"start blkaddr = 0x%llx, len = 0x%llx, flags = %u, " "start blkaddr = 0x%llx, len = 0x%llx, flags = %u, "
"seg_type = %d, may_create = %d, multidevice = %d, " "seg_type = %d, may_create = %d, multidevice = %d, "
"create = %d, flag = %d, err = %d", "flag = %d, err = %d",
show_dev_ino(__entry), show_dev_ino(__entry),
(unsigned long long)__entry->m_lblk, (unsigned long long)__entry->m_lblk,
(unsigned long long)__entry->m_pblk, (unsigned long long)__entry->m_pblk,
...@@ -616,7 +614,6 @@ TRACE_EVENT(f2fs_map_blocks, ...@@ -616,7 +614,6 @@ TRACE_EVENT(f2fs_map_blocks,
__entry->m_seg_type, __entry->m_seg_type,
__entry->m_may_create, __entry->m_may_create,
__entry->m_multidev_dio, __entry->m_multidev_dio,
__entry->create,
__entry->flag, __entry->flag,
__entry->ret) __entry->ret)
); );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment