@@ -37,6 +37,7 @@ extern int optind;
#include "../version.h"
char *program_name, *device_name, *io_options;
+int meta_bg_resizing;
static void usage (char *prog)
{
@@ -187,6 +188,10 @@ int main (int argc, char ** argv)
if (argc && *argv)
program_name = *argv;
+ if ((access("/sys/fs/ext4/features/meta_bg_resize", R_OK) == 0) &&
+ !getenv("RESIZE2FS_NO_META_BG_RESIZE"))
+ meta_bg_resizing = 1;
+
while ((c = getopt (argc, argv, "d:fFhMPpS:")) != EOF) {
switch (c) {
case 'h':
@@ -385,19 +390,24 @@ int main (int argc, char ** argv)
exit(1);
}
} else {
- /* Take down devices exactly 16T to 2^32-1 blocks */
- if (max_size == (1ULL << 32))
- max_size--;
- else if (max_size > (1ULL << 32)) {
- com_err(program_name, 0, _("New size too large to be "
- "expressed in 32 bits\n"));
- exit(1);
- }
new_size = max_size;
/* Round down to an even multiple of a pagesize */
if (sys_page_size > fs->blocksize)
new_size &= ~((sys_page_size / fs->blocksize)-1);
}
+ if (!EXT2_HAS_INCOMPAT_FEATURE(fs->super,
+ EXT4_FEATURE_INCOMPAT_64BIT) ||
+ !meta_bg_resizing) {
+ /* Take 16T down to 2^32-1 blocks */
+ if (new_size == (1ULL << 32))
+ new_size--;
+ else if (new_size > (1ULL << 32)) {
+ com_err(program_name, 0,
+ _("New size too large to be "
+ "expressed in 32 bits\n"));
+ exit(1);
+ }
+ }
if (!force && new_size < min_size) {
com_err(program_name, 0,
@@ -81,6 +81,11 @@ typedef struct ext2_sim_progress *ext2_sim_progmeter;
#define RESIZE_VERBOSE 0x0200
/*
+ * Is meta_bg resizing supported by the kernel?
+ */
+extern int meta_bg_resizing;
+
+/*
* The core state structure for the ext2 resizer
*/
typedef struct ext2_resize_struct *ext2_resize_t;
The 16TB limit must be enforced regardless of whether the new size is specified on the command line or implied by the size of the device, but only if the file system does not support 64-bit block sizes, or the kernel does not advertise support of meta_bg resizing. Previously we were unconditionally enforcing it when it was implied by the device size, but not if the new size was specified on the command line. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> --- resize/main.c | 26 ++++++++++++++++++-------- resize/resize2fs.h | 5 +++++ 2 files changed, 23 insertions(+), 8 deletions(-)