aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/direct.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-08-13 17:15:50 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-09-28 16:03:03 -0400
commitb3c54de6f82d01637796bcc1f667a45f3b32e814 (patch)
tree9b0e87f60b2815ca20ef47eceed6da0f16b799ef /fs/nfs/direct.c
parenta11a2bf4de5679fa0b63474c7d39bea2dac7d061 (diff)
NFS: Convert nfs_get_lock_context to return an ERR_PTR on failure
We want to be able to distinguish between allocation failures, and the case where the lock context is not needed (because there are no locks). Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/direct.c')
-rw-r--r--fs/nfs/direct.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 1ba385b7c90d..22130df16218 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -450,6 +450,7 @@ static ssize_t nfs_direct_read(struct kiocb *iocb, const struct iovec *iov,
450 ssize_t result = -ENOMEM; 450 ssize_t result = -ENOMEM;
451 struct inode *inode = iocb->ki_filp->f_mapping->host; 451 struct inode *inode = iocb->ki_filp->f_mapping->host;
452 struct nfs_direct_req *dreq; 452 struct nfs_direct_req *dreq;
453 struct nfs_lock_context *l_ctx;
453 454
454 dreq = nfs_direct_req_alloc(); 455 dreq = nfs_direct_req_alloc();
455 if (dreq == NULL) 456 if (dreq == NULL)
@@ -457,9 +458,12 @@ static ssize_t nfs_direct_read(struct kiocb *iocb, const struct iovec *iov,
457 458
458 dreq->inode = inode; 459 dreq->inode = inode;
459 dreq->ctx = get_nfs_open_context(nfs_file_open_context(iocb->ki_filp)); 460 dreq->ctx = get_nfs_open_context(nfs_file_open_context(iocb->ki_filp));
460 dreq->l_ctx = nfs_get_lock_context(dreq->ctx); 461 l_ctx = nfs_get_lock_context(dreq->ctx);
461 if (dreq->l_ctx == NULL) 462 if (IS_ERR(l_ctx)) {
463 result = PTR_ERR(l_ctx);
462 goto out_release; 464 goto out_release;
465 }
466 dreq->l_ctx = l_ctx;
463 if (!is_sync_kiocb(iocb)) 467 if (!is_sync_kiocb(iocb))
464 dreq->iocb = iocb; 468 dreq->iocb = iocb;
465 469
@@ -849,6 +853,7 @@ static ssize_t nfs_direct_write(struct kiocb *iocb, const struct iovec *iov,
849 ssize_t result = -ENOMEM; 853 ssize_t result = -ENOMEM;
850 struct inode *inode = iocb->ki_filp->f_mapping->host; 854 struct inode *inode = iocb->ki_filp->f_mapping->host;
851 struct nfs_direct_req *dreq; 855 struct nfs_direct_req *dreq;
856 struct nfs_lock_context *l_ctx;
852 857
853 dreq = nfs_direct_req_alloc(); 858 dreq = nfs_direct_req_alloc();
854 if (!dreq) 859 if (!dreq)
@@ -856,9 +861,12 @@ static ssize_t nfs_direct_write(struct kiocb *iocb, const struct iovec *iov,
856 861
857 dreq->inode = inode; 862 dreq->inode = inode;
858 dreq->ctx = get_nfs_open_context(nfs_file_open_context(iocb->ki_filp)); 863 dreq->ctx = get_nfs_open_context(nfs_file_open_context(iocb->ki_filp));
859 dreq->l_ctx = nfs_get_lock_context(dreq->ctx); 864 l_ctx = nfs_get_lock_context(dreq->ctx);
860 if (dreq->l_ctx == NULL) 865 if (IS_ERR(l_ctx)) {
866 result = PTR_ERR(l_ctx);
861 goto out_release; 867 goto out_release;
868 }
869 dreq->l_ctx = l_ctx;
862 if (!is_sync_kiocb(iocb)) 870 if (!is_sync_kiocb(iocb))
863 dreq->iocb = iocb; 871 dreq->iocb = iocb;
864 872