diff options
author | Jim Rees <rees@umich.edu> | 2011-07-30 20:52:43 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-07-31 12:18:16 -0400 |
commit | 025a70ed6518f635f66f314d6959718be79638db (patch) | |
tree | 9ad10662a6dc6d864c2459012d6751e77964794b /fs/nfs/blocklayout | |
parent | fe0a9b740881d181e3c96c1f6f6043e252692ffe (diff) |
pnfsblock: remove device operations
Signed-off-by: Jim Rees <rees@umich.edu>
Signed-off-by: Fred Isaman <iisaman@citi.umich.edu>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Benny Halevy <bhalevy@tonian.com>
[upcall bugfixes]
Signed-off-by: Peng Tao <peng_tao@emc.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/blocklayout')
-rw-r--r-- | fs/nfs/blocklayout/Makefile | 2 | ||||
-rw-r--r-- | fs/nfs/blocklayout/blocklayout.h | 3 | ||||
-rw-r--r-- | fs/nfs/blocklayout/blocklayoutdm.c | 111 |
3 files changed, 115 insertions, 1 deletions
diff --git a/fs/nfs/blocklayout/Makefile b/fs/nfs/blocklayout/Makefile index 5bf3409084d..d5815505c02 100644 --- a/fs/nfs/blocklayout/Makefile +++ b/fs/nfs/blocklayout/Makefile | |||
@@ -2,4 +2,4 @@ | |||
2 | # Makefile for the pNFS block layout driver kernel module | 2 | # Makefile for the pNFS block layout driver kernel module |
3 | # | 3 | # |
4 | obj-$(CONFIG_PNFS_BLOCK) += blocklayoutdriver.o | 4 | obj-$(CONFIG_PNFS_BLOCK) += blocklayoutdriver.o |
5 | blocklayoutdriver-objs := blocklayout.o extents.o blocklayoutdev.o | 5 | blocklayoutdriver-objs := blocklayout.o extents.o blocklayoutdev.o blocklayoutdm.o |
diff --git a/fs/nfs/blocklayout/blocklayout.h b/fs/nfs/blocklayout/blocklayout.h index dd25f1b3fe1..1527f88e00d 100644 --- a/fs/nfs/blocklayout/blocklayout.h +++ b/fs/nfs/blocklayout/blocklayout.h | |||
@@ -128,5 +128,8 @@ struct pnfs_block_dev *nfs4_blk_decode_device(struct nfs_server *server, | |||
128 | int nfs4_blk_process_layoutget(struct pnfs_layout_hdr *lo, | 128 | int nfs4_blk_process_layoutget(struct pnfs_layout_hdr *lo, |
129 | struct nfs4_layoutget_res *lgr, gfp_t gfp_flags); | 129 | struct nfs4_layoutget_res *lgr, gfp_t gfp_flags); |
130 | 130 | ||
131 | /* blocklayoutdm.c */ | ||
132 | void bl_free_block_dev(struct pnfs_block_dev *bdev); | ||
133 | |||
131 | void bl_put_extent(struct pnfs_block_extent *be); | 134 | void bl_put_extent(struct pnfs_block_extent *be); |
132 | #endif /* FS_NFS_NFS4BLOCKLAYOUT_H */ | 135 | #endif /* FS_NFS_NFS4BLOCKLAYOUT_H */ |
diff --git a/fs/nfs/blocklayout/blocklayoutdm.c b/fs/nfs/blocklayout/blocklayoutdm.c new file mode 100644 index 00000000000..d055c755807 --- /dev/null +++ b/fs/nfs/blocklayout/blocklayoutdm.c | |||
@@ -0,0 +1,111 @@ | |||
1 | /* | ||
2 | * linux/fs/nfs/blocklayout/blocklayoutdm.c | ||
3 | * | ||
4 | * Module for the NFSv4.1 pNFS block layout driver. | ||
5 | * | ||
6 | * Copyright (c) 2007 The Regents of the University of Michigan. | ||
7 | * All rights reserved. | ||
8 | * | ||
9 | * Fred Isaman <iisaman@umich.edu> | ||
10 | * Andy Adamson <andros@citi.umich.edu> | ||
11 | * | ||
12 | * permission is granted to use, copy, create derivative works and | ||
13 | * redistribute this software and such derivative works for any purpose, | ||
14 | * so long as the name of the university of michigan is not used in | ||
15 | * any advertising or publicity pertaining to the use or distribution | ||
16 | * of this software without specific, written prior authorization. if | ||
17 | * the above copyright notice or any other identification of the | ||
18 | * university of michigan is included in any copy of any portion of | ||
19 | * this software, then the disclaimer below must also be included. | ||
20 | * | ||
21 | * this software is provided as is, without representation from the | ||
22 | * university of michigan as to its fitness for any purpose, and without | ||
23 | * warranty by the university of michigan of any kind, either express | ||
24 | * or implied, including without limitation the implied warranties of | ||
25 | * merchantability and fitness for a particular purpose. the regents | ||
26 | * of the university of michigan shall not be liable for any damages, | ||
27 | * including special, indirect, incidental, or consequential damages, | ||
28 | * with respect to any claim arising out or in connection with the use | ||
29 | * of the software, even if it has been or is hereafter advised of the | ||
30 | * possibility of such damages. | ||
31 | */ | ||
32 | |||
33 | #include <linux/genhd.h> /* gendisk - used in a dprintk*/ | ||
34 | #include <linux/sched.h> | ||
35 | #include <linux/hash.h> | ||
36 | |||
37 | #include "blocklayout.h" | ||
38 | |||
39 | #define NFSDBG_FACILITY NFSDBG_PNFS_LD | ||
40 | |||
41 | static void dev_remove(dev_t dev) | ||
42 | { | ||
43 | struct rpc_pipe_msg msg; | ||
44 | struct bl_dev_msg bl_umount_request; | ||
45 | struct bl_msg_hdr bl_msg = { | ||
46 | .type = BL_DEVICE_UMOUNT, | ||
47 | .totallen = sizeof(bl_umount_request), | ||
48 | }; | ||
49 | uint8_t *dataptr; | ||
50 | DECLARE_WAITQUEUE(wq, current); | ||
51 | |||
52 | dprintk("Entering %s\n", __func__); | ||
53 | |||
54 | memset(&msg, 0, sizeof(msg)); | ||
55 | msg.data = kzalloc(1 + sizeof(bl_umount_request), GFP_NOFS); | ||
56 | if (!msg.data) | ||
57 | goto out; | ||
58 | |||
59 | memset(&bl_umount_request, 0, sizeof(bl_umount_request)); | ||
60 | bl_umount_request.major = MAJOR(dev); | ||
61 | bl_umount_request.minor = MINOR(dev); | ||
62 | |||
63 | memcpy(msg.data, &bl_msg, sizeof(bl_msg)); | ||
64 | dataptr = (uint8_t *) msg.data; | ||
65 | memcpy(&dataptr[sizeof(bl_msg)], &bl_umount_request, sizeof(bl_umount_request)); | ||
66 | msg.len = sizeof(bl_msg) + bl_msg.totallen; | ||
67 | |||
68 | add_wait_queue(&bl_wq, &wq); | ||
69 | if (rpc_queue_upcall(bl_device_pipe->d_inode, &msg) < 0) { | ||
70 | remove_wait_queue(&bl_wq, &wq); | ||
71 | goto out; | ||
72 | } | ||
73 | |||
74 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
75 | schedule(); | ||
76 | __set_current_state(TASK_RUNNING); | ||
77 | remove_wait_queue(&bl_wq, &wq); | ||
78 | |||
79 | out: | ||
80 | kfree(msg.data); | ||
81 | } | ||
82 | |||
83 | /* | ||
84 | * Release meta device | ||
85 | */ | ||
86 | static void nfs4_blk_metadev_release(struct pnfs_block_dev *bdev) | ||
87 | { | ||
88 | int rv; | ||
89 | |||
90 | dprintk("%s Releasing\n", __func__); | ||
91 | rv = nfs4_blkdev_put(bdev->bm_mdev); | ||
92 | if (rv) | ||
93 | printk(KERN_ERR "%s nfs4_blkdev_put returns %d\n", | ||
94 | __func__, rv); | ||
95 | |||
96 | dev_remove(bdev->bm_mdev->bd_dev); | ||
97 | } | ||
98 | |||
99 | void bl_free_block_dev(struct pnfs_block_dev *bdev) | ||
100 | { | ||
101 | if (bdev) { | ||
102 | if (bdev->bm_mdev) { | ||
103 | dprintk("%s Removing DM device: %d:%d\n", | ||
104 | __func__, | ||
105 | MAJOR(bdev->bm_mdev->bd_dev), | ||
106 | MINOR(bdev->bm_mdev->bd_dev)); | ||
107 | nfs4_blk_metadev_release(bdev); | ||
108 | } | ||
109 | kfree(bdev); | ||
110 | } | ||
111 | } | ||