2 * QEMU Block driver for native access to files on NFS shares
4 * Copyright (c) 2014-2016 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-common.h"
29 #include "qemu/config-file.h"
30 #include "qemu/error-report.h"
31 #include "qapi/error.h"
32 #include "block/block_int.h"
36 #include "qemu/cutils.h"
37 #include "sysemu/sysemu.h"
38 #include "qapi/qmp/qdict.h"
39 #include "qapi/qmp/qint.h"
40 #include "qapi/qmp/qstring.h"
41 #include "qapi-visit.h"
42 #include "qapi/qobject-input-visitor.h"
43 #include "qapi/qobject-output-visitor.h"
44 #include <nfsc/libnfs.h>
47 #define QEMU_NFS_MAX_READAHEAD_SIZE 1048576
48 #define QEMU_NFS_MAX_PAGECACHE_SIZE (8388608 / NFS_BLKSIZE)
49 #define QEMU_NFS_MAX_DEBUG_LEVEL 2
51 typedef struct NFSClient
{
52 struct nfs_context
*context
;
56 AioContext
*aio_context
;
61 int64_t uid
, gid
, tcp_syncnt
, readahead
, pagecache
, debug
;
64 typedef struct NFSRPC
{
74 static int nfs_parse_uri(const char *filename
, QDict
*options
, Error
**errp
)
77 QueryParams
*qp
= NULL
;
80 uri
= uri_parse(filename
);
82 error_setg(errp
, "Invalid URI specified");
85 if (strcmp(uri
->scheme
, "nfs") != 0) {
86 error_setg(errp
, "URI scheme must be 'nfs'");
91 error_setg(errp
, "missing hostname in URI");
96 error_setg(errp
, "missing file path in URI");
100 qp
= query_params_parse(uri
->query
);
102 error_setg(errp
, "could not parse query parameters");
106 qdict_put(options
, "server.host", qstring_from_str(uri
->server
));
107 qdict_put(options
, "server.type", qstring_from_str("inet"));
108 qdict_put(options
, "path", qstring_from_str(uri
->path
));
110 for (i
= 0; i
< qp
->n
; i
++) {
111 unsigned long long val
;
112 if (!qp
->p
[i
].value
) {
113 error_setg(errp
, "Value for NFS parameter expected: %s",
117 if (parse_uint_full(qp
->p
[i
].value
, &val
, 0)) {
118 error_setg(errp
, "Illegal value for NFS parameter: %s",
122 if (!strcmp(qp
->p
[i
].name
, "uid")) {
123 qdict_put(options
, "user",
124 qstring_from_str(qp
->p
[i
].value
));
125 } else if (!strcmp(qp
->p
[i
].name
, "gid")) {
126 qdict_put(options
, "group",
127 qstring_from_str(qp
->p
[i
].value
));
128 } else if (!strcmp(qp
->p
[i
].name
, "tcp-syncnt")) {
129 qdict_put(options
, "tcp-syn-count",
130 qstring_from_str(qp
->p
[i
].value
));
131 } else if (!strcmp(qp
->p
[i
].name
, "readahead")) {
132 qdict_put(options
, "readahead-size",
133 qstring_from_str(qp
->p
[i
].value
));
134 } else if (!strcmp(qp
->p
[i
].name
, "pagecache")) {
135 qdict_put(options
, "page-cache-size",
136 qstring_from_str(qp
->p
[i
].value
));
137 } else if (!strcmp(qp
->p
[i
].name
, "debug")) {
138 qdict_put(options
, "debug",
139 qstring_from_str(qp
->p
[i
].value
));
141 error_setg(errp
, "Unknown NFS parameter name: %s",
149 query_params_free(qp
);
157 static bool nfs_has_filename_options_conflict(QDict
*options
, Error
**errp
)
159 const QDictEntry
*qe
;
161 for (qe
= qdict_first(options
); qe
; qe
= qdict_next(options
, qe
)) {
162 if (!strcmp(qe
->key
, "host") ||
163 !strcmp(qe
->key
, "path") ||
164 !strcmp(qe
->key
, "user") ||
165 !strcmp(qe
->key
, "group") ||
166 !strcmp(qe
->key
, "tcp-syn-count") ||
167 !strcmp(qe
->key
, "readahead-size") ||
168 !strcmp(qe
->key
, "page-cache-size") ||
169 !strcmp(qe
->key
, "debug") ||
170 strstart(qe
->key
, "server.", NULL
))
172 error_setg(errp
, "Option %s cannot be used with a filename",
181 static void nfs_parse_filename(const char *filename
, QDict
*options
,
184 if (nfs_has_filename_options_conflict(options
, errp
)) {
188 nfs_parse_uri(filename
, options
, errp
);
191 static void nfs_process_read(void *arg
);
192 static void nfs_process_write(void *arg
);
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
;
211 nfs_service(client
->context
, POLLIN
);
212 nfs_set_events(client
);
215 static void nfs_process_write(void *arg
)
217 NFSClient
*client
= arg
;
218 nfs_service(client
->context
, POLLOUT
);
219 nfs_set_events(client
);
222 static void nfs_co_init_task(BlockDriverState
*bs
, NFSRPC
*task
)
225 .co
= qemu_coroutine_self(),
227 .client
= bs
->opaque
,
231 static void nfs_co_generic_bh_cb(void *opaque
)
233 NFSRPC
*task
= opaque
;
235 qemu_coroutine_enter(task
->co
);
239 nfs_co_generic_cb(int ret
, struct nfs_context
*nfs
, void *data
,
242 NFSRPC
*task
= private_data
;
245 if (task
->ret
> 0 && task
->iov
) {
246 if (task
->ret
<= task
->iov
->size
) {
247 qemu_iovec_from_buf(task
->iov
, 0, data
, task
->ret
);
253 error_report("NFS Error: %s", nfs_get_error(nfs
));
255 aio_bh_schedule_oneshot(task
->client
->aio_context
,
256 nfs_co_generic_bh_cb
, task
);
259 static int coroutine_fn
nfs_co_readv(BlockDriverState
*bs
,
260 int64_t sector_num
, int nb_sectors
,
263 NFSClient
*client
= bs
->opaque
;
266 nfs_co_init_task(bs
, &task
);
269 if (nfs_pread_async(client
->context
, client
->fh
,
270 sector_num
* BDRV_SECTOR_SIZE
,
271 nb_sectors
* BDRV_SECTOR_SIZE
,
272 nfs_co_generic_cb
, &task
) != 0) {
276 nfs_set_events(client
);
277 while (!task
.complete
) {
278 qemu_coroutine_yield();
285 /* zero pad short reads */
286 if (task
.ret
< iov
->size
) {
287 qemu_iovec_memset(iov
, task
.ret
, 0, iov
->size
- task
.ret
);
293 static int coroutine_fn
nfs_co_writev(BlockDriverState
*bs
,
294 int64_t sector_num
, int nb_sectors
,
297 NFSClient
*client
= bs
->opaque
;
301 nfs_co_init_task(bs
, &task
);
303 buf
= g_try_malloc(nb_sectors
* BDRV_SECTOR_SIZE
);
304 if (nb_sectors
&& buf
== NULL
) {
308 qemu_iovec_to_buf(iov
, 0, buf
, nb_sectors
* BDRV_SECTOR_SIZE
);
310 if (nfs_pwrite_async(client
->context
, client
->fh
,
311 sector_num
* BDRV_SECTOR_SIZE
,
312 nb_sectors
* BDRV_SECTOR_SIZE
,
313 buf
, nfs_co_generic_cb
, &task
) != 0) {
318 nfs_set_events(client
);
319 while (!task
.complete
) {
320 qemu_coroutine_yield();
325 if (task
.ret
!= nb_sectors
* BDRV_SECTOR_SIZE
) {
326 return task
.ret
< 0 ? task
.ret
: -EIO
;
332 static int coroutine_fn
nfs_co_flush(BlockDriverState
*bs
)
334 NFSClient
*client
= bs
->opaque
;
337 nfs_co_init_task(bs
, &task
);
339 if (nfs_fsync_async(client
->context
, client
->fh
, nfs_co_generic_cb
,
344 nfs_set_events(client
);
345 while (!task
.complete
) {
346 qemu_coroutine_yield();
352 static QemuOptsList runtime_opts
= {
354 .head
= QTAILQ_HEAD_INITIALIZER(runtime_opts
.head
),
358 .type
= QEMU_OPT_STRING
,
359 .help
= "Path of the image on the host",
363 .type
= QEMU_OPT_NUMBER
,
364 .help
= "UID value to use when talking to the server",
368 .type
= QEMU_OPT_NUMBER
,
369 .help
= "GID value to use when talking to the server",
372 .name
= "tcp-syn-count",
373 .type
= QEMU_OPT_NUMBER
,
374 .help
= "Number of SYNs to send during the session establish",
377 .name
= "readahead-size",
378 .type
= QEMU_OPT_NUMBER
,
379 .help
= "Set the readahead size in bytes",
382 .name
= "page-cache-size",
383 .type
= QEMU_OPT_NUMBER
,
384 .help
= "Set the pagecache size in bytes",
388 .type
= QEMU_OPT_NUMBER
,
389 .help
= "Set the NFS debug level (max 2)",
391 { /* end of list */ }
395 static void nfs_detach_aio_context(BlockDriverState
*bs
)
397 NFSClient
*client
= bs
->opaque
;
399 aio_set_fd_handler(client
->aio_context
, nfs_get_fd(client
->context
),
400 false, NULL
, NULL
, NULL
, NULL
);
404 static void nfs_attach_aio_context(BlockDriverState
*bs
,
405 AioContext
*new_context
)
407 NFSClient
*client
= bs
->opaque
;
409 client
->aio_context
= new_context
;
410 nfs_set_events(client
);
413 static void nfs_client_close(NFSClient
*client
)
415 if (client
->context
) {
417 nfs_close(client
->context
, client
->fh
);
419 aio_set_fd_handler(client
->aio_context
, nfs_get_fd(client
->context
),
420 false, NULL
, NULL
, NULL
, NULL
);
421 nfs_destroy_context(client
->context
);
423 memset(client
, 0, sizeof(NFSClient
));
426 static void nfs_file_close(BlockDriverState
*bs
)
428 NFSClient
*client
= bs
->opaque
;
429 nfs_client_close(client
);
432 static NFSServer
*nfs_config(QDict
*options
, Error
**errp
)
434 NFSServer
*server
= NULL
;
436 QObject
*crumpled_addr
= NULL
;
438 Error
*local_error
= NULL
;
440 qdict_extract_subqdict(options
, &addr
, "server.");
441 if (!qdict_size(addr
)) {
442 error_setg(errp
, "NFS server address missing");
446 crumpled_addr
= qdict_crumple(addr
, errp
);
447 if (!crumpled_addr
) {
451 iv
= qobject_input_visitor_new(crumpled_addr
, true);
452 visit_type_NFSServer(iv
, NULL
, &server
, &local_error
);
454 error_propagate(errp
, local_error
);
460 qobject_decref(crumpled_addr
);
466 static int64_t nfs_client_open(NFSClient
*client
, QDict
*options
,
467 int flags
, Error
**errp
, int open_flags
)
470 QemuOpts
*opts
= NULL
;
471 Error
*local_err
= NULL
;
473 char *file
= NULL
, *strp
= NULL
;
475 opts
= qemu_opts_create(&runtime_opts
, NULL
, 0, &error_abort
);
476 qemu_opts_absorb_qdict(opts
, options
, &local_err
);
478 error_propagate(errp
, local_err
);
483 client
->path
= g_strdup(qemu_opt_get(opts
, "path"));
486 error_setg(errp
, "No path was specified");
490 strp
= strrchr(client
->path
, '/');
492 error_setg(errp
, "Invalid URL specified");
495 file
= g_strdup(strp
);
498 /* Pop the config into our state object, Exit if invalid */
499 client
->server
= nfs_config(options
, errp
);
500 if (!client
->server
) {
505 client
->context
= nfs_init_context();
506 if (client
->context
== NULL
) {
507 error_setg(errp
, "Failed to init NFS context");
511 if (qemu_opt_get(opts
, "user")) {
512 client
->uid
= qemu_opt_get_number(opts
, "user", 0);
513 nfs_set_uid(client
->context
, client
->uid
);
516 if (qemu_opt_get(opts
, "group")) {
517 client
->gid
= qemu_opt_get_number(opts
, "group", 0);
518 nfs_set_gid(client
->context
, client
->gid
);
521 if (qemu_opt_get(opts
, "tcp-syn-count")) {
522 client
->tcp_syncnt
= qemu_opt_get_number(opts
, "tcp-syn-count", 0);
523 nfs_set_tcp_syncnt(client
->context
, client
->tcp_syncnt
);
526 #ifdef LIBNFS_FEATURE_READAHEAD
527 if (qemu_opt_get(opts
, "readahead-size")) {
528 if (open_flags
& BDRV_O_NOCACHE
) {
529 error_setg(errp
, "Cannot enable NFS readahead "
530 "if cache.direct = on");
533 client
->readahead
= qemu_opt_get_number(opts
, "readahead-size", 0);
534 if (client
->readahead
> QEMU_NFS_MAX_READAHEAD_SIZE
) {
535 error_report("NFS Warning: Truncating NFS readahead "
536 "size to %d", QEMU_NFS_MAX_READAHEAD_SIZE
);
537 client
->readahead
= QEMU_NFS_MAX_READAHEAD_SIZE
;
539 nfs_set_readahead(client
->context
, client
->readahead
);
540 #ifdef LIBNFS_FEATURE_PAGECACHE
541 nfs_set_pagecache_ttl(client
->context
, 0);
543 client
->cache_used
= true;
547 #ifdef LIBNFS_FEATURE_PAGECACHE
548 if (qemu_opt_get(opts
, "page-cache-size")) {
549 if (open_flags
& BDRV_O_NOCACHE
) {
550 error_setg(errp
, "Cannot enable NFS pagecache "
551 "if cache.direct = on");
554 client
->pagecache
= qemu_opt_get_number(opts
, "page-cache-size", 0);
555 if (client
->pagecache
> QEMU_NFS_MAX_PAGECACHE_SIZE
) {
556 error_report("NFS Warning: Truncating NFS pagecache "
557 "size to %d pages", QEMU_NFS_MAX_PAGECACHE_SIZE
);
558 client
->pagecache
= QEMU_NFS_MAX_PAGECACHE_SIZE
;
560 nfs_set_pagecache(client
->context
, client
->pagecache
);
561 nfs_set_pagecache_ttl(client
->context
, 0);
562 client
->cache_used
= true;
566 #ifdef LIBNFS_FEATURE_DEBUG
567 if (qemu_opt_get(opts
, "debug")) {
568 client
->debug
= qemu_opt_get_number(opts
, "debug", 0);
569 /* limit the maximum debug level to avoid potential flooding
570 * of our log files. */
571 if (client
->debug
> QEMU_NFS_MAX_DEBUG_LEVEL
) {
572 error_report("NFS Warning: Limiting NFS debug level "
573 "to %d", QEMU_NFS_MAX_DEBUG_LEVEL
);
574 client
->debug
= QEMU_NFS_MAX_DEBUG_LEVEL
;
576 nfs_set_debug(client
->context
, client
->debug
);
580 ret
= nfs_mount(client
->context
, client
->server
->host
, client
->path
);
582 error_setg(errp
, "Failed to mount nfs share: %s",
583 nfs_get_error(client
->context
));
587 if (flags
& O_CREAT
) {
588 ret
= nfs_creat(client
->context
, file
, 0600, &client
->fh
);
590 error_setg(errp
, "Failed to create file: %s",
591 nfs_get_error(client
->context
));
595 ret
= nfs_open(client
->context
, file
, flags
, &client
->fh
);
597 error_setg(errp
, "Failed to open file : %s",
598 nfs_get_error(client
->context
));
603 ret
= nfs_fstat(client
->context
, client
->fh
, &st
);
605 error_setg(errp
, "Failed to fstat file: %s",
606 nfs_get_error(client
->context
));
610 ret
= DIV_ROUND_UP(st
.st_size
, BDRV_SECTOR_SIZE
);
611 client
->st_blocks
= st
.st_blocks
;
612 client
->has_zero_init
= S_ISREG(st
.st_mode
);
617 nfs_client_close(client
);
624 static int nfs_file_open(BlockDriverState
*bs
, QDict
*options
, int flags
,
626 NFSClient
*client
= bs
->opaque
;
629 client
->aio_context
= bdrv_get_aio_context(bs
);
631 ret
= nfs_client_open(client
, options
,
632 (flags
& BDRV_O_RDWR
) ? O_RDWR
: O_RDONLY
,
633 errp
, bs
->open_flags
);
637 bs
->total_sectors
= ret
;
642 static QemuOptsList nfs_create_opts
= {
643 .name
= "nfs-create-opts",
644 .head
= QTAILQ_HEAD_INITIALIZER(nfs_create_opts
.head
),
647 .name
= BLOCK_OPT_SIZE
,
648 .type
= QEMU_OPT_SIZE
,
649 .help
= "Virtual disk size"
651 { /* end of list */ }
655 static int nfs_file_create(const char *url
, QemuOpts
*opts
, Error
**errp
)
658 int64_t total_size
= 0;
659 NFSClient
*client
= g_new0(NFSClient
, 1);
660 QDict
*options
= NULL
;
662 client
->aio_context
= qemu_get_aio_context();
664 /* Read out options */
665 total_size
= ROUND_UP(qemu_opt_get_size_del(opts
, BLOCK_OPT_SIZE
, 0),
668 options
= qdict_new();
669 ret
= nfs_parse_uri(url
, options
, errp
);
674 ret
= nfs_client_open(client
, options
, O_CREAT
, errp
, 0);
678 ret
= nfs_ftruncate(client
->context
, client
->fh
, total_size
);
679 nfs_client_close(client
);
686 static int nfs_has_zero_init(BlockDriverState
*bs
)
688 NFSClient
*client
= bs
->opaque
;
689 return client
->has_zero_init
;
693 nfs_get_allocated_file_size_cb(int ret
, struct nfs_context
*nfs
, void *data
,
696 NFSRPC
*task
= private_data
;
698 if (task
->ret
== 0) {
699 memcpy(task
->st
, data
, sizeof(struct stat
));
702 error_report("NFS Error: %s", nfs_get_error(nfs
));
705 bdrv_wakeup(task
->bs
);
708 static int64_t nfs_get_allocated_file_size(BlockDriverState
*bs
)
710 NFSClient
*client
= bs
->opaque
;
714 if (bdrv_is_read_only(bs
) &&
715 !(bs
->open_flags
& BDRV_O_NOCACHE
)) {
716 return client
->st_blocks
* 512;
721 if (nfs_fstat_async(client
->context
, client
->fh
, nfs_get_allocated_file_size_cb
,
726 nfs_set_events(client
);
727 BDRV_POLL_WHILE(bs
, !task
.complete
);
729 return (task
.ret
< 0 ? task
.ret
: st
.st_blocks
* 512);
732 static int nfs_file_truncate(BlockDriverState
*bs
, int64_t offset
)
734 NFSClient
*client
= bs
->opaque
;
735 return nfs_ftruncate(client
->context
, client
->fh
, offset
);
738 /* Note that this will not re-establish a connection with the NFS server
739 * - it is effectively a NOP. */
740 static int nfs_reopen_prepare(BDRVReopenState
*state
,
741 BlockReopenQueue
*queue
, Error
**errp
)
743 NFSClient
*client
= state
->bs
->opaque
;
747 if (state
->flags
& BDRV_O_RDWR
&& bdrv_is_read_only(state
->bs
)) {
748 error_setg(errp
, "Cannot open a read-only mount as read-write");
752 if ((state
->flags
& BDRV_O_NOCACHE
) && client
->cache_used
) {
753 error_setg(errp
, "Cannot disable cache if libnfs readahead or"
754 " pagecache is enabled");
758 /* Update cache for read-only reopens */
759 if (!(state
->flags
& BDRV_O_RDWR
)) {
760 ret
= nfs_fstat(client
->context
, client
->fh
, &st
);
762 error_setg(errp
, "Failed to fstat file: %s",
763 nfs_get_error(client
->context
));
766 client
->st_blocks
= st
.st_blocks
;
772 static void nfs_refresh_filename(BlockDriverState
*bs
, QDict
*options
)
774 NFSClient
*client
= bs
->opaque
;
775 QDict
*opts
= qdict_new();
776 QObject
*server_qdict
;
779 qdict_put(opts
, "driver", qstring_from_str("nfs"));
781 if (client
->uid
&& !client
->gid
) {
782 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
783 "nfs://%s%s?uid=%" PRId64
, client
->server
->host
, client
->path
,
785 } else if (!client
->uid
&& client
->gid
) {
786 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
787 "nfs://%s%s?gid=%" PRId64
, client
->server
->host
, client
->path
,
789 } else if (client
->uid
&& client
->gid
) {
790 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
791 "nfs://%s%s?uid=%" PRId64
"&gid=%" PRId64
,
792 client
->server
->host
, client
->path
, client
->uid
, client
->gid
);
794 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
795 "nfs://%s%s", client
->server
->host
, client
->path
);
798 ov
= qobject_output_visitor_new(&server_qdict
);
799 visit_type_NFSServer(ov
, NULL
, &client
->server
, &error_abort
);
800 visit_complete(ov
, &server_qdict
);
801 assert(qobject_type(server_qdict
) == QTYPE_QDICT
);
803 qdict_put_obj(opts
, "server", server_qdict
);
804 qdict_put(opts
, "path", qstring_from_str(client
->path
));
807 qdict_put(opts
, "user", qint_from_int(client
->uid
));
810 qdict_put(opts
, "group", qint_from_int(client
->gid
));
812 if (client
->tcp_syncnt
) {
813 qdict_put(opts
, "tcp-syn-cnt",
814 qint_from_int(client
->tcp_syncnt
));
816 if (client
->readahead
) {
817 qdict_put(opts
, "readahead-size",
818 qint_from_int(client
->readahead
));
820 if (client
->pagecache
) {
821 qdict_put(opts
, "page-cache-size",
822 qint_from_int(client
->pagecache
));
825 qdict_put(opts
, "debug", qint_from_int(client
->debug
));
830 bs
->full_open_options
= opts
;
833 #ifdef LIBNFS_FEATURE_PAGECACHE
834 static void nfs_invalidate_cache(BlockDriverState
*bs
,
837 NFSClient
*client
= bs
->opaque
;
838 nfs_pagecache_invalidate(client
->context
, client
->fh
);
842 static BlockDriver bdrv_nfs
= {
843 .format_name
= "nfs",
844 .protocol_name
= "nfs",
846 .instance_size
= sizeof(NFSClient
),
847 .bdrv_parse_filename
= nfs_parse_filename
,
848 .create_opts
= &nfs_create_opts
,
850 .bdrv_has_zero_init
= nfs_has_zero_init
,
851 .bdrv_get_allocated_file_size
= nfs_get_allocated_file_size
,
852 .bdrv_truncate
= nfs_file_truncate
,
854 .bdrv_file_open
= nfs_file_open
,
855 .bdrv_close
= nfs_file_close
,
856 .bdrv_create
= nfs_file_create
,
857 .bdrv_reopen_prepare
= nfs_reopen_prepare
,
859 .bdrv_co_readv
= nfs_co_readv
,
860 .bdrv_co_writev
= nfs_co_writev
,
861 .bdrv_co_flush_to_disk
= nfs_co_flush
,
863 .bdrv_detach_aio_context
= nfs_detach_aio_context
,
864 .bdrv_attach_aio_context
= nfs_attach_aio_context
,
865 .bdrv_refresh_filename
= nfs_refresh_filename
,
867 #ifdef LIBNFS_FEATURE_PAGECACHE
868 .bdrv_invalidate_cache
= nfs_invalidate_cache
,
872 static void nfs_block_init(void)
874 bdrv_register(&bdrv_nfs
);
877 block_init(nfs_block_init
);