Lines Matching refs:sufile

35 static inline struct nilfs_sufile_info *NILFS_SUI(struct inode *sufile)  in NILFS_SUI()  argument
37 return (struct nilfs_sufile_info *)NILFS_MDT(sufile); in NILFS_SUI()
41 nilfs_sufile_segment_usages_per_block(const struct inode *sufile) in nilfs_sufile_segment_usages_per_block() argument
43 return NILFS_MDT(sufile)->mi_entries_per_block; in nilfs_sufile_segment_usages_per_block()
47 nilfs_sufile_get_blkoff(const struct inode *sufile, __u64 segnum) in nilfs_sufile_get_blkoff() argument
49 __u64 t = segnum + NILFS_MDT(sufile)->mi_first_entry_offset; in nilfs_sufile_get_blkoff()
51 do_div(t, nilfs_sufile_segment_usages_per_block(sufile)); in nilfs_sufile_get_blkoff()
56 nilfs_sufile_get_offset(const struct inode *sufile, __u64 segnum) in nilfs_sufile_get_offset() argument
58 __u64 t = segnum + NILFS_MDT(sufile)->mi_first_entry_offset; in nilfs_sufile_get_offset()
60 return do_div(t, nilfs_sufile_segment_usages_per_block(sufile)); in nilfs_sufile_get_offset()
64 nilfs_sufile_segment_usages_in_block(const struct inode *sufile, __u64 curr, in nilfs_sufile_segment_usages_in_block() argument
68 nilfs_sufile_segment_usages_per_block(sufile) - in nilfs_sufile_segment_usages_in_block()
69 nilfs_sufile_get_offset(sufile, curr), in nilfs_sufile_segment_usages_in_block()
74 nilfs_sufile_block_get_segment_usage(const struct inode *sufile, __u64 segnum, in nilfs_sufile_block_get_segment_usage() argument
78 nilfs_sufile_get_offset(sufile, segnum) * in nilfs_sufile_block_get_segment_usage()
79 NILFS_MDT(sufile)->mi_entry_size; in nilfs_sufile_block_get_segment_usage()
82 static inline int nilfs_sufile_get_header_block(struct inode *sufile, in nilfs_sufile_get_header_block() argument
85 return nilfs_mdt_get_block(sufile, 0, 0, NULL, bhp); in nilfs_sufile_get_header_block()
89 nilfs_sufile_get_segment_usage_block(struct inode *sufile, __u64 segnum, in nilfs_sufile_get_segment_usage_block() argument
92 return nilfs_mdt_get_block(sufile, in nilfs_sufile_get_segment_usage_block()
93 nilfs_sufile_get_blkoff(sufile, segnum), in nilfs_sufile_get_segment_usage_block()
97 static int nilfs_sufile_delete_segment_usage_block(struct inode *sufile, in nilfs_sufile_delete_segment_usage_block() argument
100 return nilfs_mdt_delete_block(sufile, in nilfs_sufile_delete_segment_usage_block()
101 nilfs_sufile_get_blkoff(sufile, segnum)); in nilfs_sufile_delete_segment_usage_block()
123 unsigned long nilfs_sufile_get_ncleansegs(struct inode *sufile) in nilfs_sufile_get_ncleansegs() argument
125 return NILFS_SUI(sufile)->ncleansegs; in nilfs_sufile_get_ncleansegs()
156 int nilfs_sufile_updatev(struct inode *sufile, __u64 *segnumv, size_t nsegs, in nilfs_sufile_updatev() argument
171 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_updatev()
173 if (unlikely(*seg >= nilfs_sufile_get_nsegments(sufile))) { in nilfs_sufile_updatev()
174 nilfs_warn(sufile->i_sb, in nilfs_sufile_updatev()
185 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_updatev()
190 blkoff = nilfs_sufile_get_blkoff(sufile, *seg); in nilfs_sufile_updatev()
191 ret = nilfs_mdt_get_block(sufile, blkoff, create, NULL, &bh); in nilfs_sufile_updatev()
196 dofunc(sufile, *seg, header_bh, bh); in nilfs_sufile_updatev()
201 blkoff = nilfs_sufile_get_blkoff(sufile, *seg); in nilfs_sufile_updatev()
207 ret = nilfs_mdt_get_block(sufile, blkoff, create, NULL, &bh); in nilfs_sufile_updatev()
217 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_updatev()
224 int nilfs_sufile_update(struct inode *sufile, __u64 segnum, int create, in nilfs_sufile_update() argument
232 if (unlikely(segnum >= nilfs_sufile_get_nsegments(sufile))) { in nilfs_sufile_update()
233 nilfs_warn(sufile->i_sb, "%s: invalid segment number: %llu", in nilfs_sufile_update()
237 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_update()
239 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_update()
243 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, create, &bh); in nilfs_sufile_update()
245 dofunc(sufile, segnum, header_bh, bh); in nilfs_sufile_update()
251 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_update()
266 int nilfs_sufile_set_alloc_range(struct inode *sufile, __u64 start, __u64 end) in nilfs_sufile_set_alloc_range() argument
268 struct nilfs_sufile_info *sui = NILFS_SUI(sufile); in nilfs_sufile_set_alloc_range()
272 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_alloc_range()
273 nsegs = nilfs_sufile_get_nsegments(sufile); in nilfs_sufile_set_alloc_range()
280 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_alloc_range()
301 int nilfs_sufile_alloc(struct inode *sufile, __u64 *segnump) in nilfs_sufile_alloc() argument
306 struct nilfs_sufile_info *sui = NILFS_SUI(sufile); in nilfs_sufile_alloc()
307 size_t susz = NILFS_MDT(sufile)->mi_entry_size; in nilfs_sufile_alloc()
313 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_alloc()
315 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_alloc()
323 nsegments = nilfs_sufile_get_nsegments(sufile); in nilfs_sufile_alloc()
350 trace_nilfs2_segment_usage_check(sufile, segnum, cnt); in nilfs_sufile_alloc()
351 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 1, in nilfs_sufile_alloc()
357 sufile, segnum, su_bh, kaddr); in nilfs_sufile_alloc()
360 sufile, segnum, maxsegnum); in nilfs_sufile_alloc()
378 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_alloc()
382 trace_nilfs2_segment_usage_allocated(sufile, segnum); in nilfs_sufile_alloc()
398 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_alloc()
402 void nilfs_sufile_do_cancel_free(struct inode *sufile, __u64 segnum, in nilfs_sufile_do_cancel_free() argument
410 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr); in nilfs_sufile_do_cancel_free()
412 nilfs_warn(sufile->i_sb, "%s: segment %llu must be clean", in nilfs_sufile_do_cancel_free()
421 NILFS_SUI(sufile)->ncleansegs--; in nilfs_sufile_do_cancel_free()
424 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_do_cancel_free()
427 void nilfs_sufile_do_scrap(struct inode *sufile, __u64 segnum, in nilfs_sufile_do_scrap() argument
436 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr); in nilfs_sufile_do_scrap()
452 NILFS_SUI(sufile)->ncleansegs -= clean; in nilfs_sufile_do_scrap()
455 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_do_scrap()
458 void nilfs_sufile_do_free(struct inode *sufile, __u64 segnum, in nilfs_sufile_do_free() argument
467 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr); in nilfs_sufile_do_free()
469 nilfs_warn(sufile->i_sb, "%s: segment %llu is already clean", in nilfs_sufile_do_free()
483 NILFS_SUI(sufile)->ncleansegs++; in nilfs_sufile_do_free()
485 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_do_free()
487 trace_nilfs2_segment_usage_freed(sufile, segnum); in nilfs_sufile_do_free()
495 int nilfs_sufile_mark_dirty(struct inode *sufile, __u64 segnum) in nilfs_sufile_mark_dirty() argument
500 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, &bh); in nilfs_sufile_mark_dirty()
503 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_mark_dirty()
516 int nilfs_sufile_set_segment_usage(struct inode *sufile, __u64 segnum, in nilfs_sufile_set_segment_usage() argument
524 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_segment_usage()
525 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, &bh); in nilfs_sufile_set_segment_usage()
530 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, bh, kaddr); in nilfs_sufile_set_segment_usage()
538 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_set_segment_usage()
542 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_segment_usage()
562 int nilfs_sufile_get_stat(struct inode *sufile, struct nilfs_sustat *sustat) in nilfs_sufile_get_stat() argument
566 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_get_stat()
570 down_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_get_stat()
572 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_get_stat()
578 sustat->ss_nsegs = nilfs_sufile_get_nsegments(sufile); in nilfs_sufile_get_stat()
590 up_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_get_stat()
594 void nilfs_sufile_do_set_error(struct inode *sufile, __u64 segnum, in nilfs_sufile_do_set_error() argument
603 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr); in nilfs_sufile_do_set_error()
614 NILFS_SUI(sufile)->ncleansegs--; in nilfs_sufile_do_set_error()
617 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_do_set_error()
637 static int nilfs_sufile_truncate_range(struct inode *sufile, in nilfs_sufile_truncate_range() argument
640 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_truncate_range()
644 size_t susz = NILFS_MDT(sufile)->mi_entry_size; in nilfs_sufile_truncate_range()
653 nsegs = nilfs_sufile_get_nsegments(sufile); in nilfs_sufile_truncate_range()
659 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_truncate_range()
663 segusages_per_block = nilfs_sufile_segment_usages_per_block(sufile); in nilfs_sufile_truncate_range()
669 nilfs_sufile_get_offset(sufile, segnum), in nilfs_sufile_truncate_range()
671 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, in nilfs_sufile_truncate_range()
681 sufile, segnum, su_bh, kaddr); in nilfs_sufile_truncate_range()
709 nilfs_sufile_delete_segment_usage_block(sufile, segnum); in nilfs_sufile_truncate_range()
716 NILFS_SUI(sufile)->ncleansegs += ncleaned; in nilfs_sufile_truncate_range()
718 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_truncate_range()
741 int nilfs_sufile_resize(struct inode *sufile, __u64 newnsegs) in nilfs_sufile_resize() argument
743 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_resize()
746 struct nilfs_sufile_info *sui = NILFS_SUI(sufile); in nilfs_sufile_resize()
751 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_resize()
753 nsegs = nilfs_sufile_get_nsegments(sufile); in nilfs_sufile_resize()
762 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_resize()
769 ret = nilfs_sufile_truncate_range(sufile, newnsegs, nsegs - 1); in nilfs_sufile_resize()
782 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_resize()
788 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_resize()
809 ssize_t nilfs_sufile_get_suinfo(struct inode *sufile, __u64 segnum, void *buf, in nilfs_sufile_get_suinfo() argument
815 size_t susz = NILFS_MDT(sufile)->mi_entry_size; in nilfs_sufile_get_suinfo()
816 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_get_suinfo()
822 down_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_get_suinfo()
824 segusages_per_block = nilfs_sufile_segment_usages_per_block(sufile); in nilfs_sufile_get_suinfo()
826 nilfs_sufile_get_nsegments(sufile) - segnum, in nilfs_sufile_get_suinfo()
831 nilfs_sufile_get_offset(sufile, segnum), in nilfs_sufile_get_suinfo()
833 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, in nilfs_sufile_get_suinfo()
846 sufile, segnum, su_bh, kaddr); in nilfs_sufile_get_suinfo()
863 up_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_get_suinfo()
887 ssize_t nilfs_sufile_set_suinfo(struct inode *sufile, void *buf, in nilfs_sufile_set_suinfo() argument
890 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_set_suinfo()
913 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_suinfo()
915 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_set_suinfo()
920 blkoff = nilfs_sufile_get_blkoff(sufile, sup->sup_segnum); in nilfs_sufile_set_suinfo()
921 ret = nilfs_mdt_get_block(sufile, blkoff, 1, NULL, &bh); in nilfs_sufile_set_suinfo()
928 sufile, sup->sup_segnum, bh, kaddr); in nilfs_sufile_set_suinfo()
970 blkoff = nilfs_sufile_get_blkoff(sufile, sup->sup_segnum); in nilfs_sufile_set_suinfo()
977 ret = nilfs_mdt_get_block(sufile, blkoff, 1, NULL, &bh); in nilfs_sufile_set_suinfo()
988 NILFS_SUI(sufile)->ncleansegs += ncleaned; in nilfs_sufile_set_suinfo()
990 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_set_suinfo()
994 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_suinfo()
1014 int nilfs_sufile_trim_fs(struct inode *sufile, struct fstrim_range *range) in nilfs_sufile_trim_fs() argument
1016 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_trim_fs()
1020 size_t n, i, susz = NILFS_MDT(sufile)->mi_entry_size; in nilfs_sufile_trim_fs()
1052 down_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_trim_fs()
1055 n = nilfs_sufile_segment_usages_in_block(sufile, segnum, in nilfs_sufile_trim_fs()
1058 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, in nilfs_sufile_trim_fs()
1069 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, in nilfs_sufile_trim_fs()
1112 sufile, segnum, su_bh, kaddr); in nilfs_sufile_trim_fs()
1144 up_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_trim_fs()
1160 struct inode *sufile; in nilfs_sufile_read() local
1177 sufile = nilfs_iget_locked(sb, NULL, NILFS_SUFILE_INO); in nilfs_sufile_read()
1178 if (unlikely(!sufile)) in nilfs_sufile_read()
1180 if (!(sufile->i_state & I_NEW)) in nilfs_sufile_read()
1183 err = nilfs_mdt_init(sufile, NILFS_MDT_GFP, sizeof(*sui)); in nilfs_sufile_read()
1187 nilfs_mdt_set_entry_size(sufile, susize, in nilfs_sufile_read()
1190 err = nilfs_read_inode_common(sufile, raw_inode); in nilfs_sufile_read()
1194 err = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_read()
1198 sui = NILFS_SUI(sufile); in nilfs_sufile_read()
1205 sui->allocmax = nilfs_sufile_get_nsegments(sufile) - 1; in nilfs_sufile_read()
1208 unlock_new_inode(sufile); in nilfs_sufile_read()
1210 *inodep = sufile; in nilfs_sufile_read()
1213 iget_failed(sufile); in nilfs_sufile_read()