The patch titled Subject: nilfs2: move cleanup code of metadata file from inode routines has been added to the -mm tree. Its filename is nilfs2-move-cleanup-code-of-metadata-file-from-inode-routines.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/nilfs2-move-cleanup-code-of-metadata-file-from-inode-routines.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/nilfs2-move-cleanup-code-of-metadata-file-from-inode-routines.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Ryusuke Konishi <konishi.ryusuke@xxxxxxxxxxxxx> Subject: nilfs2: move cleanup code of metadata file from inode routines Refactor nilfs_clear_inode() and nilfs_i_callback() so that cleanup code or resource deallocation related to metadata file will be moved out to mdt.c. Link: http://lkml.kernel.org/r/1461935747-10380-9-git-send-email-konishi.ryusuke@xxxxxxxxxxxxx Signed-off-by: Ryusuke Konishi <konishi.ryusuke@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/nilfs2/inode.c | 5 ++--- fs/nilfs2/mdt.c | 25 +++++++++++++++++++++++++ fs/nilfs2/mdt.h | 8 ++++++++ fs/nilfs2/super.c | 8 +++----- 4 files changed, 38 insertions(+), 8 deletions(-) diff -puN fs/nilfs2/inode.c~nilfs2-move-cleanup-code-of-metadata-file-from-inode-routines fs/nilfs2/inode.c --- a/fs/nilfs2/inode.c~nilfs2-move-cleanup-code-of-metadata-file-from-inode-routines +++ a/fs/nilfs2/inode.c @@ -755,7 +755,6 @@ void nilfs_truncate(struct inode *inode) static void nilfs_clear_inode(struct inode *inode) { struct nilfs_inode_info *ii = NILFS_I(inode); - struct nilfs_mdt_info *mdi = NILFS_MDT(inode); /* * Free resources allocated in nilfs_read_inode(), here. @@ -764,8 +763,8 @@ static void nilfs_clear_inode(struct ino brelse(ii->i_bh); ii->i_bh = NULL; - if (mdi && mdi->mi_palloc_cache) - nilfs_palloc_destroy_cache(inode); + if (nilfs_is_metadata_file_inode(inode)) + nilfs_mdt_clear(inode); if (test_bit(NILFS_I_BMAP, &ii->i_state)) nilfs_bmap_clear(ii->i_bmap); diff -puN fs/nilfs2/mdt.c~nilfs2-move-cleanup-code-of-metadata-file-from-inode-routines fs/nilfs2/mdt.c --- a/fs/nilfs2/mdt.c~nilfs2-move-cleanup-code-of-metadata-file-from-inode-routines +++ a/fs/nilfs2/mdt.c @@ -28,6 +28,7 @@ #include "segment.h" #include "page.h" #include "mdt.h" +#include "alloc.h" /* nilfs_palloc_destroy_cache() */ #include <trace/events/nilfs2.h> @@ -465,6 +466,30 @@ int nilfs_mdt_init(struct inode *inode, return 0; } +/** + * nilfs_mdt_clear - do cleanup for the metadata file + * @inode: inode of the metadata file + */ +void nilfs_mdt_clear(struct inode *inode) +{ + struct nilfs_mdt_info *mdi = NILFS_MDT(inode); + + if (mdi->mi_palloc_cache) + nilfs_palloc_destroy_cache(inode); +} + +/** + * nilfs_mdt_destroy - release resources used by the metadata file + * @inode: inode of the metadata file + */ +void nilfs_mdt_destroy(struct inode *inode) +{ + struct nilfs_mdt_info *mdi = NILFS_MDT(inode); + + kfree(mdi->mi_bgl); /* kfree(NULL) is safe */ + kfree(mdi); +} + void nilfs_mdt_set_entry_size(struct inode *inode, unsigned entry_size, unsigned header_size) { diff -puN fs/nilfs2/mdt.h~nilfs2-move-cleanup-code-of-metadata-file-from-inode-routines fs/nilfs2/mdt.h --- a/fs/nilfs2/mdt.h~nilfs2-move-cleanup-code-of-metadata-file-from-inode-routines +++ a/fs/nilfs2/mdt.h @@ -67,6 +67,11 @@ static inline struct nilfs_mdt_info *NIL return inode->i_private; } +static inline int nilfs_is_metadata_file_inode(const struct inode *inode) +{ + return inode->i_private != NULL; +} + /* Default GFP flags using highmem */ #define NILFS_MDT_GFP (__GFP_RECLAIM | __GFP_IO | __GFP_HIGHMEM) @@ -82,6 +87,9 @@ int nilfs_mdt_forget_block(struct inode int nilfs_mdt_fetch_dirty(struct inode *); int nilfs_mdt_init(struct inode *inode, gfp_t gfp_mask, size_t objsz); +void nilfs_mdt_clear(struct inode *inode); +void nilfs_mdt_destroy(struct inode *inode); + void nilfs_mdt_set_entry_size(struct inode *, unsigned, unsigned); int nilfs_mdt_setup_shadow_map(struct inode *inode, diff -puN fs/nilfs2/super.c~nilfs2-move-cleanup-code-of-metadata-file-from-inode-routines fs/nilfs2/super.c --- a/fs/nilfs2/super.c~nilfs2-move-cleanup-code-of-metadata-file-from-inode-routines +++ a/fs/nilfs2/super.c @@ -169,12 +169,10 @@ struct inode *nilfs_alloc_inode(struct s static void nilfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - struct nilfs_mdt_info *mdi = NILFS_MDT(inode); - if (mdi) { - kfree(mdi->mi_bgl); /* kfree(NULL) is safe */ - kfree(mdi); - } + if (nilfs_is_metadata_file_inode(inode)) + nilfs_mdt_destroy(inode); + kmem_cache_free(nilfs_inode_cachep, NILFS_I(inode)); } _ Patches currently in -mm which might be from konishi.ryusuke@xxxxxxxxxxxxx are nilfs2-fix-white-space-issue-in-nilfs_mount.patch nilfs2-remove-space-before-comma.patch nilfs2-remove-fsf-mailing-address-from-gpl-notices.patch nilfs2-clean-up-old-e-mail-addresses.patch maintainers-add-web-link-for-nilfs-project.patch nilfs2-clarify-permission-to-replicate-the-design.patch nilfs2-get-rid-of-nilfs_mdt_mark_block_dirty.patch nilfs2-move-cleanup-code-of-metadata-file-from-inode-routines.patch nilfs2-replace-__attribute__packed-with-__packed.patch nilfs2-add-missing-line-spacing.patch nilfs2-clean-trailing-semicolons-in-macros.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html