Merge branch 'master' of ../mine
[cascardo/linux.git] / fs / nfs / pagelist.c
index a3654e5..137b549 100644 (file)
@@ -65,6 +65,13 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
        if (req == NULL)
                return ERR_PTR(-ENOMEM);
 
+       /* get lock context early so we can deal with alloc failures */
+       req->wb_lock_context = nfs_get_lock_context(ctx);
+       if (req->wb_lock_context == NULL) {
+               nfs_page_free(req);
+               return ERR_PTR(-ENOMEM);
+       }
+
        /* Initialize the request struct. Initially, we assume a
         * long write-back delay. This will be adjusted in
         * update_nfs_request below if the region is not locked. */
@@ -141,11 +148,16 @@ void nfs_clear_request(struct nfs_page *req)
 {
        struct page *page = req->wb_page;
        struct nfs_open_context *ctx = req->wb_context;
+       struct nfs_lock_context *l_ctx = req->wb_lock_context;
 
        if (page != NULL) {
                page_cache_release(page);
                req->wb_page = NULL;
        }
+       if (l_ctx != NULL) {
+               nfs_put_lock_context(l_ctx);
+               req->wb_lock_context = NULL;
+       }
        if (ctx != NULL) {
                put_nfs_open_context(ctx);
                req->wb_context = NULL;
@@ -235,7 +247,7 @@ static int nfs_can_coalesce_requests(struct nfs_page *prev,
 {
        if (req->wb_context->cred != prev->wb_context->cred)
                return 0;
-       if (req->wb_context->lockowner != prev->wb_context->lockowner)
+       if (req->wb_lock_context->lockowner != prev->wb_lock_context->lockowner)
                return 0;
        if (req->wb_context->state != prev->wb_context->state)
                return 0;