4411 case ENOTSUP:
4412 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
4413 "pool must be upgraded"));
4414 err = zfs_error(hdl, EZFS_BADVERSION, errbuf);
4415 break;
4416 case EINVAL:
4417 err = zfs_error(hdl, EZFS_BADTYPE, errbuf);
4418 break;
4419 case ENOENT:
4420 err = zfs_error(hdl, EZFS_NOENT, errbuf);
4421 break;
4422 default:
4423 err = zfs_standard_error_fmt(hdl, errno, errbuf);
4424 break;
4425 }
4426 }
4427
4428 return (err);
4429 }
4430
4431 uint64_t
4432 zvol_volsize_to_reservation(uint64_t volsize, nvlist_t *props)
4433 {
4434 uint64_t numdb;
4435 uint64_t nblocks, volblocksize;
4436 int ncopies;
4437 char *strval;
4438
4439 if (nvlist_lookup_string(props,
4440 zfs_prop_to_name(ZFS_PROP_COPIES), &strval) == 0)
4441 ncopies = atoi(strval);
4442 else
4443 ncopies = 1;
4444 if (nvlist_lookup_uint64(props,
4445 zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE),
4446 &volblocksize) != 0)
4447 volblocksize = ZVOL_DEFAULT_BLOCKSIZE;
4448 nblocks = volsize/volblocksize;
4449 /* start with metadnode L0-L6 */
4450 numdb = 7;
|
4411 case ENOTSUP:
4412 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
4413 "pool must be upgraded"));
4414 err = zfs_error(hdl, EZFS_BADVERSION, errbuf);
4415 break;
4416 case EINVAL:
4417 err = zfs_error(hdl, EZFS_BADTYPE, errbuf);
4418 break;
4419 case ENOENT:
4420 err = zfs_error(hdl, EZFS_NOENT, errbuf);
4421 break;
4422 default:
4423 err = zfs_standard_error_fmt(hdl, errno, errbuf);
4424 break;
4425 }
4426 }
4427
4428 return (err);
4429 }
4430
4431 /*
4432 * Convert the zvol's volume size to an appropriate reservation.
4433 * Note: If this routine is updated, it is necessary to update the ZFS test
4434 * suite's shell version in reservation.kshlib.
4435 */
4436 uint64_t
4437 zvol_volsize_to_reservation(uint64_t volsize, nvlist_t *props)
4438 {
4439 uint64_t numdb;
4440 uint64_t nblocks, volblocksize;
4441 int ncopies;
4442 char *strval;
4443
4444 if (nvlist_lookup_string(props,
4445 zfs_prop_to_name(ZFS_PROP_COPIES), &strval) == 0)
4446 ncopies = atoi(strval);
4447 else
4448 ncopies = 1;
4449 if (nvlist_lookup_uint64(props,
4450 zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE),
4451 &volblocksize) != 0)
4452 volblocksize = ZVOL_DEFAULT_BLOCKSIZE;
4453 nblocks = volsize/volblocksize;
4454 /* start with metadnode L0-L6 */
4455 numdb = 7;
|