• Home
  • Raw
  • Download

Lines Matching refs:info

27 static int get_index(struct qtree_mem_dqinfo *info, qid_t id, int depth)  in get_index()  argument
29 unsigned int epb = info->dqi_usable_bs >> 2; in get_index()
31 depth = info->dqi_qtree_depth - depth - 1; in get_index()
38 static inline int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info) in qtree_dqstr_in_blk() argument
40 return (info->dqi_usable_bs - sizeof(struct qt_disk_dqdbheader)) in qtree_dqstr_in_blk()
41 / info->dqi_entry_size; in qtree_dqstr_in_blk()
57 static inline ssize_t read_blk(struct qtree_mem_dqinfo *info, uint blk, dqbuf_t buf) in read_blk() argument
59 struct super_block *sb = info->dqi_sb; in read_blk()
61 memset(buf, 0, info->dqi_usable_bs); in read_blk()
62 return sb->s_op->quota_read(sb, info->dqi_type, (char *)buf, in read_blk()
63 info->dqi_usable_bs, blk << info->dqi_blocksize_bits); in read_blk()
66 static inline ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, dqbuf_t buf) in write_blk() argument
68 struct super_block *sb = info->dqi_sb; in write_blk()
70 return sb->s_op->quota_write(sb, info->dqi_type, (char *)buf, in write_blk()
71 info->dqi_usable_bs, blk << info->dqi_blocksize_bits); in write_blk()
75 static int get_free_dqblk(struct qtree_mem_dqinfo *info) in get_free_dqblk() argument
77 dqbuf_t buf = getdqbuf(info->dqi_usable_bs); in get_free_dqblk()
83 if (info->dqi_free_blk) { in get_free_dqblk()
84 blk = info->dqi_free_blk; in get_free_dqblk()
85 ret = read_blk(info, blk, buf); in get_free_dqblk()
88 info->dqi_free_blk = le32_to_cpu(dh->dqdh_next_free); in get_free_dqblk()
91 memset(buf, 0, info->dqi_usable_bs); in get_free_dqblk()
93 ret = write_blk(info, info->dqi_blocks, buf); in get_free_dqblk()
96 blk = info->dqi_blocks++; in get_free_dqblk()
98 mark_info_dirty(info->dqi_sb, info->dqi_type); in get_free_dqblk()
106 static int put_free_dqblk(struct qtree_mem_dqinfo *info, dqbuf_t buf, uint blk) in put_free_dqblk() argument
111 dh->dqdh_next_free = cpu_to_le32(info->dqi_free_blk); in put_free_dqblk()
114 err = write_blk(info, blk, buf); in put_free_dqblk()
117 info->dqi_free_blk = blk; in put_free_dqblk()
118 mark_info_dirty(info->dqi_sb, info->dqi_type); in put_free_dqblk()
123 static int remove_free_dqentry(struct qtree_mem_dqinfo *info, dqbuf_t buf, uint blk) in remove_free_dqentry() argument
125 dqbuf_t tmpbuf = getdqbuf(info->dqi_usable_bs); in remove_free_dqentry()
134 err = read_blk(info, nextblk, tmpbuf); in remove_free_dqentry()
139 err = write_blk(info, nextblk, tmpbuf); in remove_free_dqentry()
144 err = read_blk(info, prevblk, tmpbuf); in remove_free_dqentry()
149 err = write_blk(info, prevblk, tmpbuf); in remove_free_dqentry()
153 info->dqi_free_entry = nextblk; in remove_free_dqentry()
154 mark_info_dirty(info->dqi_sb, info->dqi_type); in remove_free_dqentry()
159 if (write_blk(info, blk, buf) < 0) in remove_free_dqentry()
168 static int insert_free_dqentry(struct qtree_mem_dqinfo *info, dqbuf_t buf, uint blk) in insert_free_dqentry() argument
170 dqbuf_t tmpbuf = getdqbuf(info->dqi_usable_bs); in insert_free_dqentry()
176 dh->dqdh_next_free = cpu_to_le32(info->dqi_free_entry); in insert_free_dqentry()
178 err = write_blk(info, blk, buf); in insert_free_dqentry()
181 if (info->dqi_free_entry) { in insert_free_dqentry()
182 err = read_blk(info, info->dqi_free_entry, tmpbuf); in insert_free_dqentry()
187 err = write_blk(info, info->dqi_free_entry, tmpbuf); in insert_free_dqentry()
192 info->dqi_free_entry = blk; in insert_free_dqentry()
193 mark_info_dirty(info->dqi_sb, info->dqi_type); in insert_free_dqentry()
201 int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk) in qtree_entry_unused() argument
205 for (i = 0; i < info->dqi_entry_size; i++) in qtree_entry_unused()
213 static uint find_free_dqentry(struct qtree_mem_dqinfo *info, in find_free_dqentry() argument
218 dqbuf_t buf = getdqbuf(info->dqi_usable_bs); in find_free_dqentry()
227 if (info->dqi_free_entry) { in find_free_dqentry()
228 blk = info->dqi_free_entry; in find_free_dqentry()
229 *err = read_blk(info, blk, buf); in find_free_dqentry()
233 blk = get_free_dqblk(info); in find_free_dqentry()
239 memset(buf, 0, info->dqi_usable_bs); in find_free_dqentry()
241 info->dqi_free_entry = blk; in find_free_dqentry()
245 if (le16_to_cpu(dh->dqdh_entries) + 1 >= qtree_dqstr_in_blk(info)) { in find_free_dqentry()
246 *err = remove_free_dqentry(info, buf, blk); in find_free_dqentry()
257 i < qtree_dqstr_in_blk(info) && !qtree_entry_unused(info, ddquot); in find_free_dqentry()
258 i++, ddquot += info->dqi_entry_size); in find_free_dqentry()
260 if (i == qtree_dqstr_in_blk(info)) { in find_free_dqentry()
267 *err = write_blk(info, blk, buf); in find_free_dqentry()
273 dquot->dq_off = (blk << info->dqi_blocksize_bits) + in find_free_dqentry()
275 i * info->dqi_entry_size; in find_free_dqentry()
284 static int do_insert_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, in do_insert_tree() argument
287 dqbuf_t buf = getdqbuf(info->dqi_usable_bs); in do_insert_tree()
295 ret = get_free_dqblk(info); in do_insert_tree()
299 memset(buf, 0, info->dqi_usable_bs); in do_insert_tree()
302 ret = read_blk(info, *treeblk, buf); in do_insert_tree()
310 newblk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]); in do_insert_tree()
313 if (depth == info->dqi_qtree_depth - 1) { in do_insert_tree()
318 le32_to_cpu(ref[get_index(info, in do_insert_tree()
324 newblk = find_free_dqentry(info, dquot, &ret); in do_insert_tree()
326 ret = do_insert_tree(info, dquot, &newblk, depth+1); in do_insert_tree()
329 ref[get_index(info, dquot->dq_id, depth)] = in do_insert_tree()
331 ret = write_blk(info, *treeblk, buf); in do_insert_tree()
333 put_free_dqblk(info, buf, *treeblk); in do_insert_tree()
341 static inline int dq_insert_tree(struct qtree_mem_dqinfo *info, in dq_insert_tree() argument
345 return do_insert_tree(info, dquot, &tmp, 0); in dq_insert_tree()
351 int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) in qtree_write_dquot() argument
356 dqbuf_t ddquot = getdqbuf(info->dqi_entry_size); in qtree_write_dquot()
363 ret = dq_insert_tree(info, dquot); in qtree_write_dquot()
372 info->dqi_ops->mem2disk_dqblk(ddquot, dquot); in qtree_write_dquot()
375 info->dqi_entry_size, dquot->dq_off); in qtree_write_dquot()
376 if (ret != info->dqi_entry_size) { in qtree_write_dquot()
392 static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot, in free_dqentry() argument
396 dqbuf_t buf = getdqbuf(info->dqi_usable_bs); in free_dqentry()
401 if (dquot->dq_off >> info->dqi_blocksize_bits != blk) { in free_dqentry()
404 (uint)(dquot->dq_off >> info->dqi_blocksize_bits)); in free_dqentry()
407 ret = read_blk(info, blk, buf); in free_dqentry()
415 ret = remove_free_dqentry(info, buf, blk); in free_dqentry()
417 ret = put_free_dqblk(info, buf, blk); in free_dqentry()
425 (dquot->dq_off & ((1 << info->dqi_blocksize_bits) - 1)), in free_dqentry()
426 0, info->dqi_entry_size); in free_dqentry()
428 qtree_dqstr_in_blk(info) - 1) { in free_dqentry()
430 ret = insert_free_dqentry(info, buf, blk); in free_dqentry()
437 ret = write_blk(info, blk, buf); in free_dqentry()
452 static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, in remove_tree() argument
455 dqbuf_t buf = getdqbuf(info->dqi_usable_bs); in remove_tree()
462 ret = read_blk(info, *blk, buf); in remove_tree()
467 newblk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]); in remove_tree()
468 if (depth == info->dqi_qtree_depth - 1) { in remove_tree()
469 ret = free_dqentry(info, dquot, newblk); in remove_tree()
472 ret = remove_tree(info, dquot, &newblk, depth+1); in remove_tree()
476 ref[get_index(info, dquot->dq_id, depth)] = cpu_to_le32(0); in remove_tree()
479 i < (info->dqi_usable_bs >> 2) && !ref[i]; in remove_tree()
482 if (i == (info->dqi_usable_bs >> 2) in remove_tree()
484 put_free_dqblk(info, buf, *blk); in remove_tree()
487 ret = write_blk(info, *blk, buf); in remove_tree()
499 int qtree_delete_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) in qtree_delete_dquot() argument
505 return remove_tree(info, dquot, &tmp, 0); in qtree_delete_dquot()
510 static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info, in find_block_dqentry() argument
513 dqbuf_t buf = getdqbuf(info->dqi_usable_bs); in find_block_dqentry()
520 ret = read_blk(info, blk, buf); in find_block_dqentry()
526 i < qtree_dqstr_in_blk(info) && !info->dqi_ops->is_id(ddquot, dquot); in find_block_dqentry()
527 i++, ddquot += info->dqi_entry_size); in find_block_dqentry()
528 if (i == qtree_dqstr_in_blk(info)) { in find_block_dqentry()
534 ret = (blk << info->dqi_blocksize_bits) + sizeof(struct in find_block_dqentry()
535 qt_disk_dqdbheader) + i * info->dqi_entry_size; in find_block_dqentry()
543 static loff_t find_tree_dqentry(struct qtree_mem_dqinfo *info, in find_tree_dqentry() argument
546 dqbuf_t buf = getdqbuf(info->dqi_usable_bs); in find_tree_dqentry()
552 ret = read_blk(info, blk, buf); in find_tree_dqentry()
558 blk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]); in find_tree_dqentry()
561 if (depth < info->dqi_qtree_depth - 1) in find_tree_dqentry()
562 ret = find_tree_dqentry(info, dquot, blk, depth+1); in find_tree_dqentry()
564 ret = find_block_dqentry(info, dquot, blk); in find_tree_dqentry()
571 static inline loff_t find_dqentry(struct qtree_mem_dqinfo *info, in find_dqentry() argument
574 return find_tree_dqentry(info, dquot, QT_TREEOFF, 0); in find_dqentry()
577 int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) in qtree_read_dquot() argument
594 offset = find_dqentry(info, dquot); in qtree_read_dquot()
607 ddquot = getdqbuf(info->dqi_entry_size); in qtree_read_dquot()
611 info->dqi_entry_size, dquot->dq_off); in qtree_read_dquot()
612 if (ret != info->dqi_entry_size) { in qtree_read_dquot()
623 info->dqi_ops->disk2mem_dqblk(dquot, ddquot); in qtree_read_dquot()
639 int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) in qtree_release_dquot() argument
642 return qtree_delete_dquot(info, dquot); in qtree_release_dquot()