Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1678183rwo; Wed, 2 Aug 2023 19:41:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlG5ZVZfrloaMAVabM7yV4ou3MwV9o1msDePVmyullP/igYcdeYJ50+Y7NLXlkJqspy+p3BA X-Received: by 2002:a05:6a20:6a28:b0:13c:9317:ad78 with SMTP id p40-20020a056a206a2800b0013c9317ad78mr18326301pzk.46.1691030503469; Wed, 02 Aug 2023 19:41:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691030503; cv=none; d=google.com; s=arc-20160816; b=lJ14KhBU9WnVNClQUj85DZHb7cs8L+tDyl14Dd4xtYUxqiexe3W8ofYI361vcpPBKv w1odoPFa7+FJnxaA1ZjcptM2mQfTp5yPO/D82CzdF3zvgU9+V+tc/r9uQu6hIjdH5wpK vF81Gc6m3NXJCUqNbANrYz6W5W50roiEkGhwGhwLPwz2OSCBD0Oj2p+Ph3gPupGG7/Gh odzCMWrx5/jhEBZDuOV6di4IO0caOYoVB8B3HpovN/Ws8AESh3STIHk5S335g0Ce5o6g d8y5qsBB0MAJH2fWgffj2+CUnuAnAxd5Oltp0gm7QAivdXYu9qq2C11nW1/HyAWD16wk HcHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=CsG6+wYSRWQhINWwbIjioiAopQTd0VvGBOIeMjxShWs=; fh=2ki6oDoj5WWdyjfCtFb3x19BE33gAtUqg6BW2rwEc30=; b=eXBdeYwHYptLW6BBdl8JwcmJCI/Ayr11llvbpzv7CkBUBlQS34O3HaCwS8lLjdQkNr fug7JpNwjRwfr9kHES0mYsN0T/Sa3DxvHHaGQxd3OiZsJ1o6cVSOOP4f1p8mY+wfLvd+ Y+O9PG5LAbdenCewwVcNI6+ZEsarPFPKBu9o0SJ0qvu5mXQQouNDM2hT5kd75cos85o3 ZG7yJA9u+laGoelf0eBabwB1sQUkoQiDLeVtw7fCH31lHf2UCXCf/fBq3h7k2cIM9X2H f++HKqu9nRnfqSzKSndvY/3Y/BES9VhNwYQIpjdROjfpwz7skPQxIPeP+D7mS7K5mwb7 rOgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g4-20020a170902d1c400b001b9d2010c39si11461006plb.192.2023.08.02.19.41.26; Wed, 02 Aug 2023 19:41:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233613AbjHCCgx (ORCPT + 99 others); Wed, 2 Aug 2023 22:36:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233738AbjHCCgf (ORCPT ); Wed, 2 Aug 2023 22:36:35 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BD05558B for ; Wed, 2 Aug 2023 19:34:49 -0700 (PDT) Received: from dggpeml500016.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RGXw31PB1z1GDVG; Thu, 3 Aug 2023 10:33:39 +0800 (CST) Received: from huawei.com (10.175.127.227) by dggpeml500016.china.huawei.com (7.185.36.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 3 Aug 2023 10:34:40 +0800 From: zhanchengbin To: CC: , , , , , , zhanchengbin Subject: [RFC PATCH v2 0/2] ext4: Fix the conflict between modifying the superblock in user mode and kernel mode Date: Thu, 3 Aug 2023 10:31:26 +0800 Message-ID: <20230803023128.35170-1-zhanchengbin1@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500016.china.huawei.com (7.185.36.70) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Tune2fs does not recognize writes to filesystems in another namespace. Two simultaneous write operations on a block will lead to file system inconsistency, because there is no lock protection between userland and kernelland. The operation is as follows: first terminal second terminal mkfs.ext4 /dev/sdb; mount /dev/sdb /test-sdb; dd if=/dev/zero of=/test-sdb/test1 bs=1M count=100; unshare -m; umount; gdb tune2fs; b io_channel_write_byte r -e remount-ro /dev/sdb c(Write a byte of old data into the cache) exit; (gdb finish) tune2fs -l /dev/sdb; tune2fs 1.46.4 (18-Aug-2021) tune2fs: Superblock checksum does not match superblock while trying to open /dev/sdb Couldn't find valid filesystem superblock. Link: https://lore.kernel.org/linux-ext4/29f6134f-ba0a-d601-0a5a-ad2b5e9bbf1d@huawei.com/ After discussing with Tytso, I decided to use ioctl to solve the above problems. These patches are an example I wrote to complete the modification of the s_errors variable in the super block. Finally, if you have any good ideas, welcome to communicate with me by email. Diff V2 vs V1: 1) Modify symbols of comment. Link: https://lore.kernel.org/oe-kbuild-all/202308030412.jMcaYq0E-lkp@intel.com/ 2) Add static symbols to functions. Link: https://lore.kernel.org/oe-kbuild-all/202308021801.ieUVR2xl-lkp@intel.com/ zhanchengbin (2): ext4: ioctl adds a framework for modifying superblock parameters ext4: ioctl add EXT4_IOC_SUPERBLOCK_KEY_S_ERRORS fs/ext4/ext4.h | 12 +++ fs/ext4/ioctl.c | 149 ++++++++++++++++++++++++++++++++++++++ include/uapi/linux/ext4.h | 28 +++++++ 3 files changed, 189 insertions(+) -- 2.31.1