Print this page
4012 Upper limit of zfs set bounds check for refreservation on volumes is too low

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zfs/zfs_main.c
          +++ new/usr/src/cmd/zfs/zfs_main.c
↓ open down ↓ 774 lines elided ↑ open up ↑
 775  775          }
 776  776  
 777  777          if (type == ZFS_TYPE_VOLUME && !noreserve) {
 778  778                  zpool_handle_t *zpool_handle;
 779  779                  nvlist_t *real_props;
 780  780                  uint64_t spa_version;
 781  781                  char *p;
 782  782                  zfs_prop_t resv_prop;
 783  783                  char *strval;
 784  784                  char msg[1024];
      785 +                uint64_t volblocksize;
      786 +                int ncopies;
 785  787  
 786  788                  if (p = strchr(argv[0], '/'))
 787  789                          *p = '\0';
 788  790                  zpool_handle = zpool_open(g_zfs, argv[0]);
 789  791                  if (p != NULL)
 790  792                          *p = '/';
 791  793                  if (zpool_handle == NULL)
 792  794                          goto error;
 793  795                  spa_version = zpool_get_prop_int(zpool_handle,
 794  796                      ZPOOL_PROP_VERSION, NULL);
↓ open down ↓ 2 lines elided ↑ open up ↑
 797  799                          resv_prop = ZFS_PROP_REFRESERVATION;
 798  800                  else
 799  801                          resv_prop = ZFS_PROP_RESERVATION;
 800  802  
 801  803                  (void) snprintf(msg, sizeof (msg),
 802  804                      gettext("cannot create '%s'"), argv[0]);
 803  805                  if (props && (real_props = zfs_valid_proplist(g_zfs, type,
 804  806                      props, 0, NULL, msg)) == NULL)
 805  807                          goto error;
 806  808  
 807      -                volsize = zvol_volsize_to_reservation(volsize, real_props);
      809 +                if (nvlist_lookup_string(real_props,
      810 +                    zfs_prop_to_name(ZFS_PROP_COPIES), &strval) == 0)
      811 +                        ncopies = atoi(strval);
      812 +                else
      813 +                        ncopies = 1;
      814 +                if (nvlist_lookup_uint64(real_props,
      815 +                    zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE),
      816 +                    &volblocksize) != 0)
      817 +                        volblocksize = ZVOL_DEFAULT_BLOCKSIZE;
      818 +
      819 +                volsize = zvol_volsize_to_reservation_impl(volsize,
      820 +                    volblocksize, ncopies);
 808  821                  nvlist_free(real_props);
 809  822  
 810  823                  if (nvlist_lookup_string(props, zfs_prop_to_name(resv_prop),
 811  824                      &strval) != 0) {
 812  825                          if (nvlist_add_uint64(props,
 813  826                              zfs_prop_to_name(resv_prop), volsize) != 0) {
 814  827                                  nvlist_free(props);
 815  828                                  nomem();
 816  829                          }
 817  830                  }
↓ open down ↓ 5803 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX