mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 10:54:35 +03:00
zfs_create: round up volume size to multiple of bs
Round up the volume size requested in `zfs create -V size` to the next higher multiple of the volblocksize. Updates the man page and adds a test to verify the new behavior. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reported-by: puffi <puffi@users.noreply.github.com> Signed-off-by: Alex John <alex@stty.io> Closes #8541 Closes #10196
This commit is contained in:
@@ -1038,6 +1038,31 @@ zfs_do_create(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* if volsize is not a multiple of volblocksize, round it up to the
|
||||
* nearest multiple of the volblocksize
|
||||
*/
|
||||
if (type == ZFS_TYPE_VOLUME) {
|
||||
uint64_t volblocksize;
|
||||
|
||||
if (nvlist_lookup_uint64(props,
|
||||
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE),
|
||||
&volblocksize) != 0)
|
||||
volblocksize = ZVOL_DEFAULT_BLOCKSIZE;
|
||||
|
||||
if (volsize % volblocksize) {
|
||||
volsize = P2ROUNDUP_TYPED(volsize, volblocksize,
|
||||
uint64_t);
|
||||
|
||||
if (nvlist_add_uint64(props,
|
||||
zfs_prop_to_name(ZFS_PROP_VOLSIZE), volsize) != 0) {
|
||||
nvlist_free(props);
|
||||
nomem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (type == ZFS_TYPE_VOLUME && !noreserve) {
|
||||
uint64_t spa_version;
|
||||
zfs_prop_t resv_prop;
|
||||
|
||||
Reference in New Issue
Block a user