From patchwork Mon Mar 20 05:04:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiqiang Liu X-Patchwork-Id: 1758815 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=xefr=7m=vger.kernel.org=linux-ext4-owner@ozlabs.org; receiver=) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Pg2jG4msLz247d for ; Mon, 20 Mar 2023 16:04:50 +1100 (AEDT) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Pg2j91pY8z4whr for ; Mon, 20 Mar 2023 16:04:45 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Pg2j91VGrz4x1d; Mon, 20 Mar 2023 16:04:45 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Pg2j845GQz4whr for ; Mon, 20 Mar 2023 16:04:44 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229524AbjCTFEl (ORCPT ); Mon, 20 Mar 2023 01:04:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjCTFEj (ORCPT ); Mon, 20 Mar 2023 01:04:39 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCC1D1E9EC for ; Sun, 19 Mar 2023 22:04:37 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Pg2dS3tG9z17MPH; Mon, 20 Mar 2023 13:01:32 +0800 (CST) Received: from [10.174.179.254] (10.174.179.254) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 20 Mar 2023 13:04:35 +0800 To: CC: "Theodore Y. Ts'o" , , Jan Kara , linfeilong , wuguanghao , zhanchengbin , From: Zhiqiang Liu Subject: [PATCH] tune2fs: check whether filesystem is in use for I_flag and Q_flag test Message-ID: <28455341-ca26-d203-8b54-792bae002251@huawei.com> Date: Mon, 20 Mar 2023 13:04:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 Content-Language: en-US X-Originating-IP: [10.174.179.254] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Zhiqiang Liu For changing inode size (-I) and setting quota fearture (-Q), tune2fs only check whether the filesystem is umounted. Considering mount namepspaces, the filesystem is umounted, however it already be left in other mount namespace. So we add one check whether the filesystem is not in use with using EXT2_MF_BUSY flag, which can indicate the device is already opened with O_EXCL, as suggested by Ted. Reported-by: Baokun Li Signed-off-by: Zhiqiang Liu Signed-off-by: zhanchengbin --- misc/tune2fs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 458f7cf6..d75f4d94 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -3520,9 +3520,9 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n" } if (Q_flag) { - if (mount_flags & EXT2_MF_MOUNTED) { + if (mount_flags & (EXT2_MF_BUSY | EXT2_MF_MOUNTED)) { fputs(_("The quota feature may only be changed when " - "the filesystem is unmounted.\n"), stderr); + "the filesystem is unmounted and not in use.\n"), stderr); rc = 1; goto closefs; } @@ -3673,10 +3673,10 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n" } if (I_flag) { - if (mount_flags & EXT2_MF_MOUNTED) { + if (mount_flags & (EXT2_MF_BUSY | EXT2_MF_MOUNTED)) { fputs(_("The inode size may only be " "changed when the filesystem is " - "unmounted.\n"), stderr); + "unmounted and not in use.\n"), stderr); rc = 1; goto closefs; }