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


 765 
 766         /* check number of arguments */
 767         if (argc == 0) {
 768                 (void) fprintf(stderr, gettext("missing %s argument\n"),
 769                     zfs_type_to_name(type));
 770                 goto badusage;
 771         }
 772         if (argc > 1) {
 773                 (void) fprintf(stderr, gettext("too many arguments\n"));
 774                 goto badusage;
 775         }
 776 
 777         if (type == ZFS_TYPE_VOLUME && !noreserve) {
 778                 zpool_handle_t *zpool_handle;
 779                 nvlist_t *real_props;
 780                 uint64_t spa_version;
 781                 char *p;
 782                 zfs_prop_t resv_prop;
 783                 char *strval;
 784                 char msg[1024];


 785 
 786                 if (p = strchr(argv[0], '/'))
 787                         *p = '\0';
 788                 zpool_handle = zpool_open(g_zfs, argv[0]);
 789                 if (p != NULL)
 790                         *p = '/';
 791                 if (zpool_handle == NULL)
 792                         goto error;
 793                 spa_version = zpool_get_prop_int(zpool_handle,
 794                     ZPOOL_PROP_VERSION, NULL);
 795                 zpool_close(zpool_handle);
 796                 if (spa_version >= SPA_VERSION_REFRESERVATION)
 797                         resv_prop = ZFS_PROP_REFRESERVATION;
 798                 else
 799                         resv_prop = ZFS_PROP_RESERVATION;
 800 
 801                 (void) snprintf(msg, sizeof (msg),
 802                     gettext("cannot create '%s'"), argv[0]);
 803                 if (props && (real_props = zfs_valid_proplist(g_zfs, type,
 804                     props, 0, NULL, msg)) == NULL)
 805                         goto error;
 806 
 807                 volsize = zvol_volsize_to_reservation(volsize, real_props);











 808                 nvlist_free(real_props);
 809 
 810                 if (nvlist_lookup_string(props, zfs_prop_to_name(resv_prop),
 811                     &strval) != 0) {
 812                         if (nvlist_add_uint64(props,
 813                             zfs_prop_to_name(resv_prop), volsize) != 0) {
 814                                 nvlist_free(props);
 815                                 nomem();
 816                         }
 817                 }
 818         }
 819 
 820         if (parents && zfs_name_valid(argv[0], type)) {
 821                 /*
 822                  * Now create the ancestors of target dataset.  If the target
 823                  * already exists and '-p' option was used we should not
 824                  * complain.
 825                  */
 826                 if (zfs_dataset_exists(g_zfs, argv[0], type)) {
 827                         ret = 0;




 765 
 766         /* check number of arguments */
 767         if (argc == 0) {
 768                 (void) fprintf(stderr, gettext("missing %s argument\n"),
 769                     zfs_type_to_name(type));
 770                 goto badusage;
 771         }
 772         if (argc > 1) {
 773                 (void) fprintf(stderr, gettext("too many arguments\n"));
 774                 goto badusage;
 775         }
 776 
 777         if (type == ZFS_TYPE_VOLUME && !noreserve) {
 778                 zpool_handle_t *zpool_handle;
 779                 nvlist_t *real_props;
 780                 uint64_t spa_version;
 781                 char *p;
 782                 zfs_prop_t resv_prop;
 783                 char *strval;
 784                 char msg[1024];
 785                 uint64_t volblocksize;
 786                 int ncopies;
 787 
 788                 if (p = strchr(argv[0], '/'))
 789                         *p = '\0';
 790                 zpool_handle = zpool_open(g_zfs, argv[0]);
 791                 if (p != NULL)
 792                         *p = '/';
 793                 if (zpool_handle == NULL)
 794                         goto error;
 795                 spa_version = zpool_get_prop_int(zpool_handle,
 796                     ZPOOL_PROP_VERSION, NULL);
 797                 zpool_close(zpool_handle);
 798                 if (spa_version >= SPA_VERSION_REFRESERVATION)
 799                         resv_prop = ZFS_PROP_REFRESERVATION;
 800                 else
 801                         resv_prop = ZFS_PROP_RESERVATION;
 802 
 803                 (void) snprintf(msg, sizeof (msg),
 804                     gettext("cannot create '%s'"), argv[0]);
 805                 if (props && (real_props = zfs_valid_proplist(g_zfs, type,
 806                     props, 0, NULL, msg)) == NULL)
 807                         goto error;
 808 
 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);
 821                 nvlist_free(real_props);
 822 
 823                 if (nvlist_lookup_string(props, zfs_prop_to_name(resv_prop),
 824                     &strval) != 0) {
 825                         if (nvlist_add_uint64(props,
 826                             zfs_prop_to_name(resv_prop), volsize) != 0) {
 827                                 nvlist_free(props);
 828                                 nomem();
 829                         }
 830                 }
 831         }
 832 
 833         if (parents && zfs_name_valid(argv[0], type)) {
 834                 /*
 835                  * Now create the ancestors of target dataset.  If the target
 836                  * already exists and '-p' option was used we should not
 837                  * complain.
 838                  */
 839                 if (zfs_dataset_exists(g_zfs, argv[0], type)) {
 840                         ret = 0;