mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
Implemented zpool sync command
This addition will enable us to sync an open TXG to the main pool on demand. The functionality is similar to 'sync(2)' but 'zpool sync' will return when data has hit the main storage instead of potentially just the ZIL as is the case with the 'sync(2)' cmd. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Signed-off-by: Alek Pinchuk <apinchuk@datto.com> Closes #6122
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
|
||||
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
|
||||
* Copyright (c) 2017 Datto Inc.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
@@ -3288,6 +3289,27 @@ zpool_reopen(zpool_handle_t *zhp)
|
||||
return (zpool_standard_error(hdl, errno, msg));
|
||||
}
|
||||
|
||||
/* call into libzfs_core to execute the sync IOCTL per pool */
|
||||
int
|
||||
zpool_sync_one(zpool_handle_t *zhp, void *data)
|
||||
{
|
||||
int ret;
|
||||
libzfs_handle_t *hdl = zpool_get_handle(zhp);
|
||||
const char *pool_name = zpool_get_name(zhp);
|
||||
boolean_t *force = data;
|
||||
nvlist_t *innvl = fnvlist_alloc();
|
||||
|
||||
fnvlist_add_boolean_value(innvl, "force", *force);
|
||||
if ((ret = lzc_sync(pool_name, innvl, NULL)) != 0) {
|
||||
nvlist_free(innvl);
|
||||
return (zpool_standard_error_fmt(hdl, ret,
|
||||
dgettext(TEXT_DOMAIN, "sync '%s' failed"), pool_name));
|
||||
}
|
||||
nvlist_free(innvl);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if defined(__sun__) || defined(__sun)
|
||||
/*
|
||||
* Convert from a devid string to a path.
|
||||
|
||||
Reference in New Issue
Block a user