]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/nfs/file.c
Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck...
[karo-tx-linux.git] / fs / nfs / file.c
index 94e94bd11aae6d0a6c32acf5c16491448edb93f8..1e6bfdbc1aff4403a194798d3c3928993948710d 100644 (file)
@@ -37,6 +37,8 @@
 #include "iostat.h"
 #include "fscache.h"
 
+#include "nfstrace.h"
+
 #define NFSDBG_FACILITY                NFSDBG_FILE
 
 static const struct vm_operations_struct nfs_file_vm_ops;
@@ -294,6 +296,8 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
        int ret;
        struct inode *inode = file_inode(file);
 
+       trace_nfs_fsync_enter(inode);
+
        do {
                ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
                if (ret != 0)
@@ -310,6 +314,7 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
                end = LLONG_MAX;
        } while (ret == -EAGAIN);
 
+       trace_nfs_fsync_exit(inode, ret);
        return ret;
 }
 
@@ -406,6 +411,7 @@ static int nfs_write_end(struct file *file, struct address_space *mapping,
                        struct page *page, void *fsdata)
 {
        unsigned offset = pos & (PAGE_CACHE_SIZE - 1);
+       struct nfs_open_context *ctx = nfs_file_open_context(file);
        int status;
 
        dfprintk(PAGECACHE, "NFS: write_end(%s/%s(%ld), %u@%lld)\n",
@@ -441,6 +447,13 @@ static int nfs_write_end(struct file *file, struct address_space *mapping,
        if (status < 0)
                return status;
        NFS_I(mapping->host)->write_io += copied;
+
+       if (nfs_ctx_key_to_expire(ctx)) {
+               status = nfs_wb_all(mapping->host);
+               if (status < 0)
+                       return status;
+       }
+
        return copied;
 }
 
@@ -637,7 +650,8 @@ static int nfs_need_sync_write(struct file *filp, struct inode *inode)
        if (IS_SYNC(inode) || (filp->f_flags & O_DSYNC))
                return 1;
        ctx = nfs_file_open_context(filp);
-       if (test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags))
+       if (test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags) ||
+           nfs_ctx_key_to_expire(ctx))
                return 1;
        return 0;
 }
@@ -651,6 +665,10 @@ ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
        ssize_t result;
        size_t count = iov_length(iov, nr_segs);
 
+       result = nfs_key_timeout_notify(iocb->ki_filp, inode);
+       if (result)
+               return result;
+
        if (iocb->ki_filp->f_flags & O_DIRECT)
                return nfs_file_direct_write(iocb, iov, nr_segs, pos, true);