From patchwork Mon Apr 25 14:13:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1621974 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=OEiqdle0; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kn6S11VcWz9s0B for ; Tue, 26 Apr 2022 00:13:20 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nizSk-0005XA-QE; Mon, 25 Apr 2022 14:13:14 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nizSi-0005Vl-CV for kernel-team@lists.ubuntu.com; Mon, 25 Apr 2022 14:13:12 +0000 Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 0D8B83FD8D for ; Mon, 25 Apr 2022 14:13:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1650895992; bh=MKsdac8dBDi3REVQlO2Xt8G3CSiA5dYdF/+CUx6TnTU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OEiqdle0+BynfAikg/MFJWlW7WfHvNLwVW5nbki3aO/5Nz0oFhK1wOSm6ja+LJaQQ 3d/PFbM+R9gpFvBvGO0qvCrnkgexwqgqQZ56xAzZSyKJpyDfVA85K0RuPVe+cQhRHP H4mKIWtCNq5lEdPrtFqEh27Ji4mnjwuIt6jMtpyiSypy8J1Opj3jR7sGaURSbgPBjc AT99HlrJTV7VYRapoGCvnENlDqthuk5rhAIvDY502GePyD7w2zBRt9avLpzWl1v8L+ kbrO9OniTdmz9Au0Y95+voTC+IJgR+z4VHZ80ikjBrSpq1Y9DQXN31Uq2GTu50sc9X F/DDtfI7sujwQ== Received: by mail-pf1-f198.google.com with SMTP id m8-20020a62a208000000b0050593296139so10542116pff.1 for ; Mon, 25 Apr 2022 07:13:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MKsdac8dBDi3REVQlO2Xt8G3CSiA5dYdF/+CUx6TnTU=; b=Hwb9B6a5alYaqcZhpKvPnyR2ZXD170FRTjlBzBEwfzx7yE6nWtWI2K486ghlj+8LZQ 3swggSXcbGtYijbWXdlNyECE+DG06eeDmXeLztPUQRIQkCYT7wyY5pVUAx+0/GlmPrz2 xVSI/oR/z+e+zhZsXV/nsf5UVDqLY8WOris4sjJgAXPSXwSvJJJF0ENSQY5YnzRLcxGZ op+dxqoSmncfd3imCoVwyUu/5E6OXXYeThD0XbUwdDZzJqbmxJooJPMTaDIvHoh1fMYJ 6zqfiXFR6LVvBXxSPLJ6JqJ+1LyFizxRASQ9iYeO0W8NwgzdHQML4Bcn9QKAex0Qtzov F1cA== X-Gm-Message-State: AOAM530bjvXFkirTFGoLNScIM8+j0BX5hR21hALYGhL8Fs3IkY5kZjdm LqumEUnuJ0IW7A1WKeAX9mT69pWtuZXZ8r9uyK/CkPJs43r5e+yv67yfygJhiFu+h/vYDuae4Xf atRthjOLcDYMBqsYRFBEHEjW0uQvU+OYk9G//wHOLnQ== X-Received: by 2002:a63:5a20:0:b0:3aa:2fd0:9e94 with SMTP id o32-20020a635a20000000b003aa2fd09e94mr15657978pgb.602.1650895989551; Mon, 25 Apr 2022 07:13:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMTuuQbll6hJl7Fs/+KmK/doG8TDJZWr1sAN9iXVE9Rndmg794//uG/5NG4OIivX670tyFNw== X-Received: by 2002:a63:5a20:0:b0:3aa:2fd0:9e94 with SMTP id o32-20020a635a20000000b003aa2fd09e94mr15657953pgb.602.1650895989235; Mon, 25 Apr 2022 07:13:09 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id d6-20020a17090a8d8600b001cd4989fecesm529524pjo.26.2022.04.25.07.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Apr 2022 07:13:08 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH][impish/linux-azure] ext4: add check to prevent attempting to resize an fs with sparse_super2 Date: Mon, 25 Apr 2022 08:13:00 -0600 Message-Id: <20220425141300.16548-3-tim.gardner@canonical.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220425141300.16548-1-tim.gardner@canonical.com> References: <20220425141300.16548-1-tim.gardner@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Josh Triplett BugLink: https://bugs.launchpad.net/bugs/1970223 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 Link: https://lore.kernel.org/r/74b8ae78405270211943cd7393e65586c5faeed1.1623093259.git.josh@joshtriplett.org Signed-off-by: Theodore Ts'o (backported from commit b1489186cc8391e0c1e342f9fbc3eedf6b944c61) [rtg - context adjustment] Signed-off-by: Tim Gardner --- fs/ext4/resize.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index bd0d185654f3..7a9f1adef679 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -74,6 +74,11 @@ int ext4_resize_begin(struct super_block *sb) return -EPERM; } + 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)) ret = -EBUSY;