Print this page
6536 zfs send: want a way to disable sending of free records
Reviewed by: Alexander Stetsenko <astetsenko@racktopsystems.com>
Reviewed by: Kim Shrier <kshrier@racktopsystems.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/zfs_ioctl.c
          +++ new/usr/src/uts/common/fs/zfs/zfs_ioctl.c
↓ open down ↓ 20 lines elided ↑ open up ↑
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Portions Copyright 2011 Martin Matuska
  25   25   * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
  26   26   * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  27   27   * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  28   28   * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
  29   29   * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
  30   30   * Copyright (c) 2013 Steven Hartland. All rights reserved.
       31 + * Copyright 2015 RackTop Systems.
  31   32   */
  32   33  
  33   34  /*
  34   35   * ZFS ioctls.
  35   36   *
  36   37   * This file handles the ioctls to /dev/zfs, used for configuring ZFS storage
  37   38   * pools and filesystems, e.g. with /sbin/zfs and /sbin/zpool.
  38   39   *
  39   40   * There are two ways that we handle ioctls: the legacy way where almost
  40   41   * all of the logic is in the ioctl callback, and the new way where most
↓ open down ↓ 4357 lines elided ↑ open up ↑
4398 4399   * zc_objset_type       estimated size, if zc_guid is set
4399 4400   */
4400 4401  static int
4401 4402  zfs_ioc_send(zfs_cmd_t *zc)
4402 4403  {
4403 4404          int error;
4404 4405          offset_t off;
4405 4406          boolean_t estimate = (zc->zc_guid != 0);
4406 4407          boolean_t embedok = (zc->zc_flags & 0x1);
4407 4408          boolean_t large_block_ok = (zc->zc_flags & 0x2);
     4409 +        boolean_t skip_free = (zc->zc_flags & 0x4);
4408 4410  
4409 4411          if (zc->zc_obj != 0) {
4410 4412                  dsl_pool_t *dp;
4411 4413                  dsl_dataset_t *tosnap;
4412 4414  
4413 4415                  error = dsl_pool_hold(zc->zc_name, FTAG, &dp);
4414 4416                  if (error != 0)
4415 4417                          return (error);
4416 4418  
4417 4419                  error = dsl_dataset_hold_obj(dp, zc->zc_sendobj, FTAG, &tosnap);
↓ open down ↓ 42 lines elided ↑ open up ↑
4460 4462                  dsl_dataset_rele(tosnap, FTAG);
4461 4463                  dsl_pool_rele(dp, FTAG);
4462 4464          } else {
4463 4465                  file_t *fp = getf(zc->zc_cookie);
4464 4466                  if (fp == NULL)
4465 4467                          return (SET_ERROR(EBADF));
4466 4468  
4467 4469                  off = fp->f_offset;
4468 4470                  error = dmu_send_obj(zc->zc_name, zc->zc_sendobj,
4469 4471                      zc->zc_fromobj, embedok, large_block_ok,
4470      -                    zc->zc_cookie, fp->f_vnode, &off);
     4472 +                    skip_free, zc->zc_cookie, fp->f_vnode, &off);
4471 4473  
4472 4474                  if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0)
4473 4475                          fp->f_offset = off;
4474 4476                  releasef(zc->zc_cookie);
4475 4477          }
4476 4478          return (error);
4477 4479  }
4478 4480  
4479 4481  /*
4480 4482   * inputs:
↓ open down ↓ 908 lines elided ↑ open up ↑
5389 5391  }
5390 5392  
5391 5393  /*
5392 5394   * innvl: {
5393 5395   *     "fd" -> file descriptor to write stream to (int32)
5394 5396   *     (optional) "fromsnap" -> full snap name to send an incremental from
5395 5397   *     (optional) "largeblockok" -> (value ignored)
5396 5398   *         indicates that blocks > 128KB are permitted
5397 5399   *     (optional) "embedok" -> (value ignored)
5398 5400   *         presence indicates DRR_WRITE_EMBEDDED records are permitted
     5401 + *     (optional) "skipfree" -> (value ignored)
     5402 + *         presence indicates free records should be omitted
5399 5403   *     (optional) "resume_object" and "resume_offset" -> (uint64)
5400 5404   *         if present, resume send stream from specified object and offset.
5401 5405   * }
5402 5406   *
5403 5407   * outnvl is unused
5404 5408   */
5405 5409  /* ARGSUSED */
5406 5410  static int
5407 5411  zfs_ioc_send_new(const char *snapname, nvlist_t *innvl, nvlist_t *outnvl)
5408 5412  {
5409 5413          int error;
5410 5414          offset_t off;
5411 5415          char *fromname = NULL;
5412 5416          int fd;
5413 5417          boolean_t largeblockok;
5414 5418          boolean_t embedok;
     5419 +        boolean_t skipfree;
5415 5420          uint64_t resumeobj = 0;
5416 5421          uint64_t resumeoff = 0;
5417 5422  
5418 5423          error = nvlist_lookup_int32(innvl, "fd", &fd);
5419 5424          if (error != 0)
5420 5425                  return (SET_ERROR(EINVAL));
5421 5426  
5422 5427          (void) nvlist_lookup_string(innvl, "fromsnap", &fromname);
5423 5428  
5424 5429          largeblockok = nvlist_exists(innvl, "largeblockok");
5425 5430          embedok = nvlist_exists(innvl, "embedok");
     5431 +        skipfree = nvlist_exists(innvl, "skipfree");
5426 5432  
5427 5433          (void) nvlist_lookup_uint64(innvl, "resume_object", &resumeobj);
5428 5434          (void) nvlist_lookup_uint64(innvl, "resume_offset", &resumeoff);
5429 5435  
5430 5436          file_t *fp = getf(fd);
5431 5437          if (fp == NULL)
5432 5438                  return (SET_ERROR(EBADF));
5433 5439  
5434 5440          off = fp->f_offset;
5435      -        error = dmu_send(snapname, fromname, embedok, largeblockok, fd,
5436      -            resumeobj, resumeoff, fp->f_vnode, &off);
     5441 +        error = dmu_send(snapname, fromname, embedok, largeblockok, skipfree,
     5442 +            fd, resumeobj, resumeoff, fp->f_vnode, &off);
5437 5443  
5438 5444          if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0)
5439 5445                  fp->f_offset = off;
5440 5446          releasef(fd);
5441 5447          return (error);
5442 5448  }
5443 5449  
5444 5450  /*
5445 5451   * Determine approximately how large a zfs send stream will be -- the number
5446 5452   * of bytes that will be written to the fd supplied to zfs_ioc_send_new().
↓ open down ↓ 838 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX