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
502 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_mark_dirty()
503 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, &bh); in nilfs_sufile_mark_dirty()
506 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_mark_dirty()
508 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, bh, kaddr); in nilfs_sufile_mark_dirty()
513 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_mark_dirty()
524 int nilfs_sufile_set_segment_usage(struct inode *sufile, __u64 segnum, in nilfs_sufile_set_segment_usage() argument
532 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_segment_usage()
533 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, &bh); in nilfs_sufile_set_segment_usage()
538 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, bh, kaddr); in nilfs_sufile_set_segment_usage()
546 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_set_segment_usage()
550 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_segment_usage()
570 int nilfs_sufile_get_stat(struct inode *sufile, struct nilfs_sustat *sustat) in nilfs_sufile_get_stat() argument
574 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_get_stat()
578 down_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_get_stat()
580 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_get_stat()
586 sustat->ss_nsegs = nilfs_sufile_get_nsegments(sufile); in nilfs_sufile_get_stat()
598 up_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_get_stat()
602 void nilfs_sufile_do_set_error(struct inode *sufile, __u64 segnum, in nilfs_sufile_do_set_error() argument
611 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr); in nilfs_sufile_do_set_error()
622 NILFS_SUI(sufile)->ncleansegs--; in nilfs_sufile_do_set_error()
625 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_do_set_error()
645 static int nilfs_sufile_truncate_range(struct inode *sufile, in nilfs_sufile_truncate_range() argument
648 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_truncate_range()
652 size_t susz = NILFS_MDT(sufile)->mi_entry_size; in nilfs_sufile_truncate_range()
661 nsegs = nilfs_sufile_get_nsegments(sufile); in nilfs_sufile_truncate_range()
667 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_truncate_range()
671 segusages_per_block = nilfs_sufile_segment_usages_per_block(sufile); in nilfs_sufile_truncate_range()
677 nilfs_sufile_get_offset(sufile, segnum), in nilfs_sufile_truncate_range()
679 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, in nilfs_sufile_truncate_range()
689 sufile, segnum, su_bh, kaddr); in nilfs_sufile_truncate_range()
717 nilfs_sufile_delete_segment_usage_block(sufile, segnum); in nilfs_sufile_truncate_range()
724 NILFS_SUI(sufile)->ncleansegs += ncleaned; in nilfs_sufile_truncate_range()
726 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_truncate_range()
749 int nilfs_sufile_resize(struct inode *sufile, __u64 newnsegs) in nilfs_sufile_resize() argument
751 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_resize()
754 struct nilfs_sufile_info *sui = NILFS_SUI(sufile); in nilfs_sufile_resize()
759 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_resize()
761 nsegs = nilfs_sufile_get_nsegments(sufile); in nilfs_sufile_resize()
770 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_resize()
777 ret = nilfs_sufile_truncate_range(sufile, newnsegs, nsegs - 1); in nilfs_sufile_resize()
799 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_resize()
805 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_resize()
826 ssize_t nilfs_sufile_get_suinfo(struct inode *sufile, __u64 segnum, void *buf, in nilfs_sufile_get_suinfo() argument
832 size_t susz = NILFS_MDT(sufile)->mi_entry_size; in nilfs_sufile_get_suinfo()
833 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_get_suinfo()
839 down_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_get_suinfo()
841 segusages_per_block = nilfs_sufile_segment_usages_per_block(sufile); in nilfs_sufile_get_suinfo()
843 nilfs_sufile_get_nsegments(sufile) - segnum, in nilfs_sufile_get_suinfo()
848 nilfs_sufile_get_offset(sufile, segnum), in nilfs_sufile_get_suinfo()
850 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, in nilfs_sufile_get_suinfo()
863 sufile, segnum, su_bh, kaddr); in nilfs_sufile_get_suinfo()
880 up_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_get_suinfo()
904 ssize_t nilfs_sufile_set_suinfo(struct inode *sufile, void *buf, in nilfs_sufile_set_suinfo() argument
907 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_set_suinfo()
930 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_suinfo()
932 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_set_suinfo()
937 blkoff = nilfs_sufile_get_blkoff(sufile, sup->sup_segnum); in nilfs_sufile_set_suinfo()
938 ret = nilfs_mdt_get_block(sufile, blkoff, 1, NULL, &bh); in nilfs_sufile_set_suinfo()
945 sufile, sup->sup_segnum, bh, kaddr); in nilfs_sufile_set_suinfo()
987 blkoff = nilfs_sufile_get_blkoff(sufile, sup->sup_segnum); in nilfs_sufile_set_suinfo()
994 ret = nilfs_mdt_get_block(sufile, blkoff, 1, NULL, &bh); in nilfs_sufile_set_suinfo()
1005 NILFS_SUI(sufile)->ncleansegs += ncleaned; in nilfs_sufile_set_suinfo()
1007 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_set_suinfo()
1011 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_suinfo()
1031 int nilfs_sufile_trim_fs(struct inode *sufile, struct fstrim_range *range) in nilfs_sufile_trim_fs() argument
1033 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_trim_fs()
1037 size_t n, i, susz = NILFS_MDT(sufile)->mi_entry_size; in nilfs_sufile_trim_fs()
1069 down_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_trim_fs()
1072 n = nilfs_sufile_segment_usages_in_block(sufile, segnum, in nilfs_sufile_trim_fs()
1075 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, in nilfs_sufile_trim_fs()
1086 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, in nilfs_sufile_trim_fs()
1129 sufile, segnum, su_bh, kaddr); in nilfs_sufile_trim_fs()
1161 up_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_trim_fs()
1177 struct inode *sufile; in nilfs_sufile_read() local
1194 sufile = nilfs_iget_locked(sb, NULL, NILFS_SUFILE_INO); in nilfs_sufile_read()
1195 if (unlikely(!sufile)) in nilfs_sufile_read()
1197 if (!(sufile->i_state & I_NEW)) in nilfs_sufile_read()
1200 err = nilfs_mdt_init(sufile, NILFS_MDT_GFP, sizeof(*sui)); in nilfs_sufile_read()
1204 nilfs_mdt_set_entry_size(sufile, susize, in nilfs_sufile_read()
1207 err = nilfs_read_inode_common(sufile, raw_inode); in nilfs_sufile_read()
1211 err = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_read()
1215 sui = NILFS_SUI(sufile); in nilfs_sufile_read()
1222 sui->allocmax = nilfs_sufile_get_nsegments(sufile) - 1; in nilfs_sufile_read()
1225 unlock_new_inode(sufile); in nilfs_sufile_read()
1227 *inodep = sufile; in nilfs_sufile_read()
1230 iget_failed(sufile); in nilfs_sufile_read()