]> err.no Git - linux-2.6/blobdiff - fs/ocfs2/alloc.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[linux-2.6] / fs / ocfs2 / alloc.c
index 0eab0d328289cbfe0a63f6d9489203124e60da69..19712a7d145feeeded8e6b21bfcd9ec7ac2a2349 100644 (file)
@@ -2417,6 +2417,8 @@ out_add:
        status = ocfs2_do_insert_extent(inode, handle, fe_bh, &rec, &insert);
        if (status < 0)
                mlog_errno(status);
+       else
+               ocfs2_extent_map_insert_rec(inode, &rec);
 
 bail:
        if (bh)
@@ -2867,7 +2869,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
        tl = &tl_copy->id2.i_dealloc;
        num_recs = le16_to_cpu(tl->tl_used);
        mlog(0, "cleanup %u records from %llu\n", num_recs,
-            (unsigned long long)tl_copy->i_blkno);
+            (unsigned long long)le64_to_cpu(tl_copy->i_blkno));
 
        mutex_lock(&tl_inode->i_mutex);
        for(i = 0; i < num_recs; i++) {
@@ -3487,6 +3489,7 @@ static int ocfs2_grab_eof_pages(struct inode *inode, loff_t isize, struct page *
 {
        int i, numpages = 0, ret = 0;
        unsigned int csize = OCFS2_SB(inode->i_sb)->s_clustersize;
+       unsigned int ext_flags;
        struct super_block *sb = inode->i_sb;
        struct address_space *mapping = inode->i_mapping;
        unsigned long index;
@@ -3499,7 +3502,7 @@ static int ocfs2_grab_eof_pages(struct inode *inode, loff_t isize, struct page *
                goto out;
 
        ret = ocfs2_extent_map_get_blocks(inode, isize >> sb->s_blocksize_bits,
-                                         phys, NULL);
+                                         phys, NULL, &ext_flags);
        if (ret) {
                mlog_errno(ret);
                goto out;
@@ -3509,6 +3512,11 @@ static int ocfs2_grab_eof_pages(struct inode *inode, loff_t isize, struct page *
        if (*phys == 0)
                goto out;
 
+       /* Tail is marked as unwritten, we can count on write to zero
+        * in that case. */
+       if (ext_flags & OCFS2_EXT_UNWRITTEN)
+               goto out;
+
        next_cluster_bytes = ocfs2_align_bytes_to_clusters(inode->i_sb, isize);
        index = isize >> PAGE_CACHE_SHIFT;
        do {
@@ -3579,9 +3587,6 @@ int ocfs2_zero_tail_for_truncate(struct inode *inode, handle_t *handle,
                goto out;
        }
 
-       /*
-        * Truncate on an i_size boundary - nothing more to do.
-        */
        if (numpages == 0)
                goto out;
 
@@ -3637,6 +3642,9 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb,
                mlog_errno(status);
                goto bail;
        }
+
+       ocfs2_extent_map_trunc(inode, new_highest_cpos);
+
 start:
        /*
         * Check that we still have allocation to delete.
@@ -3793,8 +3801,8 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb,
        fe = (struct ocfs2_dinode *) fe_bh->b_data;
 
        mlog(0, "fe->i_clusters = %u, new_i_clusters = %u, fe->i_size ="
-            "%llu\n", fe->i_clusters, new_i_clusters,
-            (unsigned long long)fe->i_size);
+            "%llu\n", le32_to_cpu(fe->i_clusters), new_i_clusters,
+            (unsigned long long)le64_to_cpu(fe->i_size));
 
        *tc = kzalloc(sizeof(struct ocfs2_truncate_context), GFP_KERNEL);
        if (!(*tc)) {