Print this page
3740 Poor ZFS send / receive performance due to snapshot hold / release processing
Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
   1 /*
   2  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2013 by Delphix. All rights reserved.

   4  */
   5 
   6 /*
   7  * BSD 3 Clause License
   8  *
   9  * Copyright (c) 2007, The Storage Networking Industry Association.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  *      - Redistributions of source code must retain the above copyright
  15  *        notice, this list of conditions and the following disclaimer.
  16  *
  17  *      - Redistributions in binary form must reproduce the above copyright
  18  *        notice, this list of conditions and the following disclaimer in
  19  *        the documentation and/or other materials provided with the
  20  *        distribution.
  21  *
  22  *      - Neither the name of The Storage Networking Industry Association (SNIA)
  23  *        nor the names of its contributors may be used to endorse or promote


 186  */
 187 int
 188 snapshot_hold(char *volname, char *snapname, char *jname, boolean_t recursive)
 189 {
 190         zfs_handle_t *zhp;
 191         char *p;
 192 
 193         if ((zhp = zfs_open(zlibh, volname, ZFS_TYPE_DATASET)) == 0) {
 194                 NDMP_LOG(LOG_ERR, "Cannot open volume %s.", volname);
 195                 return (-1);
 196         }
 197 
 198         if (cleanup_fd == -1 && (cleanup_fd = open(ZFS_DEV,
 199             O_RDWR|O_EXCL)) < 0) {
 200                 NDMP_LOG(LOG_ERR, "Cannot open dev %d", errno);
 201                 zfs_close(zhp);
 202                 return (-1);
 203         }
 204 
 205         p = strchr(snapname, '@') + 1;
 206         if (zfs_hold(zhp, p, jname, recursive, B_FALSE, cleanup_fd) != 0) {
 207                 NDMP_LOG(LOG_ERR, "Cannot hold snapshot %s", p);
 208                 zfs_close(zhp);
 209                 return (-1);
 210         }
 211         zfs_close(zhp);
 212         return (0);
 213 }
 214 
 215 int
 216 snapshot_release(char *volname, char *snapname, char *jname,
 217     boolean_t recursive)
 218 {
 219         zfs_handle_t *zhp;
 220         char *p;
 221         int rv = 0;
 222 
 223         if ((zhp = zfs_open(zlibh, volname, ZFS_TYPE_DATASET)) == 0) {
 224                 NDMP_LOG(LOG_ERR, "Cannot open volume %s", volname);
 225                 return (-1);
 226         }


   1 /*
   2  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2013 by Delphix. All rights reserved.
   4  * Copyright (c) 2013 Steven Hartland. All rights reserved.
   5  */
   6 
   7 /*
   8  * BSD 3 Clause License
   9  *
  10  * Copyright (c) 2007, The Storage Networking Industry Association.
  11  *
  12  * Redistribution and use in source and binary forms, with or without
  13  * modification, are permitted provided that the following conditions
  14  * are met:
  15  *      - Redistributions of source code must retain the above copyright
  16  *        notice, this list of conditions and the following disclaimer.
  17  *
  18  *      - Redistributions in binary form must reproduce the above copyright
  19  *        notice, this list of conditions and the following disclaimer in
  20  *        the documentation and/or other materials provided with the
  21  *        distribution.
  22  *
  23  *      - Neither the name of The Storage Networking Industry Association (SNIA)
  24  *        nor the names of its contributors may be used to endorse or promote


 187  */
 188 int
 189 snapshot_hold(char *volname, char *snapname, char *jname, boolean_t recursive)
 190 {
 191         zfs_handle_t *zhp;
 192         char *p;
 193 
 194         if ((zhp = zfs_open(zlibh, volname, ZFS_TYPE_DATASET)) == 0) {
 195                 NDMP_LOG(LOG_ERR, "Cannot open volume %s.", volname);
 196                 return (-1);
 197         }
 198 
 199         if (cleanup_fd == -1 && (cleanup_fd = open(ZFS_DEV,
 200             O_RDWR|O_EXCL)) < 0) {
 201                 NDMP_LOG(LOG_ERR, "Cannot open dev %d", errno);
 202                 zfs_close(zhp);
 203                 return (-1);
 204         }
 205 
 206         p = strchr(snapname, '@') + 1;
 207         if (zfs_hold(zhp, p, jname, recursive, cleanup_fd) != 0) {
 208                 NDMP_LOG(LOG_ERR, "Cannot hold snapshot %s", p);
 209                 zfs_close(zhp);
 210                 return (-1);
 211         }
 212         zfs_close(zhp);
 213         return (0);
 214 }
 215 
 216 int
 217 snapshot_release(char *volname, char *snapname, char *jname,
 218     boolean_t recursive)
 219 {
 220         zfs_handle_t *zhp;
 221         char *p;
 222         int rv = 0;
 223 
 224         if ((zhp = zfs_open(zlibh, volname, ZFS_TYPE_DATASET)) == 0) {
 225                 NDMP_LOG(LOG_ERR, "Cannot open volume %s", volname);
 226                 return (-1);
 227         }