Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3502596pxj; Mon, 7 Jun 2021 12:17:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxICldKkPB4bChpvTBvuRMeC8ovqlc75i4mwS9zlUY34BfMm1XPWZg6FbJqq0tAWyDED898 X-Received: by 2002:a17:907:33d0:: with SMTP id zk16mr19260299ejb.144.1623093445651; Mon, 07 Jun 2021 12:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623093445; cv=none; d=google.com; s=arc-20160816; b=HSdNfd0cRZ+i4RnuwnidvMh152YOaoBdMnnQcAin3btwEY3PymkR578EUH5QoB6Qeo cVL8a9S2lFmBu0cpE8rTylhL7tvCTBc7uSPePbJrO6in014AqIA7zZsVEl0/hlwoVJW1 46GDjTWTAX1En87Mi+PXgmOf0GMd9UW3CNFFOvqHXJmRGbmrQiFxHUCMerBYumjjbxPm LFMpXpx1Ybt1KFL+bX7fT5xo78wOrVk5XBob07If/fbJD0i8Rwhkmqi4Gx5quxkfkfka RFSDykqqJe1+HvufOV2z9ERax6XNhP751RjiMrEMK5tbjVyhdBulomA5OVsIDBJWI5/m D/5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=QFIu4MlrM4IRUGCFVkosaV7dehWqEzpaQ1JMIHrGrbg=; b=KSLkzzz440rvMfW85rcdmp5Q8S82kavf4a0Cq/aHAQLWijnHiUacloiqUzOvoszQAi F5LVKzT6kDgsnKbMtmklXHsFUzqC3e/2CHXvWNosuxHCzTTA1hXDmNM1pQB1svGBYEK4 wm7WfCvNe2C8cDShRuU3FgapMQUKu2gUo0oSftUceyKjMX/WAsJxwPzMyjSiD6+VbTSj KrqsCfYGLx+uFBSx2c3PFX94gZYvKKeid54ov14NifIIzpD7bR6UKKyUfIf8iAKGvCDg Ns0ZRW+h+c5vLSvhPTQHGFk/oIWx6tT8Du0z3phB+M70X+ngxQGoyD6I8rKnZRa2fVsw 6ilA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id da5si12472853edb.538.2021.06.07.12.17.00; Mon, 07 Jun 2021 12:17:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231409AbhFGTRV (ORCPT + 99 others); Mon, 7 Jun 2021 15:17:21 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:48987 "EHLO relay8-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230282AbhFGTRU (ORCPT ); Mon, 7 Jun 2021 15:17:20 -0400 Received: (Authenticated sender: josh@joshtriplett.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 71F391BF205; Mon, 7 Jun 2021 19:15:26 +0000 (UTC) Date: Mon, 7 Jun 2021 12:15:24 -0700 From: Josh Triplett To: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Dilger , Theodore Ts'o Subject: [PATCH 2/2] fs: ext4: Add check to prevent attempting to resize an fs with sparse_super2 Message-ID: <74b8ae78405270211943cd7393e65586c5faeed1.1623093259.git.josh@joshtriplett.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org The in-kernel ext4 resize code doesn't support filesystem with the sparse_super2 feature. It fails with errors like this and doesn't finish the resize: EXT4-fs (loop0): resizing filesystem from 16640 to 7864320 blocks EXT4-fs warning (device loop0): verify_reserved_gdb:760: reserved GDT 2 missing grp 1 (32770) EXT4-fs warning (device loop0): ext4_resize_fs:2111: error (-22) occurred during file system resize EXT4-fs (loop0): resized filesystem to 2097152 To reproduce: mkfs.ext4 -b 4096 -I 256 -J size=32 -E resize=$((256*1024*1024)) -O sparse_super2 ext4.img 65M truncate -s 30G ext4.img mount ext4.img /mnt python3 -c 'import fcntl, os, struct ; fd = os.open("/mnt", os.O_RDONLY | os.O_DIRECTORY) ; fcntl.ioctl(fd, 0x40086610, struct.pack("Q", 30 * 1024 * 1024 * 1024 // 4096), False) ; os.close(fd)' dmesg | tail e2fsck ext4.img The userspace resize2fs tool has a check for this case: it checks if the filesystem has sparse_super2 set and if the kernel provides /sys/fs/ext4/features/sparse_super2. However, the former check requires manually reading and parsing the filesystem superblock. Detect this case in ext4_resize_begin and error out early with a clear error message. Signed-off-by: Josh Triplett --- fs/ext4/resize.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index d13bb9e76482..fc885914c88a 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -78,6 +78,10 @@ int ext4_resize_begin(struct super_block *sb) ext4_msg(sb, KERN_ERR, "Online resizing not supported with bigalloc"); return -EOPNOTSUPP; } + if (ext4_has_feature_sparse_super2(sb)) { + ext4_msg(sb, KERN_ERR, "Online resizing not supported with sparse_super2"); + return -EOPNOTSUPP; + } if (test_and_set_bit_lock(EXT4_FLAGS_RESIZING, &EXT4_SB(sb)->s_ext4_flags)) -- 2.32.0.rc2