Commit 516f2e24 authored by Jim Rees's avatar Jim Rees Committed by Trond Myklebust

pnfsblock: fix return code confusion

Always return PTR_ERR, not NULL, from nfs4_blk_get_deviceinfo and
nfs4_blk_decode_device.

Check for IS_ERR, not NULL, in bl_set_layoutdriver when calling
nfs4_blk_get_deviceinfo.
Signed-off-by: default avatarJim Rees <rees@umich.edu>
Signed-off-by: default avatarBenny Halevy <bhalevy@tonian.com>
Cc: stable@kernel.org [3.0]
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 2da95652
...@@ -805,7 +805,7 @@ nfs4_blk_get_deviceinfo(struct nfs_server *server, const struct nfs_fh *fh, ...@@ -805,7 +805,7 @@ nfs4_blk_get_deviceinfo(struct nfs_server *server, const struct nfs_fh *fh,
struct nfs4_deviceid *d_id) struct nfs4_deviceid *d_id)
{ {
struct pnfs_device *dev; struct pnfs_device *dev;
struct pnfs_block_dev *rv = NULL; struct pnfs_block_dev *rv;
u32 max_resp_sz; u32 max_resp_sz;
int max_pages; int max_pages;
struct page **pages = NULL; struct page **pages = NULL;
...@@ -823,18 +823,20 @@ nfs4_blk_get_deviceinfo(struct nfs_server *server, const struct nfs_fh *fh, ...@@ -823,18 +823,20 @@ nfs4_blk_get_deviceinfo(struct nfs_server *server, const struct nfs_fh *fh,
dev = kmalloc(sizeof(*dev), GFP_NOFS); dev = kmalloc(sizeof(*dev), GFP_NOFS);
if (!dev) { if (!dev) {
dprintk("%s kmalloc failed\n", __func__); dprintk("%s kmalloc failed\n", __func__);
return NULL; return ERR_PTR(-ENOMEM);
} }
pages = kzalloc(max_pages * sizeof(struct page *), GFP_NOFS); pages = kzalloc(max_pages * sizeof(struct page *), GFP_NOFS);
if (pages == NULL) { if (pages == NULL) {
kfree(dev); kfree(dev);
return NULL; return ERR_PTR(-ENOMEM);
} }
for (i = 0; i < max_pages; i++) { for (i = 0; i < max_pages; i++) {
pages[i] = alloc_page(GFP_NOFS); pages[i] = alloc_page(GFP_NOFS);
if (!pages[i]) if (!pages[i]) {
rv = ERR_PTR(-ENOMEM);
goto out_free; goto out_free;
}
} }
memcpy(&dev->dev_id, d_id, sizeof(*d_id)); memcpy(&dev->dev_id, d_id, sizeof(*d_id));
...@@ -847,8 +849,10 @@ nfs4_blk_get_deviceinfo(struct nfs_server *server, const struct nfs_fh *fh, ...@@ -847,8 +849,10 @@ nfs4_blk_get_deviceinfo(struct nfs_server *server, const struct nfs_fh *fh,
dprintk("%s: dev_id: %s\n", __func__, dev->dev_id.data); dprintk("%s: dev_id: %s\n", __func__, dev->dev_id.data);
rc = nfs4_proc_getdeviceinfo(server, dev); rc = nfs4_proc_getdeviceinfo(server, dev);
dprintk("%s getdevice info returns %d\n", __func__, rc); dprintk("%s getdevice info returns %d\n", __func__, rc);
if (rc) if (rc) {
rv = ERR_PTR(rc);
goto out_free; goto out_free;
}
rv = nfs4_blk_decode_device(server, dev); rv = nfs4_blk_decode_device(server, dev);
out_free: out_free:
...@@ -866,7 +870,7 @@ bl_set_layoutdriver(struct nfs_server *server, const struct nfs_fh *fh) ...@@ -866,7 +870,7 @@ bl_set_layoutdriver(struct nfs_server *server, const struct nfs_fh *fh)
struct pnfs_devicelist *dlist = NULL; struct pnfs_devicelist *dlist = NULL;
struct pnfs_block_dev *bdev; struct pnfs_block_dev *bdev;
LIST_HEAD(block_disklist); LIST_HEAD(block_disklist);
int status = 0, i; int status, i;
dprintk("%s enter\n", __func__); dprintk("%s enter\n", __func__);
...@@ -898,8 +902,8 @@ bl_set_layoutdriver(struct nfs_server *server, const struct nfs_fh *fh) ...@@ -898,8 +902,8 @@ bl_set_layoutdriver(struct nfs_server *server, const struct nfs_fh *fh)
for (i = 0; i < dlist->num_devs; i++) { for (i = 0; i < dlist->num_devs; i++) {
bdev = nfs4_blk_get_deviceinfo(server, fh, bdev = nfs4_blk_get_deviceinfo(server, fh,
&dlist->dev_id[i]); &dlist->dev_id[i]);
if (!bdev) { if (IS_ERR(bdev)) {
status = -ENODEV; status = PTR_ERR(bdev);
goto out_error; goto out_error;
} }
spin_lock(&b_mt_id->bm_lock); spin_lock(&b_mt_id->bm_lock);
......
...@@ -131,7 +131,7 @@ struct pnfs_block_dev * ...@@ -131,7 +131,7 @@ struct pnfs_block_dev *
nfs4_blk_decode_device(struct nfs_server *server, nfs4_blk_decode_device(struct nfs_server *server,
struct pnfs_device *dev) struct pnfs_device *dev)
{ {
struct pnfs_block_dev *rv = NULL; struct pnfs_block_dev *rv;
struct block_device *bd = NULL; struct block_device *bd = NULL;
struct rpc_pipe_msg msg; struct rpc_pipe_msg msg;
struct bl_msg_hdr bl_msg = { struct bl_msg_hdr bl_msg = {
...@@ -141,7 +141,7 @@ nfs4_blk_decode_device(struct nfs_server *server, ...@@ -141,7 +141,7 @@ nfs4_blk_decode_device(struct nfs_server *server,
uint8_t *dataptr; uint8_t *dataptr;
DECLARE_WAITQUEUE(wq, current); DECLARE_WAITQUEUE(wq, current);
struct bl_dev_msg *reply = &bl_mount_reply; struct bl_dev_msg *reply = &bl_mount_reply;
int offset, len, i; int offset, len, i, rc;
dprintk("%s CREATING PIPEFS MESSAGE\n", __func__); dprintk("%s CREATING PIPEFS MESSAGE\n", __func__);
dprintk("%s: deviceid: %s, mincount: %d\n", __func__, dev->dev_id.data, dprintk("%s: deviceid: %s, mincount: %d\n", __func__, dev->dev_id.data,
...@@ -168,8 +168,10 @@ nfs4_blk_decode_device(struct nfs_server *server, ...@@ -168,8 +168,10 @@ nfs4_blk_decode_device(struct nfs_server *server,
dprintk("%s CALLING USERSPACE DAEMON\n", __func__); dprintk("%s CALLING USERSPACE DAEMON\n", __func__);
add_wait_queue(&bl_wq, &wq); add_wait_queue(&bl_wq, &wq);
if (rpc_queue_upcall(bl_device_pipe->d_inode, &msg) < 0) { rc = rpc_queue_upcall(bl_device_pipe->d_inode, &msg);
if (rc < 0) {
remove_wait_queue(&bl_wq, &wq); remove_wait_queue(&bl_wq, &wq);
rv = ERR_PTR(rc);
goto out; goto out;
} }
...@@ -187,8 +189,9 @@ nfs4_blk_decode_device(struct nfs_server *server, ...@@ -187,8 +189,9 @@ nfs4_blk_decode_device(struct nfs_server *server,
bd = nfs4_blkdev_get(MKDEV(reply->major, reply->minor)); bd = nfs4_blkdev_get(MKDEV(reply->major, reply->minor));
if (IS_ERR(bd)) { if (IS_ERR(bd)) {
dprintk("%s failed to open device : %ld\n", rc = PTR_ERR(bd);
__func__, PTR_ERR(bd)); dprintk("%s failed to open device : %d\n", __func__, rc);
rv = ERR_PTR(rc);
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment