From 82ec9d41d85b1643402493bf72a7e7d2896b7310 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 28 Oct 2016 23:53:24 +0000 Subject: [PATCH] Fix 32-bit maximum volume size A limit of 1TB exists for zvols on 32-bit systems. Update the code to correctly reflect this limitation in a similar manor as the OpenZFS implementation. Reviewed-by: Tom Caputi Reviewed-by: Tim Chase Signed-off-by: Brian Behlendorf Issue #5347 --- include/sys/zvol.h | 3 +++ module/zfs/zvol.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/sys/zvol.h b/include/sys/zvol.h index 00ed220d3b17..2fb20fbf9441 100644 --- a/include/sys/zvol.h +++ b/include/sys/zvol.h @@ -32,6 +32,9 @@ #define ZVOL_OBJ 1ULL #define ZVOL_ZAP_OBJ 2ULL +#define SPEC_MAXOFFSET_T ((1LL << ((NBBY * sizeof (daddr32_t)) + \ + DEV_BSHIFT - 1)) - 1) + extern void *zvol_tag; extern void zvol_create_minors(spa_t *spa, const char *name, boolean_t async); diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c index b5169baf48d0..ea6997b5b9e9 100644 --- a/module/zfs/zvol.c +++ b/module/zfs/zvol.c @@ -281,7 +281,7 @@ zvol_check_volsize(uint64_t volsize, uint64_t blocksize) return (SET_ERROR(EINVAL)); #ifdef _ILP32 - if (volsize - 1 > MAXOFFSET_T) + if (volsize - 1 > SPEC_MAXOFFSET_T) return (SET_ERROR(EOVERFLOW)); #endif return (0);