Lines Matching refs:dir
3 * dir.c
9 * Portions of this code from linux/fs/ext3/dir.c
18 * linux/fs/minix/dir.c
37 #include "dir.h"
58 struct inode *dir,
69 static int ocfs2_supports_dir_trailer(struct inode *dir)
71 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
73 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
76 return ocfs2_meta_ecc(osb) || ocfs2_dir_indexed(dir);
87 static int ocfs2_new_dir_wants_trailer(struct inode *dir)
89 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
117 static int ocfs2_skip_dir_trailer(struct inode *dir,
124 if (!ocfs2_supports_dir_trailer(dir))
147 * Link an unindexed block with a dir trailer structure into the index free
151 static int ocfs2_dx_dir_link_trailer(struct inode *dir, handle_t *handle,
159 ret = ocfs2_journal_access_dr(handle, INODE_CACHE(dir), dx_root_bh,
165 trailer = ocfs2_trailer_from_bh(dirdata_bh, dir->i_sb);
251 static void ocfs2_dx_dir_name_hash(struct inode *dir, const char *name, int len,
254 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
294 * bh passed here can be an inode block or a dir data block, depending
297 static int ocfs2_check_dir_entry(struct inode * dir,
312 ((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize))
318 (unsigned long long)OCFS2_I(dir)->ip_blkno, error_msg,
340 struct inode *dir,
364 if (!ocfs2_check_dir_entry(dir, de, bh, offset)) {
391 struct inode *dir,
399 ret = ocfs2_read_inode_block(dir, &di_bh);
408 found = ocfs2_search_dirblock(di_bh, dir, name, namelen, 0,
409 data->id_data, i_size_read(dir), res_dir);
457 static int ocfs2_check_dir_trailer(struct inode *dir, struct buffer_head *bh)
462 trailer = ocfs2_trailer_from_bh(bh, dir->i_sb);
464 rc = ocfs2_error(dir->i_sb,
471 rc = ocfs2_error(dir->i_sb,
478 OCFS2_I(dir)->ip_blkno) {
479 rc = ocfs2_error(dir->i_sb,
482 (unsigned long long)OCFS2_I(dir)->ip_blkno,
533 static int ocfs2_read_dir_block_direct(struct inode *dir, u64 phys,
539 ret = ocfs2_read_block(INODE_CACHE(dir), phys, &tmp,
546 if (ocfs2_supports_dir_trailer(dir)) {
547 ret = ocfs2_check_dir_trailer(dir, tmp);
575 "Checksum failed for dir index root block %llu\n",
590 static int ocfs2_read_dx_root(struct inode *dir, struct ocfs2_dinode *di,
597 ret = ocfs2_read_block(INODE_CACHE(dir), blkno, &tmp,
618 "Checksum failed for dir index leaf block %llu\n",
631 static int ocfs2_read_dx_leaf(struct inode *dir, u64 blkno,
637 ret = ocfs2_read_block(INODE_CACHE(dir), blkno, &tmp,
651 static int ocfs2_read_dx_leaves(struct inode *dir, u64 start, int num,
656 ret = ocfs2_read_blocks(INODE_CACHE(dir), start, num, dx_leaf_bhs, 0,
665 struct inode *dir,
679 sb = dir->i_sb;
681 nblocks = i_size_read(dir) >> sb->s_blocksize_bits;
682 start = OCFS2_I(dir)->ip_dir_start_lookup;
709 ocfs2_read_dir_block(dir, b++, &bh,
716 if (ocfs2_read_dir_block(dir, block, &bh, 0)) {
721 (unsigned long long)OCFS2_I(dir)->ip_blkno,
725 i = ocfs2_search_dirblock(bh, dir, name, namelen,
730 OCFS2_I(dir)->ip_dir_start_lookup = block;
748 nblocks = i_size_read(dir) >> sb->s_blocksize_bits;
890 struct inode *dir,
905 ocfs2_dx_dir_name_hash(dir, name, namelen, &res->dl_hinfo);
914 ret = ocfs2_dx_dir_lookup(dir, dr_el, hinfo, NULL, &phys);
920 trace_ocfs2_dx_dir_search((unsigned long long)OCFS2_I(dir)->ip_blkno,
924 ret = ocfs2_read_dx_leaf(dir, phys, &dx_leaf_bh);
954 ret = ocfs2_read_dir_block_direct(dir,
967 found = ocfs2_search_dirblock(dir_ent_bh, dir, name, namelen,
969 dir->i_sb->s_blocksize, &dir_ent);
1004 struct inode *dir,
1013 ret = ocfs2_read_inode_block(dir, &di_bh);
1021 ret = ocfs2_read_dx_root(dir, di, &dx_root_bh);
1028 ret = ocfs2_dx_dir_search(name, namelen, dir, dx_root, lookup);
1044 * Try to find an entry of the provided name within 'dir'.
1058 struct inode *dir, struct ocfs2_dir_lookup_result *lookup)
1063 if (ocfs2_dir_indexed(dir))
1064 return ocfs2_find_entry_dx(name, namelen, dir, lookup);
1067 * The unindexed dir code only uses part of the lookup
1071 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
1072 bh = ocfs2_find_entry_id(name, namelen, dir, &res_dir);
1074 bh = ocfs2_find_entry_el(name, namelen, dir, &res_dir);
1087 int ocfs2_update_entry(struct inode *dir, handle_t *handle,
1102 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
1105 ret = access(handle, INODE_CACHE(dir), de_bh,
1125 static int __ocfs2_delete_entry(handle_t *handle, struct inode *dir,
1134 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
1141 if (!ocfs2_check_dir_entry(dir, de, bh, i)) {
1147 status = access(handle, INODE_CACHE(dir), bh,
1158 inode_inc_iversion(dir);
1229 static int ocfs2_delete_entry_dx(handle_t *handle, struct inode *dir,
1270 (unsigned long long)OCFS2_I(dir)->ip_blkno, index,
1280 trailer = ocfs2_trailer_from_bh(leaf_bh, dir->i_sb);
1295 ret = ocfs2_journal_access_dr(handle, INODE_CACHE(dir), dx_root_bh,
1303 ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir),
1312 trace_ocfs2_delete_entry_dx((unsigned long long)OCFS2_I(dir)->ip_blkno,
1315 ret = __ocfs2_delete_entry(handle, dir, lookup->dl_entry,
1322 max_rec_len = ocfs2_find_max_rec_len(dir->i_sb, leaf_bh);
1346 struct inode *dir,
1355 ret = ocfs2_read_inode_block(dir, &di_bh);
1364 ret = __ocfs2_delete_entry(handle, dir, de_del, bh, data->id_data,
1365 i_size_read(dir));
1373 struct inode *dir,
1377 return __ocfs2_delete_entry(handle, dir, de_del, bh, bh->b_data,
1386 struct inode *dir,
1389 if (ocfs2_dir_indexed(dir))
1390 return ocfs2_delete_entry_dx(handle, dir, res);
1392 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
1393 return ocfs2_delete_entry_id(handle, dir, res->dl_entry,
1396 return ocfs2_delete_entry_el(handle, dir, res->dl_entry,
1454 static int __ocfs2_dx_dir_leaf_insert(struct inode *dir, handle_t *handle,
1462 ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir), dx_leaf_bh,
1477 static void ocfs2_dx_inline_root_insert(struct inode *dir, handle_t *handle,
1485 static int ocfs2_dx_dir_insert(struct inode *dir, handle_t *handle,
1492 ret = ocfs2_journal_access_dr(handle, INODE_CACHE(dir), dx_root_bh,
1501 ocfs2_dx_inline_root_insert(dir, handle,
1506 ret = __ocfs2_dx_dir_leaf_insert(dir, handle, &lookup->dl_hinfo,
1520 static void ocfs2_remove_block_from_free_list(struct inode *dir,
1528 trailer = ocfs2_trailer_from_bh(lookup->dl_leaf_bh, dir->i_sb);
1536 prev = ocfs2_trailer_from_bh(bh, dir->i_sb);
1551 static void ocfs2_recalc_free_list(struct inode *dir, handle_t *handle,
1558 max_rec_len = ocfs2_find_max_rec_len(dir->i_sb, lookup->dl_leaf_bh);
1565 trailer = ocfs2_trailer_from_bh(lookup->dl_leaf_bh, dir->i_sb);
1569 ocfs2_remove_block_from_free_list(dir, handle, lookup);
1574 * like orphan dir can call this instead.
1580 struct inode *dir,
1590 struct super_block *sb = dir->i_sb;
1599 if (ocfs2_dir_indexed(dir)) {
1603 * An indexed dir may require that we update the free space
1613 INODE_CACHE(dir), bh,
1618 INODE_CACHE(dir), bh,
1625 } else if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
1627 size = i_size_read(dir);
1641 if (!ocfs2_check_dir_entry(dir, de, insert_bh, offset)) {
1652 mlog_bug_on_msg(ocfs2_skip_dir_trailer(dir, de, offset, size),
1653 "Hit dir trailer trying to insert %.*s "
1658 offset, ocfs2_dir_trailer_blk_off(dir->i_sb));
1661 dir->i_mtime = inode_set_ctime_current(dir);
1662 retval = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh);
1670 INODE_CACHE(dir),
1675 INODE_CACHE(dir),
1679 if (!retval && ocfs2_dir_indexed(dir))
1680 retval = ocfs2_dx_dir_insert(dir,
1710 if (ocfs2_dir_indexed(dir))
1711 ocfs2_recalc_free_list(dir, handle, lookup);
1713 inode_inc_iversion(dir);
1746 mlog(ML_ERROR, "Unable to read inode block for dir %llu\n",
1755 /* If the dir block has changed since the last call to
1845 /* If the dir block has changed since the last call to
1960 * NOTE: this should always be called with parent dir i_rwsem taken.
1989 int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name,
1995 ret = ocfs2_find_files_on_disk(name, namelen, blkno, dir, &lookup);
2006 * Callers should have i_rwsem + a cluster lock on dir
2008 int ocfs2_check_dir_for_entry(struct inode *dir,
2016 (unsigned long long)OCFS2_I(dir)->ip_blkno, namelen, name);
2018 if (ocfs2_find_entry(name, namelen, dir, &lookup) == 0) {
2109 * Returns 1 if dir is empty, zero otherwise.
2135 mlog(ML_ERROR, "bad directory (dir #%llu) - no `.' or `..'\n",
2283 handle_t *handle, struct inode *dir,
2298 ocfs2_trailer_from_bh(dirdata_bh, dir->i_sb);
2308 (unsigned long long)OCFS2_I(dir)->ip_blkno,
2316 ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), dx_root_bh);
2318 ret = ocfs2_journal_access_dr(handle, INODE_CACHE(dir), dx_root_bh,
2333 dx_root->dr_dir_blkno = cpu_to_le64(OCFS2_I(dir)->ip_blkno);
2350 ret = ocfs2_journal_access_di(handle, INODE_CACHE(dir), di_bh,
2359 spin_lock(&OCFS2_I(dir)->ip_lock);
2360 OCFS2_I(dir)->ip_dyn_features |= OCFS2_INDEXED_DIR_FL;
2361 di->i_dyn_features = cpu_to_le16(OCFS2_I(dir)->ip_dyn_features);
2362 spin_unlock(&OCFS2_I(dir)->ip_lock);
2375 handle_t *handle, struct inode *dir,
2391 ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), bh);
2393 ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir), bh,
2410 (unsigned long long)OCFS2_I(dir)->ip_blkno,
2423 * Allocates and formats a new cluster for use in an indexed dir
2427 static int __ocfs2_dx_dir_new_cluster(struct inode *dir,
2436 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
2455 ret = ocfs2_dx_dir_format_cluster(osb, handle, dir, dx_leaves,
2467 static int ocfs2_dx_dir_new_cluster(struct inode *dir,
2478 ret = __ocfs2_dx_dir_new_cluster(dir, cpos, handle, data_ac, dx_leaves,
2584 static int ocfs2_dx_dir_index_block(struct inode *dir,
2599 limit = de_buf + dir->i_sb->s_blocksize;
2608 ocfs2_dx_dir_name_hash(dir, de->name, namelen, &hinfo);
2610 i = ocfs2_dx_dir_hash_idx(OCFS2_SB(dir->i_sb), &hinfo);
2613 ret = __ocfs2_dx_dir_leaf_insert(dir, handle, &hinfo,
2633 static void ocfs2_dx_dir_index_root_block(struct inode *dir,
2646 limit = de_buf + dir->i_sb->s_blocksize;
2654 ocfs2_dx_dir_name_hash(dir, de->name, de->name_len, &hinfo);
2657 (unsigned long long)dir->i_ino,
2676 static int ocfs2_new_dx_should_be_inline(struct inode *dir,
2685 limit = de_buf + i_size_read(dir);
2697 return dirent_count < ocfs2_dx_entries_per_root(dir->i_sb);
2703 * expansion from an inline directory to one with extents. The first dir block
2709 * accounting. We do this here since we're already walking the entire dir
2712 * We add the dir trailer if this filesystem wants it.
2715 struct inode *dir)
2717 struct super_block *sb = dir->i_sb;
2725 if (ocfs2_new_dir_wants_trailer(dir))
2764 static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
2770 struct super_block *sb = dir->i_sb;
2775 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
2776 struct ocfs2_inode_info *oi = OCFS2_I(dir);
2788 ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(dir), di_bh);
2798 dx_inline = ocfs2_new_dx_should_be_inline(dir, di_bh);
2849 ret = dquot_alloc_space_nodirty(dir,
2861 ret = __ocfs2_dx_dir_new_cluster(dir, 0, handle, data_ac,
2868 bytes_allocated += ocfs2_clusters_to_bytes(dir->i_sb, 1);
2883 bytes_allocated += ocfs2_clusters_to_bytes(dir->i_sb, 1);
2890 blkno = ocfs2_clusters_to_blocks(dir->i_sb, bit_off);
2898 ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), dirdata_bh);
2900 ret = ocfs2_journal_access_db(handle, INODE_CACHE(dir), dirdata_bh,
2907 memcpy(dirdata_bh->b_data, di->id2.i_data.id_data, i_size_read(dir));
2908 memset(dirdata_bh->b_data + i_size_read(dir), 0,
2909 sb->s_blocksize - i_size_read(dir));
2910 i = ocfs2_expand_last_dirent(dirdata_bh->b_data, i_size_read(dir), dir);
2911 if (ocfs2_new_dir_wants_trailer(dir)) {
2913 * Prepare the dir trailer up front. It will otherwise look
2915 * (unlikely), then all we'll have done is given first dir
2918 ocfs2_init_dir_trailer(dir, dirdata_bh, i);
2921 ocfs2_update_inode_fsync_trans(handle, dir, 1);
2933 ret = ocfs2_dx_dir_index_block(dir, handle, dx_leaves,
2950 ret = ocfs2_journal_access_di(handle, INODE_CACHE(dir), di_bh,
2962 ocfs2_dinode_new_extent_list(dir, di);
2964 i_size_write(dir, sb->s_blocksize);
2965 dir->i_mtime = inode_set_ctime_current(dir);
2968 di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(dir).tv_sec);
2969 di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(dir).tv_nsec);
2970 ocfs2_update_inode_fsync_trans(handle, dir, 1);
2987 dir->i_blocks = ocfs2_inode_sector_count(dir);
2992 ret = ocfs2_dx_dir_attach_index(osb, handle, dir, di_bh,
3001 ocfs2_dx_dir_index_root_block(dir, dx_root_bh,
3005 INODE_CACHE(dir),
3025 blkno = ocfs2_clusters_to_blocks(dir->i_sb, bit_off);
3033 bytes_allocated += ocfs2_clusters_to_bytes(dir->i_sb, 1);
3057 dquot_free_space_nodirty(dir, bytes_allocated);
3083 struct inode *dir,
3093 spin_lock(&OCFS2_I(dir)->ip_lock);
3094 extend = (i_size_read(dir) == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters));
3095 spin_unlock(&OCFS2_I(dir)->ip_lock);
3098 u32 offset = OCFS2_I(dir)->ip_clusters;
3100 status = dquot_alloc_space_nodirty(dir,
3106 status = ocfs2_add_inode_data(OCFS2_SB(sb), dir, &offset,
3116 v_blkno = ocfs2_blocks_for_bytes(sb, i_size_read(dir));
3117 status = ocfs2_extent_map_get_blocks(dir, v_blkno, &p_blkno, NULL, NULL);
3132 dquot_free_space_nodirty(dir, ocfs2_clusters_to_bytes(sb, 1));
3147 struct inode *dir,
3167 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
3174 status = ocfs2_expand_inline_dir(dir, parent_fe_bh,
3205 down_write(&OCFS2_I(dir)->ip_alloc_sem);
3207 dir_i_size = i_size_read(dir);
3212 down_write(&OCFS2_I(dir)->ip_alloc_sem);
3214 dir_i_size = i_size_read(dir);
3215 trace_ocfs2_extend_dir((unsigned long long)OCFS2_I(dir)->ip_blkno,
3218 /* dir->i_size is always block aligned. */
3219 spin_lock(&OCFS2_I(dir)->ip_lock);
3220 if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) {
3221 spin_unlock(&OCFS2_I(dir)->ip_lock);
3222 ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(dir),
3248 data_ac->ac_resv = &OCFS2_I(dir)->ip_la_data_resv;
3252 spin_unlock(&OCFS2_I(dir)->ip_lock);
3257 if (ocfs2_dir_indexed(dir))
3269 status = ocfs2_do_extend_dir(osb->sb, handle, dir, parent_fe_bh,
3276 ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), new_bh);
3278 status = ocfs2_journal_access_db(handle, INODE_CACHE(dir), new_bh,
3288 if (ocfs2_supports_dir_trailer(dir)) {
3291 ocfs2_init_dir_trailer(dir, new_bh, le16_to_cpu(de->rec_len));
3293 if (ocfs2_dir_indexed(dir)) {
3294 status = ocfs2_dx_dir_link_trailer(dir, handle,
3304 ocfs2_update_inode_fsync_trans(handle, dir, 1);
3307 dir_i_size += dir->i_sb->s_blocksize;
3308 i_size_write(dir, dir_i_size);
3309 dir->i_blocks = ocfs2_inode_sector_count(dir);
3310 status = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh);
3323 up_write(&OCFS2_I(dir)->ip_alloc_sem);
3335 static int ocfs2_find_dir_space_id(struct inode *dir, struct buffer_head *di_bh,
3341 struct super_block *sb = dir->i_sb;
3352 if (ocfs2_new_dir_wants_trailer(dir))
3353 free_space = ocfs2_dir_trailer_blk_off(sb) - i_size_read(dir);
3355 free_space = dir->i_sb->s_blocksize - i_size_read(dir);
3358 limit = de_buf + i_size_read(dir);
3364 if (!ocfs2_check_dir_entry(dir, de, di_bh, offset)) {
3406 static int ocfs2_find_dir_space_el(struct inode *dir, const char *name,
3413 struct super_block *sb = dir->i_sb;
3415 int blocksize = dir->i_sb->s_blocksize;
3417 status = ocfs2_read_dir_block(dir, 0, &bh, 0);
3429 if (i_size_read(dir) <= offset) {
3437 status = ocfs2_read_dir_block(dir,
3446 if (!ocfs2_check_dir_entry(dir, de, bh, offset)) {
3455 if (ocfs2_skip_dir_trailer(dir, de, offset % blocksize,
3627 static void ocfs2_dx_dir_transfer_leaf(struct inode *dir, u32 split_hash,
3649 memcpy(tmp_dx_leaf, orig_dx_leaf, dir->i_sb->s_blocksize);
3663 memcpy(orig_dx_leaf, tmp_dx_leaf, dir->i_sb->s_blocksize);
3684 static int ocfs2_dx_dir_rebalance(struct ocfs2_super *osb, struct inode *dir,
3703 trace_ocfs2_dx_dir_rebalance((unsigned long long)OCFS2_I(dir)->ip_blkno,
3707 ocfs2_init_dx_root_extent_tree(&et, INODE_CACHE(dir), dx_root_bh);
3720 "%llu, %d\n", (unsigned long long)OCFS2_I(dir)->ip_blkno,
3740 ret = ocfs2_lock_allocators(dir, &et, 1, 0, &data_ac, &meta_ac);
3756 ret = dquot_alloc_space_nodirty(dir,
3757 ocfs2_clusters_to_bytes(dir->i_sb, 1));
3762 ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir), dx_leaf_bh,
3812 orig_leaves_start = ocfs2_block_to_cluster_start(dir->i_sb, leaf_blkno);
3813 ret = ocfs2_read_dx_leaves(dir, orig_leaves_start, num_dx_leaves,
3821 ret = ocfs2_dx_dir_new_cluster(dir, &et, cpos, handle,
3830 ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir),
3838 ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir),
3847 ocfs2_dx_dir_transfer_leaf(dir, split_hash, handle, tmp_dx_leaf,
3852 dquot_free_space_nodirty(dir,
3853 ocfs2_clusters_to_bytes(dir->i_sb, 1));
3855 ocfs2_update_inode_fsync_trans(handle, dir, 1);
3879 static int ocfs2_find_dir_space_dx(struct ocfs2_super *osb, struct inode *dir,
3895 ret = ocfs2_dx_dir_lookup(dir, &dx_root->dr_list, &lookup->dl_hinfo,
3902 ret = ocfs2_read_dx_leaf(dir, blkno, &dx_leaf_bh);
3924 ret = ocfs2_dx_dir_rebalance(osb, dir, dx_root_bh, dx_leaf_bh,
3952 static int ocfs2_search_dx_free_list(struct inode *dir,
3972 ret = ocfs2_read_dir_block_direct(dir, next_block, &leaf_bh);
3978 db = ocfs2_trailer_from_bh(leaf_bh, dir->i_sb);
4000 static int ocfs2_expand_inline_dx_root(struct inode *dir,
4008 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
4035 ret = dquot_alloc_space_nodirty(dir,
4046 ret = ocfs2_journal_access_dr(handle, INODE_CACHE(dir), dx_root_bh,
4053 ret = __ocfs2_dx_dir_new_cluster(dir, 0, handle, data_ac, dx_leaves,
4088 ocfs2_init_dx_root_extent_tree(&et, INODE_CACHE(dir), dx_root_bh);
4094 ocfs2_update_inode_fsync_trans(handle, dir, 1);
4099 dquot_free_space_nodirty(dir,
4100 ocfs2_clusters_to_bytes(dir->i_sb, 1));
4131 static int ocfs2_prepare_dx_dir_for_insert(struct inode *dir,
4138 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
4144 ret = ocfs2_read_dx_root(dir, di, &dx_root_bh);
4168 ret = ocfs2_expand_inline_dx_root(dir, dx_root_bh);
4181 ret = ocfs2_find_dir_space_dx(osb, dir, di_bh, dx_root_bh, name,
4195 ret = ocfs2_search_dx_free_list(dir, dx_root_bh, namelen, lookup);
4206 ret = ocfs2_extend_dir(osb, dir, di_bh, 1, lookup, &leaf_bh);
4229 * happens here. Success returns zero, and enough context in the dir
4234 struct inode *dir,
4245 (unsigned long long)OCFS2_I(dir)->ip_blkno, namelen);
4265 ocfs2_dx_dir_name_hash(dir, name, namelen, &lookup->dl_hinfo);
4267 if (ocfs2_dir_indexed(dir)) {
4268 ret = ocfs2_prepare_dx_dir_for_insert(dir, parent_fe_bh,
4275 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
4276 ret = ocfs2_find_dir_space_id(dir, parent_fe_bh, name,
4279 ret = ocfs2_find_dir_space_el(dir, name, namelen, &bh);
4292 ret = ocfs2_extend_dir(osb, dir, parent_fe_bh, blocks_wanted,
4310 static int ocfs2_dx_dir_remove_index(struct inode *dir,
4315 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
4350 ret = ocfs2_journal_access_di(handle, INODE_CACHE(dir), di_bh,
4357 spin_lock(&OCFS2_I(dir)->ip_lock);
4358 OCFS2_I(dir)->ip_dyn_features &= ~OCFS2_INDEXED_DIR_FL;
4359 di->i_dyn_features = cpu_to_le16(OCFS2_I(dir)->ip_dyn_features);
4360 spin_unlock(&OCFS2_I(dir)->ip_lock);
4362 ocfs2_update_inode_fsync_trans(handle, dir, 1);
4391 int ocfs2_dx_dir_truncate(struct inode *dir, struct buffer_head *di_bh)
4397 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
4406 if (!ocfs2_dir_indexed(dir))
4409 ret = ocfs2_read_dx_root(dir, di, &dx_root_bh);
4419 ocfs2_init_dx_root_extent_tree(&et, INODE_CACHE(dir), dx_root_bh);
4423 ret = ocfs2_dx_dir_lookup_rec(dir, &dx_root->dr_list,
4430 p_cpos = ocfs2_blocks_to_clusters(dir->i_sb, blkno);
4432 ret = ocfs2_remove_btree_range(dir, &et, cpos, p_cpos, clen, 0,
4446 ret = ocfs2_dx_dir_remove_index(dir, di_bh, dx_root_bh);
4452 ocfs2_remove_from_cache(INODE_CACHE(dir), dx_root_bh);