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>


   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  25  * Copyright (c) 2012 by Delphix. All rights reserved.
  26  * Copyright 2012 Milan Jurik. All rights reserved.
  27  * Copyright (c) 2012, Joyent, Inc. All rights reserved.

  28  */
  29 
  30 #include <assert.h>
  31 #include <ctype.h>
  32 #include <errno.h>
  33 #include <libgen.h>
  34 #include <libintl.h>
  35 #include <libuutil.h>
  36 #include <libnvpair.h>
  37 #include <locale.h>
  38 #include <stddef.h>
  39 #include <stdio.h>
  40 #include <stdlib.h>
  41 #include <strings.h>
  42 #include <unistd.h>
  43 #include <fcntl.h>
  44 #include <zone.h>
  45 #include <grp.h>
  46 #include <pwd.h>
  47 #include <signal.h>


5147                 const char *delim;
5148                 char *path = argv[i];
5149 
5150                 delim = strchr(path, '@');
5151                 if (delim == NULL) {
5152                         (void) fprintf(stderr,
5153                             gettext("'%s' is not a snapshot\n"), path);
5154                         ++errors;
5155                         continue;
5156                 }
5157                 (void) strncpy(parent, path, delim - path);
5158                 parent[delim - path] = '\0';
5159 
5160                 zhp = zfs_open(g_zfs, parent,
5161                     ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME);
5162                 if (zhp == NULL) {
5163                         ++errors;
5164                         continue;
5165                 }
5166                 if (holding) {
5167                         if (zfs_hold(zhp, delim+1, tag, recursive,
5168                             B_FALSE, -1) != 0)
5169                                 ++errors;
5170                 } else {
5171                         if (zfs_release(zhp, delim+1, tag, recursive) != 0)
5172                                 ++errors;
5173                 }
5174                 zfs_close(zhp);
5175         }
5176 
5177         return (errors != 0);
5178 }
5179 
5180 /*
5181  * zfs hold [-r] [-t] <tag> <snap> ...
5182  *
5183  *      -r      Recursively hold
5184  *
5185  * Apply a user-hold with the given tag to the list of snapshots.
5186  */
5187 static int
5188 zfs_do_hold(int argc, char **argv)




   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  25  * Copyright (c) 2012 by Delphix. All rights reserved.
  26  * Copyright 2012 Milan Jurik. All rights reserved.
  27  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  28  * Copyright (c) 2013 Steven Hartland.  All rights reserved.
  29  */
  30 
  31 #include <assert.h>
  32 #include <ctype.h>
  33 #include <errno.h>
  34 #include <libgen.h>
  35 #include <libintl.h>
  36 #include <libuutil.h>
  37 #include <libnvpair.h>
  38 #include <locale.h>
  39 #include <stddef.h>
  40 #include <stdio.h>
  41 #include <stdlib.h>
  42 #include <strings.h>
  43 #include <unistd.h>
  44 #include <fcntl.h>
  45 #include <zone.h>
  46 #include <grp.h>
  47 #include <pwd.h>
  48 #include <signal.h>


5148                 const char *delim;
5149                 char *path = argv[i];
5150 
5151                 delim = strchr(path, '@');
5152                 if (delim == NULL) {
5153                         (void) fprintf(stderr,
5154                             gettext("'%s' is not a snapshot\n"), path);
5155                         ++errors;
5156                         continue;
5157                 }
5158                 (void) strncpy(parent, path, delim - path);
5159                 parent[delim - path] = '\0';
5160 
5161                 zhp = zfs_open(g_zfs, parent,
5162                     ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME);
5163                 if (zhp == NULL) {
5164                         ++errors;
5165                         continue;
5166                 }
5167                 if (holding) {
5168                         if (zfs_hold(zhp, delim+1, tag, recursive, -1) != 0)

5169                                 ++errors;
5170                 } else {
5171                         if (zfs_release(zhp, delim+1, tag, recursive) != 0)
5172                                 ++errors;
5173                 }
5174                 zfs_close(zhp);
5175         }
5176 
5177         return (errors != 0);
5178 }
5179 
5180 /*
5181  * zfs hold [-r] [-t] <tag> <snap> ...
5182  *
5183  *      -r      Recursively hold
5184  *
5185  * Apply a user-hold with the given tag to the list of snapshots.
5186  */
5187 static int
5188 zfs_do_hold(int argc, char **argv)