From patchwork Tue Jun 14 02:32:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Rees X-Patchwork-Id: 877422 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5E2W3Mk029514 for ; Tue, 14 Jun 2011 02:32:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753950Ab1FNCca (ORCPT ); Mon, 13 Jun 2011 22:32:30 -0400 Received: from merit-proxy02.merit.edu ([207.75.116.194]:52001 "EHLO merit-proxy02.merit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753622Ab1FNCca (ORCPT ); Mon, 13 Jun 2011 22:32:30 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by merit-proxy02.merit.edu (Postfix) with ESMTP id C23932039CF4; Mon, 13 Jun 2011 22:32:29 -0400 (EDT) X-Virus-Scanned: amavisd-new at merit-proxy02.merit.edu Received: from merit-proxy02.merit.edu ([127.0.0.1]) by localhost (merit-proxy02.merit.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FtxVxq-r1YjL; Mon, 13 Jun 2011 22:32:29 -0400 (EDT) Received: from merit.edu (74-126-0-171.static.123.net [74.126.0.171]) by merit-proxy02.merit.edu (Postfix) with ESMTPSA id F347D2039CEF; Mon, 13 Jun 2011 22:32:28 -0400 (EDT) X-Mailbox-Line: From a9a8d6f2cfe27f1be595d6b9e0372d70f595d2a0 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: Subject: [PATCH 11/33] pnfsblock: add block device discovery pipe To: Benny Halevy Cc: linux-nfs@vger.kernel.org, peter honeyman Date: Mon, 13 Jun 2011 22:32:27 -0400 From: Jim Rees Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 14 Jun 2011 02:32:31 +0000 (UTC) Signed-off-by: Eric Anderle Signed-off-by: Jim Rees Signed-off-by: Benny Halevy --- fs/nfs/blocklayout/Makefile | 2 +- fs/nfs/blocklayout/block-device-discovery-pipe.c | 66 ++++++++++++++++++++++ fs/nfs/blocklayout/blocklayout.c | 3 + fs/nfs/blocklayout/blocklayout.h | 14 +++++ 4 files changed, 84 insertions(+), 1 deletions(-) create mode 100644 fs/nfs/blocklayout/block-device-discovery-pipe.c diff --git a/fs/nfs/blocklayout/Makefile b/fs/nfs/blocklayout/Makefile index 6bf49cd..d2bcd81 100644 --- a/fs/nfs/blocklayout/Makefile +++ b/fs/nfs/blocklayout/Makefile @@ -2,4 +2,4 @@ # Makefile for the pNFS block layout driver kernel module # obj-$(CONFIG_PNFS_BLOCK) += blocklayoutdriver.o -blocklayoutdriver-objs := blocklayout.o +blocklayoutdriver-objs := blocklayout.o block-device-discovery-pipe.o diff --git a/fs/nfs/blocklayout/block-device-discovery-pipe.c b/fs/nfs/blocklayout/block-device-discovery-pipe.c new file mode 100644 index 0000000..e4c199f --- /dev/null +++ b/fs/nfs/blocklayout/block-device-discovery-pipe.c @@ -0,0 +1,66 @@ +#include +#include +#include +#include +#include +#include +#include +#include "blocklayout.h" + +#define NFSDBG_FACILITY NFSDBG_PNFS_LD + +struct pipefs_list bl_device_list; +struct dentry *bl_device_pipe; + +ssize_t bl_pipe_downcall(struct file *filp, const char __user *src, size_t len) +{ + int err; + struct pipefs_hdr *msg; + + dprintk("Entering %s...\n", __func__); + + msg = pipefs_readmsg(filp, src, len); + if (IS_ERR(msg)) { + dprintk("ERROR: unable to read pipefs message.\n"); + return PTR_ERR(msg); + } + + /* now assign the result, which wakes the blocked thread */ + err = pipefs_assign_upcall_reply(msg, &bl_device_list); + if (err) { + dprintk("ERROR: failed to assign upcall with id %u\n", + msg->msgid); + kfree(msg); + } + return len; +} + +static const struct rpc_pipe_ops bl_pipe_ops = { + .upcall = pipefs_generic_upcall, + .downcall = bl_pipe_downcall, + .destroy_msg = pipefs_generic_destroy_msg, +}; + +int bl_pipe_init(void) +{ + dprintk("%s: block_device pipefs registering...\n", __func__); + bl_device_pipe = pipefs_mkpipe("bl_device_pipe", &bl_pipe_ops, 1); + if (IS_ERR(bl_device_pipe)) + dprintk("ERROR, unable to make block_device pipe\n"); + + if (!bl_device_pipe) + dprintk("bl_device_pipe is NULL!\n"); + else + dprintk("bl_device_pipe created!\n"); + pipefs_init_list(&bl_device_list); + return 0; +} + +void bl_pipe_exit(void) +{ + dprintk("%s: block_device pipefs unregistering...\n", __func__); + if (IS_ERR(bl_device_pipe)) + return ; + pipefs_closepipe(bl_device_pipe); + return; +} diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c index 08458c6..bc6a0b2 100644 --- a/fs/nfs/blocklayout/blocklayout.c +++ b/fs/nfs/blocklayout/blocklayout.c @@ -185,6 +185,8 @@ static int __init nfs4blocklayout_init(void) dprintk("%s: NFSv4 Block Layout Driver Registering...\n", __func__); ret = pnfs_register_layoutdriver(&blocklayout_type); + if (!ret) + bl_pipe_init(); return ret; } @@ -194,6 +196,7 @@ static void __exit nfs4blocklayout_exit(void) __func__); pnfs_unregister_layoutdriver(&blocklayout_type); + bl_pipe_exit(); } module_init(nfs4blocklayout_init); diff --git a/fs/nfs/blocklayout/blocklayout.h b/fs/nfs/blocklayout/blocklayout.h index 49d69c7..4b8608c 100644 --- a/fs/nfs/blocklayout/blocklayout.h +++ b/fs/nfs/blocklayout/blocklayout.h @@ -87,4 +87,18 @@ static inline struct pnfs_block_layout *BLK_LO2EXT(struct pnfs_layout_hdr *lo) return container_of(lo, struct pnfs_block_layout, bl_layout); } +#include + +extern struct pipefs_list bl_device_list; +extern struct dentry *bl_device_pipe; + +int bl_pipe_init(void); +void bl_pipe_exit(void); + +#define BL_DEVICE_UMOUNT 0x0 /* Umount--delete devices */ +#define BL_DEVICE_MOUNT 0x1 /* Mount--create devices*/ +#define BL_DEVICE_REQUEST_INIT 0x0 /* Start request */ +#define BL_DEVICE_REQUEST_PROC 0x1 /* User level process succeeds */ +#define BL_DEVICE_REQUEST_ERR 0x2 /* User level process fails */ + #endif /* FS_NFS_NFS4BLOCKLAYOUT_H */