2 * QEMU Block driver for native access to files on NFS shares
4 * Copyright (c) 2014-2017 Peter Lieven <pl@kamp.de>
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
25 #include "qemu/osdep.h"
28 #include "qemu/config-file.h"
29 #include "qemu/error-report.h"
30 #include "qapi/error.h"
31 #include "block/block_int.h"
32 #include "block/qdict.h"
35 #include "qemu/main-loop.h"
36 #include "qemu/module.h"
37 #include "qemu/option.h"
39 #include "qemu/cutils.h"
40 #include "qapi/qapi-visit-block-core.h"
41 #include "qapi/qmp/qdict.h"
42 #include "qapi/qmp/qstring.h"
43 #include "qapi/qobject-input-visitor.h"
44 #include "qapi/qobject-output-visitor.h"
45 #include <nfsc/libnfs.h>
48 #define QEMU_NFS_MAX_READAHEAD_SIZE 1048576
49 #define QEMU_NFS_MAX_PAGECACHE_SIZE (8388608 / NFS_BLKSIZE)
50 #define QEMU_NFS_MAX_DEBUG_LEVEL 2
52 typedef struct NFSClient
{
53 struct nfs_context
*context
;
57 AioContext
*aio_context
;
63 int64_t uid
, gid
, tcp_syncnt
, readahead
, pagecache
, debug
;
66 typedef struct NFSRPC
{
76 static int nfs_parse_uri(const char *filename
, QDict
*options
, Error
**errp
)
79 QueryParams
*qp
= NULL
;
82 uri
= uri_parse(filename
);
84 error_setg(errp
, "Invalid URI specified");
87 if (g_strcmp0(uri
->scheme
, "nfs") != 0) {
88 error_setg(errp
, "URI scheme must be 'nfs'");
93 error_setg(errp
, "missing hostname in URI");
98 error_setg(errp
, "missing file path in URI");
102 qp
= query_params_parse(uri
->query
);
104 error_setg(errp
, "could not parse query parameters");
108 qdict_put_str(options
, "server.host", uri
->server
);
109 qdict_put_str(options
, "server.type", "inet");
110 qdict_put_str(options
, "path", uri
->path
);
112 for (i
= 0; i
< qp
->n
; i
++) {
113 unsigned long long val
;
114 if (!qp
->p
[i
].value
) {
115 error_setg(errp
, "Value for NFS parameter expected: %s",
119 if (parse_uint_full(qp
->p
[i
].value
, &val
, 0)) {
120 error_setg(errp
, "Illegal value for NFS parameter: %s",
124 if (!strcmp(qp
->p
[i
].name
, "uid")) {
125 qdict_put_str(options
, "user", qp
->p
[i
].value
);
126 } else if (!strcmp(qp
->p
[i
].name
, "gid")) {
127 qdict_put_str(options
, "group", qp
->p
[i
].value
);
128 } else if (!strcmp(qp
->p
[i
].name
, "tcp-syncnt")) {
129 qdict_put_str(options
, "tcp-syn-count", qp
->p
[i
].value
);
130 } else if (!strcmp(qp
->p
[i
].name
, "readahead")) {
131 qdict_put_str(options
, "readahead-size", qp
->p
[i
].value
);
132 } else if (!strcmp(qp
->p
[i
].name
, "pagecache")) {
133 qdict_put_str(options
, "page-cache-size", qp
->p
[i
].value
);
134 } else if (!strcmp(qp
->p
[i
].name
, "debug")) {
135 qdict_put_str(options
, "debug", qp
->p
[i
].value
);
137 error_setg(errp
, "Unknown NFS parameter name: %s",
145 query_params_free(qp
);
153 static bool nfs_has_filename_options_conflict(QDict
*options
, Error
**errp
)
155 const QDictEntry
*qe
;
157 for (qe
= qdict_first(options
); qe
; qe
= qdict_next(options
, qe
)) {
158 if (!strcmp(qe
->key
, "host") ||
159 !strcmp(qe
->key
, "path") ||
160 !strcmp(qe
->key
, "user") ||
161 !strcmp(qe
->key
, "group") ||
162 !strcmp(qe
->key
, "tcp-syn-count") ||
163 !strcmp(qe
->key
, "readahead-size") ||
164 !strcmp(qe
->key
, "page-cache-size") ||
165 !strcmp(qe
->key
, "debug") ||
166 strstart(qe
->key
, "server.", NULL
))
168 error_setg(errp
, "Option %s cannot be used with a filename",
177 static void nfs_parse_filename(const char *filename
, QDict
*options
,
180 if (nfs_has_filename_options_conflict(options
, errp
)) {
184 nfs_parse_uri(filename
, options
, errp
);
187 static void nfs_process_read(void *arg
);
188 static void nfs_process_write(void *arg
);
190 /* Called with QemuMutex held. */
191 static void nfs_set_events(NFSClient
*client
)
193 int ev
= nfs_which_events(client
->context
);
194 if (ev
!= client
->events
) {
195 aio_set_fd_handler(client
->aio_context
, nfs_get_fd(client
->context
),
197 (ev
& POLLIN
) ? nfs_process_read
: NULL
,
198 (ev
& POLLOUT
) ? nfs_process_write
: NULL
,
205 static void nfs_process_read(void *arg
)
207 NFSClient
*client
= arg
;
209 qemu_mutex_lock(&client
->mutex
);
210 nfs_service(client
->context
, POLLIN
);
211 nfs_set_events(client
);
212 qemu_mutex_unlock(&client
->mutex
);
215 static void nfs_process_write(void *arg
)
217 NFSClient
*client
= arg
;
219 qemu_mutex_lock(&client
->mutex
);
220 nfs_service(client
->context
, POLLOUT
);
221 nfs_set_events(client
);
222 qemu_mutex_unlock(&client
->mutex
);
225 static void nfs_co_init_task(BlockDriverState
*bs
, NFSRPC
*task
)
228 .co
= qemu_coroutine_self(),
230 .client
= bs
->opaque
,
234 static void nfs_co_generic_bh_cb(void *opaque
)
236 NFSRPC
*task
= opaque
;
239 aio_co_wake(task
->co
);
242 /* Called (via nfs_service) with QemuMutex held. */
244 nfs_co_generic_cb(int ret
, struct nfs_context
*nfs
, void *data
,
247 NFSRPC
*task
= private_data
;
250 if (task
->ret
> 0 && task
->iov
) {
251 if (task
->ret
<= task
->iov
->size
) {
252 qemu_iovec_from_buf(task
->iov
, 0, data
, task
->ret
);
258 error_report("NFS Error: %s", nfs_get_error(nfs
));
260 aio_bh_schedule_oneshot(task
->client
->aio_context
,
261 nfs_co_generic_bh_cb
, task
);
264 static int coroutine_fn
nfs_co_preadv(BlockDriverState
*bs
, uint64_t offset
,
265 uint64_t bytes
, QEMUIOVector
*iov
,
268 NFSClient
*client
= bs
->opaque
;
271 nfs_co_init_task(bs
, &task
);
274 qemu_mutex_lock(&client
->mutex
);
275 if (nfs_pread_async(client
->context
, client
->fh
,
276 offset
, bytes
, nfs_co_generic_cb
, &task
) != 0) {
277 qemu_mutex_unlock(&client
->mutex
);
281 nfs_set_events(client
);
282 qemu_mutex_unlock(&client
->mutex
);
283 while (!task
.complete
) {
284 qemu_coroutine_yield();
291 /* zero pad short reads */
292 if (task
.ret
< iov
->size
) {
293 qemu_iovec_memset(iov
, task
.ret
, 0, iov
->size
- task
.ret
);
299 static int coroutine_fn
nfs_co_pwritev(BlockDriverState
*bs
, uint64_t offset
,
300 uint64_t bytes
, QEMUIOVector
*iov
,
303 NFSClient
*client
= bs
->opaque
;
306 bool my_buffer
= false;
308 nfs_co_init_task(bs
, &task
);
310 if (iov
->niov
!= 1) {
311 buf
= g_try_malloc(bytes
);
312 if (bytes
&& buf
== NULL
) {
315 qemu_iovec_to_buf(iov
, 0, buf
, bytes
);
318 buf
= iov
->iov
[0].iov_base
;
321 qemu_mutex_lock(&client
->mutex
);
322 if (nfs_pwrite_async(client
->context
, client
->fh
,
324 nfs_co_generic_cb
, &task
) != 0) {
325 qemu_mutex_unlock(&client
->mutex
);
332 nfs_set_events(client
);
333 qemu_mutex_unlock(&client
->mutex
);
334 while (!task
.complete
) {
335 qemu_coroutine_yield();
342 if (task
.ret
!= bytes
) {
343 return task
.ret
< 0 ? task
.ret
: -EIO
;
349 static int coroutine_fn
nfs_co_flush(BlockDriverState
*bs
)
351 NFSClient
*client
= bs
->opaque
;
354 nfs_co_init_task(bs
, &task
);
356 qemu_mutex_lock(&client
->mutex
);
357 if (nfs_fsync_async(client
->context
, client
->fh
, nfs_co_generic_cb
,
359 qemu_mutex_unlock(&client
->mutex
);
363 nfs_set_events(client
);
364 qemu_mutex_unlock(&client
->mutex
);
365 while (!task
.complete
) {
366 qemu_coroutine_yield();
372 static void nfs_detach_aio_context(BlockDriverState
*bs
)
374 NFSClient
*client
= bs
->opaque
;
376 aio_set_fd_handler(client
->aio_context
, nfs_get_fd(client
->context
),
377 false, NULL
, NULL
, NULL
, NULL
);
381 static void nfs_attach_aio_context(BlockDriverState
*bs
,
382 AioContext
*new_context
)
384 NFSClient
*client
= bs
->opaque
;
386 client
->aio_context
= new_context
;
387 nfs_set_events(client
);
390 static void nfs_client_close(NFSClient
*client
)
392 if (client
->context
) {
393 qemu_mutex_lock(&client
->mutex
);
394 aio_set_fd_handler(client
->aio_context
, nfs_get_fd(client
->context
),
395 false, NULL
, NULL
, NULL
, NULL
);
396 qemu_mutex_unlock(&client
->mutex
);
398 nfs_close(client
->context
, client
->fh
);
401 #ifdef LIBNFS_FEATURE_UMOUNT
402 nfs_umount(client
->context
);
404 nfs_destroy_context(client
->context
);
405 client
->context
= NULL
;
407 g_free(client
->path
);
408 qemu_mutex_destroy(&client
->mutex
);
409 qapi_free_NFSServer(client
->server
);
410 client
->server
= NULL
;
413 static void nfs_file_close(BlockDriverState
*bs
)
415 NFSClient
*client
= bs
->opaque
;
416 nfs_client_close(client
);
419 static int64_t nfs_client_open(NFSClient
*client
, BlockdevOptionsNfs
*opts
,
420 int flags
, int open_flags
, Error
**errp
)
422 int64_t ret
= -EINVAL
;
424 char *file
= NULL
, *strp
= NULL
;
426 qemu_mutex_init(&client
->mutex
);
428 client
->path
= g_strdup(opts
->path
);
430 strp
= strrchr(client
->path
, '/');
432 error_setg(errp
, "Invalid URL specified");
435 file
= g_strdup(strp
);
438 /* Steal the NFSServer object from opts; set the original pointer to NULL
439 * to avoid use after free and double free. */
440 client
->server
= opts
->server
;
443 client
->context
= nfs_init_context();
444 if (client
->context
== NULL
) {
445 error_setg(errp
, "Failed to init NFS context");
449 if (opts
->has_user
) {
450 client
->uid
= opts
->user
;
451 nfs_set_uid(client
->context
, client
->uid
);
454 if (opts
->has_group
) {
455 client
->gid
= opts
->group
;
456 nfs_set_gid(client
->context
, client
->gid
);
459 if (opts
->has_tcp_syn_count
) {
460 client
->tcp_syncnt
= opts
->tcp_syn_count
;
461 nfs_set_tcp_syncnt(client
->context
, client
->tcp_syncnt
);
464 #ifdef LIBNFS_FEATURE_READAHEAD
465 if (opts
->has_readahead_size
) {
466 if (open_flags
& BDRV_O_NOCACHE
) {
467 error_setg(errp
, "Cannot enable NFS readahead "
468 "if cache.direct = on");
471 client
->readahead
= opts
->readahead_size
;
472 if (client
->readahead
> QEMU_NFS_MAX_READAHEAD_SIZE
) {
473 warn_report("Truncating NFS readahead size to %d",
474 QEMU_NFS_MAX_READAHEAD_SIZE
);
475 client
->readahead
= QEMU_NFS_MAX_READAHEAD_SIZE
;
477 nfs_set_readahead(client
->context
, client
->readahead
);
478 #ifdef LIBNFS_FEATURE_PAGECACHE
479 nfs_set_pagecache_ttl(client
->context
, 0);
481 client
->cache_used
= true;
485 #ifdef LIBNFS_FEATURE_PAGECACHE
486 if (opts
->has_page_cache_size
) {
487 if (open_flags
& BDRV_O_NOCACHE
) {
488 error_setg(errp
, "Cannot enable NFS pagecache "
489 "if cache.direct = on");
492 client
->pagecache
= opts
->page_cache_size
;
493 if (client
->pagecache
> QEMU_NFS_MAX_PAGECACHE_SIZE
) {
494 warn_report("Truncating NFS pagecache size to %d pages",
495 QEMU_NFS_MAX_PAGECACHE_SIZE
);
496 client
->pagecache
= QEMU_NFS_MAX_PAGECACHE_SIZE
;
498 nfs_set_pagecache(client
->context
, client
->pagecache
);
499 nfs_set_pagecache_ttl(client
->context
, 0);
500 client
->cache_used
= true;
504 #ifdef LIBNFS_FEATURE_DEBUG
505 if (opts
->has_debug
) {
506 client
->debug
= opts
->debug
;
507 /* limit the maximum debug level to avoid potential flooding
508 * of our log files. */
509 if (client
->debug
> QEMU_NFS_MAX_DEBUG_LEVEL
) {
510 warn_report("Limiting NFS debug level to %d",
511 QEMU_NFS_MAX_DEBUG_LEVEL
);
512 client
->debug
= QEMU_NFS_MAX_DEBUG_LEVEL
;
514 nfs_set_debug(client
->context
, client
->debug
);
518 ret
= nfs_mount(client
->context
, client
->server
->host
, client
->path
);
520 error_setg(errp
, "Failed to mount nfs share: %s",
521 nfs_get_error(client
->context
));
525 if (flags
& O_CREAT
) {
526 ret
= nfs_creat(client
->context
, file
, 0600, &client
->fh
);
528 error_setg(errp
, "Failed to create file: %s",
529 nfs_get_error(client
->context
));
533 ret
= nfs_open(client
->context
, file
, flags
, &client
->fh
);
535 error_setg(errp
, "Failed to open file : %s",
536 nfs_get_error(client
->context
));
541 ret
= nfs_fstat(client
->context
, client
->fh
, &st
);
543 error_setg(errp
, "Failed to fstat file: %s",
544 nfs_get_error(client
->context
));
548 ret
= DIV_ROUND_UP(st
.st_size
, BDRV_SECTOR_SIZE
);
549 client
->st_blocks
= st
.st_blocks
;
550 client
->has_zero_init
= S_ISREG(st
.st_mode
);
555 nfs_client_close(client
);
561 static BlockdevOptionsNfs
*nfs_options_qdict_to_qapi(QDict
*options
,
564 BlockdevOptionsNfs
*opts
= NULL
;
567 Error
*local_err
= NULL
;
569 v
= qobject_input_visitor_new_flat_confused(options
, errp
);
574 visit_type_BlockdevOptionsNfs(v
, NULL
, &opts
, &local_err
);
578 error_propagate(errp
, local_err
);
582 /* Remove the processed options from the QDict (the visitor processes
583 * _all_ options in the QDict) */
584 while ((e
= qdict_first(options
))) {
585 qdict_del(options
, e
->key
);
591 static int64_t nfs_client_open_qdict(NFSClient
*client
, QDict
*options
,
592 int flags
, int open_flags
, Error
**errp
)
594 BlockdevOptionsNfs
*opts
;
597 opts
= nfs_options_qdict_to_qapi(options
, errp
);
603 ret
= nfs_client_open(client
, opts
, flags
, open_flags
, errp
);
605 qapi_free_BlockdevOptionsNfs(opts
);
609 static int nfs_file_open(BlockDriverState
*bs
, QDict
*options
, int flags
,
611 NFSClient
*client
= bs
->opaque
;
614 client
->aio_context
= bdrv_get_aio_context(bs
);
616 ret
= nfs_client_open_qdict(client
, options
,
617 (flags
& BDRV_O_RDWR
) ? O_RDWR
: O_RDONLY
,
618 bs
->open_flags
, errp
);
623 bs
->total_sectors
= ret
;
628 static QemuOptsList nfs_create_opts
= {
629 .name
= "nfs-create-opts",
630 .head
= QTAILQ_HEAD_INITIALIZER(nfs_create_opts
.head
),
633 .name
= BLOCK_OPT_SIZE
,
634 .type
= QEMU_OPT_SIZE
,
635 .help
= "Virtual disk size"
637 { /* end of list */ }
641 static int nfs_file_co_create(BlockdevCreateOptions
*options
, Error
**errp
)
643 BlockdevCreateOptionsNfs
*opts
= &options
->u
.nfs
;
644 NFSClient
*client
= g_new0(NFSClient
, 1);
647 assert(options
->driver
== BLOCKDEV_DRIVER_NFS
);
649 client
->aio_context
= qemu_get_aio_context();
651 ret
= nfs_client_open(client
, opts
->location
, O_CREAT
, 0, errp
);
655 ret
= nfs_ftruncate(client
->context
, client
->fh
, opts
->size
);
656 nfs_client_close(client
);
663 static int coroutine_fn
nfs_file_co_create_opts(const char *url
, QemuOpts
*opts
,
666 BlockdevCreateOptions
*create_options
;
667 BlockdevCreateOptionsNfs
*nfs_opts
;
671 create_options
= g_new0(BlockdevCreateOptions
, 1);
672 create_options
->driver
= BLOCKDEV_DRIVER_NFS
;
673 nfs_opts
= &create_options
->u
.nfs
;
675 /* Read out options */
676 nfs_opts
->size
= ROUND_UP(qemu_opt_get_size_del(opts
, BLOCK_OPT_SIZE
, 0),
679 options
= qdict_new();
680 ret
= nfs_parse_uri(url
, options
, errp
);
685 nfs_opts
->location
= nfs_options_qdict_to_qapi(options
, errp
);
686 if (nfs_opts
->location
== NULL
) {
691 ret
= nfs_file_co_create(create_options
, errp
);
698 qobject_unref(options
);
699 qapi_free_BlockdevCreateOptions(create_options
);
703 static int nfs_has_zero_init(BlockDriverState
*bs
)
705 NFSClient
*client
= bs
->opaque
;
706 return client
->has_zero_init
;
709 /* Called (via nfs_service) with QemuMutex held. */
711 nfs_get_allocated_file_size_cb(int ret
, struct nfs_context
*nfs
, void *data
,
714 NFSRPC
*task
= private_data
;
716 if (task
->ret
== 0) {
717 memcpy(task
->st
, data
, sizeof(struct stat
));
720 error_report("NFS Error: %s", nfs_get_error(nfs
));
723 /* Set task->complete before reading bs->wakeup. */
724 atomic_mb_set(&task
->complete
, 1);
725 bdrv_wakeup(task
->bs
);
728 static int64_t nfs_get_allocated_file_size(BlockDriverState
*bs
)
730 NFSClient
*client
= bs
->opaque
;
734 if (bdrv_is_read_only(bs
) &&
735 !(bs
->open_flags
& BDRV_O_NOCACHE
)) {
736 return client
->st_blocks
* 512;
741 if (nfs_fstat_async(client
->context
, client
->fh
, nfs_get_allocated_file_size_cb
,
746 nfs_set_events(client
);
747 BDRV_POLL_WHILE(bs
, !task
.complete
);
749 return (task
.ret
< 0 ? task
.ret
: st
.st_blocks
* 512);
752 static int coroutine_fn
753 nfs_file_co_truncate(BlockDriverState
*bs
, int64_t offset
,
754 PreallocMode prealloc
, Error
**errp
)
756 NFSClient
*client
= bs
->opaque
;
759 if (prealloc
!= PREALLOC_MODE_OFF
) {
760 error_setg(errp
, "Unsupported preallocation mode '%s'",
761 PreallocMode_str(prealloc
));
765 ret
= nfs_ftruncate(client
->context
, client
->fh
, offset
);
767 error_setg_errno(errp
, -ret
, "Failed to truncate file");
774 /* Note that this will not re-establish a connection with the NFS server
775 * - it is effectively a NOP. */
776 static int nfs_reopen_prepare(BDRVReopenState
*state
,
777 BlockReopenQueue
*queue
, Error
**errp
)
779 NFSClient
*client
= state
->bs
->opaque
;
783 if (state
->flags
& BDRV_O_RDWR
&& bdrv_is_read_only(state
->bs
)) {
784 error_setg(errp
, "Cannot open a read-only mount as read-write");
788 if ((state
->flags
& BDRV_O_NOCACHE
) && client
->cache_used
) {
789 error_setg(errp
, "Cannot disable cache if libnfs readahead or"
790 " pagecache is enabled");
794 /* Update cache for read-only reopens */
795 if (!(state
->flags
& BDRV_O_RDWR
)) {
796 ret
= nfs_fstat(client
->context
, client
->fh
, &st
);
798 error_setg(errp
, "Failed to fstat file: %s",
799 nfs_get_error(client
->context
));
802 client
->st_blocks
= st
.st_blocks
;
808 static void nfs_refresh_filename(BlockDriverState
*bs
)
810 NFSClient
*client
= bs
->opaque
;
812 if (client
->uid
&& !client
->gid
) {
813 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
814 "nfs://%s%s?uid=%" PRId64
, client
->server
->host
, client
->path
,
816 } else if (!client
->uid
&& client
->gid
) {
817 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
818 "nfs://%s%s?gid=%" PRId64
, client
->server
->host
, client
->path
,
820 } else if (client
->uid
&& client
->gid
) {
821 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
822 "nfs://%s%s?uid=%" PRId64
"&gid=%" PRId64
,
823 client
->server
->host
, client
->path
, client
->uid
, client
->gid
);
825 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
826 "nfs://%s%s", client
->server
->host
, client
->path
);
830 static char *nfs_dirname(BlockDriverState
*bs
, Error
**errp
)
832 NFSClient
*client
= bs
->opaque
;
834 if (client
->uid
|| client
->gid
) {
835 bdrv_refresh_filename(bs
);
836 error_setg(errp
, "Cannot generate a base directory for NFS node '%s'",
841 return g_strdup_printf("nfs://%s%s/", client
->server
->host
, client
->path
);
844 #ifdef LIBNFS_FEATURE_PAGECACHE
845 static void coroutine_fn
nfs_co_invalidate_cache(BlockDriverState
*bs
,
848 NFSClient
*client
= bs
->opaque
;
849 nfs_pagecache_invalidate(client
->context
, client
->fh
);
853 static const char *nfs_strong_runtime_opts
[] = {
862 static BlockDriver bdrv_nfs
= {
863 .format_name
= "nfs",
864 .protocol_name
= "nfs",
866 .instance_size
= sizeof(NFSClient
),
867 .bdrv_parse_filename
= nfs_parse_filename
,
868 .create_opts
= &nfs_create_opts
,
870 .bdrv_has_zero_init
= nfs_has_zero_init
,
871 .bdrv_has_zero_init_truncate
= nfs_has_zero_init
,
872 .bdrv_get_allocated_file_size
= nfs_get_allocated_file_size
,
873 .bdrv_co_truncate
= nfs_file_co_truncate
,
875 .bdrv_file_open
= nfs_file_open
,
876 .bdrv_close
= nfs_file_close
,
877 .bdrv_co_create
= nfs_file_co_create
,
878 .bdrv_co_create_opts
= nfs_file_co_create_opts
,
879 .bdrv_reopen_prepare
= nfs_reopen_prepare
,
881 .bdrv_co_preadv
= nfs_co_preadv
,
882 .bdrv_co_pwritev
= nfs_co_pwritev
,
883 .bdrv_co_flush_to_disk
= nfs_co_flush
,
885 .bdrv_detach_aio_context
= nfs_detach_aio_context
,
886 .bdrv_attach_aio_context
= nfs_attach_aio_context
,
887 .bdrv_refresh_filename
= nfs_refresh_filename
,
888 .bdrv_dirname
= nfs_dirname
,
890 .strong_runtime_opts
= nfs_strong_runtime_opts
,
892 #ifdef LIBNFS_FEATURE_PAGECACHE
893 .bdrv_co_invalidate_cache
= nfs_co_invalidate_cache
,
897 static void nfs_block_init(void)
899 bdrv_register(&bdrv_nfs
);
902 block_init(nfs_block_init
);