0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _NILFS_ALLOC_H
0012 #define _NILFS_ALLOC_H
0013
0014 #include <linux/types.h>
0015 #include <linux/buffer_head.h>
0016 #include <linux/fs.h>
0017
0018
0019
0020
0021
0022
0023
0024
0025 static inline unsigned long
0026 nilfs_palloc_entries_per_group(const struct inode *inode)
0027 {
0028 return 1UL << (inode->i_blkbits + 3 );
0029 }
0030
0031 int nilfs_palloc_init_blockgroup(struct inode *, unsigned int);
0032 int nilfs_palloc_get_entry_block(struct inode *, __u64, int,
0033 struct buffer_head **);
0034 void *nilfs_palloc_block_get_entry(const struct inode *, __u64,
0035 const struct buffer_head *, void *);
0036
0037 int nilfs_palloc_count_max_entries(struct inode *, u64, u64 *);
0038
0039
0040
0041
0042
0043
0044
0045
0046 struct nilfs_palloc_req {
0047 __u64 pr_entry_nr;
0048 struct buffer_head *pr_desc_bh;
0049 struct buffer_head *pr_bitmap_bh;
0050 struct buffer_head *pr_entry_bh;
0051 };
0052
0053 int nilfs_palloc_prepare_alloc_entry(struct inode *,
0054 struct nilfs_palloc_req *);
0055 void nilfs_palloc_commit_alloc_entry(struct inode *,
0056 struct nilfs_palloc_req *);
0057 void nilfs_palloc_abort_alloc_entry(struct inode *, struct nilfs_palloc_req *);
0058 void nilfs_palloc_commit_free_entry(struct inode *, struct nilfs_palloc_req *);
0059 int nilfs_palloc_prepare_free_entry(struct inode *, struct nilfs_palloc_req *);
0060 void nilfs_palloc_abort_free_entry(struct inode *, struct nilfs_palloc_req *);
0061 int nilfs_palloc_freev(struct inode *, __u64 *, size_t);
0062
0063 #define nilfs_set_bit_atomic ext2_set_bit_atomic
0064 #define nilfs_clear_bit_atomic ext2_clear_bit_atomic
0065 #define nilfs_find_next_zero_bit find_next_zero_bit_le
0066 #define nilfs_find_next_bit find_next_bit_le
0067
0068
0069
0070
0071
0072
0073 struct nilfs_bh_assoc {
0074 unsigned long blkoff;
0075 struct buffer_head *bh;
0076 };
0077
0078
0079
0080
0081
0082
0083
0084
0085 struct nilfs_palloc_cache {
0086 spinlock_t lock;
0087 struct nilfs_bh_assoc prev_desc;
0088 struct nilfs_bh_assoc prev_bitmap;
0089 struct nilfs_bh_assoc prev_entry;
0090 };
0091
0092 void nilfs_palloc_setup_cache(struct inode *inode,
0093 struct nilfs_palloc_cache *cache);
0094 void nilfs_palloc_clear_cache(struct inode *inode);
0095 void nilfs_palloc_destroy_cache(struct inode *inode);
0096
0097 #endif