]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/ocfs2/dir.c
ocfs2: Add the 'inode64' mount option.
[karo-tx-linux.git] / fs / ocfs2 / dir.c
index 8a18758480805504c453ed291908b36764b9f722..167e6c96277d4c0d7ad52c77857574fac7d1ea3d 100644 (file)
@@ -1192,6 +1192,9 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
        struct buffer_head *dirdata_bh = NULL;
        struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
        handle_t *handle;
+       struct ocfs2_extent_tree et;
+
+       ocfs2_init_dinode_extent_tree(&et, dir, di_bh);
 
        alloc = ocfs2_clusters_for_bytes(sb, bytes);
 
@@ -1300,19 +1303,24 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
        di->i_size = cpu_to_le64(sb->s_blocksize);
        di->i_ctime = di->i_mtime = cpu_to_le64(dir->i_ctime.tv_sec);
        di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(dir->i_ctime.tv_nsec);
-       dir->i_blocks = ocfs2_inode_sector_count(dir);
 
        /*
         * This should never fail as our extent list is empty and all
         * related blocks have been journaled already.
         */
-       ret = ocfs2_insert_extent(osb, handle, dir, di_bh, 0, blkno, len, 0,
-                                 NULL);
+       ret = ocfs2_insert_extent(osb, handle, dir, &et, 0, blkno, len,
+                                 0, NULL);
        if (ret) {
                mlog_errno(ret);
-               goto out;
+               goto out_commit;
        }
 
+       /*
+        * Set i_blocks after the extent insert for the most up to
+        * date ip_clusters value.
+        */
+       dir->i_blocks = ocfs2_inode_sector_count(dir);
+
        ret = ocfs2_journal_dirty(handle, di_bh);
        if (ret) {
                mlog_errno(ret);
@@ -1332,11 +1340,11 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
                }
                blkno = ocfs2_clusters_to_blocks(dir->i_sb, bit_off);
 
-               ret = ocfs2_insert_extent(osb, handle, dir, di_bh, 1, blkno,
-                                         len, 0, NULL);
+               ret = ocfs2_insert_extent(osb, handle, dir, &et, 1,
+                                         blkno, len, 0, NULL);
                if (ret) {
                        mlog_errno(ret);
-                       goto out;
+                       goto out_commit;
                }
        }
 
@@ -1378,9 +1386,9 @@ static int ocfs2_do_extend_dir(struct super_block *sb,
        if (extend) {
                u32 offset = OCFS2_I(dir)->ip_clusters;
 
-               status = ocfs2_do_extend_allocation(OCFS2_SB(sb), dir, &offset,
-                                                   1, 0, parent_fe_bh, handle,
-                                                   data_ac, meta_ac, NULL);
+               status = ocfs2_add_inode_data(OCFS2_SB(sb), dir, &offset,
+                                             1, 0, parent_fe_bh, handle,
+                                             data_ac, meta_ac, NULL);
                BUG_ON(status == -EAGAIN);
                if (status < 0) {
                        mlog_errno(status);
@@ -1425,12 +1433,14 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
        int credits, num_free_extents, drop_alloc_sem = 0;
        loff_t dir_i_size;
        struct ocfs2_dinode *fe = (struct ocfs2_dinode *) parent_fe_bh->b_data;
+       struct ocfs2_extent_list *el = &fe->id2.i_list;
        struct ocfs2_alloc_context *data_ac = NULL;
        struct ocfs2_alloc_context *meta_ac = NULL;
        handle_t *handle = NULL;
        struct buffer_head *new_bh = NULL;
        struct ocfs2_dir_entry * de;
        struct super_block *sb = osb->sb;
+       struct ocfs2_extent_tree et;
 
        mlog_entry_void();
 
@@ -1474,7 +1484,8 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
        spin_lock(&OCFS2_I(dir)->ip_lock);
        if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) {
                spin_unlock(&OCFS2_I(dir)->ip_lock);
-               num_free_extents = ocfs2_num_free_extents(osb, dir, fe);
+               ocfs2_init_dinode_extent_tree(&et, dir, parent_fe_bh);
+               num_free_extents = ocfs2_num_free_extents(osb, dir, &et);
                if (num_free_extents < 0) {
                        status = num_free_extents;
                        mlog_errno(status);
@@ -1482,7 +1493,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
                }
 
                if (!num_free_extents) {
-                       status = ocfs2_reserve_new_metadata(osb, fe, &meta_ac);
+                       status = ocfs2_reserve_new_metadata(osb, el, &meta_ac);
                        if (status < 0) {
                                if (status != -ENOSPC)
                                        mlog_errno(status);
@@ -1497,7 +1508,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
                        goto bail;
                }
 
-               credits = ocfs2_calc_extend_credits(sb, fe, 1);
+               credits = ocfs2_calc_extend_credits(sb, el, 1);
        } else {
                spin_unlock(&OCFS2_I(dir)->ip_lock);
                credits = OCFS2_SIMPLE_DIR_EXTEND_CREDITS;