The 'struct ext4_journalled_wb_page' is a journal callback entry; use 'kmem_cache ext4_journalled_wb_page_cachep' to alloc/free it. It will be used to end page writeback on transaction commit, only for writeback of mmaped pagecache in data=journal mode (i.e., ext4_writepage() -> __ext4_journalled_writepage()). The next patch will add the associated set page writeback and add the callback entry to the list in the transaction; and process that list in the ext4 journal commit callback. This builds on top of the existing journal commit callback functions (not used anymore), using t_private_list in jbd2. (introduced with commit 18aadd47f884 ("ext4: expand commit callback and"), and not used in commit a015434480dc ("ext4: send parallel discards on commit completions").) P.S.: ext4_journal_commit_callback() does have spinlocking with s_md_lock that is not needed for this particular case (which seems to be the only one), as it has no concurrency on transaction commit time/only during transaction running time (currently only done in __ext4_journalled_writepage()). But no changes for now, just keep it as it is/has been, so it remains general in case other usages arise that need it. Signed-off-by: Mauricio Faria de Oliveira <mfo@xxxxxxxxxxxxx> --- fs/ext4/ext4_jbd2.h | 16 ++++++++++++++++ fs/ext4/page-io.c | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h index 4b9002f0e84c..9ea8ee583931 100644 --- a/fs/ext4/ext4_jbd2.h +++ b/fs/ext4/ext4_jbd2.h @@ -209,6 +209,22 @@ static inline bool ext4_journal_callback_try_del(handle_t *handle, return deleted; } +/* The struct ext4_journalled_wb_page is a journal callback entry to + * end page writeback on transaction commit in the data=journal mode. + * + * This is used for writeback of mmaped pagecache in data=journal mode + * (see ext4_writepage() -> __ext4_journalled_writepage() for details.) + */ +struct ext4_journalled_wb_page { + /* First member must be the journal callback entry */ + struct ext4_journal_cb_entry ejwp_jce; + + /* Pointer to page marked for writeback */ + struct page *ejwp_page; +}; + +extern struct kmem_cache *ext4_journalled_wb_page_cachep; + int ext4_mark_iloc_dirty(handle_t *handle, struct inode *inode, diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index de6fe969f773..67fabeef6bf2 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -32,6 +32,7 @@ static struct kmem_cache *io_end_cachep; static struct kmem_cache *io_end_vec_cachep; +struct kmem_cache *ext4_journalled_wb_page_cachep; int __init ext4_init_pageio(void) { @@ -44,6 +45,15 @@ int __init ext4_init_pageio(void) kmem_cache_destroy(io_end_cachep); return -ENOMEM; } + + ext4_journalled_wb_page_cachep = KMEM_CACHE(ext4_journalled_wb_page, + SLAB_RECLAIM_ACCOUNT); + if (ext4_journalled_wb_page_cachep == NULL) { + kmem_cache_destroy(io_end_cachep); + kmem_cache_destroy(io_end_vec_cachep); + return -ENOMEM; + } + return 0; } @@ -51,6 +61,7 @@ void ext4_exit_pageio(void) { kmem_cache_destroy(io_end_cachep); kmem_cache_destroy(io_end_vec_cachep); + kmem_cache_destroy(ext4_journalled_wb_page_cachep); } struct ext4_io_end_vec *ext4_alloc_io_end_vec(ext4_io_end_t *io_end) -- 2.20.1