diff options
Diffstat (limited to 'fs/nfs/blocklayout/blocklayoutdev.c')
-rw-r--r-- | fs/nfs/blocklayout/blocklayoutdev.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/fs/nfs/blocklayout/blocklayoutdev.c b/fs/nfs/blocklayout/blocklayoutdev.c index d08ba9107fde..a5c88a554d92 100644 --- a/fs/nfs/blocklayout/blocklayoutdev.c +++ b/fs/nfs/blocklayout/blocklayoutdev.c | |||
@@ -46,7 +46,7 @@ static int decode_sector_number(__be32 **rp, sector_t *sp) | |||
46 | 46 | ||
47 | *rp = xdr_decode_hyper(*rp, &s); | 47 | *rp = xdr_decode_hyper(*rp, &s); |
48 | if (s & 0x1ff) { | 48 | if (s & 0x1ff) { |
49 | printk(KERN_WARNING "%s: sector not aligned\n", __func__); | 49 | printk(KERN_WARNING "NFS: %s: sector not aligned\n", __func__); |
50 | return -1; | 50 | return -1; |
51 | } | 51 | } |
52 | *sp = s >> SECTOR_SHIFT; | 52 | *sp = s >> SECTOR_SHIFT; |
@@ -79,27 +79,30 @@ int nfs4_blkdev_put(struct block_device *bdev) | |||
79 | return blkdev_put(bdev, FMODE_READ); | 79 | return blkdev_put(bdev, FMODE_READ); |
80 | } | 80 | } |
81 | 81 | ||
82 | static struct bl_dev_msg bl_mount_reply; | ||
83 | |||
84 | ssize_t bl_pipe_downcall(struct file *filp, const char __user *src, | 82 | ssize_t bl_pipe_downcall(struct file *filp, const char __user *src, |
85 | size_t mlen) | 83 | size_t mlen) |
86 | { | 84 | { |
85 | struct nfs_net *nn = net_generic(filp->f_dentry->d_sb->s_fs_info, | ||
86 | nfs_net_id); | ||
87 | |||
87 | if (mlen != sizeof (struct bl_dev_msg)) | 88 | if (mlen != sizeof (struct bl_dev_msg)) |
88 | return -EINVAL; | 89 | return -EINVAL; |
89 | 90 | ||
90 | if (copy_from_user(&bl_mount_reply, src, mlen) != 0) | 91 | if (copy_from_user(&nn->bl_mount_reply, src, mlen) != 0) |
91 | return -EFAULT; | 92 | return -EFAULT; |
92 | 93 | ||
93 | wake_up(&bl_wq); | 94 | wake_up(&nn->bl_wq); |
94 | 95 | ||
95 | return mlen; | 96 | return mlen; |
96 | } | 97 | } |
97 | 98 | ||
98 | void bl_pipe_destroy_msg(struct rpc_pipe_msg *msg) | 99 | void bl_pipe_destroy_msg(struct rpc_pipe_msg *msg) |
99 | { | 100 | { |
101 | struct bl_pipe_msg *bl_pipe_msg = container_of(msg, struct bl_pipe_msg, msg); | ||
102 | |||
100 | if (msg->errno >= 0) | 103 | if (msg->errno >= 0) |
101 | return; | 104 | return; |
102 | wake_up(&bl_wq); | 105 | wake_up(bl_pipe_msg->bl_wq); |
103 | } | 106 | } |
104 | 107 | ||
105 | /* | 108 | /* |
@@ -111,29 +114,33 @@ nfs4_blk_decode_device(struct nfs_server *server, | |||
111 | { | 114 | { |
112 | struct pnfs_block_dev *rv; | 115 | struct pnfs_block_dev *rv; |
113 | struct block_device *bd = NULL; | 116 | struct block_device *bd = NULL; |
114 | struct rpc_pipe_msg msg; | 117 | struct bl_pipe_msg bl_pipe_msg; |
118 | struct rpc_pipe_msg *msg = &bl_pipe_msg.msg; | ||
115 | struct bl_msg_hdr bl_msg = { | 119 | struct bl_msg_hdr bl_msg = { |
116 | .type = BL_DEVICE_MOUNT, | 120 | .type = BL_DEVICE_MOUNT, |
117 | .totallen = dev->mincount, | 121 | .totallen = dev->mincount, |
118 | }; | 122 | }; |
119 | uint8_t *dataptr; | 123 | uint8_t *dataptr; |
120 | DECLARE_WAITQUEUE(wq, current); | 124 | DECLARE_WAITQUEUE(wq, current); |
121 | struct bl_dev_msg *reply = &bl_mount_reply; | ||
122 | int offset, len, i, rc; | 125 | int offset, len, i, rc; |
126 | struct net *net = server->nfs_client->net; | ||
127 | struct nfs_net *nn = net_generic(net, nfs_net_id); | ||
128 | struct bl_dev_msg *reply = &nn->bl_mount_reply; | ||
123 | 129 | ||
124 | dprintk("%s CREATING PIPEFS MESSAGE\n", __func__); | 130 | dprintk("%s CREATING PIPEFS MESSAGE\n", __func__); |
125 | dprintk("%s: deviceid: %s, mincount: %d\n", __func__, dev->dev_id.data, | 131 | dprintk("%s: deviceid: %s, mincount: %d\n", __func__, dev->dev_id.data, |
126 | dev->mincount); | 132 | dev->mincount); |
127 | 133 | ||
128 | memset(&msg, 0, sizeof(msg)); | 134 | bl_pipe_msg.bl_wq = &nn->bl_wq; |
129 | msg.data = kzalloc(sizeof(bl_msg) + dev->mincount, GFP_NOFS); | 135 | memset(msg, 0, sizeof(*msg)); |
130 | if (!msg.data) { | 136 | msg->data = kzalloc(sizeof(bl_msg) + dev->mincount, GFP_NOFS); |
137 | if (!msg->data) { | ||
131 | rv = ERR_PTR(-ENOMEM); | 138 | rv = ERR_PTR(-ENOMEM); |
132 | goto out; | 139 | goto out; |
133 | } | 140 | } |
134 | 141 | ||
135 | memcpy(msg.data, &bl_msg, sizeof(bl_msg)); | 142 | memcpy(msg->data, &bl_msg, sizeof(bl_msg)); |
136 | dataptr = (uint8_t *) msg.data; | 143 | dataptr = (uint8_t *) msg->data; |
137 | len = dev->mincount; | 144 | len = dev->mincount; |
138 | offset = sizeof(bl_msg); | 145 | offset = sizeof(bl_msg); |
139 | for (i = 0; len > 0; i++) { | 146 | for (i = 0; len > 0; i++) { |
@@ -142,13 +149,13 @@ nfs4_blk_decode_device(struct nfs_server *server, | |||
142 | len -= PAGE_CACHE_SIZE; | 149 | len -= PAGE_CACHE_SIZE; |
143 | offset += PAGE_CACHE_SIZE; | 150 | offset += PAGE_CACHE_SIZE; |
144 | } | 151 | } |
145 | msg.len = sizeof(bl_msg) + dev->mincount; | 152 | msg->len = sizeof(bl_msg) + dev->mincount; |
146 | 153 | ||
147 | dprintk("%s CALLING USERSPACE DAEMON\n", __func__); | 154 | dprintk("%s CALLING USERSPACE DAEMON\n", __func__); |
148 | add_wait_queue(&bl_wq, &wq); | 155 | add_wait_queue(&nn->bl_wq, &wq); |
149 | rc = rpc_queue_upcall(bl_device_pipe->d_inode, &msg); | 156 | rc = rpc_queue_upcall(nn->bl_device_pipe, msg); |
150 | if (rc < 0) { | 157 | if (rc < 0) { |
151 | remove_wait_queue(&bl_wq, &wq); | 158 | remove_wait_queue(&nn->bl_wq, &wq); |
152 | rv = ERR_PTR(rc); | 159 | rv = ERR_PTR(rc); |
153 | goto out; | 160 | goto out; |
154 | } | 161 | } |
@@ -156,7 +163,7 @@ nfs4_blk_decode_device(struct nfs_server *server, | |||
156 | set_current_state(TASK_UNINTERRUPTIBLE); | 163 | set_current_state(TASK_UNINTERRUPTIBLE); |
157 | schedule(); | 164 | schedule(); |
158 | __set_current_state(TASK_RUNNING); | 165 | __set_current_state(TASK_RUNNING); |
159 | remove_wait_queue(&bl_wq, &wq); | 166 | remove_wait_queue(&nn->bl_wq, &wq); |
160 | 167 | ||
161 | if (reply->status != BL_DEVICE_REQUEST_PROC) { | 168 | if (reply->status != BL_DEVICE_REQUEST_PROC) { |
162 | dprintk("%s failed to open device: %d\n", | 169 | dprintk("%s failed to open device: %d\n", |
@@ -181,13 +188,14 @@ nfs4_blk_decode_device(struct nfs_server *server, | |||
181 | 188 | ||
182 | rv->bm_mdev = bd; | 189 | rv->bm_mdev = bd; |
183 | memcpy(&rv->bm_mdevid, &dev->dev_id, sizeof(struct nfs4_deviceid)); | 190 | memcpy(&rv->bm_mdevid, &dev->dev_id, sizeof(struct nfs4_deviceid)); |
191 | rv->net = net; | ||
184 | dprintk("%s Created device %s with bd_block_size %u\n", | 192 | dprintk("%s Created device %s with bd_block_size %u\n", |
185 | __func__, | 193 | __func__, |
186 | bd->bd_disk->disk_name, | 194 | bd->bd_disk->disk_name, |
187 | bd->bd_block_size); | 195 | bd->bd_block_size); |
188 | 196 | ||
189 | out: | 197 | out: |
190 | kfree(msg.data); | 198 | kfree(msg->data); |
191 | return rv; | 199 | return rv; |
192 | } | 200 | } |
193 | 201 | ||