ext4: main fast-commit commit path
[linux-2.6-microblaze.git] / fs / ext4 / extents.c
index a048158..a2bb87d 100644 (file)
@@ -501,7 +501,7 @@ __read_extent_tree_block(const char *function, unsigned int line,
 
        if (!bh_uptodate_or_lock(bh)) {
                trace_ext4_ext_load_extent(inode, pblk, _RET_IP_);
-               err = bh_submit_read(bh);
+               err = ext4_read_bh(bh, 0, NULL);
                if (err < 0)
                        goto errout;
        }
@@ -3723,6 +3723,7 @@ static int ext4_convert_unwritten_extents_endio(handle_t *handle,
        err = ext4_ext_dirty(handle, inode, path + path->p_depth);
 out:
        ext4_ext_show_leaf(inode, path);
+       ext4_fc_track_range(inode, ee_block, ee_block + ee_len - 1);
        return err;
 }
 
@@ -3794,6 +3795,7 @@ convert_initialized_extent(handle_t *handle, struct inode *inode,
        if (*allocated > map->m_len)
                *allocated = map->m_len;
        map->m_len = *allocated;
+       ext4_fc_track_range(inode, ee_block, ee_block + ee_len - 1);
        return 0;
 }
 
@@ -4023,7 +4025,7 @@ static int get_implied_cluster_alloc(struct super_block *sb,
  * down_read(&EXT4_I(inode)->i_data_sem) if not allocating file system block
  * (ie, create is zero). Otherwise down_write(&EXT4_I(inode)->i_data_sem)
  *
- * return > 0, number of of blocks already mapped/allocated
+ * return > 0, number of blocks already mapped/allocated
  *          if create == 0 and these are pre-allocated blocks
  *             buffer head is unmapped
  *          otherwise blocks are mapped
@@ -4327,7 +4329,7 @@ got_allocated_blocks:
        map->m_len = ar.len;
        allocated = map->m_len;
        ext4_ext_show_leaf(inode, path);
-
+       ext4_fc_track_range(inode, map->m_lblk, map->m_lblk + map->m_len - 1);
 out:
        ext4_ext_drop_refs(path);
        kfree(path);
@@ -4600,7 +4602,8 @@ static long ext4_zero_range(struct file *file, loff_t offset,
        ret = ext4_mark_inode_dirty(handle, inode);
        if (unlikely(ret))
                goto out_handle;
-
+       ext4_fc_track_range(inode, offset >> inode->i_sb->s_blocksize_bits,
+                       (offset + len - 1) >> inode->i_sb->s_blocksize_bits);
        /* Zero out partial block at the edges of the range */
        ret = ext4_zero_partial_blocks(handle, inode, offset, len);
        if (ret >= 0)
@@ -4648,23 +4651,34 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
                     FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE |
                     FALLOC_FL_INSERT_RANGE))
                return -EOPNOTSUPP;
+       ext4_fc_track_range(inode, offset >> blkbits,
+                       (offset + len - 1) >> blkbits);
 
-       if (mode & FALLOC_FL_PUNCH_HOLE)
-               return ext4_punch_hole(inode, offset, len);
+       ext4_fc_start_update(inode);
+
+       if (mode & FALLOC_FL_PUNCH_HOLE) {
+               ret = ext4_punch_hole(inode, offset, len);
+               goto exit;
+       }
 
        ret = ext4_convert_inline_data(inode);
        if (ret)
-               return ret;
+               goto exit;
 
-       if (mode & FALLOC_FL_COLLAPSE_RANGE)
-               return ext4_collapse_range(inode, offset, len);
-
-       if (mode & FALLOC_FL_INSERT_RANGE)
-               return ext4_insert_range(inode, offset, len);
+       if (mode & FALLOC_FL_COLLAPSE_RANGE) {
+               ret = ext4_collapse_range(inode, offset, len);
+               goto exit;
+       }
 
-       if (mode & FALLOC_FL_ZERO_RANGE)
-               return ext4_zero_range(file, offset, len, mode);
+       if (mode & FALLOC_FL_INSERT_RANGE) {
+               ret = ext4_insert_range(inode, offset, len);
+               goto exit;
+       }
 
+       if (mode & FALLOC_FL_ZERO_RANGE) {
+               ret = ext4_zero_range(file, offset, len, mode);
+               goto exit;
+       }
        trace_ext4_fallocate_enter(inode, offset, len, mode);
        lblk = offset >> blkbits;
 
@@ -4698,12 +4712,14 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
                goto out;
 
        if (file->f_flags & O_SYNC && EXT4_SB(inode->i_sb)->s_journal) {
-               ret = jbd2_complete_transaction(EXT4_SB(inode->i_sb)->s_journal,
-                                               EXT4_I(inode)->i_sync_tid);
+               ret = ext4_fc_commit(EXT4_SB(inode->i_sb)->s_journal,
+                                       EXT4_I(inode)->i_sync_tid);
        }
 out:
        inode_unlock(inode);
        trace_ext4_fallocate_exit(inode, offset, max_blocks, ret);
+exit:
+       ext4_fc_stop_update(inode);
        return ret;
 }
 
@@ -4769,7 +4785,7 @@ int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode,
 
 int ext4_convert_unwritten_io_end_vec(handle_t *handle, ext4_io_end_t *io_end)
 {
-       int ret, err = 0;
+       int ret = 0, err = 0;
        struct ext4_io_end_vec *io_end_vec;
 
        /*
@@ -5291,6 +5307,7 @@ static int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
                ret = PTR_ERR(handle);
                goto out_mmap;
        }
+       ext4_fc_start_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE);
 
        down_write(&EXT4_I(inode)->i_data_sem);
        ext4_discard_preallocations(inode, 0);
@@ -5329,6 +5346,7 @@ static int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
 
 out_stop:
        ext4_journal_stop(handle);
+       ext4_fc_stop_ineligible(sb);
 out_mmap:
        up_write(&EXT4_I(inode)->i_mmap_sem);
 out_mutex:
@@ -5429,6 +5447,7 @@ static int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len)
                ret = PTR_ERR(handle);
                goto out_mmap;
        }
+       ext4_fc_start_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE);
 
        /* Expand file to avoid data loss if there is error while shifting */
        inode->i_size += len;
@@ -5503,6 +5522,7 @@ static int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len)
 
 out_stop:
        ext4_journal_stop(handle);
+       ext4_fc_stop_ineligible(sb);
 out_mmap:
        up_write(&EXT4_I(inode)->i_mmap_sem);
 out_mutex: