Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jlbec...
[linux-2.6.git] / fs / ocfs2 / file.c
index 2effac5..89fc8ee 100644 (file)
@@ -1998,8 +1998,7 @@ relock:
                        goto out_dio;
                }
        } else {
-               written = generic_file_aio_write_nolock(iocb, iov, nr_segs,
-                                                       *ppos);
+               written = __generic_file_aio_write(iocb, iov, nr_segs, ppos);
        }
 
 out_dio:
@@ -2007,18 +2006,21 @@ out_dio:
        BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT));
 
        if ((file->f_flags & O_SYNC && !direct_io) || IS_SYNC(inode)) {
-               /*
-                * The generic write paths have handled getting data
-                * to disk, but since we don't make use of the dirty
-                * inode list, a manual journal commit is necessary
-                * here.
-                */
-               if (old_size != i_size_read(inode) ||
-                   old_clusters != OCFS2_I(inode)->ip_clusters) {
+               ret = filemap_fdatawrite_range(file->f_mapping, pos,
+                                              pos + count - 1);
+               if (ret < 0)
+                       written = ret;
+
+               if (!ret && (old_size != i_size_read(inode) ||
+                   old_clusters != OCFS2_I(inode)->ip_clusters)) {
                        ret = jbd2_journal_force_commit(osb->journal->j_journal);
                        if (ret < 0)
                                written = ret;
                }
+
+               if (!ret)
+                       ret = filemap_fdatawait_range(file->f_mapping, pos,
+                                                     pos + count - 1);
        }
 
        /* 
@@ -2118,31 +2120,16 @@ static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe,
 
        if (ret > 0) {
                unsigned long nr_pages;
+               int err;
 
-               *ppos += ret;
                nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
 
-               /*
-                * If file or inode is SYNC and we actually wrote some data,
-                * sync it.
-                */
-               if (unlikely((out->f_flags & O_SYNC) || IS_SYNC(inode))) {
-                       int err;
-
-                       mutex_lock(&inode->i_mutex);
-                       err = ocfs2_rw_lock(inode, 1);
-                       if (err < 0) {
-                               mlog_errno(err);
-                       } else {
-                               err = generic_osync_inode(inode, mapping,
-                                                 OSYNC_METADATA|OSYNC_DATA);
-                               ocfs2_rw_unlock(inode, 1);
-                       }
-                       mutex_unlock(&inode->i_mutex);
+               err = generic_write_sync(out, *ppos, ret);
+               if (err)
+                       ret = err;
+               else
+                       *ppos += ret;
 
-                       if (err)
-                               ret = err;
-               }
                balance_dirty_pages_ratelimited_nr(mapping, nr_pages);
        }