Lines Matching defs:inode

3  * NILFS dat/inode allocator
23 * @inode: inode of metadata file using this allocator
28 nilfs_palloc_groups_per_desc_block(const struct inode *inode)
30 return i_blocksize(inode) /
36 * @inode: inode of metadata file using this allocator
41 nilfs_palloc_groups_count(const struct inode *inode)
43 return 1UL << (BITS_PER_LONG - (inode->i_blkbits + 3 /* log2(8) */));
48 * @inode: inode of metadata file using this allocator
53 int nilfs_palloc_init_blockgroup(struct inode *inode, unsigned int entry_size)
55 struct nilfs_mdt_info *mi = NILFS_MDT(inode);
63 nilfs_mdt_set_entry_size(inode, entry_size, 0);
66 DIV_ROUND_UP(nilfs_palloc_entries_per_group(inode),
73 nilfs_palloc_groups_per_desc_block(inode) *
84 * @inode: inode of metadata file using this allocator
85 * @nr: serial number of the entry (e.g. inode number)
91 static unsigned long nilfs_palloc_group(const struct inode *inode, __u64 nr,
96 *offset = do_div(group, nilfs_palloc_entries_per_group(inode));
102 * @inode: inode of metadata file using this allocator
109 nilfs_palloc_desc_blkoff(const struct inode *inode, unsigned long group)
112 group / nilfs_palloc_groups_per_desc_block(inode);
113 return desc_block * NILFS_MDT(inode)->mi_blocks_per_desc_block;
118 * @inode: inode of metadata file using this allocator
128 nilfs_palloc_bitmap_blkoff(const struct inode *inode, unsigned long group)
131 group % nilfs_palloc_groups_per_desc_block(inode);
132 return nilfs_palloc_desc_blkoff(inode, group) + 1 +
133 desc_offset * NILFS_MDT(inode)->mi_blocks_per_group;
179 * @inode: inode of metadata file using this allocator
180 * @nr: serial number of the entry (e.g. inode number)
186 nilfs_palloc_entry_blkoff(const struct inode *inode, __u64 nr)
190 group = nilfs_palloc_group(inode, nr, &group_offset);
192 return nilfs_palloc_bitmap_blkoff(inode, group) + 1 +
193 group_offset / NILFS_MDT(inode)->mi_entries_per_block;
198 * @inode: inode of metadata file
204 static void nilfs_palloc_desc_block_init(struct inode *inode,
208 unsigned long n = nilfs_palloc_groups_per_desc_block(inode);
211 nfrees = cpu_to_le32(nilfs_palloc_entries_per_group(inode));
218 static int nilfs_palloc_get_block(struct inode *inode, unsigned long blkoff,
220 void (*init_block)(struct inode *,
239 ret = nilfs_mdt_get_block(inode, blkoff, create, init_block, bhp);
257 * @inode: inode of metadata file using this allocator
268 static int nilfs_palloc_delete_block(struct inode *inode, unsigned long blkoff,
278 return nilfs_mdt_delete_block(inode, blkoff);
283 * @inode: inode of metadata file using this allocator
290 static int nilfs_palloc_get_desc_block(struct inode *inode,
294 struct nilfs_palloc_cache *cache = NILFS_MDT(inode)->mi_palloc_cache;
296 return nilfs_palloc_get_block(inode,
297 nilfs_palloc_desc_blkoff(inode, group),
304 * @inode: inode of metadata file using this allocator
311 static int nilfs_palloc_get_bitmap_block(struct inode *inode,
315 struct nilfs_palloc_cache *cache = NILFS_MDT(inode)->mi_palloc_cache;
317 return nilfs_palloc_get_block(inode,
318 nilfs_palloc_bitmap_blkoff(inode, group),
325 * @inode: inode of metadata file using this allocator
330 static int nilfs_palloc_delete_bitmap_block(struct inode *inode,
333 struct nilfs_palloc_cache *cache = NILFS_MDT(inode)->mi_palloc_cache;
335 return nilfs_palloc_delete_block(inode,
336 nilfs_palloc_bitmap_blkoff(inode,
343 * @inode: inode of metadata file using this allocator
344 * @nr: serial number of the entry (e.g. inode number)
350 int nilfs_palloc_get_entry_block(struct inode *inode, __u64 nr,
353 struct nilfs_palloc_cache *cache = NILFS_MDT(inode)->mi_palloc_cache;
355 return nilfs_palloc_get_block(inode,
356 nilfs_palloc_entry_blkoff(inode, nr),
363 * @inode: inode of metadata file using this allocator
368 static int nilfs_palloc_delete_entry_block(struct inode *inode, __u64 nr)
370 struct nilfs_palloc_cache *cache = NILFS_MDT(inode)->mi_palloc_cache;
372 return nilfs_palloc_delete_block(inode,
373 nilfs_palloc_entry_blkoff(inode, nr),
380 * @inode: inode of metadata file using this allocator
386 static size_t nilfs_palloc_group_desc_offset(const struct inode *inode,
392 (group % nilfs_palloc_groups_per_desc_block(inode));
410 * @inode: inode of metadata file using this allocator
411 * @nr: serial number of the entry (e.g. inode number)
416 size_t nilfs_palloc_entry_offset(const struct inode *inode, __u64 nr,
421 nilfs_palloc_group(inode, nr, &entry_index_in_group);
423 NILFS_MDT(inode)->mi_entries_per_block;
426 entry_index_in_block * NILFS_MDT(inode)->mi_entry_size;
477 * @inode: inode of metadata file using this allocator
485 nilfs_palloc_rest_groups_in_desc_block(const struct inode *inode,
489 nilfs_palloc_groups_per_desc_block(inode) -
490 curr % nilfs_palloc_groups_per_desc_block(inode),
496 * @inode: inode of metadata file using this allocator
501 static int nilfs_palloc_count_desc_blocks(struct inode *inode,
507 ret = nilfs_bmap_last_key(NILFS_I(inode)->i_bmap, &blknum);
511 NILFS_MDT(inode)->mi_blocks_per_desc_block);
518 * @inode: inode of metadata file using this allocator
523 static inline bool nilfs_palloc_mdt_file_can_grow(struct inode *inode,
526 return (nilfs_palloc_groups_per_desc_block(inode) * desc_blocks) <
527 nilfs_palloc_groups_count(inode);
533 * @inode: inode of metadata file using this allocator
543 int nilfs_palloc_count_max_entries(struct inode *inode, u64 nused, u64 *nmaxp)
549 err = nilfs_palloc_count_desc_blocks(inode, &desc_blocks);
553 entries_per_desc_block = (u64)nilfs_palloc_entries_per_group(inode) *
554 nilfs_palloc_groups_per_desc_block(inode);
558 nilfs_palloc_mdt_file_can_grow(inode, desc_blocks))
570 * @inode: inode of metadata file using this allocator
581 int nilfs_palloc_prepare_alloc_entry(struct inode *inode,
595 ngroups = nilfs_palloc_groups_count(inode);
597 group = nilfs_palloc_group(inode, req->pr_entry_nr, &group_offset);
598 entries_per_group = nilfs_palloc_entries_per_group(inode);
604 maxgroup = nilfs_palloc_group(inode, req->pr_entry_nr,
607 ret = nilfs_palloc_get_desc_block(inode, group, 1, &desc_bh);
611 doff = nilfs_palloc_group_desc_offset(inode, group, desc_bh);
613 n = nilfs_palloc_rest_groups_in_desc_block(inode, group,
616 lock = nilfs_mdt_bgl_lock(inode, group);
621 ret = nilfs_palloc_get_bitmap_block(inode, group, 1,
672 * @inode: inode of metadata file using this allocator
675 void nilfs_palloc_commit_alloc_entry(struct inode *inode,
680 nilfs_mdt_mark_dirty(inode);
688 * @inode: inode of metadata file using this allocator
691 void nilfs_palloc_commit_free_entry(struct inode *inode,
700 group = nilfs_palloc_group(inode, req->pr_entry_nr, &group_offset);
701 doff = nilfs_palloc_group_desc_offset(inode, group, req->pr_desc_bh);
706 lock = nilfs_mdt_bgl_lock(inode, group);
709 nilfs_warn(inode->i_sb,
711 __func__, inode->i_ino,
721 nilfs_mdt_mark_dirty(inode);
729 * @inode: inode of metadata file using this allocator
732 void nilfs_palloc_abort_alloc_entry(struct inode *inode,
741 group = nilfs_palloc_group(inode, req->pr_entry_nr, &group_offset);
742 doff = nilfs_palloc_group_desc_offset(inode, group, req->pr_desc_bh);
747 lock = nilfs_mdt_bgl_lock(inode, group);
750 nilfs_warn(inode->i_sb,
752 __func__, inode->i_ino,
770 * @inode: inode of metadata file using this allocator
775 int nilfs_palloc_prepare_free_entry(struct inode *inode,
782 group = nilfs_palloc_group(inode, req->pr_entry_nr, &group_offset);
783 ret = nilfs_palloc_get_desc_block(inode, group, 1, &desc_bh);
786 ret = nilfs_palloc_get_bitmap_block(inode, group, 1, &bitmap_bh);
799 * @inode: inode of metadata file using this allocator
802 void nilfs_palloc_abort_free_entry(struct inode *inode,
815 * @inode: inode of metadata file using this allocator
821 int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems)
829 const unsigned long epg = nilfs_palloc_entries_per_group(inode);
830 const unsigned int epb = NILFS_MDT(inode)->mi_entries_per_block;
840 group = nilfs_palloc_group(inode, entry_nrs[i], &group_offset);
841 ret = nilfs_palloc_get_desc_block(inode, group, 0, &desc_bh);
844 ret = nilfs_palloc_get_bitmap_block(inode, group, 0,
856 lock = nilfs_mdt_bgl_lock(inode, group);
863 nilfs_warn(inode->i_sb,
865 __func__, inode->i_ino,
905 ret = nilfs_palloc_delete_entry_block(inode,
908 nilfs_warn(inode->i_sb,
911 inode->i_ino);
914 doff = nilfs_palloc_group_desc_offset(inode, group, desc_bh);
919 nilfs_mdt_mark_dirty(inode);
922 if (nfree == nilfs_palloc_entries_per_group(inode)) {
923 ret = nilfs_palloc_delete_bitmap_block(inode, group);
925 nilfs_warn(inode->i_sb,
927 ret, group, inode->i_ino);
933 void nilfs_palloc_setup_cache(struct inode *inode,
936 NILFS_MDT(inode)->mi_palloc_cache = cache;
940 void nilfs_palloc_clear_cache(struct inode *inode)
942 struct nilfs_palloc_cache *cache = NILFS_MDT(inode)->mi_palloc_cache;
954 void nilfs_palloc_destroy_cache(struct inode *inode)
956 nilfs_palloc_clear_cache(inode);
957 NILFS_MDT(inode)->mi_palloc_cache = NULL;