ocfs2: do not fallback to buffer I/O write if appending
[firefly-linux-kernel-4.4.55.git] / fs / ocfs2 / file.c
index 3950693dd0f6d9026587ac71e85037c555790f77..1055a2ece738dedecae41ebcd9f03fd94f0bafd0 100644 (file)
@@ -295,7 +295,7 @@ out:
        return ret;
 }
 
-static int ocfs2_set_inode_size(handle_t *handle,
+int ocfs2_set_inode_size(handle_t *handle,
                                struct inode *inode,
                                struct buffer_head *fe_bh,
                                u64 new_i_size)
@@ -441,7 +441,7 @@ out:
        return status;
 }
 
-static int ocfs2_truncate_file(struct inode *inode,
+int ocfs2_truncate_file(struct inode *inode,
                               struct buffer_head *di_bh,
                               u64 new_i_size)
 {
@@ -569,7 +569,7 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
        handle_t *handle = NULL;
        struct ocfs2_alloc_context *data_ac = NULL;
        struct ocfs2_alloc_context *meta_ac = NULL;
-       enum ocfs2_alloc_restarted why;
+       enum ocfs2_alloc_restarted why = RESTART_NONE;
        struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
        struct ocfs2_extent_tree et;
        int did_quota = 0;
@@ -709,6 +709,13 @@ leave:
        return status;
 }
 
+int ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
+               u32 clusters_to_add, int mark_unwritten)
+{
+       return __ocfs2_extend_allocation(inode, logical_start,
+                       clusters_to_add, mark_unwritten);
+}
+
 /*
  * While a write will already be ordering the data, a truncate will not.
  * Thus, we need to explicitly order the zeroed pages.
@@ -2109,6 +2116,9 @@ static int ocfs2_prepare_inode_for_write(struct file *file,
        struct dentry *dentry = file->f_path.dentry;
        struct inode *inode = dentry->d_inode;
        loff_t saved_pos = 0, end;
+       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+       int full_coherency = !(osb->s_mount_opt &
+               OCFS2_MOUNT_COHERENCY_BUFFERED);
 
        /*
         * We start with a read level meta lock and only jump to an ex
@@ -2197,7 +2207,7 @@ static int ocfs2_prepare_inode_for_write(struct file *file,
                 * one node could wind up truncating another
                 * nodes writes.
                 */
-               if (end > i_size_read(inode)) {
+               if (end > i_size_read(inode) && !full_coherency) {
                        *direct_io = 0;
                        break;
                }
@@ -2363,7 +2373,7 @@ relock:
                        goto out_dio;
                }
        } else {
-               current->backing_dev_info = file->f_mapping->backing_dev_info;
+               current->backing_dev_info = inode_to_bdi(inode);
                written = generic_perform_write(file, from, *ppos);
                if (likely(written >= 0))
                        iocb->ki_pos = *ppos + written;