Commit 05ca3632 authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: add sbi and page pointer in f2fs_io_info

This patch adds f2fs_sb_info and page pointers in f2fs_io_info structure.
With this change, we can reduce a lot of parameters for IO functions.
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 01b960e9
...@@ -52,6 +52,7 @@ struct page *get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index) ...@@ -52,6 +52,7 @@ struct page *get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
struct address_space *mapping = META_MAPPING(sbi); struct address_space *mapping = META_MAPPING(sbi);
struct page *page; struct page *page;
struct f2fs_io_info fio = { struct f2fs_io_info fio = {
.sbi = sbi,
.type = META, .type = META,
.rw = READ_SYNC | REQ_META | REQ_PRIO, .rw = READ_SYNC | REQ_META | REQ_PRIO,
.blk_addr = index, .blk_addr = index,
...@@ -65,7 +66,9 @@ struct page *get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index) ...@@ -65,7 +66,9 @@ struct page *get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
if (PageUptodate(page)) if (PageUptodate(page))
goto out; goto out;
if (f2fs_submit_page_bio(sbi, page, &fio)) fio.page = page;
if (f2fs_submit_page_bio(&fio))
goto repeat; goto repeat;
lock_page(page); lock_page(page);
...@@ -117,6 +120,7 @@ int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages, int type ...@@ -117,6 +120,7 @@ int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages, int type
struct page *page; struct page *page;
block_t blkno = start; block_t blkno = start;
struct f2fs_io_info fio = { struct f2fs_io_info fio = {
.sbi = sbi,
.type = META, .type = META,
.rw = READ_SYNC | REQ_META | REQ_PRIO .rw = READ_SYNC | REQ_META | REQ_PRIO
}; };
...@@ -160,7 +164,8 @@ int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages, int type ...@@ -160,7 +164,8 @@ int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages, int type
continue; continue;
} }
f2fs_submit_page_mbio(sbi, page, &fio); fio.page = page;
f2fs_submit_page_mbio(&fio);
f2fs_put_page(page, 0); f2fs_put_page(page, 0);
} }
out: out:
......
...@@ -158,16 +158,16 @@ void f2fs_submit_merged_bio(struct f2fs_sb_info *sbi, ...@@ -158,16 +158,16 @@ void f2fs_submit_merged_bio(struct f2fs_sb_info *sbi,
* Fill the locked page with data located in the block address. * Fill the locked page with data located in the block address.
* Return unlocked page. * Return unlocked page.
*/ */
int f2fs_submit_page_bio(struct f2fs_sb_info *sbi, struct page *page, int f2fs_submit_page_bio(struct f2fs_io_info *fio)
struct f2fs_io_info *fio)
{ {
struct bio *bio; struct bio *bio;
struct page *page = fio->page;
trace_f2fs_submit_page_bio(page, fio); trace_f2fs_submit_page_bio(page, fio);
f2fs_trace_ios(page, fio, 0); f2fs_trace_ios(fio, 0);
/* Allocate a new bio */ /* Allocate a new bio */
bio = __bio_alloc(sbi, fio->blk_addr, 1, is_read_io(fio->rw)); bio = __bio_alloc(fio->sbi, fio->blk_addr, 1, is_read_io(fio->rw));
if (bio_add_page(bio, page, PAGE_CACHE_SIZE, 0) < PAGE_CACHE_SIZE) { if (bio_add_page(bio, page, PAGE_CACHE_SIZE, 0) < PAGE_CACHE_SIZE) {
bio_put(bio); bio_put(bio);
...@@ -179,9 +179,9 @@ int f2fs_submit_page_bio(struct f2fs_sb_info *sbi, struct page *page, ...@@ -179,9 +179,9 @@ int f2fs_submit_page_bio(struct f2fs_sb_info *sbi, struct page *page,
return 0; return 0;
} }
void f2fs_submit_page_mbio(struct f2fs_sb_info *sbi, struct page *page, void f2fs_submit_page_mbio(struct f2fs_io_info *fio)
struct f2fs_io_info *fio)
{ {
struct f2fs_sb_info *sbi = fio->sbi;
enum page_type btype = PAGE_TYPE_OF_BIO(fio->type); enum page_type btype = PAGE_TYPE_OF_BIO(fio->type);
struct f2fs_bio_info *io; struct f2fs_bio_info *io;
bool is_read = is_read_io(fio->rw); bool is_read = is_read_io(fio->rw);
...@@ -206,17 +206,17 @@ void f2fs_submit_page_mbio(struct f2fs_sb_info *sbi, struct page *page, ...@@ -206,17 +206,17 @@ void f2fs_submit_page_mbio(struct f2fs_sb_info *sbi, struct page *page,
io->fio = *fio; io->fio = *fio;
} }
if (bio_add_page(io->bio, page, PAGE_CACHE_SIZE, 0) < if (bio_add_page(io->bio, fio->page, PAGE_CACHE_SIZE, 0) <
PAGE_CACHE_SIZE) { PAGE_CACHE_SIZE) {
__submit_merged_bio(io); __submit_merged_bio(io);
goto alloc_new; goto alloc_new;
} }
io->last_block_in_bio = fio->blk_addr; io->last_block_in_bio = fio->blk_addr;
f2fs_trace_ios(page, fio, 0); f2fs_trace_ios(fio, 0);
up_write(&io->io_rwsem); up_write(&io->io_rwsem);
trace_f2fs_submit_page_mbio(page, fio); trace_f2fs_submit_page_mbio(fio->page, fio);
} }
/* /*
...@@ -925,6 +925,7 @@ struct page *find_data_page(struct inode *inode, pgoff_t index, bool sync) ...@@ -925,6 +925,7 @@ struct page *find_data_page(struct inode *inode, pgoff_t index, bool sync)
struct extent_info ei; struct extent_info ei;
int err; int err;
struct f2fs_io_info fio = { struct f2fs_io_info fio = {
.sbi = F2FS_I_SB(inode),
.type = DATA, .type = DATA,
.rw = sync ? READ_SYNC : READA, .rw = sync ? READ_SYNC : READA,
}; };
...@@ -971,7 +972,8 @@ struct page *find_data_page(struct inode *inode, pgoff_t index, bool sync) ...@@ -971,7 +972,8 @@ struct page *find_data_page(struct inode *inode, pgoff_t index, bool sync)
} }
fio.blk_addr = dn.data_blkaddr; fio.blk_addr = dn.data_blkaddr;
err = f2fs_submit_page_bio(F2FS_I_SB(inode), page, &fio); fio.page = page;
err = f2fs_submit_page_bio(&fio);
if (err) if (err)
return ERR_PTR(err); return ERR_PTR(err);
...@@ -998,6 +1000,7 @@ struct page *get_lock_data_page(struct inode *inode, pgoff_t index) ...@@ -998,6 +1000,7 @@ struct page *get_lock_data_page(struct inode *inode, pgoff_t index)
struct extent_info ei; struct extent_info ei;
int err; int err;
struct f2fs_io_info fio = { struct f2fs_io_info fio = {
.sbi = F2FS_I_SB(inode),
.type = DATA, .type = DATA,
.rw = READ_SYNC, .rw = READ_SYNC,
}; };
...@@ -1041,7 +1044,8 @@ struct page *get_lock_data_page(struct inode *inode, pgoff_t index) ...@@ -1041,7 +1044,8 @@ struct page *get_lock_data_page(struct inode *inode, pgoff_t index)
} }
fio.blk_addr = dn.data_blkaddr; fio.blk_addr = dn.data_blkaddr;
err = f2fs_submit_page_bio(F2FS_I_SB(inode), page, &fio); fio.page = page;
err = f2fs_submit_page_bio(&fio);
if (err) if (err)
return ERR_PTR(err); return ERR_PTR(err);
...@@ -1092,11 +1096,13 @@ struct page *get_new_data_page(struct inode *inode, ...@@ -1092,11 +1096,13 @@ struct page *get_new_data_page(struct inode *inode,
SetPageUptodate(page); SetPageUptodate(page);
} else { } else {
struct f2fs_io_info fio = { struct f2fs_io_info fio = {
.sbi = F2FS_I_SB(inode),
.type = DATA, .type = DATA,
.rw = READ_SYNC, .rw = READ_SYNC,
.blk_addr = dn.data_blkaddr, .blk_addr = dn.data_blkaddr,
.page = page,
}; };
err = f2fs_submit_page_bio(F2FS_I_SB(inode), page, &fio); err = f2fs_submit_page_bio(&fio);
if (err) if (err)
goto put_err; goto put_err;
...@@ -1529,8 +1535,9 @@ static int f2fs_read_data_pages(struct file *file, ...@@ -1529,8 +1535,9 @@ static int f2fs_read_data_pages(struct file *file,
return f2fs_mpage_readpages(mapping, pages, NULL, nr_pages); return f2fs_mpage_readpages(mapping, pages, NULL, nr_pages);
} }
int do_write_data_page(struct page *page, struct f2fs_io_info *fio) int do_write_data_page(struct f2fs_io_info *fio)
{ {
struct page *page = fio->page;
struct inode *inode = page->mapping->host; struct inode *inode = page->mapping->host;
struct dnode_of_data dn; struct dnode_of_data dn;
int err = 0; int err = 0;
...@@ -1557,11 +1564,11 @@ int do_write_data_page(struct page *page, struct f2fs_io_info *fio) ...@@ -1557,11 +1564,11 @@ int do_write_data_page(struct page *page, struct f2fs_io_info *fio)
if (unlikely(fio->blk_addr != NEW_ADDR && if (unlikely(fio->blk_addr != NEW_ADDR &&
!is_cold_data(page) && !is_cold_data(page) &&
need_inplace_update(inode))) { need_inplace_update(inode))) {
rewrite_data_page(page, fio); rewrite_data_page(fio);
set_inode_flag(F2FS_I(inode), FI_UPDATE_WRITE); set_inode_flag(F2FS_I(inode), FI_UPDATE_WRITE);
trace_f2fs_do_write_data_page(page, IPU); trace_f2fs_do_write_data_page(page, IPU);
} else { } else {
write_data_page(page, &dn, fio); write_data_page(&dn, fio);
set_data_blkaddr(&dn); set_data_blkaddr(&dn);
f2fs_update_extent_cache(&dn); f2fs_update_extent_cache(&dn);
trace_f2fs_do_write_data_page(page, OPU); trace_f2fs_do_write_data_page(page, OPU);
...@@ -1586,8 +1593,10 @@ static int f2fs_write_data_page(struct page *page, ...@@ -1586,8 +1593,10 @@ static int f2fs_write_data_page(struct page *page,
bool need_balance_fs = false; bool need_balance_fs = false;
int err = 0; int err = 0;
struct f2fs_io_info fio = { struct f2fs_io_info fio = {
.sbi = sbi,
.type = DATA, .type = DATA,
.rw = (wbc->sync_mode == WB_SYNC_ALL) ? WRITE_SYNC : WRITE, .rw = (wbc->sync_mode == WB_SYNC_ALL) ? WRITE_SYNC : WRITE,
.page = page,
}; };
trace_f2fs_writepage(page, DATA); trace_f2fs_writepage(page, DATA);
...@@ -1617,7 +1626,7 @@ static int f2fs_write_data_page(struct page *page, ...@@ -1617,7 +1626,7 @@ static int f2fs_write_data_page(struct page *page,
if (S_ISDIR(inode->i_mode)) { if (S_ISDIR(inode->i_mode)) {
if (unlikely(f2fs_cp_error(sbi))) if (unlikely(f2fs_cp_error(sbi)))
goto redirty_out; goto redirty_out;
err = do_write_data_page(page, &fio); err = do_write_data_page(&fio);
goto done; goto done;
} }
...@@ -1637,7 +1646,7 @@ static int f2fs_write_data_page(struct page *page, ...@@ -1637,7 +1646,7 @@ static int f2fs_write_data_page(struct page *page,
if (f2fs_has_inline_data(inode)) if (f2fs_has_inline_data(inode))
err = f2fs_write_inline_data(inode, page); err = f2fs_write_inline_data(inode, page);
if (err == -EAGAIN) if (err == -EAGAIN)
err = do_write_data_page(page, &fio); err = do_write_data_page(&fio);
f2fs_unlock_op(sbi); f2fs_unlock_op(sbi);
done: done:
if (err && err != -ENOENT) if (err && err != -ENOENT)
...@@ -1806,11 +1815,13 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, ...@@ -1806,11 +1815,13 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
zero_user_segment(page, 0, PAGE_CACHE_SIZE); zero_user_segment(page, 0, PAGE_CACHE_SIZE);
} else { } else {
struct f2fs_io_info fio = { struct f2fs_io_info fio = {
.sbi = sbi,
.type = DATA, .type = DATA,
.rw = READ_SYNC, .rw = READ_SYNC,
.blk_addr = dn.data_blkaddr, .blk_addr = dn.data_blkaddr,
.page = page,
}; };
err = f2fs_submit_page_bio(sbi, page, &fio); err = f2fs_submit_page_bio(&fio);
if (err) if (err)
goto fail; goto fail;
......
...@@ -601,9 +601,11 @@ enum page_type { ...@@ -601,9 +601,11 @@ enum page_type {
}; };
struct f2fs_io_info { struct f2fs_io_info {
struct f2fs_sb_info *sbi; /* f2fs_sb_info pointer */
enum page_type type; /* contains DATA/NODE/META/META_FLUSH */ enum page_type type; /* contains DATA/NODE/META/META_FLUSH */
int rw; /* contains R/RS/W/WS with REQ_META/REQ_PRIO */ int rw; /* contains R/RS/W/WS with REQ_META/REQ_PRIO */
block_t blk_addr; /* block address to be written */ block_t blk_addr; /* block address to be written */
struct page *page; /* page to be written */
}; };
#define is_read_io(rw) (((rw) & 1) == READ) #define is_read_io(rw) (((rw) & 1) == READ)
...@@ -1601,11 +1603,9 @@ void allocate_new_segments(struct f2fs_sb_info *); ...@@ -1601,11 +1603,9 @@ void allocate_new_segments(struct f2fs_sb_info *);
int f2fs_trim_fs(struct f2fs_sb_info *, struct fstrim_range *); int f2fs_trim_fs(struct f2fs_sb_info *, struct fstrim_range *);
struct page *get_sum_page(struct f2fs_sb_info *, unsigned int); struct page *get_sum_page(struct f2fs_sb_info *, unsigned int);
void write_meta_page(struct f2fs_sb_info *, struct page *); void write_meta_page(struct f2fs_sb_info *, struct page *);
void write_node_page(struct f2fs_sb_info *, struct page *, void write_node_page(unsigned int, struct f2fs_io_info *);
unsigned int, struct f2fs_io_info *); void write_data_page(struct dnode_of_data *, struct f2fs_io_info *);
void write_data_page(struct page *, struct dnode_of_data *, void rewrite_data_page(struct f2fs_io_info *);
struct f2fs_io_info *);
void rewrite_data_page(struct page *, struct f2fs_io_info *);
void recover_data_page(struct f2fs_sb_info *, struct page *, void recover_data_page(struct f2fs_sb_info *, struct page *,
struct f2fs_summary *, block_t, block_t); struct f2fs_summary *, block_t, block_t);
void allocate_data_block(struct f2fs_sb_info *, struct page *, void allocate_data_block(struct f2fs_sb_info *, struct page *,
...@@ -1653,10 +1653,8 @@ void destroy_checkpoint_caches(void); ...@@ -1653,10 +1653,8 @@ void destroy_checkpoint_caches(void);
* data.c * data.c
*/ */
void f2fs_submit_merged_bio(struct f2fs_sb_info *, enum page_type, int); void f2fs_submit_merged_bio(struct f2fs_sb_info *, enum page_type, int);
int f2fs_submit_page_bio(struct f2fs_sb_info *, struct page *, int f2fs_submit_page_bio(struct f2fs_io_info *);
struct f2fs_io_info *); void f2fs_submit_page_mbio(struct f2fs_io_info *);
void f2fs_submit_page_mbio(struct f2fs_sb_info *, struct page *,
struct f2fs_io_info *);
void set_data_blkaddr(struct dnode_of_data *); void set_data_blkaddr(struct dnode_of_data *);
int reserve_new_block(struct dnode_of_data *); int reserve_new_block(struct dnode_of_data *);
int f2fs_reserve_block(struct dnode_of_data *, pgoff_t); int f2fs_reserve_block(struct dnode_of_data *, pgoff_t);
...@@ -1668,7 +1666,7 @@ void f2fs_preserve_extent_tree(struct inode *); ...@@ -1668,7 +1666,7 @@ void f2fs_preserve_extent_tree(struct inode *);
struct page *find_data_page(struct inode *, pgoff_t, bool); struct page *find_data_page(struct inode *, pgoff_t, bool);
struct page *get_lock_data_page(struct inode *, pgoff_t); struct page *get_lock_data_page(struct inode *, pgoff_t);
struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool); struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool);
int do_write_data_page(struct page *, struct f2fs_io_info *); int do_write_data_page(struct f2fs_io_info *);
int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *, u64, u64); int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *, u64, u64);
void init_extent_cache_info(struct f2fs_sb_info *); void init_extent_cache_info(struct f2fs_sb_info *);
int __init create_extent_cache(void); int __init create_extent_cache(void);
......
...@@ -271,7 +271,7 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) ...@@ -271,7 +271,7 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
ret = f2fs_issue_flush(sbi); ret = f2fs_issue_flush(sbi);
out: out:
trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret); trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret);
f2fs_trace_ios(NULL, NULL, 1); f2fs_trace_ios(NULL, 1);
return ret; return ret;
} }
......
...@@ -521,8 +521,10 @@ static int check_dnode(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, ...@@ -521,8 +521,10 @@ static int check_dnode(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
static void move_data_page(struct inode *inode, struct page *page, int gc_type) static void move_data_page(struct inode *inode, struct page *page, int gc_type)
{ {
struct f2fs_io_info fio = { struct f2fs_io_info fio = {
.sbi = F2FS_I_SB(inode),
.type = DATA, .type = DATA,
.rw = WRITE_SYNC, .rw = WRITE_SYNC,
.page = page,
}; };
if (gc_type == BG_GC) { if (gc_type == BG_GC) {
...@@ -536,7 +538,7 @@ static void move_data_page(struct inode *inode, struct page *page, int gc_type) ...@@ -536,7 +538,7 @@ static void move_data_page(struct inode *inode, struct page *page, int gc_type)
if (clear_page_dirty_for_io(page)) if (clear_page_dirty_for_io(page))
inode_dec_dirty_pages(inode); inode_dec_dirty_pages(inode);
set_cold_data(page); set_cold_data(page);
do_write_data_page(page, &fio); do_write_data_page(&fio);
clear_cold_data(page); clear_cold_data(page);
} }
out: out:
......
...@@ -106,8 +106,10 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page) ...@@ -106,8 +106,10 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page)
{ {
void *src_addr, *dst_addr; void *src_addr, *dst_addr;
struct f2fs_io_info fio = { struct f2fs_io_info fio = {
.sbi = F2FS_I_SB(dn->inode),
.type = DATA, .type = DATA,
.rw = WRITE_SYNC | REQ_PRIO, .rw = WRITE_SYNC | REQ_PRIO,
.page = page,
}; };
int dirty, err; int dirty, err;
...@@ -141,7 +143,7 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page) ...@@ -141,7 +143,7 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page)
/* write data page to try to make data consistent */ /* write data page to try to make data consistent */
set_page_writeback(page); set_page_writeback(page);
fio.blk_addr = dn->data_blkaddr; fio.blk_addr = dn->data_blkaddr;
write_data_page(page, dn, &fio); write_data_page(dn, &fio);
set_data_blkaddr(dn); set_data_blkaddr(dn);
f2fs_update_extent_cache(dn); f2fs_update_extent_cache(dn);
f2fs_wait_on_page_writeback(page, DATA); f2fs_wait_on_page_writeback(page, DATA);
......
...@@ -995,8 +995,10 @@ static int read_node_page(struct page *page, int rw) ...@@ -995,8 +995,10 @@ static int read_node_page(struct page *page, int rw)
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;
struct f2fs_io_info fio = { struct f2fs_io_info fio = {
.sbi = sbi,
.type = NODE, .type = NODE,
.rw = rw, .rw = rw,
.page = page,
}; };
get_node_info(sbi, page->index, &ni); get_node_info(sbi, page->index, &ni);
...@@ -1011,7 +1013,7 @@ static int read_node_page(struct page *page, int rw) ...@@ -1011,7 +1013,7 @@ static int read_node_page(struct page *page, int rw)
return LOCKED_PAGE; return LOCKED_PAGE;
fio.blk_addr = ni.blk_addr; fio.blk_addr = ni.blk_addr;
return f2fs_submit_page_bio(sbi, page, &fio); return f2fs_submit_page_bio(&fio);
} }
/* /*
...@@ -1293,8 +1295,10 @@ static int f2fs_write_node_page(struct page *page, ...@@ -1293,8 +1295,10 @@ static int f2fs_write_node_page(struct page *page,
nid_t nid; nid_t nid;
struct node_info ni; struct node_info ni;
struct f2fs_io_info fio = { struct f2fs_io_info fio = {
.sbi = sbi,
.type = NODE, .type = NODE,
.rw = (wbc->sync_mode == WB_SYNC_ALL) ? WRITE_SYNC : WRITE, .rw = (wbc->sync_mode == WB_SYNC_ALL) ? WRITE_SYNC : WRITE,
.page = page,
}; };
trace_f2fs_writepage(page, NODE); trace_f2fs_writepage(page, NODE);
...@@ -1329,7 +1333,7 @@ static int f2fs_write_node_page(struct page *page, ...@@ -1329,7 +1333,7 @@ static int f2fs_write_node_page(struct page *page,
set_page_writeback(page); set_page_writeback(page);
fio.blk_addr = ni.blk_addr; fio.blk_addr = ni.blk_addr;
write_node_page(sbi, page, nid, &fio); write_node_page(nid, &fio);
set_node_addr(sbi, &ni, fio.blk_addr, is_fsync_dnode(page)); set_node_addr(sbi, &ni, fio.blk_addr, is_fsync_dnode(page));
dec_page_count(sbi, F2FS_DIRTY_NODES); dec_page_count(sbi, F2FS_DIRTY_NODES);
up_read(&sbi->node_write); up_read(&sbi->node_write);
......
...@@ -216,6 +216,7 @@ void commit_inmem_pages(struct inode *inode, bool abort) ...@@ -216,6 +216,7 @@ void commit_inmem_pages(struct inode *inode, bool abort)
struct inmem_pages *cur, *tmp; struct inmem_pages *cur, *tmp;
bool submit_bio = false; bool submit_bio = false;
struct f2fs_io_info fio = { struct f2fs_io_info fio = {
.sbi = sbi,
.type = DATA, .type = DATA,
.rw = WRITE_SYNC | REQ_PRIO, .rw = WRITE_SYNC | REQ_PRIO,
}; };
...@@ -241,7 +242,8 @@ void commit_inmem_pages(struct inode *inode, bool abort) ...@@ -241,7 +242,8 @@ void commit_inmem_pages(struct inode *inode, bool abort)
if (clear_page_dirty_for_io(cur->page)) if (clear_page_dirty_for_io(cur->page))
inode_dec_dirty_pages(inode); inode_dec_dirty_pages(inode);
trace_f2fs_commit_inmem_page(cur->page, INMEM); trace_f2fs_commit_inmem_page(cur->page, INMEM);
do_write_data_page(cur->page, &fio); fio.page = cur->page;
do_write_data_page(&fio);
submit_bio = true; submit_bio = true;
} }
f2fs_put_page(cur->page, 1); f2fs_put_page(cur->page, 1);
...@@ -1206,56 +1208,56 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, ...@@ -1206,56 +1208,56 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
mutex_unlock(&curseg->curseg_mutex); mutex_unlock(&curseg->curseg_mutex);
} }
static void do_write_page(struct f2fs_sb_info *sbi, struct page *page, static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio)
struct f2fs_summary *sum,
struct f2fs_io_info *fio)
{ {
int type = __get_segment_type(page, fio->type); int type = __get_segment_type(fio->page, fio->type);
allocate_data_block(sbi, page, fio->blk_addr, &fio->blk_addr, sum, type); allocate_data_block(fio->sbi, fio->page, fio->blk_addr,
&fio->blk_addr, sum, type);
/* writeout dirty page into bdev */ /* writeout dirty page into bdev */
f2fs_submit_page_mbio(sbi, page, fio); f2fs_submit_page_mbio(fio);
} }
void write_meta_page(struct f2fs_sb_info *sbi, struct page *page) void write_meta_page(struct f2fs_sb_info *sbi, struct page *page)
{ {
struct f2fs_io_info fio = { struct f2fs_io_info fio = {
.sbi = sbi,
.type = META, .type = META,
.rw = WRITE_SYNC | REQ_META | REQ_PRIO, .rw = WRITE_SYNC | REQ_META | REQ_PRIO,
.blk_addr = page->index, .blk_addr = page->index,
.page = page,
}; };
set_page_writeback(page); set_page_writeback(page);
f2fs_submit_page_mbio(sbi, page, &fio); f2fs_submit_page_mbio(&fio);
} }
void write_node_page(struct f2fs_sb_info *sbi, struct page *page, void write_node_page(unsigned int nid, struct f2fs_io_info *fio)
unsigned int nid, struct f2fs_io_info *fio)
{ {
struct f2fs_summary sum; struct f2fs_summary sum;
set_summary(&sum, nid, 0, 0); set_summary(&sum, nid, 0, 0);
do_write_page(sbi, page, &sum, fio); do_write_page(&sum, fio);
} }
void write_data_page(struct page *page, struct dnode_of_data *dn, void write_data_page(struct dnode_of_data *dn, struct f2fs_io_info *fio)
struct f2fs_io_info *fio)
{ {
struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode); struct f2fs_sb_info *sbi = fio->sbi;
struct f2fs_summary sum; struct f2fs_summary sum;
struct node_info ni; struct node_info ni;
f2fs_bug_on(sbi, dn->data_blkaddr == NULL_ADDR); f2fs_bug_on(sbi, dn->data_blkaddr == NULL_ADDR);
get_node_info(sbi, dn->nid, &ni); get_node_info(sbi, dn->nid, &ni);
set_summary(&sum, dn->nid, dn->ofs_in_node, ni.version); set_summary(&sum, dn->nid, dn->ofs_in_node, ni.version);
do_write_page(sbi, page, &sum, fio); do_write_page(&sum, fio);
dn->data_blkaddr = fio->blk_addr; dn->data_blkaddr = fio->blk_addr;
} }
void rewrite_data_page(struct page *page, struct f2fs_io_info *fio) void rewrite_data_page(struct f2fs_io_info *fio)
{ {
stat_inc_inplace_blocks(F2FS_P_SB(page)); stat_inc_inplace_blocks(fio->sbi);
f2fs_submit_page_mbio(F2FS_P_SB(page), page, fio); f2fs_submit_page_mbio(fio);
} }
void recover_data_page(struct f2fs_sb_info *sbi, void recover_data_page(struct f2fs_sb_info *sbi,
......
...@@ -520,7 +520,7 @@ int f2fs_sync_fs(struct super_block *sb, int sync) ...@@ -520,7 +520,7 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
} else { } else {
f2fs_balance_fs(sbi); f2fs_balance_fs(sbi);
} }
f2fs_trace_ios(NULL, NULL, 1); f2fs_trace_ios(NULL, 1);
return 0; return 0;
} }
......
...@@ -80,7 +80,7 @@ void f2fs_trace_pid(struct page *page) ...@@ -80,7 +80,7 @@ void f2fs_trace_pid(struct page *page)
radix_tree_preload_end(); radix_tree_preload_end();
} }
void f2fs_trace_ios(struct page *page, struct f2fs_io_info *fio, int flush) void f2fs_trace_ios(struct f2fs_io_info *fio, int flush)
{ {
struct inode *inode; struct inode *inode;
pid_t pid; pid_t pid;
...@@ -91,8 +91,8 @@ void f2fs_trace_ios(struct page *page, struct f2fs_io_info *fio, int flush) ...@@ -91,8 +91,8 @@ void f2fs_trace_ios(struct page *page, struct f2fs_io_info *fio, int flush)
return; return;
} }
inode = page->mapping->host; inode = fio->page->mapping->host;
pid = page_private(page); pid = page_private(fio->page);
major = MAJOR(inode->i_sb->s_dev); major = MAJOR(inode->i_sb->s_dev);
minor = MINOR(inode->i_sb->s_dev); minor = MINOR(inode->i_sb->s_dev);
......
...@@ -33,12 +33,12 @@ struct last_io_info { ...@@ -33,12 +33,12 @@ struct last_io_info {
}; };
extern void f2fs_trace_pid(struct page *); extern void f2fs_trace_pid(struct page *);
extern void f2fs_trace_ios(struct page *, struct f2fs_io_info *, int); extern void f2fs_trace_ios(struct f2fs_io_info *, int);
extern void f2fs_build_trace_ios(void); extern void f2fs_build_trace_ios(void);
extern void f2fs_destroy_trace_ios(void); extern void f2fs_destroy_trace_ios(void);
#else #else
#define f2fs_trace_pid(p) #define f2fs_trace_pid(p)
#define f2fs_trace_ios(p, i, n) #define f2fs_trace_ios(i, n)
#define f2fs_build_trace_ios() #define f2fs_build_trace_ios()
#define f2fs_destroy_trace_ios() #define f2fs_destroy_trace_ios()
......
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