0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _NILFS_MDT_H
0011 #define _NILFS_MDT_H
0012
0013 #include <linux/buffer_head.h>
0014 #include <linux/blockgroup_lock.h>
0015 #include "nilfs.h"
0016 #include "page.h"
0017
0018
0019
0020
0021
0022
0023
0024 struct nilfs_shadow_map {
0025 struct nilfs_bmap_store bmap_store;
0026 struct inode *inode;
0027 struct list_head frozen_buffers;
0028 };
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 struct nilfs_mdt_info {
0043 struct rw_semaphore mi_sem;
0044 struct blockgroup_lock *mi_bgl;
0045 unsigned int mi_entry_size;
0046 unsigned int mi_first_entry_offset;
0047 unsigned long mi_entries_per_block;
0048 struct nilfs_palloc_cache *mi_palloc_cache;
0049 struct nilfs_shadow_map *mi_shadow;
0050 unsigned long mi_blocks_per_group;
0051 unsigned long mi_blocks_per_desc_block;
0052 };
0053
0054 static inline struct nilfs_mdt_info *NILFS_MDT(const struct inode *inode)
0055 {
0056 return inode->i_private;
0057 }
0058
0059 static inline int nilfs_is_metadata_file_inode(const struct inode *inode)
0060 {
0061 return inode->i_private != NULL;
0062 }
0063
0064
0065 #define NILFS_MDT_GFP (__GFP_RECLAIM | __GFP_IO | __GFP_HIGHMEM)
0066
0067 int nilfs_mdt_get_block(struct inode *, unsigned long, int,
0068 void (*init_block)(struct inode *,
0069 struct buffer_head *, void *),
0070 struct buffer_head **);
0071 int nilfs_mdt_find_block(struct inode *inode, unsigned long start,
0072 unsigned long end, unsigned long *blkoff,
0073 struct buffer_head **out_bh);
0074 int nilfs_mdt_delete_block(struct inode *, unsigned long);
0075 int nilfs_mdt_forget_block(struct inode *, unsigned long);
0076 int nilfs_mdt_fetch_dirty(struct inode *);
0077
0078 int nilfs_mdt_init(struct inode *inode, gfp_t gfp_mask, size_t objsz);
0079 void nilfs_mdt_clear(struct inode *inode);
0080 void nilfs_mdt_destroy(struct inode *inode);
0081
0082 void nilfs_mdt_set_entry_size(struct inode *, unsigned int, unsigned int);
0083
0084 int nilfs_mdt_setup_shadow_map(struct inode *inode,
0085 struct nilfs_shadow_map *shadow);
0086 int nilfs_mdt_save_to_shadow_map(struct inode *inode);
0087 void nilfs_mdt_restore_from_shadow_map(struct inode *inode);
0088 void nilfs_mdt_clear_shadow_map(struct inode *inode);
0089 int nilfs_mdt_freeze_buffer(struct inode *inode, struct buffer_head *bh);
0090 struct buffer_head *nilfs_mdt_get_frozen_buffer(struct inode *inode,
0091 struct buffer_head *bh);
0092
0093 static inline void nilfs_mdt_mark_dirty(struct inode *inode)
0094 {
0095 if (!test_bit(NILFS_I_DIRTY, &NILFS_I(inode)->i_state))
0096 set_bit(NILFS_I_DIRTY, &NILFS_I(inode)->i_state);
0097 }
0098
0099 static inline void nilfs_mdt_clear_dirty(struct inode *inode)
0100 {
0101 clear_bit(NILFS_I_DIRTY, &NILFS_I(inode)->i_state);
0102 }
0103
0104 static inline __u64 nilfs_mdt_cno(struct inode *inode)
0105 {
0106 return ((struct the_nilfs *)inode->i_sb->s_fs_info)->ns_cno;
0107 }
0108
0109 static inline spinlock_t *
0110 nilfs_mdt_bgl_lock(struct inode *inode, unsigned int block_group)
0111 {
0112 return bgl_lock_ptr(NILFS_MDT(inode)->mi_bgl, block_group);
0113 }
0114
0115 #endif