return err;
 }
 
+static int ocfs2_lock_get_block(struct inode *inode, sector_t iblock,
+                   struct buffer_head *bh_result, int create)
+{
+       int ret = 0;
+       struct ocfs2_inode_info *oi = OCFS2_I(inode);
+
+       down_read(&oi->ip_alloc_sem);
+       ret = ocfs2_get_block(inode, iblock, bh_result, create);
+       up_read(&oi->ip_alloc_sem);
+
+       return ret;
+}
+
 int ocfs2_get_block(struct inode *inode, sector_t iblock,
                    struct buffer_head *bh_result, int create)
 {
  * called like this: dio->get_blocks(dio->inode, fs_startblk,
  *                                     fs_count, map_bh, dio->rw == WRITE);
  */
-static int ocfs2_dio_get_block(struct inode *inode, sector_t iblock,
+static int ocfs2_dio_wr_get_block(struct inode *inode, sector_t iblock,
                               struct buffer_head *bh_result, int create)
 {
        struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
         * while file size will be changed.
         */
        if (pos + total_len <= i_size_read(inode)) {
-               down_read(&oi->ip_alloc_sem);
-               /* This is the fast path for re-write. */
-               ret = ocfs2_get_block(inode, iblock, bh_result, create);
-
-               up_read(&oi->ip_alloc_sem);
 
+               /* This is the fast path for re-write. */
+               ret = ocfs2_lock_get_block(inode, iblock, bh_result, create);
                if (buffer_mapped(bh_result) &&
                    !buffer_new(bh_result) &&
                    ret == 0)
                return 0;
 
        if (iov_iter_rw(iter) == READ)
-               get_block = ocfs2_get_block;
+               get_block = ocfs2_lock_get_block;
        else
-               get_block = ocfs2_dio_get_block;
+               get_block = ocfs2_dio_wr_get_block;
 
        return __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev,
                                    iter, get_block,