Lines Matching refs:sufile

49 static inline struct nilfs_sufile_info *NILFS_SUI(struct inode *sufile)  in NILFS_SUI()  argument
51 return (struct nilfs_sufile_info *)NILFS_MDT(sufile); in NILFS_SUI()
55 nilfs_sufile_segment_usages_per_block(const struct inode *sufile) in nilfs_sufile_segment_usages_per_block() argument
57 return NILFS_MDT(sufile)->mi_entries_per_block; in nilfs_sufile_segment_usages_per_block()
61 nilfs_sufile_get_blkoff(const struct inode *sufile, __u64 segnum) in nilfs_sufile_get_blkoff() argument
63 __u64 t = segnum + NILFS_MDT(sufile)->mi_first_entry_offset; in nilfs_sufile_get_blkoff()
64 do_div(t, nilfs_sufile_segment_usages_per_block(sufile)); in nilfs_sufile_get_blkoff()
69 nilfs_sufile_get_offset(const struct inode *sufile, __u64 segnum) in nilfs_sufile_get_offset() argument
71 __u64 t = segnum + NILFS_MDT(sufile)->mi_first_entry_offset; in nilfs_sufile_get_offset()
72 return do_div(t, nilfs_sufile_segment_usages_per_block(sufile)); in nilfs_sufile_get_offset()
76 nilfs_sufile_segment_usages_in_block(const struct inode *sufile, __u64 curr, in nilfs_sufile_segment_usages_in_block() argument
80 nilfs_sufile_segment_usages_per_block(sufile) - in nilfs_sufile_segment_usages_in_block()
81 nilfs_sufile_get_offset(sufile, curr), in nilfs_sufile_segment_usages_in_block()
86 nilfs_sufile_block_get_segment_usage(const struct inode *sufile, __u64 segnum, in nilfs_sufile_block_get_segment_usage() argument
90 nilfs_sufile_get_offset(sufile, segnum) * in nilfs_sufile_block_get_segment_usage()
91 NILFS_MDT(sufile)->mi_entry_size; in nilfs_sufile_block_get_segment_usage()
94 static inline int nilfs_sufile_get_header_block(struct inode *sufile, in nilfs_sufile_get_header_block() argument
97 return nilfs_mdt_get_block(sufile, 0, 0, NULL, bhp); in nilfs_sufile_get_header_block()
101 nilfs_sufile_get_segment_usage_block(struct inode *sufile, __u64 segnum, in nilfs_sufile_get_segment_usage_block() argument
104 return nilfs_mdt_get_block(sufile, in nilfs_sufile_get_segment_usage_block()
105 nilfs_sufile_get_blkoff(sufile, segnum), in nilfs_sufile_get_segment_usage_block()
109 static int nilfs_sufile_delete_segment_usage_block(struct inode *sufile, in nilfs_sufile_delete_segment_usage_block() argument
112 return nilfs_mdt_delete_block(sufile, in nilfs_sufile_delete_segment_usage_block()
113 nilfs_sufile_get_blkoff(sufile, segnum)); in nilfs_sufile_delete_segment_usage_block()
135 unsigned long nilfs_sufile_get_ncleansegs(struct inode *sufile) in nilfs_sufile_get_ncleansegs() argument
137 return NILFS_SUI(sufile)->ncleansegs; in nilfs_sufile_get_ncleansegs()
168 int nilfs_sufile_updatev(struct inode *sufile, __u64 *segnumv, size_t nsegs, in nilfs_sufile_updatev() argument
183 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_updatev()
185 if (unlikely(*seg >= nilfs_sufile_get_nsegments(sufile))) { in nilfs_sufile_updatev()
197 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_updatev()
202 blkoff = nilfs_sufile_get_blkoff(sufile, *seg); in nilfs_sufile_updatev()
203 ret = nilfs_mdt_get_block(sufile, blkoff, create, NULL, &bh); in nilfs_sufile_updatev()
208 dofunc(sufile, *seg, header_bh, bh); in nilfs_sufile_updatev()
213 blkoff = nilfs_sufile_get_blkoff(sufile, *seg); in nilfs_sufile_updatev()
219 ret = nilfs_mdt_get_block(sufile, blkoff, create, NULL, &bh); in nilfs_sufile_updatev()
229 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_updatev()
236 int nilfs_sufile_update(struct inode *sufile, __u64 segnum, int create, in nilfs_sufile_update() argument
244 if (unlikely(segnum >= nilfs_sufile_get_nsegments(sufile))) { in nilfs_sufile_update()
249 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_update()
251 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_update()
255 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, create, &bh); in nilfs_sufile_update()
257 dofunc(sufile, segnum, header_bh, bh); in nilfs_sufile_update()
263 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_update()
278 int nilfs_sufile_set_alloc_range(struct inode *sufile, __u64 start, __u64 end) in nilfs_sufile_set_alloc_range() argument
280 struct nilfs_sufile_info *sui = NILFS_SUI(sufile); in nilfs_sufile_set_alloc_range()
284 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_alloc_range()
285 nsegs = nilfs_sufile_get_nsegments(sufile); in nilfs_sufile_set_alloc_range()
292 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_alloc_range()
313 int nilfs_sufile_alloc(struct inode *sufile, __u64 *segnump) in nilfs_sufile_alloc() argument
318 struct nilfs_sufile_info *sui = NILFS_SUI(sufile); in nilfs_sufile_alloc()
319 size_t susz = NILFS_MDT(sufile)->mi_entry_size; in nilfs_sufile_alloc()
325 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_alloc()
327 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_alloc()
335 nsegments = nilfs_sufile_get_nsegments(sufile); in nilfs_sufile_alloc()
362 trace_nilfs2_segment_usage_check(sufile, segnum, cnt); in nilfs_sufile_alloc()
363 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 1, in nilfs_sufile_alloc()
369 sufile, segnum, su_bh, kaddr); in nilfs_sufile_alloc()
372 sufile, segnum, maxsegnum); in nilfs_sufile_alloc()
390 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_alloc()
394 trace_nilfs2_segment_usage_allocated(sufile, segnum); in nilfs_sufile_alloc()
410 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_alloc()
414 void nilfs_sufile_do_cancel_free(struct inode *sufile, __u64 segnum, in nilfs_sufile_do_cancel_free() argument
422 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr); in nilfs_sufile_do_cancel_free()
433 NILFS_SUI(sufile)->ncleansegs--; in nilfs_sufile_do_cancel_free()
436 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_do_cancel_free()
439 void nilfs_sufile_do_scrap(struct inode *sufile, __u64 segnum, in nilfs_sufile_do_scrap() argument
448 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr); in nilfs_sufile_do_scrap()
464 NILFS_SUI(sufile)->ncleansegs -= clean; in nilfs_sufile_do_scrap()
467 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_do_scrap()
470 void nilfs_sufile_do_free(struct inode *sufile, __u64 segnum, in nilfs_sufile_do_free() argument
479 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr); in nilfs_sufile_do_free()
495 NILFS_SUI(sufile)->ncleansegs++; in nilfs_sufile_do_free()
497 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_do_free()
499 trace_nilfs2_segment_usage_freed(sufile, segnum); in nilfs_sufile_do_free()
507 int nilfs_sufile_mark_dirty(struct inode *sufile, __u64 segnum) in nilfs_sufile_mark_dirty() argument
512 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, &bh); in nilfs_sufile_mark_dirty()
515 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_mark_dirty()
528 int nilfs_sufile_set_segment_usage(struct inode *sufile, __u64 segnum, in nilfs_sufile_set_segment_usage() argument
536 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_segment_usage()
537 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, &bh); in nilfs_sufile_set_segment_usage()
542 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, bh, kaddr); in nilfs_sufile_set_segment_usage()
550 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_set_segment_usage()
554 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_segment_usage()
574 int nilfs_sufile_get_stat(struct inode *sufile, struct nilfs_sustat *sustat) in nilfs_sufile_get_stat() argument
578 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_get_stat()
582 down_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_get_stat()
584 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_get_stat()
590 sustat->ss_nsegs = nilfs_sufile_get_nsegments(sufile); in nilfs_sufile_get_stat()
602 up_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_get_stat()
606 void nilfs_sufile_do_set_error(struct inode *sufile, __u64 segnum, in nilfs_sufile_do_set_error() argument
615 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr); in nilfs_sufile_do_set_error()
626 NILFS_SUI(sufile)->ncleansegs--; in nilfs_sufile_do_set_error()
629 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_do_set_error()
649 static int nilfs_sufile_truncate_range(struct inode *sufile, in nilfs_sufile_truncate_range() argument
652 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_truncate_range()
656 size_t susz = NILFS_MDT(sufile)->mi_entry_size; in nilfs_sufile_truncate_range()
665 nsegs = nilfs_sufile_get_nsegments(sufile); in nilfs_sufile_truncate_range()
671 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_truncate_range()
675 segusages_per_block = nilfs_sufile_segment_usages_per_block(sufile); in nilfs_sufile_truncate_range()
681 nilfs_sufile_get_offset(sufile, segnum), in nilfs_sufile_truncate_range()
683 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, in nilfs_sufile_truncate_range()
693 sufile, segnum, su_bh, kaddr); in nilfs_sufile_truncate_range()
721 nilfs_sufile_delete_segment_usage_block(sufile, segnum); in nilfs_sufile_truncate_range()
728 NILFS_SUI(sufile)->ncleansegs += ncleaned; in nilfs_sufile_truncate_range()
730 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_truncate_range()
753 int nilfs_sufile_resize(struct inode *sufile, __u64 newnsegs) in nilfs_sufile_resize() argument
755 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_resize()
758 struct nilfs_sufile_info *sui = NILFS_SUI(sufile); in nilfs_sufile_resize()
763 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_resize()
765 nsegs = nilfs_sufile_get_nsegments(sufile); in nilfs_sufile_resize()
774 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_resize()
781 ret = nilfs_sufile_truncate_range(sufile, newnsegs, nsegs - 1); in nilfs_sufile_resize()
794 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_resize()
800 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_resize()
821 ssize_t nilfs_sufile_get_suinfo(struct inode *sufile, __u64 segnum, void *buf, in nilfs_sufile_get_suinfo() argument
827 size_t susz = NILFS_MDT(sufile)->mi_entry_size; in nilfs_sufile_get_suinfo()
828 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_get_suinfo()
834 down_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_get_suinfo()
836 segusages_per_block = nilfs_sufile_segment_usages_per_block(sufile); in nilfs_sufile_get_suinfo()
838 nilfs_sufile_get_nsegments(sufile) - segnum, in nilfs_sufile_get_suinfo()
843 nilfs_sufile_get_offset(sufile, segnum), in nilfs_sufile_get_suinfo()
845 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, in nilfs_sufile_get_suinfo()
858 sufile, segnum, su_bh, kaddr); in nilfs_sufile_get_suinfo()
875 up_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_get_suinfo()
899 ssize_t nilfs_sufile_set_suinfo(struct inode *sufile, void *buf, in nilfs_sufile_set_suinfo() argument
902 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_set_suinfo()
925 down_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_suinfo()
927 ret = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_set_suinfo()
932 blkoff = nilfs_sufile_get_blkoff(sufile, sup->sup_segnum); in nilfs_sufile_set_suinfo()
933 ret = nilfs_mdt_get_block(sufile, blkoff, 1, NULL, &bh); in nilfs_sufile_set_suinfo()
940 sufile, sup->sup_segnum, bh, kaddr); in nilfs_sufile_set_suinfo()
982 blkoff = nilfs_sufile_get_blkoff(sufile, sup->sup_segnum); in nilfs_sufile_set_suinfo()
989 ret = nilfs_mdt_get_block(sufile, blkoff, 1, NULL, &bh); in nilfs_sufile_set_suinfo()
1000 NILFS_SUI(sufile)->ncleansegs += ncleaned; in nilfs_sufile_set_suinfo()
1002 nilfs_mdt_mark_dirty(sufile); in nilfs_sufile_set_suinfo()
1006 up_write(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_set_suinfo()
1026 int nilfs_sufile_trim_fs(struct inode *sufile, struct fstrim_range *range) in nilfs_sufile_trim_fs() argument
1028 struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; in nilfs_sufile_trim_fs()
1032 size_t n, i, susz = NILFS_MDT(sufile)->mi_entry_size; in nilfs_sufile_trim_fs()
1064 down_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_trim_fs()
1067 n = nilfs_sufile_segment_usages_in_block(sufile, segnum, in nilfs_sufile_trim_fs()
1070 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, in nilfs_sufile_trim_fs()
1081 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, in nilfs_sufile_trim_fs()
1124 sufile, segnum, su_bh, kaddr); in nilfs_sufile_trim_fs()
1156 up_read(&NILFS_MDT(sufile)->mi_sem); in nilfs_sufile_trim_fs()
1172 struct inode *sufile; in nilfs_sufile_read() local
1191 sufile = nilfs_iget_locked(sb, NULL, NILFS_SUFILE_INO); in nilfs_sufile_read()
1192 if (unlikely(!sufile)) in nilfs_sufile_read()
1194 if (!(sufile->i_state & I_NEW)) in nilfs_sufile_read()
1197 err = nilfs_mdt_init(sufile, NILFS_MDT_GFP, sizeof(*sui)); in nilfs_sufile_read()
1201 nilfs_mdt_set_entry_size(sufile, susize, in nilfs_sufile_read()
1204 err = nilfs_read_inode_common(sufile, raw_inode); in nilfs_sufile_read()
1208 err = nilfs_sufile_get_header_block(sufile, &header_bh); in nilfs_sufile_read()
1212 sui = NILFS_SUI(sufile); in nilfs_sufile_read()
1219 sui->allocmax = nilfs_sufile_get_nsegments(sufile) - 1; in nilfs_sufile_read()
1222 unlock_new_inode(sufile); in nilfs_sufile_read()
1224 *inodep = sufile; in nilfs_sufile_read()
1227 iget_failed(sufile); in nilfs_sufile_read()