> -----Original Message----- > From: linux-nfs-owner@xxxxxxxxxxxxxxx [mailto:linux-nfs-owner@xxxxxxxxxxxxxxx] On Behalf Of Wei > Yongjun > Sent: Tuesday, September 25, 2012 1:44 PM > To: Trond.Myklebust@xxxxxxxxxx > Cc: yongjun_wei@xxxxxxxxxxxxxxxxx; linux-nfs@xxxxxxxxxxxxxxx > Subject: [PATCH] NFS: fix the return value of nfs4_blkdev_get() > > From: Wei Yongjun <yongjun_wei@xxxxxxxxxxxxxxxxx> > > In case of error, the function nfs4_blkdev_get() return NULL pointer. > But the user nfs4_blk_decode_device() check the return value by using > IS_ERR() and get error code from the return value. So we should better > change the return value of nfs4_blkdev_get() to return ERR_PTR(). > Yeah, it is merely mess and should be just removed... How about following patch? >From e268f1a5913b005d10eedb82b4d53521d56d621e Mon Sep 17 00:00:00 2001 From: Peng Tao <bergwolf@xxxxxxxxx> Date: Tue, 25 Sep 2012 14:55:57 +0800 Subject: [PATCH] pnfsblock: cleanup nfs4_blkdev_get It is not needed at all and it is messing with return values... Reported-by: Wei Yongjun <yongjun_wei@xxxxxxxxxxxxxxxxx> Signed-off-by: Peng Tao <tao.peng@xxxxxxx> --- fs/nfs/blocklayout/blocklayout.h | 1 - fs/nfs/blocklayout/blocklayoutdev.c | 25 +++++-------------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/fs/nfs/blocklayout/blocklayout.h b/fs/nfs/blocklayout/blocklayout.h index 0335069..ed96f74 100644 --- a/fs/nfs/blocklayout/blocklayout.h +++ b/fs/nfs/blocklayout/blocklayout.h @@ -172,7 +172,6 @@ struct bl_msg_hdr { /* blocklayoutdev.c */ ssize_t bl_pipe_downcall(struct file *, const char __user *, size_t); void bl_pipe_destroy_msg(struct rpc_pipe_msg *); -struct block_device *nfs4_blkdev_get(dev_t dev); int nfs4_blkdev_put(struct block_device *bdev); struct pnfs_block_dev *nfs4_blk_decode_device(struct nfs_server *server, struct pnfs_device *dev); diff --git a/fs/nfs/blocklayout/blocklayoutdev.c b/fs/nfs/blocklayout/blocklayoutdev.c index c965542..a86c5bd 100644 --- a/fs/nfs/blocklayout/blocklayoutdev.c +++ b/fs/nfs/blocklayout/blocklayoutdev.c @@ -53,22 +53,6 @@ static int decode_sector_number(__be32 **rp, sector_t *sp) return 0; } -/* Open a block_device by device number. */ -struct block_device *nfs4_blkdev_get(dev_t dev) -{ - struct block_device *bd; - - dprintk("%s enter\n", __func__); - bd = blkdev_get_by_dev(dev, FMODE_READ, NULL); - if (IS_ERR(bd)) - goto fail; - return bd; -fail: - dprintk("%s failed to open device : %ld\n", - __func__, PTR_ERR(bd)); - return NULL; -} - /* * Release the block device */ @@ -172,11 +156,12 @@ nfs4_blk_decode_device(struct nfs_server *server, goto out; } - bd = nfs4_blkdev_get(MKDEV(reply->major, reply->minor)); + bd = blkdev_get_by_dev(MKDEV(reply->major, reply->minor), + FMODE_READ, NULL); if (IS_ERR(bd)) { - rc = PTR_ERR(bd); - dprintk("%s failed to open device : %d\n", __func__, rc); - rv = ERR_PTR(rc); + dprintk("%s failed to open device : %ld\n", __func__, + PTR_ERR(bd)); + rv = ERR_CAST(bd); goto out; } -- 1.7.7.6 ��.n��������+%������w��{.n�����{��w���jg��������ݢj����G�������j:+v���w�m������w�������h�����٥