]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/nilfs2/mdt.c
nilfs2: move cleanup code of metadata file from inode routines
[linux.git] / fs / nilfs2 / mdt.c
index c8fe58406a071b33fb9fcd76962fed01cf4ae33a..8a2f8b240f253354f5e1e3943fe8806cbf400b52 100644 (file)
@@ -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, gfp_t gfp_mask, size_t objsz)
        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)
 {