NFS: Don't check lock owner compatibility in writes unless file is locked
authorTrond Myklebust <[email protected]>
Thu, 5 Sep 2013 19:52:51 +0000 (15:52 -0400)
committerTrond Myklebust <[email protected]>
Thu, 5 Sep 2013 22:11:42 +0000 (18:11 -0400)
If we're doing buffered writes, and there is no file locking involved,
then we don't have to worry about whether or not the lock owner information
is identical.
By relaxing this check, we ensure that fork()ed child processes can write
to a page without having to first sync dirty data that was written
by the parent to disk.

Reported-by: Quentin Barnes <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
Tested-by: Quentin Barnes <[email protected]>
fs/nfs/write.c

index 40979e815434bb19d3fbc0b996d4906c0896aedb..ac1dc331ba31212108cd5c93352ecdb620122690 100644 (file)
@@ -863,7 +863,7 @@ int nfs_flush_incompatible(struct file *file, struct page *page)
                        return 0;
                l_ctx = req->wb_lock_context;
                do_flush = req->wb_page != page || req->wb_context != ctx;
-               if (l_ctx) {
+               if (l_ctx && ctx->dentry->d_inode->i_flock != NULL) {
                        do_flush |= l_ctx->lockowner.l_owner != current->files
                                || l_ctx->lockowner.l_pid != current->tgid;
                }