diff options
author | Brian Behlendorf <[email protected]> | 2015-08-24 14:18:48 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2015-08-28 09:25:03 -0700 |
commit | 4cb7b9c5d42c831878e0cf90c845ed52a2a34d72 (patch) | |
tree | 597faf8d885ecc2defc14a9db674926488323f35 /module/zfs/zvol.c | |
parent | c495fe2c1c6b1c63aefcd832e2e0eb0a20d4c4dc (diff) |
Check large block feature flag on volumes
Since ZoL allows large blocks to be used by volumes, unlike upstream
illumos, the feature flag must be checked prior to volume creation.
This is critical because unlike filesystems, volumes will create a
object which uses large blocks as part of the create. Therefore, it
cannot be safely checked in zfs_check_settable() after the dataset
can been created.
In addition this patch updates the relevant error messages to use
zfs_nicenum() to print the maximum blocksize.
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #3591
Diffstat (limited to 'module/zfs/zvol.c')
-rw-r--r-- | module/zfs/zvol.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c index 2b99f44de..3cce00fb6 100644 --- a/module/zfs/zvol.c +++ b/module/zfs/zvol.c @@ -40,6 +40,7 @@ #include <sys/dsl_dataset.h> #include <sys/dsl_prop.h> #include <sys/zap.h> +#include <sys/zfeature.h> #include <sys/zil_impl.h> #include <sys/zio.h> #include <sys/zfs_rlock.h> @@ -380,8 +381,31 @@ out: * Sanity check volume block size. */ int -zvol_check_volblocksize(uint64_t volblocksize) +zvol_check_volblocksize(const char *name, uint64_t volblocksize) { + /* Record sizes above 128k need the feature to be enabled */ + if (volblocksize > SPA_OLD_MAXBLOCKSIZE) { + spa_t *spa; + int error; + + if ((error = spa_open(name, &spa, FTAG)) != 0) + return (error); + + if (!spa_feature_is_enabled(spa, SPA_FEATURE_LARGE_BLOCKS)) { + spa_close(spa, FTAG); + return (SET_ERROR(ENOTSUP)); + } + + /* + * We don't allow setting the property above 1MB, + * unless the tunable has been changed. + */ + if (volblocksize > zfs_max_recordsize) + return (SET_ERROR(EDOM)); + + spa_close(spa, FTAG); + } + if (volblocksize < SPA_MINBLOCKSIZE || volblocksize > SPA_MAXBLOCKSIZE || !ISP2(volblocksize)) |