Преглед на файлове

Merge branch 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6

* 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6:
  nfs4: The difference of 2 pointers is ptrdiff_t
  nfs: testing the wrong variable
  nfs: handle lock context allocation failures in nfs_create_request
  Fixed Regression in NFS Direct I/O path
Linus Torvalds преди 14 години
родител
ревизия
a0e3390787
променени са 4 файла, в които са добавени 11 реда и са изтрити 5 реда
  1. 1 1
      fs/nfs/direct.c
  2. 1 1
      fs/nfs/idmap.c
  3. 2 2
      fs/nfs/nfs4proc.c
  4. 7 1
      fs/nfs/pagelist.c

+ 1 - 1
fs/nfs/direct.c

@@ -873,7 +873,7 @@ static ssize_t nfs_direct_write(struct kiocb *iocb, const struct iovec *iov,
 	dreq->inode = inode;
 	dreq->inode = inode;
 	dreq->ctx = get_nfs_open_context(nfs_file_open_context(iocb->ki_filp));
 	dreq->ctx = get_nfs_open_context(nfs_file_open_context(iocb->ki_filp));
 	dreq->l_ctx = nfs_get_lock_context(dreq->ctx);
 	dreq->l_ctx = nfs_get_lock_context(dreq->ctx);
-	if (dreq->l_ctx != NULL)
+	if (dreq->l_ctx == NULL)
 		goto out_release;
 		goto out_release;
 	if (!is_sync_kiocb(iocb))
 	if (!is_sync_kiocb(iocb))
 		dreq->iocb = iocb;
 		dreq->iocb = iocb;

+ 1 - 1
fs/nfs/idmap.c

@@ -123,7 +123,7 @@ static ssize_t nfs_idmap_get_desc(const char *name, size_t namelen,
 	size_t desclen = typelen + namelen + 2;
 	size_t desclen = typelen + namelen + 2;
 
 
 	*desc = kmalloc(desclen, GFP_KERNEL);
 	*desc = kmalloc(desclen, GFP_KERNEL);
-	if (!desc)
+	if (!*desc)
 		return -ENOMEM;
 		return -ENOMEM;
 
 
 	cp = *desc;
 	cp = *desc;

+ 2 - 2
fs/nfs/nfs4proc.c

@@ -429,7 +429,7 @@ static int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *
 		 * returned NFS4ERR_DELAY as per Section 2.10.6.2
 		 * returned NFS4ERR_DELAY as per Section 2.10.6.2
 		 * of RFC5661.
 		 * of RFC5661.
 		 */
 		 */
-		dprintk("%s: slot=%ld seq=%d: Operation in progress\n",
+		dprintk("%s: slot=%td seq=%d: Operation in progress\n",
 			__func__,
 			__func__,
 			res->sr_slot - res->sr_session->fc_slot_table.slots,
 			res->sr_slot - res->sr_session->fc_slot_table.slots,
 			res->sr_slot->seq_nr);
 			res->sr_slot->seq_nr);
@@ -573,7 +573,7 @@ int nfs4_setup_sequence(const struct nfs_server *server,
 		goto out;
 		goto out;
 	}
 	}
 
 
-	dprintk("--> %s clp %p session %p sr_slot %ld\n",
+	dprintk("--> %s clp %p session %p sr_slot %td\n",
 		__func__, session->clp, session, res->sr_slot ?
 		__func__, session->clp, session, res->sr_slot ?
 			res->sr_slot - session->fc_slot_table.slots : -1);
 			res->sr_slot - session->fc_slot_table.slots : -1);
 
 

+ 7 - 1
fs/nfs/pagelist.c

@@ -65,6 +65,13 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
 	if (req == NULL)
 	if (req == NULL)
 		return ERR_PTR(-ENOMEM);
 		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
 	/* Initialize the request struct. Initially, we assume a
 	 * long write-back delay. This will be adjusted in
 	 * long write-back delay. This will be adjusted in
 	 * update_nfs_request below if the region is not locked. */
 	 * update_nfs_request below if the region is not locked. */
@@ -79,7 +86,6 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
 	req->wb_pgbase	= offset;
 	req->wb_pgbase	= offset;
 	req->wb_bytes   = count;
 	req->wb_bytes   = count;
 	req->wb_context = get_nfs_open_context(ctx);
 	req->wb_context = get_nfs_open_context(ctx);
-	req->wb_lock_context = nfs_get_lock_context(ctx);
 	kref_init(&req->wb_kref);
 	kref_init(&req->wb_kref);
 	return req;
 	return req;
 }
 }