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"
30 #include "qemu/config-file.h"
31 #include "qemu/error-report.h"
32 #include "qapi/error.h"
33 #include "block/block_int.h"
34 #include "block/qdict.h"
37 #include "qemu/main-loop.h"
38 #include "qemu/module.h"
39 #include "qemu/option.h"
41 #include "qemu/cutils.h"
42 #include "sysemu/replay.h"
43 #include "qapi/qapi-visit-block-core.h"
44 #include "qapi/qmp/qdict.h"
45 #include "qapi/qmp/qstring.h"
46 #include "qapi/qobject-input-visitor.h"
47 #include "qapi/qobject-output-visitor.h"
48 #include <nfsc/libnfs.h>
51 #define QEMU_NFS_MAX_READAHEAD_SIZE 1048576
52 #define QEMU_NFS_MAX_PAGECACHE_SIZE (8388608 / NFS_BLKSIZE)
53 #define QEMU_NFS_MAX_DEBUG_LEVEL 2
55 typedef struct NFSClient
{
56 struct nfs_context
*context
;
60 AioContext
*aio_context
;
66 int64_t uid
, gid
, tcp_syncnt
, readahead
, pagecache
, debug
;
69 typedef struct NFSRPC
{
79 static int nfs_parse_uri(const char *filename
, QDict
*options
, Error
**errp
)
82 QueryParams
*qp
= NULL
;
85 uri
= uri_parse(filename
);
87 error_setg(errp
, "Invalid URI specified");
90 if (g_strcmp0(uri
->scheme
, "nfs") != 0) {
91 error_setg(errp
, "URI scheme must be 'nfs'");
96 error_setg(errp
, "missing hostname in URI");
101 error_setg(errp
, "missing file path in URI");
105 qp
= query_params_parse(uri
->query
);
107 error_setg(errp
, "could not parse query parameters");
111 qdict_put_str(options
, "server.host", uri
->server
);
112 qdict_put_str(options
, "server.type", "inet");
113 qdict_put_str(options
, "path", uri
->path
);
115 for (i
= 0; i
< qp
->n
; i
++) {
116 unsigned long long val
;
117 if (!qp
->p
[i
].value
) {
118 error_setg(errp
, "Value for NFS parameter expected: %s",
122 if (parse_uint_full(qp
->p
[i
].value
, &val
, 0)) {
123 error_setg(errp
, "Illegal value for NFS parameter: %s",
127 if (!strcmp(qp
->p
[i
].name
, "uid")) {
128 qdict_put_str(options
, "user", qp
->p
[i
].value
);
129 } else if (!strcmp(qp
->p
[i
].name
, "gid")) {
130 qdict_put_str(options
, "group", qp
->p
[i
].value
);
131 } else if (!strcmp(qp
->p
[i
].name
, "tcp-syncnt")) {
132 qdict_put_str(options
, "tcp-syn-count", qp
->p
[i
].value
);
133 } else if (!strcmp(qp
->p
[i
].name
, "readahead")) {
134 qdict_put_str(options
, "readahead-size", qp
->p
[i
].value
);
135 } else if (!strcmp(qp
->p
[i
].name
, "pagecache")) {
136 qdict_put_str(options
, "page-cache-size", qp
->p
[i
].value
);
137 } else if (!strcmp(qp
->p
[i
].name
, "debug")) {
138 qdict_put_str(options
, "debug", qp
->p
[i
].value
);
140 error_setg(errp
, "Unknown NFS parameter name: %s",
148 query_params_free(qp
);
156 static bool nfs_has_filename_options_conflict(QDict
*options
, Error
**errp
)
158 const QDictEntry
*qe
;
160 for (qe
= qdict_first(options
); qe
; qe
= qdict_next(options
, qe
)) {
161 if (!strcmp(qe
->key
, "host") ||
162 !strcmp(qe
->key
, "path") ||
163 !strcmp(qe
->key
, "user") ||
164 !strcmp(qe
->key
, "group") ||
165 !strcmp(qe
->key
, "tcp-syn-count") ||
166 !strcmp(qe
->key
, "readahead-size") ||
167 !strcmp(qe
->key
, "page-cache-size") ||
168 !strcmp(qe
->key
, "debug") ||
169 strstart(qe
->key
, "server.", NULL
))
171 error_setg(errp
, "Option %s cannot be used with a filename",
180 static void nfs_parse_filename(const char *filename
, QDict
*options
,
183 if (nfs_has_filename_options_conflict(options
, errp
)) {
187 nfs_parse_uri(filename
, options
, errp
);
190 static void nfs_process_read(void *arg
);
191 static void nfs_process_write(void *arg
);
193 /* Called with QemuMutex held. */
194 static void nfs_set_events(NFSClient
*client
)
196 int ev
= nfs_which_events(client
->context
);
197 if (ev
!= client
->events
) {
198 aio_set_fd_handler(client
->aio_context
, nfs_get_fd(client
->context
),
200 (ev
& POLLIN
) ? nfs_process_read
: NULL
,
201 (ev
& POLLOUT
) ? nfs_process_write
: NULL
,
208 static void nfs_process_read(void *arg
)
210 NFSClient
*client
= arg
;
212 qemu_mutex_lock(&client
->mutex
);
213 nfs_service(client
->context
, POLLIN
);
214 nfs_set_events(client
);
215 qemu_mutex_unlock(&client
->mutex
);
218 static void nfs_process_write(void *arg
)
220 NFSClient
*client
= arg
;
222 qemu_mutex_lock(&client
->mutex
);
223 nfs_service(client
->context
, POLLOUT
);
224 nfs_set_events(client
);
225 qemu_mutex_unlock(&client
->mutex
);
228 static void nfs_co_init_task(BlockDriverState
*bs
, NFSRPC
*task
)
231 .co
= qemu_coroutine_self(),
233 .client
= bs
->opaque
,
237 static void nfs_co_generic_bh_cb(void *opaque
)
239 NFSRPC
*task
= opaque
;
242 aio_co_wake(task
->co
);
245 /* Called (via nfs_service) with QemuMutex held. */
247 nfs_co_generic_cb(int ret
, struct nfs_context
*nfs
, void *data
,
250 NFSRPC
*task
= private_data
;
253 if (task
->ret
> 0 && task
->iov
) {
254 if (task
->ret
<= task
->iov
->size
) {
255 qemu_iovec_from_buf(task
->iov
, 0, data
, task
->ret
);
261 error_report("NFS Error: %s", nfs_get_error(nfs
));
263 replay_bh_schedule_oneshot_event(task
->client
->aio_context
,
264 nfs_co_generic_bh_cb
, task
);
267 static int coroutine_fn
nfs_co_preadv(BlockDriverState
*bs
, uint64_t offset
,
268 uint64_t bytes
, QEMUIOVector
*iov
,
271 NFSClient
*client
= bs
->opaque
;
274 nfs_co_init_task(bs
, &task
);
277 WITH_QEMU_LOCK_GUARD(&client
->mutex
) {
278 if (nfs_pread_async(client
->context
, client
->fh
,
279 offset
, bytes
, nfs_co_generic_cb
, &task
) != 0) {
283 nfs_set_events(client
);
285 while (!task
.complete
) {
286 qemu_coroutine_yield();
293 /* zero pad short reads */
294 if (task
.ret
< iov
->size
) {
295 qemu_iovec_memset(iov
, task
.ret
, 0, iov
->size
- task
.ret
);
301 static int coroutine_fn
nfs_co_pwritev(BlockDriverState
*bs
, uint64_t offset
,
302 uint64_t bytes
, QEMUIOVector
*iov
,
305 NFSClient
*client
= bs
->opaque
;
308 bool my_buffer
= false;
310 nfs_co_init_task(bs
, &task
);
312 if (iov
->niov
!= 1) {
313 buf
= g_try_malloc(bytes
);
314 if (bytes
&& buf
== NULL
) {
317 qemu_iovec_to_buf(iov
, 0, buf
, bytes
);
320 buf
= iov
->iov
[0].iov_base
;
323 WITH_QEMU_LOCK_GUARD(&client
->mutex
) {
324 if (nfs_pwrite_async(client
->context
, client
->fh
,
326 nfs_co_generic_cb
, &task
) != 0) {
333 nfs_set_events(client
);
335 while (!task
.complete
) {
336 qemu_coroutine_yield();
343 if (task
.ret
!= bytes
) {
344 return task
.ret
< 0 ? task
.ret
: -EIO
;
350 static int coroutine_fn
nfs_co_flush(BlockDriverState
*bs
)
352 NFSClient
*client
= bs
->opaque
;
355 nfs_co_init_task(bs
, &task
);
357 WITH_QEMU_LOCK_GUARD(&client
->mutex
) {
358 if (nfs_fsync_async(client
->context
, client
->fh
, nfs_co_generic_cb
,
363 nfs_set_events(client
);
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
);
550 client
->st_blocks
= st
.st_blocks
;
552 client
->has_zero_init
= S_ISREG(st
.st_mode
);
557 nfs_client_close(client
);
563 static BlockdevOptionsNfs
*nfs_options_qdict_to_qapi(QDict
*options
,
566 BlockdevOptionsNfs
*opts
= NULL
;
570 v
= qobject_input_visitor_new_flat_confused(options
, errp
);
575 visit_type_BlockdevOptionsNfs(v
, NULL
, &opts
, errp
);
581 /* Remove the processed options from the QDict (the visitor processes
582 * _all_ options in the QDict) */
583 while ((e
= qdict_first(options
))) {
584 qdict_del(options
, e
->key
);
590 static int64_t nfs_client_open_qdict(NFSClient
*client
, QDict
*options
,
591 int flags
, int open_flags
, Error
**errp
)
593 BlockdevOptionsNfs
*opts
;
596 opts
= nfs_options_qdict_to_qapi(options
, errp
);
602 ret
= nfs_client_open(client
, opts
, flags
, open_flags
, errp
);
604 qapi_free_BlockdevOptionsNfs(opts
);
608 static int nfs_file_open(BlockDriverState
*bs
, QDict
*options
, int flags
,
610 NFSClient
*client
= bs
->opaque
;
613 client
->aio_context
= bdrv_get_aio_context(bs
);
615 ret
= nfs_client_open_qdict(client
, options
,
616 (flags
& BDRV_O_RDWR
) ? O_RDWR
: O_RDONLY
,
617 bs
->open_flags
, errp
);
622 bs
->total_sectors
= ret
;
623 if (client
->has_zero_init
) {
624 bs
->supported_truncate_flags
= BDRV_REQ_ZERO_WRITE
;
629 static QemuOptsList nfs_create_opts
= {
630 .name
= "nfs-create-opts",
631 .head
= QTAILQ_HEAD_INITIALIZER(nfs_create_opts
.head
),
634 .name
= BLOCK_OPT_SIZE
,
635 .type
= QEMU_OPT_SIZE
,
636 .help
= "Virtual disk size"
638 { /* end of list */ }
642 static int nfs_file_co_create(BlockdevCreateOptions
*options
, Error
**errp
)
644 BlockdevCreateOptionsNfs
*opts
= &options
->u
.nfs
;
645 NFSClient
*client
= g_new0(NFSClient
, 1);
648 assert(options
->driver
== BLOCKDEV_DRIVER_NFS
);
650 client
->aio_context
= qemu_get_aio_context();
652 ret
= nfs_client_open(client
, opts
->location
, O_CREAT
, 0, errp
);
656 ret
= nfs_ftruncate(client
->context
, client
->fh
, opts
->size
);
657 nfs_client_close(client
);
664 static int coroutine_fn
nfs_file_co_create_opts(BlockDriver
*drv
,
669 BlockdevCreateOptions
*create_options
;
670 BlockdevCreateOptionsNfs
*nfs_opts
;
674 create_options
= g_new0(BlockdevCreateOptions
, 1);
675 create_options
->driver
= BLOCKDEV_DRIVER_NFS
;
676 nfs_opts
= &create_options
->u
.nfs
;
678 /* Read out options */
679 nfs_opts
->size
= ROUND_UP(qemu_opt_get_size_del(opts
, BLOCK_OPT_SIZE
, 0),
682 options
= qdict_new();
683 ret
= nfs_parse_uri(url
, options
, errp
);
688 nfs_opts
->location
= nfs_options_qdict_to_qapi(options
, errp
);
689 if (nfs_opts
->location
== NULL
) {
694 ret
= nfs_file_co_create(create_options
, errp
);
701 qobject_unref(options
);
702 qapi_free_BlockdevCreateOptions(create_options
);
706 static int nfs_has_zero_init(BlockDriverState
*bs
)
708 NFSClient
*client
= bs
->opaque
;
709 return client
->has_zero_init
;
713 /* Called (via nfs_service) with QemuMutex held. */
715 nfs_get_allocated_file_size_cb(int ret
, struct nfs_context
*nfs
, void *data
,
718 NFSRPC
*task
= private_data
;
720 if (task
->ret
== 0) {
721 memcpy(task
->st
, data
, sizeof(struct stat
));
724 error_report("NFS Error: %s", nfs_get_error(nfs
));
727 /* Set task->complete before reading bs->wakeup. */
728 qatomic_mb_set(&task
->complete
, 1);
729 bdrv_wakeup(task
->bs
);
732 static int64_t nfs_get_allocated_file_size(BlockDriverState
*bs
)
734 NFSClient
*client
= bs
->opaque
;
738 if (bdrv_is_read_only(bs
) &&
739 !(bs
->open_flags
& BDRV_O_NOCACHE
)) {
740 return client
->st_blocks
* 512;
745 if (nfs_fstat_async(client
->context
, client
->fh
, nfs_get_allocated_file_size_cb
,
750 nfs_set_events(client
);
751 BDRV_POLL_WHILE(bs
, !task
.complete
);
753 return (task
.ret
< 0 ? task
.ret
: st
.st_blocks
* 512);
757 static int coroutine_fn
758 nfs_file_co_truncate(BlockDriverState
*bs
, int64_t offset
, bool exact
,
759 PreallocMode prealloc
, BdrvRequestFlags flags
,
762 NFSClient
*client
= bs
->opaque
;
765 if (prealloc
!= PREALLOC_MODE_OFF
) {
766 error_setg(errp
, "Unsupported preallocation mode '%s'",
767 PreallocMode_str(prealloc
));
771 ret
= nfs_ftruncate(client
->context
, client
->fh
, offset
);
773 error_setg_errno(errp
, -ret
, "Failed to truncate file");
780 /* Note that this will not re-establish a connection with the NFS server
781 * - it is effectively a NOP. */
782 static int nfs_reopen_prepare(BDRVReopenState
*state
,
783 BlockReopenQueue
*queue
, Error
**errp
)
785 NFSClient
*client
= state
->bs
->opaque
;
789 if (state
->flags
& BDRV_O_RDWR
&& bdrv_is_read_only(state
->bs
)) {
790 error_setg(errp
, "Cannot open a read-only mount as read-write");
794 if ((state
->flags
& BDRV_O_NOCACHE
) && client
->cache_used
) {
795 error_setg(errp
, "Cannot disable cache if libnfs readahead or"
796 " pagecache is enabled");
800 /* Update cache for read-only reopens */
801 if (!(state
->flags
& BDRV_O_RDWR
)) {
802 ret
= nfs_fstat(client
->context
, client
->fh
, &st
);
804 error_setg(errp
, "Failed to fstat file: %s",
805 nfs_get_error(client
->context
));
809 client
->st_blocks
= st
.st_blocks
;
816 static void nfs_refresh_filename(BlockDriverState
*bs
)
818 NFSClient
*client
= bs
->opaque
;
820 if (client
->uid
&& !client
->gid
) {
821 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
822 "nfs://%s%s?uid=%" PRId64
, client
->server
->host
, client
->path
,
824 } else if (!client
->uid
&& client
->gid
) {
825 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
826 "nfs://%s%s?gid=%" PRId64
, client
->server
->host
, client
->path
,
828 } else if (client
->uid
&& client
->gid
) {
829 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
830 "nfs://%s%s?uid=%" PRId64
"&gid=%" PRId64
,
831 client
->server
->host
, client
->path
, client
->uid
, client
->gid
);
833 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
834 "nfs://%s%s", client
->server
->host
, client
->path
);
838 static char *nfs_dirname(BlockDriverState
*bs
, Error
**errp
)
840 NFSClient
*client
= bs
->opaque
;
842 if (client
->uid
|| client
->gid
) {
843 bdrv_refresh_filename(bs
);
844 error_setg(errp
, "Cannot generate a base directory for NFS node '%s'",
849 return g_strdup_printf("nfs://%s%s/", client
->server
->host
, client
->path
);
852 #ifdef LIBNFS_FEATURE_PAGECACHE
853 static void coroutine_fn
nfs_co_invalidate_cache(BlockDriverState
*bs
,
856 NFSClient
*client
= bs
->opaque
;
857 nfs_pagecache_invalidate(client
->context
, client
->fh
);
861 static const char *nfs_strong_runtime_opts
[] = {
870 static BlockDriver bdrv_nfs
= {
871 .format_name
= "nfs",
872 .protocol_name
= "nfs",
874 .instance_size
= sizeof(NFSClient
),
875 .bdrv_parse_filename
= nfs_parse_filename
,
876 .create_opts
= &nfs_create_opts
,
878 .bdrv_has_zero_init
= nfs_has_zero_init
,
879 /* libnfs does not provide the allocated filesize of a file on win32. */
881 .bdrv_get_allocated_file_size
= nfs_get_allocated_file_size
,
883 .bdrv_co_truncate
= nfs_file_co_truncate
,
885 .bdrv_file_open
= nfs_file_open
,
886 .bdrv_close
= nfs_file_close
,
887 .bdrv_co_create
= nfs_file_co_create
,
888 .bdrv_co_create_opts
= nfs_file_co_create_opts
,
889 .bdrv_reopen_prepare
= nfs_reopen_prepare
,
891 .bdrv_co_preadv
= nfs_co_preadv
,
892 .bdrv_co_pwritev
= nfs_co_pwritev
,
893 .bdrv_co_flush_to_disk
= nfs_co_flush
,
895 .bdrv_detach_aio_context
= nfs_detach_aio_context
,
896 .bdrv_attach_aio_context
= nfs_attach_aio_context
,
897 .bdrv_refresh_filename
= nfs_refresh_filename
,
898 .bdrv_dirname
= nfs_dirname
,
900 .strong_runtime_opts
= nfs_strong_runtime_opts
,
902 #ifdef LIBNFS_FEATURE_PAGECACHE
903 .bdrv_co_invalidate_cache
= nfs_co_invalidate_cache
,
907 static void nfs_block_init(void)
909 bdrv_register(&bdrv_nfs
);
912 block_init(nfs_block_init
);