Lines Matching refs:dir

58 			       struct inode *dir,
69 static int ocfs2_supports_dir_trailer(struct inode *dir) in ocfs2_supports_dir_trailer() argument
71 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); in ocfs2_supports_dir_trailer()
73 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) in ocfs2_supports_dir_trailer()
76 return ocfs2_meta_ecc(osb) || ocfs2_dir_indexed(dir); in ocfs2_supports_dir_trailer()
87 static int ocfs2_new_dir_wants_trailer(struct inode *dir) in ocfs2_new_dir_wants_trailer() argument
89 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); in ocfs2_new_dir_wants_trailer()
117 static int ocfs2_skip_dir_trailer(struct inode *dir, in ocfs2_skip_dir_trailer() argument
124 if (!ocfs2_supports_dir_trailer(dir)) in ocfs2_skip_dir_trailer()
151 static int ocfs2_dx_dir_link_trailer(struct inode *dir, handle_t *handle, in ocfs2_dx_dir_link_trailer() argument
159 ret = ocfs2_journal_access_dr(handle, INODE_CACHE(dir), dx_root_bh, in ocfs2_dx_dir_link_trailer()
165 trailer = ocfs2_trailer_from_bh(dirdata_bh, dir->i_sb); in ocfs2_dx_dir_link_trailer()
251 static void ocfs2_dx_dir_name_hash(struct inode *dir, const char *name, int len, in ocfs2_dx_dir_name_hash() argument
254 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); in ocfs2_dx_dir_name_hash()
297 static int ocfs2_check_dir_entry(struct inode * dir, in ocfs2_check_dir_entry() argument
312 ((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize)) in ocfs2_check_dir_entry()
318 (unsigned long long)OCFS2_I(dir)->ip_blkno, error_msg, in ocfs2_check_dir_entry()
340 struct inode *dir, in ocfs2_search_dirblock() argument
364 if (!ocfs2_check_dir_entry(dir, de, bh, offset)) { in ocfs2_search_dirblock()
391 struct inode *dir, in ocfs2_find_entry_id() argument
399 ret = ocfs2_read_inode_block(dir, &di_bh); in ocfs2_find_entry_id()
408 found = ocfs2_search_dirblock(di_bh, dir, name, namelen, 0, in ocfs2_find_entry_id()
409 data->id_data, i_size_read(dir), res_dir); in ocfs2_find_entry_id()
457 static int ocfs2_check_dir_trailer(struct inode *dir, struct buffer_head *bh) in ocfs2_check_dir_trailer() argument
462 trailer = ocfs2_trailer_from_bh(bh, dir->i_sb); in ocfs2_check_dir_trailer()
464 rc = ocfs2_error(dir->i_sb, in ocfs2_check_dir_trailer()
471 rc = ocfs2_error(dir->i_sb, in ocfs2_check_dir_trailer()
478 OCFS2_I(dir)->ip_blkno) { in ocfs2_check_dir_trailer()
479 rc = ocfs2_error(dir->i_sb, in ocfs2_check_dir_trailer()
482 (unsigned long long)OCFS2_I(dir)->ip_blkno, in ocfs2_check_dir_trailer()
533 static int ocfs2_read_dir_block_direct(struct inode *dir, u64 phys, in ocfs2_read_dir_block_direct() argument
539 ret = ocfs2_read_block(INODE_CACHE(dir), phys, &tmp, in ocfs2_read_dir_block_direct()
546 if (ocfs2_supports_dir_trailer(dir)) { in ocfs2_read_dir_block_direct()
547 ret = ocfs2_check_dir_trailer(dir, tmp); in ocfs2_read_dir_block_direct()
590 static int ocfs2_read_dx_root(struct inode *dir, struct ocfs2_dinode *di, in ocfs2_read_dx_root() argument
597 ret = ocfs2_read_block(INODE_CACHE(dir), blkno, &tmp, in ocfs2_read_dx_root()
631 static int ocfs2_read_dx_leaf(struct inode *dir, u64 blkno, in ocfs2_read_dx_leaf() argument
637 ret = ocfs2_read_block(INODE_CACHE(dir), blkno, &tmp, in ocfs2_read_dx_leaf()
651 static int ocfs2_read_dx_leaves(struct inode *dir, u64 start, int num, in ocfs2_read_dx_leaves() argument
656 ret = ocfs2_read_blocks(INODE_CACHE(dir), start, num, dx_leaf_bhs, 0, in ocfs2_read_dx_leaves()
665 struct inode *dir, in ocfs2_find_entry_el() argument
679 sb = dir->i_sb; in ocfs2_find_entry_el()
681 nblocks = i_size_read(dir) >> sb->s_blocksize_bits; in ocfs2_find_entry_el()
682 start = OCFS2_I(dir)->ip_dir_start_lookup; in ocfs2_find_entry_el()
709 ocfs2_read_dir_block(dir, b++, &bh, in ocfs2_find_entry_el()
716 if (ocfs2_read_dir_block(dir, block, &bh, 0)) { in ocfs2_find_entry_el()
721 (unsigned long long)OCFS2_I(dir)->ip_blkno, in ocfs2_find_entry_el()
725 i = ocfs2_search_dirblock(bh, dir, name, namelen, in ocfs2_find_entry_el()
730 OCFS2_I(dir)->ip_dir_start_lookup = block; in ocfs2_find_entry_el()
748 nblocks = i_size_read(dir) >> sb->s_blocksize_bits; in ocfs2_find_entry_el()
890 struct inode *dir, in ocfs2_dx_dir_search() argument
905 ocfs2_dx_dir_name_hash(dir, name, namelen, &res->dl_hinfo); in ocfs2_dx_dir_search()
914 ret = ocfs2_dx_dir_lookup(dir, dr_el, hinfo, NULL, &phys); in ocfs2_dx_dir_search()
920 trace_ocfs2_dx_dir_search((unsigned long long)OCFS2_I(dir)->ip_blkno, in ocfs2_dx_dir_search()
924 ret = ocfs2_read_dx_leaf(dir, phys, &dx_leaf_bh); in ocfs2_dx_dir_search()
954 ret = ocfs2_read_dir_block_direct(dir, in ocfs2_dx_dir_search()
967 found = ocfs2_search_dirblock(dir_ent_bh, dir, name, namelen, in ocfs2_dx_dir_search()
969 dir->i_sb->s_blocksize, &dir_ent); in ocfs2_dx_dir_search()
1004 struct inode *dir, in ocfs2_find_entry_dx() argument
1013 ret = ocfs2_read_inode_block(dir, &di_bh); in ocfs2_find_entry_dx()
1021 ret = ocfs2_read_dx_root(dir, di, &dx_root_bh); in ocfs2_find_entry_dx()
1028 ret = ocfs2_dx_dir_search(name, namelen, dir, dx_root, lookup); in ocfs2_find_entry_dx()
1058 struct inode *dir, struct ocfs2_dir_lookup_result *lookup) in ocfs2_find_entry() argument
1063 if (ocfs2_dir_indexed(dir)) in ocfs2_find_entry()
1064 return ocfs2_find_entry_dx(name, namelen, dir, lookup); in ocfs2_find_entry()
1071 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) in ocfs2_find_entry()
1072 bh = ocfs2_find_entry_id(name, namelen, dir, &res_dir); in ocfs2_find_entry()
1074 bh = ocfs2_find_entry_el(name, namelen, dir, &res_dir); in ocfs2_find_entry()
1087 int ocfs2_update_entry(struct inode *dir, handle_t *handle, in ocfs2_update_entry() argument
1102 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) in ocfs2_update_entry()
1105 ret = access(handle, INODE_CACHE(dir), de_bh, in ocfs2_update_entry()
1125 static int __ocfs2_delete_entry(handle_t *handle, struct inode *dir, in __ocfs2_delete_entry() argument
1134 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) in __ocfs2_delete_entry()
1141 if (!ocfs2_check_dir_entry(dir, de, bh, i)) { in __ocfs2_delete_entry()
1147 status = access(handle, INODE_CACHE(dir), bh, in __ocfs2_delete_entry()
1158 inode_inc_iversion(dir); in __ocfs2_delete_entry()
1229 static int ocfs2_delete_entry_dx(handle_t *handle, struct inode *dir, in ocfs2_delete_entry_dx() argument
1270 (unsigned long long)OCFS2_I(dir)->ip_blkno, index, in ocfs2_delete_entry_dx()
1280 trailer = ocfs2_trailer_from_bh(leaf_bh, dir->i_sb); in ocfs2_delete_entry_dx()
1295 ret = ocfs2_journal_access_dr(handle, INODE_CACHE(dir), dx_root_bh, in ocfs2_delete_entry_dx()
1303 ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir), in ocfs2_delete_entry_dx()
1312 trace_ocfs2_delete_entry_dx((unsigned long long)OCFS2_I(dir)->ip_blkno, in ocfs2_delete_entry_dx()
1315 ret = __ocfs2_delete_entry(handle, dir, lookup->dl_entry, in ocfs2_delete_entry_dx()
1322 max_rec_len = ocfs2_find_max_rec_len(dir->i_sb, leaf_bh); in ocfs2_delete_entry_dx()
1346 struct inode *dir, in ocfs2_delete_entry_id() argument
1355 ret = ocfs2_read_inode_block(dir, &di_bh); in ocfs2_delete_entry_id()
1364 ret = __ocfs2_delete_entry(handle, dir, de_del, bh, data->id_data, in ocfs2_delete_entry_id()
1365 i_size_read(dir)); in ocfs2_delete_entry_id()
1373 struct inode *dir, in ocfs2_delete_entry_el() argument
1377 return __ocfs2_delete_entry(handle, dir, de_del, bh, bh->b_data, in ocfs2_delete_entry_el()
1386 struct inode *dir, in ocfs2_delete_entry() argument
1389 if (ocfs2_dir_indexed(dir)) in ocfs2_delete_entry()
1390 return ocfs2_delete_entry_dx(handle, dir, res); in ocfs2_delete_entry()
1392 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) in ocfs2_delete_entry()
1393 return ocfs2_delete_entry_id(handle, dir, res->dl_entry, in ocfs2_delete_entry()
1396 return ocfs2_delete_entry_el(handle, dir, res->dl_entry, in ocfs2_delete_entry()
1454 static int __ocfs2_dx_dir_leaf_insert(struct inode *dir, handle_t *handle, in __ocfs2_dx_dir_leaf_insert() argument
1462 ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir), dx_leaf_bh, in __ocfs2_dx_dir_leaf_insert()
1477 static void ocfs2_dx_inline_root_insert(struct inode *dir, handle_t *handle, in ocfs2_dx_inline_root_insert() argument
1485 static int ocfs2_dx_dir_insert(struct inode *dir, handle_t *handle, in ocfs2_dx_dir_insert() argument
1492 ret = ocfs2_journal_access_dr(handle, INODE_CACHE(dir), dx_root_bh, in ocfs2_dx_dir_insert()
1501 ocfs2_dx_inline_root_insert(dir, handle, in ocfs2_dx_dir_insert()
1506 ret = __ocfs2_dx_dir_leaf_insert(dir, handle, &lookup->dl_hinfo, in ocfs2_dx_dir_insert()
1520 static void ocfs2_remove_block_from_free_list(struct inode *dir, in ocfs2_remove_block_from_free_list() argument
1528 trailer = ocfs2_trailer_from_bh(lookup->dl_leaf_bh, dir->i_sb); in ocfs2_remove_block_from_free_list()
1536 prev = ocfs2_trailer_from_bh(bh, dir->i_sb); in ocfs2_remove_block_from_free_list()
1551 static void ocfs2_recalc_free_list(struct inode *dir, handle_t *handle, in ocfs2_recalc_free_list() argument
1558 max_rec_len = ocfs2_find_max_rec_len(dir->i_sb, lookup->dl_leaf_bh); in ocfs2_recalc_free_list()
1565 trailer = ocfs2_trailer_from_bh(lookup->dl_leaf_bh, dir->i_sb); in ocfs2_recalc_free_list()
1569 ocfs2_remove_block_from_free_list(dir, handle, lookup); in ocfs2_recalc_free_list()
1580 struct inode *dir, in __ocfs2_add_entry() argument
1590 struct super_block *sb = dir->i_sb; in __ocfs2_add_entry()
1599 if (ocfs2_dir_indexed(dir)) { in __ocfs2_add_entry()
1613 INODE_CACHE(dir), bh, in __ocfs2_add_entry()
1618 INODE_CACHE(dir), bh, in __ocfs2_add_entry()
1625 } else if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { in __ocfs2_add_entry()
1627 size = i_size_read(dir); in __ocfs2_add_entry()
1641 if (!ocfs2_check_dir_entry(dir, de, insert_bh, offset)) { in __ocfs2_add_entry()
1652 mlog_bug_on_msg(ocfs2_skip_dir_trailer(dir, de, offset, size), in __ocfs2_add_entry()
1658 offset, ocfs2_dir_trailer_blk_off(dir->i_sb)); in __ocfs2_add_entry()
1661 dir->i_mtime = dir->i_ctime = current_time(dir); in __ocfs2_add_entry()
1662 retval = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh); in __ocfs2_add_entry()
1670 INODE_CACHE(dir), in __ocfs2_add_entry()
1675 INODE_CACHE(dir), in __ocfs2_add_entry()
1679 if (!retval && ocfs2_dir_indexed(dir)) in __ocfs2_add_entry()
1680 retval = ocfs2_dx_dir_insert(dir, in __ocfs2_add_entry()
1710 if (ocfs2_dir_indexed(dir)) in __ocfs2_add_entry()
1711 ocfs2_recalc_free_list(dir, handle, lookup); in __ocfs2_add_entry()
1713 inode_inc_iversion(dir); in __ocfs2_add_entry()
1989 int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name, in ocfs2_lookup_ino_from_name() argument
1995 ret = ocfs2_find_files_on_disk(name, namelen, blkno, dir, &lookup); in ocfs2_lookup_ino_from_name()
2008 int ocfs2_check_dir_for_entry(struct inode *dir, in ocfs2_check_dir_for_entry() argument
2016 (unsigned long long)OCFS2_I(dir)->ip_blkno, namelen, name); in ocfs2_check_dir_for_entry()
2018 if (ocfs2_find_entry(name, namelen, dir, &lookup) == 0) { in ocfs2_check_dir_for_entry()
2283 handle_t *handle, struct inode *dir, in ocfs2_dx_dir_attach_index() argument
2298 ocfs2_trailer_from_bh(dirdata_bh, dir->i_sb); in ocfs2_dx_dir_attach_index()
2308 (unsigned long long)OCFS2_I(dir)->ip_blkno, in ocfs2_dx_dir_attach_index()
2316 ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), dx_root_bh); in ocfs2_dx_dir_attach_index()
2318 ret = ocfs2_journal_access_dr(handle, INODE_CACHE(dir), dx_root_bh, in ocfs2_dx_dir_attach_index()
2333 dx_root->dr_dir_blkno = cpu_to_le64(OCFS2_I(dir)->ip_blkno); in ocfs2_dx_dir_attach_index()
2350 ret = ocfs2_journal_access_di(handle, INODE_CACHE(dir), di_bh, in ocfs2_dx_dir_attach_index()
2359 spin_lock(&OCFS2_I(dir)->ip_lock); in ocfs2_dx_dir_attach_index()
2360 OCFS2_I(dir)->ip_dyn_features |= OCFS2_INDEXED_DIR_FL; in ocfs2_dx_dir_attach_index()
2361 di->i_dyn_features = cpu_to_le16(OCFS2_I(dir)->ip_dyn_features); in ocfs2_dx_dir_attach_index()
2362 spin_unlock(&OCFS2_I(dir)->ip_lock); in ocfs2_dx_dir_attach_index()
2375 handle_t *handle, struct inode *dir, in ocfs2_dx_dir_format_cluster() argument
2391 ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), bh); in ocfs2_dx_dir_format_cluster()
2393 ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir), bh, in ocfs2_dx_dir_format_cluster()
2410 (unsigned long long)OCFS2_I(dir)->ip_blkno, in ocfs2_dx_dir_format_cluster()
2427 static int __ocfs2_dx_dir_new_cluster(struct inode *dir, in __ocfs2_dx_dir_new_cluster() argument
2436 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); in __ocfs2_dx_dir_new_cluster()
2455 ret = ocfs2_dx_dir_format_cluster(osb, handle, dir, dx_leaves, in __ocfs2_dx_dir_new_cluster()
2467 static int ocfs2_dx_dir_new_cluster(struct inode *dir, in ocfs2_dx_dir_new_cluster() argument
2478 ret = __ocfs2_dx_dir_new_cluster(dir, cpos, handle, data_ac, dx_leaves, in ocfs2_dx_dir_new_cluster()
2584 static int ocfs2_dx_dir_index_block(struct inode *dir, in ocfs2_dx_dir_index_block() argument
2599 limit = de_buf + dir->i_sb->s_blocksize; in ocfs2_dx_dir_index_block()
2608 ocfs2_dx_dir_name_hash(dir, de->name, namelen, &hinfo); in ocfs2_dx_dir_index_block()
2610 i = ocfs2_dx_dir_hash_idx(OCFS2_SB(dir->i_sb), &hinfo); in ocfs2_dx_dir_index_block()
2613 ret = __ocfs2_dx_dir_leaf_insert(dir, handle, &hinfo, in ocfs2_dx_dir_index_block()
2633 static void ocfs2_dx_dir_index_root_block(struct inode *dir, in ocfs2_dx_dir_index_root_block() argument
2646 limit = de_buf + dir->i_sb->s_blocksize; in ocfs2_dx_dir_index_root_block()
2654 ocfs2_dx_dir_name_hash(dir, de->name, de->name_len, &hinfo); in ocfs2_dx_dir_index_root_block()
2657 (unsigned long long)dir->i_ino, in ocfs2_dx_dir_index_root_block()
2676 static int ocfs2_new_dx_should_be_inline(struct inode *dir, in ocfs2_new_dx_should_be_inline() argument
2685 limit = de_buf + i_size_read(dir); in ocfs2_new_dx_should_be_inline()
2697 return dirent_count < ocfs2_dx_entries_per_root(dir->i_sb); in ocfs2_new_dx_should_be_inline()
2715 struct inode *dir) in ocfs2_expand_last_dirent() argument
2717 struct super_block *sb = dir->i_sb; in ocfs2_expand_last_dirent()
2725 if (ocfs2_new_dir_wants_trailer(dir)) in ocfs2_expand_last_dirent()
2764 static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh, in ocfs2_expand_inline_dir() argument
2770 struct super_block *sb = dir->i_sb; in ocfs2_expand_inline_dir()
2775 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); in ocfs2_expand_inline_dir()
2776 struct ocfs2_inode_info *oi = OCFS2_I(dir); in ocfs2_expand_inline_dir()
2788 ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(dir), di_bh); in ocfs2_expand_inline_dir()
2798 dx_inline = ocfs2_new_dx_should_be_inline(dir, di_bh); in ocfs2_expand_inline_dir()
2849 ret = dquot_alloc_space_nodirty(dir, in ocfs2_expand_inline_dir()
2861 ret = __ocfs2_dx_dir_new_cluster(dir, 0, handle, data_ac, in ocfs2_expand_inline_dir()
2868 bytes_allocated += ocfs2_clusters_to_bytes(dir->i_sb, 1); in ocfs2_expand_inline_dir()
2883 bytes_allocated += ocfs2_clusters_to_bytes(dir->i_sb, 1); in ocfs2_expand_inline_dir()
2890 blkno = ocfs2_clusters_to_blocks(dir->i_sb, bit_off); in ocfs2_expand_inline_dir()
2898 ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), dirdata_bh); in ocfs2_expand_inline_dir()
2900 ret = ocfs2_journal_access_db(handle, INODE_CACHE(dir), dirdata_bh, in ocfs2_expand_inline_dir()
2907 memcpy(dirdata_bh->b_data, di->id2.i_data.id_data, i_size_read(dir)); in ocfs2_expand_inline_dir()
2908 memset(dirdata_bh->b_data + i_size_read(dir), 0, in ocfs2_expand_inline_dir()
2909 sb->s_blocksize - i_size_read(dir)); in ocfs2_expand_inline_dir()
2910 i = ocfs2_expand_last_dirent(dirdata_bh->b_data, i_size_read(dir), dir); in ocfs2_expand_inline_dir()
2911 if (ocfs2_new_dir_wants_trailer(dir)) { in ocfs2_expand_inline_dir()
2918 ocfs2_init_dir_trailer(dir, dirdata_bh, i); in ocfs2_expand_inline_dir()
2921 ocfs2_update_inode_fsync_trans(handle, dir, 1); in ocfs2_expand_inline_dir()
2933 ret = ocfs2_dx_dir_index_block(dir, handle, dx_leaves, in ocfs2_expand_inline_dir()
2950 ret = ocfs2_journal_access_di(handle, INODE_CACHE(dir), di_bh, in ocfs2_expand_inline_dir()
2962 ocfs2_dinode_new_extent_list(dir, di); in ocfs2_expand_inline_dir()
2964 i_size_write(dir, sb->s_blocksize); in ocfs2_expand_inline_dir()
2965 dir->i_mtime = dir->i_ctime = current_time(dir); in ocfs2_expand_inline_dir()
2968 di->i_ctime = di->i_mtime = cpu_to_le64(dir->i_ctime.tv_sec); in ocfs2_expand_inline_dir()
2969 di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(dir->i_ctime.tv_nsec); in ocfs2_expand_inline_dir()
2970 ocfs2_update_inode_fsync_trans(handle, dir, 1); in ocfs2_expand_inline_dir()
2987 dir->i_blocks = ocfs2_inode_sector_count(dir); in ocfs2_expand_inline_dir()
2992 ret = ocfs2_dx_dir_attach_index(osb, handle, dir, di_bh, in ocfs2_expand_inline_dir()
3001 ocfs2_dx_dir_index_root_block(dir, dx_root_bh, in ocfs2_expand_inline_dir()
3005 INODE_CACHE(dir), in ocfs2_expand_inline_dir()
3025 blkno = ocfs2_clusters_to_blocks(dir->i_sb, bit_off); in ocfs2_expand_inline_dir()
3033 bytes_allocated += ocfs2_clusters_to_bytes(dir->i_sb, 1); in ocfs2_expand_inline_dir()
3057 dquot_free_space_nodirty(dir, bytes_allocated); in ocfs2_expand_inline_dir()
3083 struct inode *dir, in ocfs2_do_extend_dir() argument
3093 spin_lock(&OCFS2_I(dir)->ip_lock); in ocfs2_do_extend_dir()
3094 extend = (i_size_read(dir) == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)); in ocfs2_do_extend_dir()
3095 spin_unlock(&OCFS2_I(dir)->ip_lock); in ocfs2_do_extend_dir()
3098 u32 offset = OCFS2_I(dir)->ip_clusters; in ocfs2_do_extend_dir()
3100 status = dquot_alloc_space_nodirty(dir, in ocfs2_do_extend_dir()
3106 status = ocfs2_add_inode_data(OCFS2_SB(sb), dir, &offset, in ocfs2_do_extend_dir()
3116 v_blkno = ocfs2_blocks_for_bytes(sb, i_size_read(dir)); in ocfs2_do_extend_dir()
3117 status = ocfs2_extent_map_get_blocks(dir, v_blkno, &p_blkno, NULL, NULL); in ocfs2_do_extend_dir()
3132 dquot_free_space_nodirty(dir, ocfs2_clusters_to_bytes(sb, 1)); in ocfs2_do_extend_dir()
3147 struct inode *dir, in ocfs2_extend_dir() argument
3167 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { in ocfs2_extend_dir()
3174 status = ocfs2_expand_inline_dir(dir, parent_fe_bh, in ocfs2_extend_dir()
3205 down_write(&OCFS2_I(dir)->ip_alloc_sem); in ocfs2_extend_dir()
3207 dir_i_size = i_size_read(dir); in ocfs2_extend_dir()
3212 down_write(&OCFS2_I(dir)->ip_alloc_sem); in ocfs2_extend_dir()
3214 dir_i_size = i_size_read(dir); in ocfs2_extend_dir()
3215 trace_ocfs2_extend_dir((unsigned long long)OCFS2_I(dir)->ip_blkno, in ocfs2_extend_dir()
3219 spin_lock(&OCFS2_I(dir)->ip_lock); in ocfs2_extend_dir()
3220 if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) { in ocfs2_extend_dir()
3221 spin_unlock(&OCFS2_I(dir)->ip_lock); in ocfs2_extend_dir()
3222 ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(dir), in ocfs2_extend_dir()
3248 data_ac->ac_resv = &OCFS2_I(dir)->ip_la_data_resv; in ocfs2_extend_dir()
3252 spin_unlock(&OCFS2_I(dir)->ip_lock); in ocfs2_extend_dir()
3257 if (ocfs2_dir_indexed(dir)) in ocfs2_extend_dir()
3269 status = ocfs2_do_extend_dir(osb->sb, handle, dir, parent_fe_bh, in ocfs2_extend_dir()
3276 ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), new_bh); in ocfs2_extend_dir()
3278 status = ocfs2_journal_access_db(handle, INODE_CACHE(dir), new_bh, in ocfs2_extend_dir()
3288 if (ocfs2_supports_dir_trailer(dir)) { in ocfs2_extend_dir()
3291 ocfs2_init_dir_trailer(dir, new_bh, le16_to_cpu(de->rec_len)); in ocfs2_extend_dir()
3293 if (ocfs2_dir_indexed(dir)) { in ocfs2_extend_dir()
3294 status = ocfs2_dx_dir_link_trailer(dir, handle, in ocfs2_extend_dir()
3304 ocfs2_update_inode_fsync_trans(handle, dir, 1); in ocfs2_extend_dir()
3307 dir_i_size += dir->i_sb->s_blocksize; in ocfs2_extend_dir()
3308 i_size_write(dir, dir_i_size); in ocfs2_extend_dir()
3309 dir->i_blocks = ocfs2_inode_sector_count(dir); in ocfs2_extend_dir()
3310 status = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh); in ocfs2_extend_dir()
3323 up_write(&OCFS2_I(dir)->ip_alloc_sem); in ocfs2_extend_dir()
3335 static int ocfs2_find_dir_space_id(struct inode *dir, struct buffer_head *di_bh, in ocfs2_find_dir_space_id() argument
3341 struct super_block *sb = dir->i_sb; in ocfs2_find_dir_space_id()
3352 if (ocfs2_new_dir_wants_trailer(dir)) in ocfs2_find_dir_space_id()
3353 free_space = ocfs2_dir_trailer_blk_off(sb) - i_size_read(dir); in ocfs2_find_dir_space_id()
3355 free_space = dir->i_sb->s_blocksize - i_size_read(dir); in ocfs2_find_dir_space_id()
3358 limit = de_buf + i_size_read(dir); in ocfs2_find_dir_space_id()
3364 if (!ocfs2_check_dir_entry(dir, de, di_bh, offset)) { in ocfs2_find_dir_space_id()
3406 static int ocfs2_find_dir_space_el(struct inode *dir, const char *name, in ocfs2_find_dir_space_el() argument
3413 struct super_block *sb = dir->i_sb; in ocfs2_find_dir_space_el()
3415 int blocksize = dir->i_sb->s_blocksize; in ocfs2_find_dir_space_el()
3417 status = ocfs2_read_dir_block(dir, 0, &bh, 0); in ocfs2_find_dir_space_el()
3429 if (i_size_read(dir) <= offset) { in ocfs2_find_dir_space_el()
3437 status = ocfs2_read_dir_block(dir, in ocfs2_find_dir_space_el()
3446 if (!ocfs2_check_dir_entry(dir, de, bh, offset)) { in ocfs2_find_dir_space_el()
3455 if (ocfs2_skip_dir_trailer(dir, de, offset % blocksize, in ocfs2_find_dir_space_el()
3627 static void ocfs2_dx_dir_transfer_leaf(struct inode *dir, u32 split_hash, in ocfs2_dx_dir_transfer_leaf() argument
3649 memcpy(tmp_dx_leaf, orig_dx_leaf, dir->i_sb->s_blocksize); in ocfs2_dx_dir_transfer_leaf()
3663 memcpy(orig_dx_leaf, tmp_dx_leaf, dir->i_sb->s_blocksize); in ocfs2_dx_dir_transfer_leaf()
3684 static int ocfs2_dx_dir_rebalance(struct ocfs2_super *osb, struct inode *dir, in ocfs2_dx_dir_rebalance() argument
3703 trace_ocfs2_dx_dir_rebalance((unsigned long long)OCFS2_I(dir)->ip_blkno, in ocfs2_dx_dir_rebalance()
3707 ocfs2_init_dx_root_extent_tree(&et, INODE_CACHE(dir), dx_root_bh); in ocfs2_dx_dir_rebalance()
3720 "%llu, %d\n", (unsigned long long)OCFS2_I(dir)->ip_blkno, in ocfs2_dx_dir_rebalance()
3740 ret = ocfs2_lock_allocators(dir, &et, 1, 0, &data_ac, &meta_ac); in ocfs2_dx_dir_rebalance()
3756 ret = dquot_alloc_space_nodirty(dir, in ocfs2_dx_dir_rebalance()
3757 ocfs2_clusters_to_bytes(dir->i_sb, 1)); in ocfs2_dx_dir_rebalance()
3762 ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir), dx_leaf_bh, in ocfs2_dx_dir_rebalance()
3812 orig_leaves_start = ocfs2_block_to_cluster_start(dir->i_sb, leaf_blkno); in ocfs2_dx_dir_rebalance()
3813 ret = ocfs2_read_dx_leaves(dir, orig_leaves_start, num_dx_leaves, in ocfs2_dx_dir_rebalance()
3821 ret = ocfs2_dx_dir_new_cluster(dir, &et, cpos, handle, in ocfs2_dx_dir_rebalance()
3830 ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir), in ocfs2_dx_dir_rebalance()
3838 ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir), in ocfs2_dx_dir_rebalance()
3847 ocfs2_dx_dir_transfer_leaf(dir, split_hash, handle, tmp_dx_leaf, in ocfs2_dx_dir_rebalance()
3852 dquot_free_space_nodirty(dir, in ocfs2_dx_dir_rebalance()
3853 ocfs2_clusters_to_bytes(dir->i_sb, 1)); in ocfs2_dx_dir_rebalance()
3855 ocfs2_update_inode_fsync_trans(handle, dir, 1); in ocfs2_dx_dir_rebalance()
3879 static int ocfs2_find_dir_space_dx(struct ocfs2_super *osb, struct inode *dir, in ocfs2_find_dir_space_dx() argument
3895 ret = ocfs2_dx_dir_lookup(dir, &dx_root->dr_list, &lookup->dl_hinfo, in ocfs2_find_dir_space_dx()
3902 ret = ocfs2_read_dx_leaf(dir, blkno, &dx_leaf_bh); in ocfs2_find_dir_space_dx()
3924 ret = ocfs2_dx_dir_rebalance(osb, dir, dx_root_bh, dx_leaf_bh, in ocfs2_find_dir_space_dx()
3952 static int ocfs2_search_dx_free_list(struct inode *dir, in ocfs2_search_dx_free_list() argument
3972 ret = ocfs2_read_dir_block_direct(dir, next_block, &leaf_bh); in ocfs2_search_dx_free_list()
3978 db = ocfs2_trailer_from_bh(leaf_bh, dir->i_sb); in ocfs2_search_dx_free_list()
4000 static int ocfs2_expand_inline_dx_root(struct inode *dir, in ocfs2_expand_inline_dx_root() argument
4008 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); in ocfs2_expand_inline_dx_root()
4035 ret = dquot_alloc_space_nodirty(dir, in ocfs2_expand_inline_dx_root()
4046 ret = ocfs2_journal_access_dr(handle, INODE_CACHE(dir), dx_root_bh, in ocfs2_expand_inline_dx_root()
4053 ret = __ocfs2_dx_dir_new_cluster(dir, 0, handle, data_ac, dx_leaves, in ocfs2_expand_inline_dx_root()
4088 ocfs2_init_dx_root_extent_tree(&et, INODE_CACHE(dir), dx_root_bh); in ocfs2_expand_inline_dx_root()
4094 ocfs2_update_inode_fsync_trans(handle, dir, 1); in ocfs2_expand_inline_dx_root()
4099 dquot_free_space_nodirty(dir, in ocfs2_expand_inline_dx_root()
4100 ocfs2_clusters_to_bytes(dir->i_sb, 1)); in ocfs2_expand_inline_dx_root()
4131 static int ocfs2_prepare_dx_dir_for_insert(struct inode *dir, in ocfs2_prepare_dx_dir_for_insert() argument
4138 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); in ocfs2_prepare_dx_dir_for_insert()
4144 ret = ocfs2_read_dx_root(dir, di, &dx_root_bh); in ocfs2_prepare_dx_dir_for_insert()
4168 ret = ocfs2_expand_inline_dx_root(dir, dx_root_bh); in ocfs2_prepare_dx_dir_for_insert()
4181 ret = ocfs2_find_dir_space_dx(osb, dir, di_bh, dx_root_bh, name, in ocfs2_prepare_dx_dir_for_insert()
4195 ret = ocfs2_search_dx_free_list(dir, dx_root_bh, namelen, lookup); in ocfs2_prepare_dx_dir_for_insert()
4206 ret = ocfs2_extend_dir(osb, dir, di_bh, 1, lookup, &leaf_bh); in ocfs2_prepare_dx_dir_for_insert()
4234 struct inode *dir, in ocfs2_prepare_dir_for_insert() argument
4245 (unsigned long long)OCFS2_I(dir)->ip_blkno, namelen); in ocfs2_prepare_dir_for_insert()
4265 ocfs2_dx_dir_name_hash(dir, name, namelen, &lookup->dl_hinfo); in ocfs2_prepare_dir_for_insert()
4267 if (ocfs2_dir_indexed(dir)) { in ocfs2_prepare_dir_for_insert()
4268 ret = ocfs2_prepare_dx_dir_for_insert(dir, parent_fe_bh, in ocfs2_prepare_dir_for_insert()
4275 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { in ocfs2_prepare_dir_for_insert()
4276 ret = ocfs2_find_dir_space_id(dir, parent_fe_bh, name, in ocfs2_prepare_dir_for_insert()
4279 ret = ocfs2_find_dir_space_el(dir, name, namelen, &bh); in ocfs2_prepare_dir_for_insert()
4292 ret = ocfs2_extend_dir(osb, dir, parent_fe_bh, blocks_wanted, in ocfs2_prepare_dir_for_insert()
4310 static int ocfs2_dx_dir_remove_index(struct inode *dir, in ocfs2_dx_dir_remove_index() argument
4315 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); in ocfs2_dx_dir_remove_index()
4350 ret = ocfs2_journal_access_di(handle, INODE_CACHE(dir), di_bh, in ocfs2_dx_dir_remove_index()
4357 spin_lock(&OCFS2_I(dir)->ip_lock); in ocfs2_dx_dir_remove_index()
4358 OCFS2_I(dir)->ip_dyn_features &= ~OCFS2_INDEXED_DIR_FL; in ocfs2_dx_dir_remove_index()
4359 di->i_dyn_features = cpu_to_le16(OCFS2_I(dir)->ip_dyn_features); in ocfs2_dx_dir_remove_index()
4360 spin_unlock(&OCFS2_I(dir)->ip_lock); in ocfs2_dx_dir_remove_index()
4362 ocfs2_update_inode_fsync_trans(handle, dir, 1); in ocfs2_dx_dir_remove_index()
4391 int ocfs2_dx_dir_truncate(struct inode *dir, struct buffer_head *di_bh) in ocfs2_dx_dir_truncate() argument
4397 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); in ocfs2_dx_dir_truncate()
4406 if (!ocfs2_dir_indexed(dir)) in ocfs2_dx_dir_truncate()
4409 ret = ocfs2_read_dx_root(dir, di, &dx_root_bh); in ocfs2_dx_dir_truncate()
4419 ocfs2_init_dx_root_extent_tree(&et, INODE_CACHE(dir), dx_root_bh); in ocfs2_dx_dir_truncate()
4423 ret = ocfs2_dx_dir_lookup_rec(dir, &dx_root->dr_list, in ocfs2_dx_dir_truncate()
4430 p_cpos = ocfs2_blocks_to_clusters(dir->i_sb, blkno); in ocfs2_dx_dir_truncate()
4432 ret = ocfs2_remove_btree_range(dir, &et, cpos, p_cpos, clen, 0, in ocfs2_dx_dir_truncate()
4446 ret = ocfs2_dx_dir_remove_index(dir, di_bh, dx_root_bh); in ocfs2_dx_dir_truncate()
4452 ocfs2_remove_from_cache(INODE_CACHE(dir), dx_root_bh); in ocfs2_dx_dir_truncate()