]>
Commit | Line | Data |
---|---|---|
6542aa9c PL |
1 | /* |
2 | * QEMU Block driver for native access to files on NFS shares | |
3 | * | |
38f8d5e0 | 4 | * Copyright (c) 2014-2016 Peter Lieven <pl@kamp.de> |
6542aa9c PL |
5 | * |
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
7 | * of this software and associated documentation files (the "Software"), to deal | |
8 | * in the Software without restriction, including without limitation the rights | |
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
10 | * copies of the Software, and to permit persons to whom the Software is | |
11 | * furnished to do so, subject to the following conditions: | |
12 | * | |
13 | * The above copyright notice and this permission notice shall be included in | |
14 | * all copies or substantial portions of the Software. | |
15 | * | |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
22 | * THE SOFTWARE. | |
23 | */ | |
24 | ||
80c71a24 | 25 | #include "qemu/osdep.h" |
6542aa9c PL |
26 | |
27 | #include <poll.h> | |
28 | #include "qemu-common.h" | |
29 | #include "qemu/config-file.h" | |
30 | #include "qemu/error-report.h" | |
d165b8cb | 31 | #include "qapi/error.h" |
6542aa9c PL |
32 | #include "block/block_int.h" |
33 | #include "trace.h" | |
34 | #include "qemu/iov.h" | |
35 | #include "qemu/uri.h" | |
0d94b746 | 36 | #include "qemu/cutils.h" |
6542aa9c PL |
37 | #include "sysemu/sysemu.h" |
38 | #include <nfsc/libnfs.h> | |
39 | ||
29c838cd | 40 | #define QEMU_NFS_MAX_READAHEAD_SIZE 1048576 |
7725b8bf | 41 | #define QEMU_NFS_MAX_DEBUG_LEVEL 2 |
29c838cd | 42 | |
6542aa9c PL |
43 | typedef struct NFSClient { |
44 | struct nfs_context *context; | |
45 | struct nfsfh *fh; | |
46 | int events; | |
47 | bool has_zero_init; | |
471799d1 | 48 | AioContext *aio_context; |
18a8056e | 49 | blkcnt_t st_blocks; |
38f8d5e0 | 50 | bool cache_used; |
6542aa9c PL |
51 | } NFSClient; |
52 | ||
53 | typedef struct NFSRPC { | |
54 | int ret; | |
55 | int complete; | |
56 | QEMUIOVector *iov; | |
57 | struct stat *st; | |
58 | Coroutine *co; | |
59 | QEMUBH *bh; | |
471799d1 | 60 | NFSClient *client; |
6542aa9c PL |
61 | } NFSRPC; |
62 | ||
63 | static void nfs_process_read(void *arg); | |
64 | static void nfs_process_write(void *arg); | |
65 | ||
66 | static void nfs_set_events(NFSClient *client) | |
67 | { | |
68 | int ev = nfs_which_events(client->context); | |
69 | if (ev != client->events) { | |
dca21ef2 FZ |
70 | aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context), |
71 | false, | |
471799d1 | 72 | (ev & POLLIN) ? nfs_process_read : NULL, |
dca21ef2 | 73 | (ev & POLLOUT) ? nfs_process_write : NULL, client); |
6542aa9c PL |
74 | |
75 | } | |
76 | client->events = ev; | |
77 | } | |
78 | ||
79 | static void nfs_process_read(void *arg) | |
80 | { | |
81 | NFSClient *client = arg; | |
82 | nfs_service(client->context, POLLIN); | |
83 | nfs_set_events(client); | |
84 | } | |
85 | ||
86 | static void nfs_process_write(void *arg) | |
87 | { | |
88 | NFSClient *client = arg; | |
89 | nfs_service(client->context, POLLOUT); | |
90 | nfs_set_events(client); | |
91 | } | |
92 | ||
93 | static void nfs_co_init_task(NFSClient *client, NFSRPC *task) | |
94 | { | |
95 | *task = (NFSRPC) { | |
471799d1 SH |
96 | .co = qemu_coroutine_self(), |
97 | .client = client, | |
6542aa9c PL |
98 | }; |
99 | } | |
100 | ||
101 | static void nfs_co_generic_bh_cb(void *opaque) | |
102 | { | |
103 | NFSRPC *task = opaque; | |
a2c0fe2f | 104 | task->complete = 1; |
6542aa9c PL |
105 | qemu_bh_delete(task->bh); |
106 | qemu_coroutine_enter(task->co, NULL); | |
107 | } | |
108 | ||
109 | static void | |
110 | nfs_co_generic_cb(int ret, struct nfs_context *nfs, void *data, | |
111 | void *private_data) | |
112 | { | |
113 | NFSRPC *task = private_data; | |
6542aa9c PL |
114 | task->ret = ret; |
115 | if (task->ret > 0 && task->iov) { | |
116 | if (task->ret <= task->iov->size) { | |
117 | qemu_iovec_from_buf(task->iov, 0, data, task->ret); | |
118 | } else { | |
119 | task->ret = -EIO; | |
120 | } | |
121 | } | |
122 | if (task->ret == 0 && task->st) { | |
123 | memcpy(task->st, data, sizeof(struct stat)); | |
124 | } | |
20fccb18 PL |
125 | if (task->ret < 0) { |
126 | error_report("NFS Error: %s", nfs_get_error(nfs)); | |
127 | } | |
6542aa9c | 128 | if (task->co) { |
471799d1 SH |
129 | task->bh = aio_bh_new(task->client->aio_context, |
130 | nfs_co_generic_bh_cb, task); | |
6542aa9c | 131 | qemu_bh_schedule(task->bh); |
a2c0fe2f PL |
132 | } else { |
133 | task->complete = 1; | |
6542aa9c PL |
134 | } |
135 | } | |
136 | ||
137 | static int coroutine_fn nfs_co_readv(BlockDriverState *bs, | |
138 | int64_t sector_num, int nb_sectors, | |
139 | QEMUIOVector *iov) | |
140 | { | |
141 | NFSClient *client = bs->opaque; | |
142 | NFSRPC task; | |
143 | ||
144 | nfs_co_init_task(client, &task); | |
145 | task.iov = iov; | |
146 | ||
147 | if (nfs_pread_async(client->context, client->fh, | |
148 | sector_num * BDRV_SECTOR_SIZE, | |
149 | nb_sectors * BDRV_SECTOR_SIZE, | |
150 | nfs_co_generic_cb, &task) != 0) { | |
151 | return -ENOMEM; | |
152 | } | |
153 | ||
154 | while (!task.complete) { | |
155 | nfs_set_events(client); | |
156 | qemu_coroutine_yield(); | |
157 | } | |
158 | ||
159 | if (task.ret < 0) { | |
160 | return task.ret; | |
161 | } | |
162 | ||
163 | /* zero pad short reads */ | |
164 | if (task.ret < iov->size) { | |
165 | qemu_iovec_memset(iov, task.ret, 0, iov->size - task.ret); | |
166 | } | |
167 | ||
168 | return 0; | |
169 | } | |
170 | ||
171 | static int coroutine_fn nfs_co_writev(BlockDriverState *bs, | |
172 | int64_t sector_num, int nb_sectors, | |
173 | QEMUIOVector *iov) | |
174 | { | |
175 | NFSClient *client = bs->opaque; | |
176 | NFSRPC task; | |
177 | char *buf = NULL; | |
178 | ||
179 | nfs_co_init_task(client, &task); | |
180 | ||
2347dd7b KW |
181 | buf = g_try_malloc(nb_sectors * BDRV_SECTOR_SIZE); |
182 | if (nb_sectors && buf == NULL) { | |
183 | return -ENOMEM; | |
184 | } | |
185 | ||
6542aa9c PL |
186 | qemu_iovec_to_buf(iov, 0, buf, nb_sectors * BDRV_SECTOR_SIZE); |
187 | ||
188 | if (nfs_pwrite_async(client->context, client->fh, | |
189 | sector_num * BDRV_SECTOR_SIZE, | |
190 | nb_sectors * BDRV_SECTOR_SIZE, | |
191 | buf, nfs_co_generic_cb, &task) != 0) { | |
192 | g_free(buf); | |
193 | return -ENOMEM; | |
194 | } | |
195 | ||
196 | while (!task.complete) { | |
197 | nfs_set_events(client); | |
198 | qemu_coroutine_yield(); | |
199 | } | |
200 | ||
201 | g_free(buf); | |
202 | ||
203 | if (task.ret != nb_sectors * BDRV_SECTOR_SIZE) { | |
204 | return task.ret < 0 ? task.ret : -EIO; | |
205 | } | |
206 | ||
207 | return 0; | |
208 | } | |
209 | ||
210 | static int coroutine_fn nfs_co_flush(BlockDriverState *bs) | |
211 | { | |
212 | NFSClient *client = bs->opaque; | |
213 | NFSRPC task; | |
214 | ||
215 | nfs_co_init_task(client, &task); | |
216 | ||
217 | if (nfs_fsync_async(client->context, client->fh, nfs_co_generic_cb, | |
218 | &task) != 0) { | |
219 | return -ENOMEM; | |
220 | } | |
221 | ||
222 | while (!task.complete) { | |
223 | nfs_set_events(client); | |
224 | qemu_coroutine_yield(); | |
225 | } | |
226 | ||
227 | return task.ret; | |
228 | } | |
229 | ||
230 | /* TODO Convert to fine grained options */ | |
231 | static QemuOptsList runtime_opts = { | |
232 | .name = "nfs", | |
233 | .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), | |
234 | .desc = { | |
235 | { | |
236 | .name = "filename", | |
237 | .type = QEMU_OPT_STRING, | |
238 | .help = "URL to the NFS file", | |
239 | }, | |
240 | { /* end of list */ } | |
241 | }, | |
242 | }; | |
243 | ||
471799d1 SH |
244 | static void nfs_detach_aio_context(BlockDriverState *bs) |
245 | { | |
246 | NFSClient *client = bs->opaque; | |
247 | ||
dca21ef2 FZ |
248 | aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context), |
249 | false, NULL, NULL, NULL); | |
471799d1 SH |
250 | client->events = 0; |
251 | } | |
252 | ||
253 | static void nfs_attach_aio_context(BlockDriverState *bs, | |
254 | AioContext *new_context) | |
255 | { | |
256 | NFSClient *client = bs->opaque; | |
257 | ||
258 | client->aio_context = new_context; | |
259 | nfs_set_events(client); | |
260 | } | |
261 | ||
6542aa9c PL |
262 | static void nfs_client_close(NFSClient *client) |
263 | { | |
264 | if (client->context) { | |
265 | if (client->fh) { | |
266 | nfs_close(client->context, client->fh); | |
267 | } | |
dca21ef2 FZ |
268 | aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context), |
269 | false, NULL, NULL, NULL); | |
6542aa9c PL |
270 | nfs_destroy_context(client->context); |
271 | } | |
272 | memset(client, 0, sizeof(NFSClient)); | |
273 | } | |
274 | ||
275 | static void nfs_file_close(BlockDriverState *bs) | |
276 | { | |
277 | NFSClient *client = bs->opaque; | |
278 | nfs_client_close(client); | |
279 | } | |
280 | ||
281 | static int64_t nfs_client_open(NFSClient *client, const char *filename, | |
38f8d5e0 | 282 | int flags, Error **errp, int open_flags) |
6542aa9c PL |
283 | { |
284 | int ret = -EINVAL, i; | |
285 | struct stat st; | |
286 | URI *uri; | |
287 | QueryParams *qp = NULL; | |
288 | char *file = NULL, *strp = NULL; | |
289 | ||
290 | uri = uri_parse(filename); | |
291 | if (!uri) { | |
292 | error_setg(errp, "Invalid URL specified"); | |
5f4d5e1a HR |
293 | goto fail; |
294 | } | |
295 | if (!uri->server) { | |
296 | error_setg(errp, "Invalid URL specified"); | |
6542aa9c PL |
297 | goto fail; |
298 | } | |
299 | strp = strrchr(uri->path, '/'); | |
300 | if (strp == NULL) { | |
301 | error_setg(errp, "Invalid URL specified"); | |
302 | goto fail; | |
303 | } | |
304 | file = g_strdup(strp); | |
305 | *strp = 0; | |
306 | ||
307 | client->context = nfs_init_context(); | |
308 | if (client->context == NULL) { | |
309 | error_setg(errp, "Failed to init NFS context"); | |
310 | goto fail; | |
311 | } | |
312 | ||
313 | qp = query_params_parse(uri->query); | |
314 | for (i = 0; i < qp->n; i++) { | |
7c24384b | 315 | unsigned long long val; |
6542aa9c PL |
316 | if (!qp->p[i].value) { |
317 | error_setg(errp, "Value for NFS parameter expected: %s", | |
318 | qp->p[i].name); | |
319 | goto fail; | |
320 | } | |
7c24384b PL |
321 | if (parse_uint_full(qp->p[i].value, &val, 0)) { |
322 | error_setg(errp, "Illegal value for NFS parameter: %s", | |
323 | qp->p[i].name); | |
324 | goto fail; | |
325 | } | |
326 | if (!strcmp(qp->p[i].name, "uid")) { | |
327 | nfs_set_uid(client->context, val); | |
328 | } else if (!strcmp(qp->p[i].name, "gid")) { | |
329 | nfs_set_gid(client->context, val); | |
330 | } else if (!strcmp(qp->p[i].name, "tcp-syncnt")) { | |
331 | nfs_set_tcp_syncnt(client->context, val); | |
f42ca3ca PL |
332 | #ifdef LIBNFS_FEATURE_READAHEAD |
333 | } else if (!strcmp(qp->p[i].name, "readahead")) { | |
38f8d5e0 PL |
334 | if (open_flags & BDRV_O_NOCACHE) { |
335 | error_setg(errp, "Cannot enable NFS readahead " | |
336 | "if cache.direct = on"); | |
337 | goto fail; | |
338 | } | |
29c838cd PL |
339 | if (val > QEMU_NFS_MAX_READAHEAD_SIZE) { |
340 | error_report("NFS Warning: Truncating NFS readahead" | |
341 | " size to %d", QEMU_NFS_MAX_READAHEAD_SIZE); | |
342 | val = QEMU_NFS_MAX_READAHEAD_SIZE; | |
343 | } | |
f42ca3ca | 344 | nfs_set_readahead(client->context, val); |
38f8d5e0 | 345 | client->cache_used = true; |
7725b8bf PL |
346 | #endif |
347 | #ifdef LIBNFS_FEATURE_DEBUG | |
348 | } else if (!strcmp(qp->p[i].name, "debug")) { | |
349 | /* limit the maximum debug level to avoid potential flooding | |
350 | * of our log files. */ | |
351 | if (val > QEMU_NFS_MAX_DEBUG_LEVEL) { | |
352 | error_report("NFS Warning: Limiting NFS debug level" | |
353 | " to %d", QEMU_NFS_MAX_DEBUG_LEVEL); | |
354 | val = QEMU_NFS_MAX_DEBUG_LEVEL; | |
355 | } | |
356 | nfs_set_debug(client->context, val); | |
f42ca3ca | 357 | #endif |
6542aa9c PL |
358 | } else { |
359 | error_setg(errp, "Unknown NFS parameter name: %s", | |
360 | qp->p[i].name); | |
361 | goto fail; | |
362 | } | |
363 | } | |
364 | ||
365 | ret = nfs_mount(client->context, uri->server, uri->path); | |
366 | if (ret < 0) { | |
367 | error_setg(errp, "Failed to mount nfs share: %s", | |
368 | nfs_get_error(client->context)); | |
369 | goto fail; | |
370 | } | |
371 | ||
372 | if (flags & O_CREAT) { | |
373 | ret = nfs_creat(client->context, file, 0600, &client->fh); | |
374 | if (ret < 0) { | |
375 | error_setg(errp, "Failed to create file: %s", | |
376 | nfs_get_error(client->context)); | |
377 | goto fail; | |
378 | } | |
379 | } else { | |
380 | ret = nfs_open(client->context, file, flags, &client->fh); | |
381 | if (ret < 0) { | |
382 | error_setg(errp, "Failed to open file : %s", | |
383 | nfs_get_error(client->context)); | |
384 | goto fail; | |
385 | } | |
386 | } | |
387 | ||
388 | ret = nfs_fstat(client->context, client->fh, &st); | |
389 | if (ret < 0) { | |
390 | error_setg(errp, "Failed to fstat file: %s", | |
391 | nfs_get_error(client->context)); | |
392 | goto fail; | |
393 | } | |
394 | ||
395 | ret = DIV_ROUND_UP(st.st_size, BDRV_SECTOR_SIZE); | |
18a8056e | 396 | client->st_blocks = st.st_blocks; |
6542aa9c PL |
397 | client->has_zero_init = S_ISREG(st.st_mode); |
398 | goto out; | |
399 | fail: | |
400 | nfs_client_close(client); | |
401 | out: | |
402 | if (qp) { | |
403 | query_params_free(qp); | |
404 | } | |
405 | uri_free(uri); | |
406 | g_free(file); | |
407 | return ret; | |
408 | } | |
409 | ||
410 | static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags, | |
411 | Error **errp) { | |
412 | NFSClient *client = bs->opaque; | |
413 | int64_t ret; | |
414 | QemuOpts *opts; | |
415 | Error *local_err = NULL; | |
416 | ||
471799d1 SH |
417 | client->aio_context = bdrv_get_aio_context(bs); |
418 | ||
6542aa9c PL |
419 | opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); |
420 | qemu_opts_absorb_qdict(opts, options, &local_err); | |
0fb6395c | 421 | if (local_err) { |
6542aa9c | 422 | error_propagate(errp, local_err); |
810f4f86 FZ |
423 | ret = -EINVAL; |
424 | goto out; | |
6542aa9c PL |
425 | } |
426 | ret = nfs_client_open(client, qemu_opt_get(opts, "filename"), | |
427 | (flags & BDRV_O_RDWR) ? O_RDWR : O_RDONLY, | |
38f8d5e0 | 428 | errp, bs->open_flags); |
6542aa9c | 429 | if (ret < 0) { |
810f4f86 | 430 | goto out; |
6542aa9c PL |
431 | } |
432 | bs->total_sectors = ret; | |
810f4f86 FZ |
433 | ret = 0; |
434 | out: | |
435 | qemu_opts_del(opts); | |
436 | return ret; | |
6542aa9c PL |
437 | } |
438 | ||
fd752801 HR |
439 | static QemuOptsList nfs_create_opts = { |
440 | .name = "nfs-create-opts", | |
441 | .head = QTAILQ_HEAD_INITIALIZER(nfs_create_opts.head), | |
442 | .desc = { | |
443 | { | |
444 | .name = BLOCK_OPT_SIZE, | |
445 | .type = QEMU_OPT_SIZE, | |
446 | .help = "Virtual disk size" | |
447 | }, | |
448 | { /* end of list */ } | |
449 | } | |
450 | }; | |
451 | ||
98c10b81 | 452 | static int nfs_file_create(const char *url, QemuOpts *opts, Error **errp) |
6542aa9c PL |
453 | { |
454 | int ret = 0; | |
455 | int64_t total_size = 0; | |
5839e53b | 456 | NFSClient *client = g_new0(NFSClient, 1); |
6542aa9c | 457 | |
471799d1 SH |
458 | client->aio_context = qemu_get_aio_context(); |
459 | ||
6542aa9c | 460 | /* Read out options */ |
c2eb918e HT |
461 | total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), |
462 | BDRV_SECTOR_SIZE); | |
6542aa9c | 463 | |
38f8d5e0 | 464 | ret = nfs_client_open(client, url, O_CREAT, errp, 0); |
6542aa9c PL |
465 | if (ret < 0) { |
466 | goto out; | |
467 | } | |
468 | ret = nfs_ftruncate(client->context, client->fh, total_size); | |
469 | nfs_client_close(client); | |
470 | out: | |
471 | g_free(client); | |
472 | return ret; | |
473 | } | |
474 | ||
475 | static int nfs_has_zero_init(BlockDriverState *bs) | |
476 | { | |
477 | NFSClient *client = bs->opaque; | |
478 | return client->has_zero_init; | |
479 | } | |
480 | ||
481 | static int64_t nfs_get_allocated_file_size(BlockDriverState *bs) | |
482 | { | |
483 | NFSClient *client = bs->opaque; | |
484 | NFSRPC task = {0}; | |
485 | struct stat st; | |
486 | ||
18a8056e PL |
487 | if (bdrv_is_read_only(bs) && |
488 | !(bs->open_flags & BDRV_O_NOCACHE)) { | |
489 | return client->st_blocks * 512; | |
490 | } | |
491 | ||
6542aa9c PL |
492 | task.st = &st; |
493 | if (nfs_fstat_async(client->context, client->fh, nfs_co_generic_cb, | |
494 | &task) != 0) { | |
495 | return -ENOMEM; | |
496 | } | |
497 | ||
498 | while (!task.complete) { | |
499 | nfs_set_events(client); | |
471799d1 | 500 | aio_poll(client->aio_context, true); |
6542aa9c PL |
501 | } |
502 | ||
055c6f91 | 503 | return (task.ret < 0 ? task.ret : st.st_blocks * 512); |
6542aa9c PL |
504 | } |
505 | ||
506 | static int nfs_file_truncate(BlockDriverState *bs, int64_t offset) | |
507 | { | |
508 | NFSClient *client = bs->opaque; | |
509 | return nfs_ftruncate(client->context, client->fh, offset); | |
510 | } | |
511 | ||
18a8056e PL |
512 | /* Note that this will not re-establish a connection with the NFS server |
513 | * - it is effectively a NOP. */ | |
514 | static int nfs_reopen_prepare(BDRVReopenState *state, | |
515 | BlockReopenQueue *queue, Error **errp) | |
516 | { | |
517 | NFSClient *client = state->bs->opaque; | |
518 | struct stat st; | |
519 | int ret = 0; | |
520 | ||
521 | if (state->flags & BDRV_O_RDWR && bdrv_is_read_only(state->bs)) { | |
522 | error_setg(errp, "Cannot open a read-only mount as read-write"); | |
523 | return -EACCES; | |
524 | } | |
525 | ||
38f8d5e0 PL |
526 | if ((state->flags & BDRV_O_NOCACHE) && client->cache_used) { |
527 | error_setg(errp, "Cannot disable cache if libnfs readahead is enabled"); | |
528 | return -EINVAL; | |
529 | } | |
530 | ||
18a8056e PL |
531 | /* Update cache for read-only reopens */ |
532 | if (!(state->flags & BDRV_O_RDWR)) { | |
533 | ret = nfs_fstat(client->context, client->fh, &st); | |
534 | if (ret < 0) { | |
535 | error_setg(errp, "Failed to fstat file: %s", | |
536 | nfs_get_error(client->context)); | |
537 | return ret; | |
538 | } | |
539 | client->st_blocks = st.st_blocks; | |
540 | } | |
541 | ||
542 | return 0; | |
543 | } | |
544 | ||
6542aa9c | 545 | static BlockDriver bdrv_nfs = { |
471799d1 SH |
546 | .format_name = "nfs", |
547 | .protocol_name = "nfs", | |
548 | ||
549 | .instance_size = sizeof(NFSClient), | |
550 | .bdrv_needs_filename = true, | |
fd752801 HR |
551 | .create_opts = &nfs_create_opts, |
552 | ||
471799d1 SH |
553 | .bdrv_has_zero_init = nfs_has_zero_init, |
554 | .bdrv_get_allocated_file_size = nfs_get_allocated_file_size, | |
555 | .bdrv_truncate = nfs_file_truncate, | |
556 | ||
557 | .bdrv_file_open = nfs_file_open, | |
558 | .bdrv_close = nfs_file_close, | |
c282e1fd | 559 | .bdrv_create = nfs_file_create, |
18a8056e | 560 | .bdrv_reopen_prepare = nfs_reopen_prepare, |
471799d1 SH |
561 | |
562 | .bdrv_co_readv = nfs_co_readv, | |
563 | .bdrv_co_writev = nfs_co_writev, | |
564 | .bdrv_co_flush_to_disk = nfs_co_flush, | |
565 | ||
566 | .bdrv_detach_aio_context = nfs_detach_aio_context, | |
567 | .bdrv_attach_aio_context = nfs_attach_aio_context, | |
6542aa9c PL |
568 | }; |
569 | ||
570 | static void nfs_block_init(void) | |
571 | { | |
572 | bdrv_register(&bdrv_nfs); | |
573 | } | |
574 | ||
575 | block_init(nfs_block_init); |