]> git.proxmox.com Git - mirror_zfs.git/blobdiff - lib/libzfs/libzfs_pool.c
Implemented zpool sync command
[mirror_zfs.git] / lib / libzfs / libzfs_pool.c
index 28ccf8f4d62e28443952774315f1183c7093074a..f36c65fda9557c4a6bf8d812b85972ba2de68c68 100644 (file)
@@ -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.