fuse: fix wrong ff->iomode state changes from parallel dio write
[sfrench/cifs-2.6.git] / fs / fuse / file.c
index a56e7bffd0004e3755d648ad9b35f67d4eba863a..b57ce41576407be3d910da8916629f640668ee9a 100644 (file)
@@ -1362,7 +1362,7 @@ static void fuse_dio_lock(struct kiocb *iocb, struct iov_iter *from,
                          bool *exclusive)
 {
        struct inode *inode = file_inode(iocb->ki_filp);
-       struct fuse_file *ff = iocb->ki_filp->private_data;
+       struct fuse_inode *fi = get_fuse_inode(inode);
 
        *exclusive = fuse_dio_wr_exclusive_lock(iocb, from);
        if (*exclusive) {
@@ -1377,7 +1377,7 @@ static void fuse_dio_lock(struct kiocb *iocb, struct iov_iter *from,
                 * have raced, so check it again.
                 */
                if (fuse_io_past_eof(iocb, from) ||
-                   fuse_file_uncached_io_start(inode, ff, NULL) != 0) {
+                   fuse_inode_uncached_io_start(fi, NULL) != 0) {
                        inode_unlock_shared(inode);
                        inode_lock(inode);
                        *exclusive = true;
@@ -1388,13 +1388,13 @@ static void fuse_dio_lock(struct kiocb *iocb, struct iov_iter *from,
 static void fuse_dio_unlock(struct kiocb *iocb, bool exclusive)
 {
        struct inode *inode = file_inode(iocb->ki_filp);
-       struct fuse_file *ff = iocb->ki_filp->private_data;
+       struct fuse_inode *fi = get_fuse_inode(inode);
 
        if (exclusive) {
                inode_unlock(inode);
        } else {
                /* Allow opens in caching mode after last parallel dio end */
-               fuse_file_uncached_io_end(inode, ff);
+               fuse_inode_uncached_io_end(fi);
                inode_unlock_shared(inode);
        }
 }
@@ -2574,8 +2574,10 @@ static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma)
                 * First mmap of direct_io file enters caching inode io mode.
                 * Also waits for parallel dio writers to go into serial mode
                 * (exclusive instead of shared lock).
+                * After first mmap, the inode stays in caching io mode until
+                * the direct_io file release.
                 */
-               rc = fuse_file_cached_io_start(inode, ff);
+               rc = fuse_file_cached_io_open(inode, ff);
                if (rc)
                        return rc;
        }