fs/f2fs: Use the enum req_op and blk_opf_t types

Improve static type checking by using the enum req_op type for variables
that represent a request operation and the new blk_opf_t type for
variables that represent request flags.

Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20220714180729.1065367-53-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Bart Van Assche 2022-07-14 11:07:18 -07:00 committed by Jens Axboe
parent 67c0f55630
commit 7649c873c1
5 changed files with 22 additions and 21 deletions

View File

@ -387,11 +387,11 @@ int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr)
return 0; return 0;
} }
static unsigned int f2fs_io_flags(struct f2fs_io_info *fio) static blk_opf_t f2fs_io_flags(struct f2fs_io_info *fio)
{ {
unsigned int temp_mask = (1 << NR_TEMP_TYPE) - 1; unsigned int temp_mask = (1 << NR_TEMP_TYPE) - 1;
unsigned int fua_flag, meta_flag, io_flag; unsigned int fua_flag, meta_flag, io_flag;
unsigned int op_flags = 0; blk_opf_t op_flags = 0;
if (fio->op != REQ_OP_WRITE) if (fio->op != REQ_OP_WRITE)
return 0; return 0;
@ -999,7 +999,7 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio)
} }
static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr, static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
unsigned nr_pages, unsigned op_flag, unsigned nr_pages, blk_opf_t op_flag,
pgoff_t first_idx, bool for_write) pgoff_t first_idx, bool for_write)
{ {
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
@ -1047,7 +1047,8 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
/* This can handle encryption stuffs */ /* This can handle encryption stuffs */
static int f2fs_submit_page_read(struct inode *inode, struct page *page, static int f2fs_submit_page_read(struct inode *inode, struct page *page,
block_t blkaddr, int op_flags, bool for_write) block_t blkaddr, blk_opf_t op_flags,
bool for_write)
{ {
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct bio *bio; struct bio *bio;
@ -1181,7 +1182,7 @@ int f2fs_get_block(struct dnode_of_data *dn, pgoff_t index)
} }
struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index, struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
int op_flags, bool for_write) blk_opf_t op_flags, bool for_write)
{ {
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = inode->i_mapping;
struct dnode_of_data dn; struct dnode_of_data dn;

View File

@ -1183,8 +1183,8 @@ struct f2fs_io_info {
nid_t ino; /* inode number */ nid_t ino; /* inode number */
enum page_type type; /* contains DATA/NODE/META/META_FLUSH */ enum page_type type; /* contains DATA/NODE/META/META_FLUSH */
enum temp_type temp; /* contains HOT/WARM/COLD */ enum temp_type temp; /* contains HOT/WARM/COLD */
int op; /* contains REQ_OP_ */ enum req_op op; /* contains REQ_OP_ */
int op_flags; /* req_flag_bits */ blk_opf_t op_flags; /* req_flag_bits */
block_t new_blkaddr; /* new block address to be written */ block_t new_blkaddr; /* new block address to be written */
block_t old_blkaddr; /* old block address before Cow */ block_t old_blkaddr; /* old block address before Cow */
struct page *page; /* page to be written */ struct page *page; /* page to be written */
@ -3741,7 +3741,7 @@ int f2fs_reserve_new_block(struct dnode_of_data *dn);
int f2fs_get_block(struct dnode_of_data *dn, pgoff_t index); int f2fs_get_block(struct dnode_of_data *dn, pgoff_t index);
int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index); int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index);
struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index, struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
int op_flags, bool for_write); blk_opf_t op_flags, bool for_write);
struct page *f2fs_find_data_page(struct inode *inode, pgoff_t index); struct page *f2fs_find_data_page(struct inode *inode, pgoff_t index);
struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index, struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index,
bool for_write); bool for_write);

View File

@ -1327,7 +1327,7 @@ struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs)
* 0: f2fs_put_page(page, 0) * 0: f2fs_put_page(page, 0)
* LOCKED_PAGE or error: f2fs_put_page(page, 1) * LOCKED_PAGE or error: f2fs_put_page(page, 1)
*/ */
static int read_node_page(struct page *page, int op_flags) static int read_node_page(struct page *page, blk_opf_t op_flags)
{ {
struct f2fs_sb_info *sbi = F2FS_P_SB(page); struct f2fs_sb_info *sbi = F2FS_P_SB(page);
struct node_info ni; struct node_info ni;

View File

@ -1082,7 +1082,7 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
struct list_head *wait_list = (dpolicy->type == DPOLICY_FSTRIM) ? struct list_head *wait_list = (dpolicy->type == DPOLICY_FSTRIM) ?
&(dcc->fstrim_list) : &(dcc->wait_list); &(dcc->fstrim_list) : &(dcc->wait_list);
int flag = dpolicy->sync ? REQ_SYNC : 0; blk_opf_t flag = dpolicy->sync ? REQ_SYNC : 0;
block_t lstart, start, len, total_len; block_t lstart, start, len, total_len;
int err = 0; int err = 0;

View File

@ -66,7 +66,7 @@ TRACE_DEFINE_ENUM(CP_RESIZE);
#define F2FS_OP_FLAGS (REQ_RAHEAD | REQ_SYNC | REQ_META | REQ_PRIO | \ #define F2FS_OP_FLAGS (REQ_RAHEAD | REQ_SYNC | REQ_META | REQ_PRIO | \
REQ_PREFLUSH | REQ_FUA) REQ_PREFLUSH | REQ_FUA)
#define F2FS_BIO_FLAG_MASK(t) (t & F2FS_OP_FLAGS) #define F2FS_BIO_FLAG_MASK(t) (__force u32)((t) & F2FS_OP_FLAGS)
#define show_bio_type(op,op_flags) show_bio_op(op), \ #define show_bio_type(op,op_flags) show_bio_op(op), \
show_bio_op_flags(op_flags) show_bio_op_flags(op_flags)
@ -75,12 +75,12 @@ TRACE_DEFINE_ENUM(CP_RESIZE);
#define show_bio_op_flags(flags) \ #define show_bio_op_flags(flags) \
__print_flags(F2FS_BIO_FLAG_MASK(flags), "|", \ __print_flags(F2FS_BIO_FLAG_MASK(flags), "|", \
{ REQ_RAHEAD, "R" }, \ { (__force u32)REQ_RAHEAD, "R" }, \
{ REQ_SYNC, "S" }, \ { (__force u32)REQ_SYNC, "S" }, \
{ REQ_META, "M" }, \ { (__force u32)REQ_META, "M" }, \
{ REQ_PRIO, "P" }, \ { (__force u32)REQ_PRIO, "P" }, \
{ REQ_PREFLUSH, "PF" }, \ { (__force u32)REQ_PREFLUSH, "PF" }, \
{ REQ_FUA, "FUA" }) { (__force u32)REQ_FUA, "FUA" })
#define show_data_type(type) \ #define show_data_type(type) \
__print_symbolic(type, \ __print_symbolic(type, \
@ -1036,8 +1036,8 @@ DECLARE_EVENT_CLASS(f2fs__submit_page_bio,
__field(pgoff_t, index) __field(pgoff_t, index)
__field(block_t, old_blkaddr) __field(block_t, old_blkaddr)
__field(block_t, new_blkaddr) __field(block_t, new_blkaddr)
__field(int, op) __field(enum req_op, op)
__field(int, op_flags) __field(blk_opf_t, op_flags)
__field(int, temp) __field(int, temp)
__field(int, type) __field(int, type)
), ),
@ -1092,8 +1092,8 @@ DECLARE_EVENT_CLASS(f2fs__bio,
TP_STRUCT__entry( TP_STRUCT__entry(
__field(dev_t, dev) __field(dev_t, dev)
__field(dev_t, target) __field(dev_t, target)
__field(int, op) __field(enum req_op, op)
__field(int, op_flags) __field(blk_opf_t, op_flags)
__field(int, type) __field(int, type)
__field(sector_t, sector) __field(sector_t, sector)
__field(unsigned int, size) __field(unsigned int, size)