From nobody Sun Feb 8 23:30:28 2026 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2BAF61494D9; Tue, 21 Jan 2025 07:16:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443799; cv=none; b=DgSSuIuVTU/qSE3ebxfluSGJj8E/qVN3ntOFyVfWxmwCKPj1ladxTobZN8kRkl0mv5sxl3Jt/dDliZMCYJVHTmddcS8b7Gl9dHEc+yHQSfwUNUTKwH+mvBQvL8WbY3ryJ2eNtsNT33W9x0N31rbjFNDt0nNm4SiYRLHynuSA+aU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443799; c=relaxed/simple; bh=8LZEGmtoNBa8NKJDXUkSmn4UUWqFvEX9ES/yP4+IGzc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=CQeY3uKug0i1jTuNT4ewbYdwWCk2r52NoO4eQeDO+LytI6RLvW123RoZKW+hvuMbAPv2br0q7rzPxRXnzXFWKsdEdGR8PyX8KX/LHbchaPnlkeInW5h8G35IJ8V2vAlQBIrVmSmbImjfHQVJ7DuJTSLqqDEY11CrAmvqjIrqUDo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YcdmL4yffz4f3jqx; Tue, 21 Jan 2025 15:16:18 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 1ECC91A0EDC; Tue, 21 Jan 2025 15:16:34 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgD3W2DNSY9n3Gg+Bg--.34135S5; Tue, 21 Jan 2025 15:16:33 +0800 (CST) From: libaokun@huaweicloud.com To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, libaokun@huaweicloud.com, Baokun Li Subject: [PATCH v2 1/8] ext4: replace opencoded ext4_end_io_end() in ext4_put_io_end() Date: Tue, 21 Jan 2025 15:10:43 +0800 Message-Id: <20250121071050.3991249-2-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250121071050.3991249-1-libaokun@huaweicloud.com> References: <20250121071050.3991249-1-libaokun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: gCh0CgD3W2DNSY9n3Gg+Bg--.34135S5 X-Coremail-Antispam: 1UD129KBjvdXoW7GF43CF1fAFW8Ar15Cw4Uurg_yoWkurb_Zr yfWrn7Cr4ayw1Ika47Aa17Xr1jkFn5Gr1ruF1rZrsIq3W3A34DtF1kArZ8Ar47WF47Aa1U Cr4kAw1fXF1jqjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbgxFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGwA2048vs2IY02 0Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4kE6xkIj40Ew7xC0wCY1x0262 kKe7AKxVWUtVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s02 6c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw 0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvE c7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14 v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x 0JUho7_UUUUU= X-CM-SenderInfo: 5olet0hnxqqx5xdzvxpfor3voofrz/1tbiAgALBWeKD3kBggAKse From: Baokun Li This reduces duplicate code and ensures that a =E2=80=9Cpotential data loss= =E2=80=9D warning is available if the unwritten conversion fails. Signed-off-by: Baokun Li Reviewed-by: Jan Kara Reviewed-by: Zhang Yi --- fs/ext4/page-io.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 69b8a7221a2b..f53b018ea259 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -299,18 +299,13 @@ void ext4_put_io_end_defer(ext4_io_end_t *io_end) =20 int ext4_put_io_end(ext4_io_end_t *io_end) { - int err =3D 0; - if (refcount_dec_and_test(&io_end->count)) { - if (io_end->flag & EXT4_IO_END_UNWRITTEN) { - err =3D ext4_convert_unwritten_io_end_vec(io_end->handle, - io_end); - io_end->handle =3D NULL; - ext4_clear_io_unwritten_flag(io_end); - } + if (io_end->flag & EXT4_IO_END_UNWRITTEN) + return ext4_end_io_end(io_end); + ext4_release_io_end(io_end); } - return err; + return 0; } =20 ext4_io_end_t *ext4_get_io_end(ext4_io_end_t *io_end) --=20 2.39.2 From nobody Sun Feb 8 23:30:28 2026 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D65151891AB; Tue, 21 Jan 2025 07:16:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443800; cv=none; b=tmWD78cpdUz+c07j1jWrWXwogSWn8HrgwxhLr8TY6ww+GF864IvbvdaOTlqUpc5mroXEd1m5fwGZGfryjKeNkPMGDxkkMi464EGmCY7d0Me3f51VBhDBr1G3OamCCC27iYmdfzbK9ejWP3u3DP76rc4trxnTnDeDxIWpD0kXZcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443800; c=relaxed/simple; bh=hZpvbfq9OM4ZwJDlxNDgyJH37/lvzaUAIUboP2stpM0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BmLC8mYwWKRdaEHf/Lrn4VCoAt3mHcRAh4rB1qMYi6q9/gQ4l8oUbJm+kPHAm60EngbUgXpCKZd93G4HFQaraas/F56VYnlrkn/iFbuG1T9XNneV5UXNhjLz1L4KkbVN/TSHTlRYGlhVw7Akzyw6zQdOOZB0fko8OChSiR8lJfo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4YcdmF6rHHz4f3jXr; Tue, 21 Jan 2025 15:16:13 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 891391A0C49; Tue, 21 Jan 2025 15:16:34 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgD3W2DNSY9n3Gg+Bg--.34135S6; Tue, 21 Jan 2025 15:16:34 +0800 (CST) From: libaokun@huaweicloud.com To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, libaokun@huaweicloud.com, Baokun Li Subject: [PATCH v2 2/8] ext4: do not convert the unwritten extents if data writeback fails Date: Tue, 21 Jan 2025 15:10:44 +0800 Message-Id: <20250121071050.3991249-3-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250121071050.3991249-1-libaokun@huaweicloud.com> References: <20250121071050.3991249-1-libaokun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: gCh0CgD3W2DNSY9n3Gg+Bg--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Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuY vjfU1lkVUUUUU X-CM-SenderInfo: 5olet0hnxqqx5xdzvxpfor3voofrz/1tbiAQAPBWeOA-NKyAABsR Content-Type: text/plain; charset="utf-8" From: Baokun Li When dioread_nolock is turned on (the default), it will convert unwritten extents to written at ext4_end_io_end(), even if the data writeback fails. It leads to the possibility that stale data may be exposed when the physical block corresponding to the file data is read-only (i.e., writes return -EIO, but reads are normal). Therefore a new ext4_io_end->flags EXT4_IO_END_FAILED is added, which indicates that some bio write-back failed in the current ext4_io_end. When this flag is set, the unwritten to written conversion is no longer performed. Users can read the data normally until the caches are dropped, after that, the failed extents can only be read to all 0. Signed-off-by: Baokun Li Reviewed-by: Jan Kara Reviewed-by: Zhang Yi --- fs/ext4/ext4.h | 3 ++- fs/ext4/page-io.c | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 4e7de7eaa374..9da0e32af02a 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -278,7 +278,8 @@ struct ext4_system_blocks { /* * Flags for ext4_io_end->flags */ -#define EXT4_IO_END_UNWRITTEN 0x0001 +#define EXT4_IO_END_UNWRITTEN 0x0001 +#define EXT4_IO_END_FAILED 0x0002 =20 struct ext4_io_end_vec { struct list_head list; /* list of io_end_vec */ diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index f53b018ea259..6054ec27fb48 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -181,14 +181,25 @@ static int ext4_end_io_end(ext4_io_end_t *io_end) "list->prev 0x%p\n", io_end, inode->i_ino, io_end->list.next, io_end->list.prev); =20 - io_end->handle =3D NULL; /* Following call will use up the handle */ - ret =3D ext4_convert_unwritten_io_end_vec(handle, io_end); + /* + * Do not convert the unwritten extents if data writeback fails, + * or stale data may be exposed. + */ + io_end->handle =3D NULL; /* Following call will use up the handle */ + if (unlikely(io_end->flag & EXT4_IO_END_FAILED)) { + ret =3D -EIO; + if (handle) + jbd2_journal_free_reserved(handle); + } else { + ret =3D ext4_convert_unwritten_io_end_vec(handle, io_end); + } if (ret < 0 && !ext4_forced_shutdown(inode->i_sb)) { ext4_msg(inode->i_sb, KERN_EMERG, "failed to convert unwritten extents to written " "extents -- potential data loss! " "(inode %lu, error %d)", inode->i_ino, ret); } + ext4_clear_io_unwritten_flag(io_end); ext4_release_io_end(io_end); return ret; @@ -339,6 +350,7 @@ static void ext4_end_bio(struct bio *bio) bio->bi_status, inode->i_ino, (unsigned long long) bi_sector >> (inode->i_blkbits - 9)); + io_end->flag |=3D EXT4_IO_END_FAILED; mapping_set_error(inode->i_mapping, blk_status_to_errno(bio->bi_status)); } --=20 2.39.2 From nobody Sun Feb 8 23:30:28 2026 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1D511A2C11; Tue, 21 Jan 2025 07:16:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443800; cv=none; b=ntpHXX6nrZzmwoCA36i+GcDlq7o9ETRcn2VEtVoPQEoj/WJLKcFaDdJbZEx3ryuvq2h4OkmpH1n/LItocpVkz/un0oIOW5U2gl+pw9bTK5HgAVVKx18QbgrGKmnGi5r6GgEPDQm2jmoJHutSHLoSBPfW1yKt1bAnH9sx20CNHfs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443800; c=relaxed/simple; bh=GQ7a5BMwcwoQb/GjrdaQJAY54iI4HzsSwETPjZ+phb8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fInGVMX2HxKhKFnSW4ULnBpfwygvumak0XCGj0nnNWMKv7ZZHu38MAR5FL2j/yeyRdFze8CrCnUSjgqpUVJQyn0mLhFL8hedYbsFeaWbKGFKiBgDgJc3UIgjI99LeRgQDiryEtFkAYwrdirGPzs3fxr/JppB+pjr7pIj2799SZI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4YcdmG2n8Qz4f3jXt; Tue, 21 Jan 2025 15:16:14 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id F06EA1A175A; Tue, 21 Jan 2025 15:16:34 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgD3W2DNSY9n3Gg+Bg--.34135S7; Tue, 21 Jan 2025 15:16:34 +0800 (CST) From: libaokun@huaweicloud.com To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, libaokun@huaweicloud.com, Baokun Li Subject: [PATCH v2 3/8] ext4: reject the 'data_err=abort' option in nojournal mode Date: Tue, 21 Jan 2025 15:10:45 +0800 Message-Id: <20250121071050.3991249-4-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250121071050.3991249-1-libaokun@huaweicloud.com> References: <20250121071050.3991249-1-libaokun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer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Ik0rVWUJVWUCwCI42IY6I8E87Iv67 AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuY vjfUOnmRUUUUU X-CM-SenderInfo: 5olet0hnxqqx5xdzvxpfor3voofrz/1tbiAQAPBWeOA-NKyAADsT Content-Type: text/plain; charset="utf-8" From: Baokun Li data_err=3Dabort aborts the journal on I/O errors. However, this option is meaningless if journal is disabled, so it is rejected in nojournal mode to reduce unnecessary checks. Also, this option is ignored upon remount. Signed-off-by: Baokun Li Reviewed-by: Zhang Yi Reviewed-by: Jan Kara --- Or maybe we should make mount and remount consistent? Rejecting it in both would make things a lot easier. fs/ext4/super.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index a50e5c31b937..34a7b6523f8b 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2785,6 +2785,13 @@ static int ext4_check_opt_consistency(struct fs_cont= ext *fc, } =20 if (is_remount) { + if (!sbi->s_journal && + ctx_test_mount_opt(ctx, EXT4_MOUNT_DATA_ERR_ABORT)) { + ext4_msg(NULL, KERN_WARNING, + "Remounting fs w/o journal so ignoring data_err option"); + ctx_clear_mount_opt(ctx, EXT4_MOUNT_DATA_ERR_ABORT); + } + if (ctx_test_mount_opt(ctx, EXT4_MOUNT_DAX_ALWAYS) && (test_opt(sb, DATA_FLAGS) =3D=3D EXT4_MOUNT_JOURNAL_DATA)) { ext4_msg(NULL, KERN_ERR, "can't mount with " @@ -5428,6 +5435,11 @@ static int __ext4_fill_super(struct fs_context *fc, = struct super_block *sb) "data=3D, fs mounted w/o journal"); goto failed_mount3a; } + if (test_opt(sb, DATA_ERR_ABORT)) { + ext4_msg(sb, KERN_ERR, + "can't mount with data_err=3Dabort, fs mounted w/o journal"); + goto failed_mount3a; + } sbi->s_def_mount_opt &=3D ~EXT4_MOUNT_JOURNAL_CHECKSUM; clear_opt(sb, JOURNAL_CHECKSUM); clear_opt(sb, DATA_FLAGS); --=20 2.39.2 From nobody Sun Feb 8 23:30:28 2026 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C3991A83F4; Tue, 21 Jan 2025 07:16:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443801; cv=none; b=RFZX1WzHvEg43HEVethBBXRiNB7hKMxe+4oKtFWvmmXLcvWdFpBIDTwqb9RySqpHXTIX97gXI5bMDOFsQP/3t9sgy07l/UIZQ9V77lkQC590ojDugwjsrBVRRurTf/FUzSFZiUtQ93J3h3/ThIcseR9yRlJMAVTEopKljRiFfr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443801; c=relaxed/simple; bh=7/PmOg2A4JWxyesnk6nAhUy5nhfdCVu+IKwKgqcEhaA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pI9jn0NUBNEXBItQsJvdibrbcBAt3p/hVof3nAAVjwIxnO4aix90twyVliP+Hgcqo9L9E/9ZatuN/84MgTbXV25ZNPBPD/CwVsR5V4TugGvGfUacxvigHIeo6f4W6YnDFAT2vsc2ZeGOXOzypcdzmpWrHOfscLmEZnOQ3VTTe/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YcdmF47Tnz4f3jLc; Tue, 21 Jan 2025 15:16:13 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 667A21A0FE9; Tue, 21 Jan 2025 15:16:35 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgD3W2DNSY9n3Gg+Bg--.34135S8; Tue, 21 Jan 2025 15:16:35 +0800 (CST) From: libaokun@huaweicloud.com To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, libaokun@huaweicloud.com, Baokun Li Subject: [PATCH v2 4/8] ext4: extract ext4_check_nojournal_options() from __ext4_fill_super() Date: Tue, 21 Jan 2025 15:10:46 +0800 Message-Id: <20250121071050.3991249-5-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250121071050.3991249-1-libaokun@huaweicloud.com> References: <20250121071050.3991249-1-libaokun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: gCh0CgD3W2DNSY9n3Gg+Bg--.34135S8 X-Coremail-Antispam: 1UD129KBjvJXoWxZr4kXFW7Zw4kur4Utr1kZrb_yoW5WFy3pF 9xZryIyrW8ZF1kurs7GFs5JrWrWw40ka4xGrZ293Z5X3y2yryIg3y8tFyYqFyaqFWxGw18 XFy0k3W8u34jkaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPG14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwAKzVCY07xG64k0F24lc7 CjxVAaw2AFwI0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l x2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14 v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IY x2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87 Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIF yTuYvjfUYl19UUUUU X-CM-SenderInfo: 5olet0hnxqqx5xdzvxpfor3voofrz/1tbiAgAPBWeOA-lJ-QABsu Content-Type: text/plain; charset="utf-8" From: Baokun Li Extract the ext4_check_nojournal_options() helper function to reduce code duplication. No functional changes. Signed-off-by: Baokun Li Reviewed-by: Zhang Yi Reviewed-by: Jan Kara --- fs/ext4/super.c | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 34a7b6523f8b..78f2433f6ca0 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5020,6 +5020,24 @@ static int ext4_check_journal_data_mode(struct super= _block *sb) return 0; } =20 +static const char *ext4_check_nojournal_options(struct super_block *sb) +{ + struct ext4_sb_info *sbi =3D EXT4_SB(sb); + + if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) + return "journal_async_commit"; + if (test_opt2(sb, EXPLICIT_JOURNAL_CHECKSUM)) + return "journal_checksum"; + if (sbi->s_commit_interval !=3D JBD2_DEFAULT_MAX_COMMIT_AGE*HZ) + return "commit=3D"; + if (EXT4_MOUNT_DATA_FLAGS & + (sbi->s_mount_opt ^ sbi->s_def_mount_opt)) + return "data=3D"; + if (test_opt(sb, DATA_ERR_ABORT)) + return "data_err=3Dabort"; + return NULL; +} + static int ext4_load_super(struct super_block *sb, ext4_fsblk_t *lsb, int silent) { @@ -5411,35 +5429,17 @@ static int __ext4_fill_super(struct fs_context *fc,= struct super_block *sb) "suppressed and not mounted read-only"); goto failed_mount3a; } else { - /* Nojournal mode, all journal mount options are illegal */ - if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { - ext4_msg(sb, KERN_ERR, "can't mount with " - "journal_async_commit, fs mounted w/o journal"); - goto failed_mount3a; - } + const char *journal_option; =20 - if (test_opt2(sb, EXPLICIT_JOURNAL_CHECKSUM)) { - ext4_msg(sb, KERN_ERR, "can't mount with " - "journal_checksum, fs mounted w/o journal"); - goto failed_mount3a; - } - if (sbi->s_commit_interval !=3D JBD2_DEFAULT_MAX_COMMIT_AGE*HZ) { - ext4_msg(sb, KERN_ERR, "can't mount with " - "commit=3D%lu, fs mounted w/o journal", - sbi->s_commit_interval / HZ); - goto failed_mount3a; - } - if (EXT4_MOUNT_DATA_FLAGS & - (sbi->s_mount_opt ^ sbi->s_def_mount_opt)) { - ext4_msg(sb, KERN_ERR, "can't mount with " - "data=3D, fs mounted w/o journal"); - goto failed_mount3a; - } - if (test_opt(sb, DATA_ERR_ABORT)) { + /* Nojournal mode, all journal mount options are illegal */ + journal_option =3D ext4_check_nojournal_options(sb); + if (journal_option !=3D NULL) { ext4_msg(sb, KERN_ERR, - "can't mount with data_err=3Dabort, fs mounted w/o journal"); + "can't mount with %s, fs mounted w/o journal", + journal_option); goto failed_mount3a; } + sbi->s_def_mount_opt &=3D ~EXT4_MOUNT_JOURNAL_CHECKSUM; clear_opt(sb, JOURNAL_CHECKSUM); clear_opt(sb, DATA_FLAGS); --=20 2.39.2 From nobody Sun Feb 8 23:30:28 2026 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB3971B4F3F; Tue, 21 Jan 2025 07:16:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443802; cv=none; b=iLsfJHHqrNw8fgbovkjRlvn3k68PkOXvGnO2skHEB/UginIiWJOqqCl/BKujbPIvbGZCNgm/t8LGjhU0H0bOHLaXoCiPz4kNO33SaJ/VzSL2rAiH1s6cS8KuoY2l1njJWpA5z17fu8oISUagL8oywz71TBGpMbDeMbASjzoBPeM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443802; c=relaxed/simple; bh=xpjTwsMLReaguQrpJ/MF2+KORN/RaYY0GGmwj2qL17o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X9M3uVx0X3vEPXbku7y5G0P06bu0EsxUc+kC5SB3t/GjAA2OiGd0yQPADEMOM6wLP0CYChQ7uxdhIJ3ArEsSRmCwx5VUh1F0F9MMW7Ek+AHXfZQVGmmK3C3C1OaawCiD9fUlm+7b8AM/gIQN1JWGyVWyoZ4jMIJCo9mQ5uvhh5A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4YcdmK0JrKz4f3jXg; Tue, 21 Jan 2025 15:16:17 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 9E71D1A0D8B; Tue, 21 Jan 2025 15:16:37 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgD3W2DNSY9n3Gg+Bg--.34135S9; Tue, 21 Jan 2025 15:16:35 +0800 (CST) From: libaokun@huaweicloud.com To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, libaokun@huaweicloud.com, Baokun Li Subject: [PATCH v2 5/8] ext4: abort journal on data writeback failure if in data_err=abort mode Date: Tue, 21 Jan 2025 15:10:47 +0800 Message-Id: <20250121071050.3991249-6-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250121071050.3991249-1-libaokun@huaweicloud.com> References: <20250121071050.3991249-1-libaokun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: gCh0CgD3W2DNSY9n3Gg+Bg--.34135S9 X-Coremail-Antispam: 1UD129KBjvJXoW3GFykCF4rtr48Gw4xAF1DWrg_yoWxurW5pF y5uFWUKF4UX3s7urZ3AF4DXF4aga4xtrW7Cr17WFZFva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AQAPBWeOA-NKygABsT Content-Type: text/plain; charset="utf-8" From: Baokun Li The data_err=3Dabort was initially introduced to address users' worries about data corruption spreading unnoticed. With direct writes, we can rely on return values to confirm successful writes to disk. But with buffered writes, a successful return only means the data has been written to memory. Users have no way of knowing if the data has actually written it to disk unless they use fsync (which impacts performance and can sometimes miss errors). The current data_err=3Dabort implementation relies on the ordered data list, but past changes have inadvertently altered its behavior. For example, if an extent is unwritten, we do not add the inode to the ordered data list. Therefore, jbd2 will not wait for the data write-back of that inode to complete and check for errors in the inode mapping. Moreover, the checks performed by jbd2 can also miss errors. Now, all buffered writes eventually call ext4_end_bio(), where I/O errors are checked. Therefore, we can check for the data_err=3Dabort mode at this point and abort the journal in a kworker (due to the interrupt context). Therefore, when data_err=3Dabort is enabled, the journal is aborted in ext4_end_io_end() when an I/O error is detected in ext4_end_bio() to make users who are concerned about the contents of the file happy. Suggested-by: Jan Kara Link: https://patch.msgid.link/c7ab26f3-85ad-4b31-b132-0afb0e07bf79@huawei.= com Signed-off-by: Baokun Li Reviewed-by: Zhang Yi Reviewed-by: Jan Kara --- fs/ext4/ext4.h | 2 ++ fs/ext4/page-io.c | 48 +++++++++++++++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 9da0e32af02a..e0b536df8872 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -281,6 +281,8 @@ struct ext4_system_blocks { #define EXT4_IO_END_UNWRITTEN 0x0001 #define EXT4_IO_END_FAILED 0x0002 =20 +#define EXT4_IO_END_NEED_COMPLETION (EXT4_IO_END_UNWRITTEN | EXT4_IO_END_F= AILED) + struct ext4_io_end_vec { struct list_head list; /* list of io_end_vec */ loff_t offset; /* offset in the file */ diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 6054ec27fb48..5dbd3ff188a3 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -164,7 +164,8 @@ static void ext4_release_io_end(ext4_io_end_t *io_end) } =20 /* - * Check a range of space and convert unwritten extents to written. Note t= hat + * On successful IO, check a range of space and convert unwritten extents = to + * written. On IO failure, check if journal abort is needed. Note that * we are protected from truncate touching same part of extent tree by the * fact that truncate code waits for all DIO to finish (thus exclusion from * direct IO is achieved) and also waits for PageWriteback bits. Thus we @@ -175,6 +176,7 @@ static int ext4_end_io_end(ext4_io_end_t *io_end) { struct inode *inode =3D io_end->inode; handle_t *handle =3D io_end->handle; + struct super_block *sb =3D inode->i_sb; int ret =3D 0; =20 ext4_debug("ext4_end_io_nolock: io_end 0x%p from inode %lu,list->next 0x%= p," @@ -190,11 +192,15 @@ static int ext4_end_io_end(ext4_io_end_t *io_end) ret =3D -EIO; if (handle) jbd2_journal_free_reserved(handle); + + if (test_opt(sb, DATA_ERR_ABORT)) + jbd2_journal_abort(EXT4_SB(sb)->s_journal, ret); } else { ret =3D ext4_convert_unwritten_io_end_vec(handle, io_end); } - if (ret < 0 && !ext4_forced_shutdown(inode->i_sb)) { - ext4_msg(inode->i_sb, KERN_EMERG, + if (ret < 0 && !ext4_forced_shutdown(sb) && + io_end->flag & EXT4_IO_END_UNWRITTEN) { + ext4_msg(sb, KERN_EMERG, "failed to convert unwritten extents to written " "extents -- potential data loss! " "(inode %lu, error %d)", inode->i_ino, ret); @@ -228,6 +234,16 @@ static void dump_completed_IO(struct inode *inode, str= uct list_head *head) #endif } =20 +static bool ext4_io_end_need_completion(ext4_io_end_t *io_end) +{ + if (io_end->flag & EXT4_IO_END_UNWRITTEN) + return true; + if (test_opt(io_end->inode->i_sb, DATA_ERR_ABORT) && + io_end->flag & EXT4_IO_END_FAILED) + return true; + return false; +} + /* Add the io_end to per-inode completed end_io list. */ static void ext4_add_complete_io(ext4_io_end_t *io_end) { @@ -236,9 +252,11 @@ static void ext4_add_complete_io(ext4_io_end_t *io_end) struct workqueue_struct *wq; unsigned long flags; =20 - /* Only reserved conversions from writeback should enter here */ - WARN_ON(!(io_end->flag & EXT4_IO_END_UNWRITTEN)); - WARN_ON(!io_end->handle && sbi->s_journal); + /* Only reserved conversions or pending IO errors will enter here. */ + WARN_ON(!(io_end->flag & EXT4_IO_END_NEED_COMPLETION)); + WARN_ON(io_end->flag & EXT4_IO_END_UNWRITTEN && + !io_end->handle && sbi->s_journal); + spin_lock_irqsave(&ei->i_completed_io_lock, flags); wq =3D sbi->rsv_conversion_wq; if (list_empty(&ei->i_rsv_conversion_list)) @@ -263,7 +281,7 @@ static int ext4_do_flush_completed_IO(struct inode *ino= de, =20 while (!list_empty(&unwritten)) { io_end =3D list_entry(unwritten.next, ext4_io_end_t, list); - BUG_ON(!(io_end->flag & EXT4_IO_END_UNWRITTEN)); + BUG_ON(!(io_end->flag & EXT4_IO_END_NEED_COMPLETION)); list_del_init(&io_end->list); =20 err =3D ext4_end_io_end(io_end); @@ -274,7 +292,8 @@ static int ext4_do_flush_completed_IO(struct inode *ino= de, } =20 /* - * work on completed IO, to convert unwritten extents to extents + * Used to convert unwritten extents to written extents upon IO completion, + * or used to abort the journal upon IO errors. */ void ext4_end_io_rsv_work(struct work_struct *work) { @@ -299,19 +318,20 @@ ext4_io_end_t *ext4_init_io_end(struct inode *inode, = gfp_t flags) void ext4_put_io_end_defer(ext4_io_end_t *io_end) { if (refcount_dec_and_test(&io_end->count)) { - if (!(io_end->flag & EXT4_IO_END_UNWRITTEN) || - list_empty(&io_end->list_vec)) { - ext4_release_io_end(io_end); + if (io_end->flag & EXT4_IO_END_FAILED || + (io_end->flag & EXT4_IO_END_UNWRITTEN && + !list_empty(&io_end->list_vec))) { + ext4_add_complete_io(io_end); return; } - ext4_add_complete_io(io_end); + ext4_release_io_end(io_end); } } =20 int ext4_put_io_end(ext4_io_end_t *io_end) { if (refcount_dec_and_test(&io_end->count)) { - if (io_end->flag & EXT4_IO_END_UNWRITTEN) + if (ext4_io_end_need_completion(io_end)) return ext4_end_io_end(io_end); =20 ext4_release_io_end(io_end); @@ -355,7 +375,7 @@ static void ext4_end_bio(struct bio *bio) blk_status_to_errno(bio->bi_status)); } =20 - if (io_end->flag & EXT4_IO_END_UNWRITTEN) { + if (ext4_io_end_need_completion(io_end)) { /* * Link bio into list hanging from io_end. We have to do it * atomically as bio completions can be racing against each --=20 2.39.2 From nobody Sun Feb 8 23:30:28 2026 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 272271B81B8; Tue, 21 Jan 2025 07:16:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443803; cv=none; b=s2etQsVY/qBbUvTfZMHF0BFDxE8qhGnudtjs7dMFGwKvFe9UOV0xA9MSf7q8U2uYA6iuemqVHvPY8eJ7fXDe7PekQIpvpKgIktLokDKQM8zAX+hEJvp40lvgXN4FvR/nAQ7KaktlfsE8hpVOtvaeqtzgba5GE7t0bT75di9nEus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443803; c=relaxed/simple; bh=FtrVKFZyNVHyXc8Ymufsw66wGj8NaMiC5Fr6Cjols38=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ibnIKmyb3tcQEf/pHKpOueGVER1ihOwSABARJJKOWwU7SK2hf3bezCaKwzUvjJ0bQYpAUDs/XMmiJTW9HUx78CQsPCWudpNyAOWVc7N2qyWzJ5zjDV1xfSk1OsfabiruHat/bl5UqSxPjdpteG1QtQ8m2+vCfZ2Nr3jNl2U2hYQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4YcdmK3XjLz4f3jMn; Tue, 21 Jan 2025 15:16:17 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 14E651A17D8; Tue, 21 Jan 2025 15:16:38 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgD3W2DNSY9n3Gg+Bg--.34135S10; Tue, 21 Jan 2025 15:16:37 +0800 (CST) From: libaokun@huaweicloud.com To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, libaokun@huaweicloud.com, Baokun Li Subject: [PATCH v2 6/8] ext4: update the descriptions of data_err=abort and data_err=ignore Date: Tue, 21 Jan 2025 15:10:48 +0800 Message-Id: <20250121071050.3991249-7-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250121071050.3991249-1-libaokun@huaweicloud.com> References: <20250121071050.3991249-1-libaokun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: gCh0CgD3W2DNSY9n3Gg+Bg--.34135S10 X-Coremail-Antispam: 1UD129KBjvJXoW7WFykArWfGF1xXr17CrWruFg_yoW8GFyDpr sxK3s2qrykuF13CF48Aa1SqFWfKF1xXF43GFs29as7Wan8JrnYqw17t3WYqFyakrWfKay5 ZrW2gw1fuFnFya7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPC14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwAKzVCY07xG64k0F24lc7 CjxVAaw2AFwI0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l x2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14 v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IY x2IY6xkF7I0E14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z2 80aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI 43ZEXa7VUbT7KDUUUUU== X-CM-SenderInfo: 5olet0hnxqqx5xdzvxpfor3voofrz/1tbiAQAPBWeOA-NKygADsR Content-Type: text/plain; charset="utf-8" From: Baokun Li We now print error messages in ext4_end_bio() when page writeback encounters an error. If data_err=3Dabort is set, the journal will also be aborted in a kworker. This means that we now check all Buffer I/O in all modes and decide whether to abort the journal based on the data_err option. Therefore, we remove the ordered mode restriction in the descriptions of data_err=3Dabort and data_err=3Dignore. Signed-off-by: Baokun Li Reviewed-by: Zhang Yi Reviewed-by: Jan Kara --- Documentation/admin-guide/ext4.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/ext4.rst b/Documentation/admin-guide= /ext4.rst index 2418b0c2d3df..b857eb6ca1b6 100644 --- a/Documentation/admin-guide/ext4.rst +++ b/Documentation/admin-guide/ext4.rst @@ -238,11 +238,10 @@ When mounting an ext4 filesystem, the following optio= n are accepted: configured using tune2fs) =20 data_err=3Dignore(*) - Just print an error message if an error occurs in a file data buff= er in - ordered mode. + Just print an error message if an error occurs in a file data buff= er. + data_err=3Dabort - Abort the journal if an error occurs in a file data buffer in orde= red - mode. + Abort the journal if an error occurs in a file data buffer. =20 grpid | bsdgroups New objects have the group ID of their parent. --=20 2.39.2 From nobody Sun Feb 8 23:30:28 2026 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B75EE1B87ED; Tue, 21 Jan 2025 07:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443803; cv=none; b=lKrJGv07jJhwwYXUaiYGUdkzYJpjMOKjGL1gV5kmzET+T3p24HM38RFaXZ+vf97P/m0C1/r2saVxAxX570xgmSSKwgC1t+L2dRIfCgIG1gy95DJCIvUYOtKZnWEJwN/T0wkJSlu79BFxf5Hmp7OE7rrymPamZJzApXQKlENFwYI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443803; c=relaxed/simple; bh=rtn2QBT2e5oly+T9szh90TRDgiycmTExCYkNJvupyNs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pozufYEI570OsGuZMYaxM27Wkhj1MKU6cfseitWhisSx8KzwtnXBymNF6Fy/HGcYkZnll08z0X1Vxc5ydX5YNeKWo1R7Ia4KCZw4OtYnf50tLpqnSo4Aene6jxopmQJFs1q3t8H7lkPK2IhR0TZP0VbpOg8pDS8JGCy6WZiO/k0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YcdmR0bZrz4f3jqx; Tue, 21 Jan 2025 15:16:23 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 7C3041A0D8A; Tue, 21 Jan 2025 15:16:38 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgD3W2DNSY9n3Gg+Bg--.34135S11; Tue, 21 Jan 2025 15:16:38 +0800 (CST) From: libaokun@huaweicloud.com To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, libaokun@huaweicloud.com, Baokun Li Subject: [PATCH v2 7/8] ext4: remove unused member 'i_unwritten' from 'ext4_inode_info' Date: Tue, 21 Jan 2025 15:10:49 +0800 Message-Id: <20250121071050.3991249-8-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250121071050.3991249-1-libaokun@huaweicloud.com> References: <20250121071050.3991249-1-libaokun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: gCh0CgD3W2DNSY9n3Gg+Bg--.34135S11 X-Coremail-Antispam: 1UD129KBjvJXoWxur1DArWxGw1fXw4UtF13urg_yoWrWw1kpF WakFy8GF4UXayq9397GFs7ZF1xtw1xKFWDXry7GayUXF9xur9YgF1rtFyrAFyjvFWxAFWx XF40kryUZr13GrJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPC14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwAKzVCY07xG64k0F24lc7 CjxVAaw2AFwI0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l x2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14 v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IY x2IY6xkF7I0E14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z2 80aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI 43ZEXa7VUbT7KDUUUUU== X-CM-SenderInfo: 5olet0hnxqqx5xdzvxpfor3voofrz/1tbiAQAPBWeOA-NKzAAAsU Content-Type: text/plain; charset="utf-8" From: Baokun Li After commit 378f32bab371 ("ext4: introduce direct I/O write using iomap infrastructure"), no one cares about the value of i_unwritten, so there is no need to maintain this variable, remove it, and clean up the associated logic. Suggested-by: Zhang Yi Signed-off-by: Baokun Li Reviewed-by: Jan Kara Reviewed-by: Zhang Yi --- fs/ext4/ext4.h | 22 +++------------------- fs/ext4/inode.c | 2 +- fs/ext4/super.c | 9 +-------- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index e0b536df8872..6fd550fc0c5c 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1061,7 +1061,6 @@ struct ext4_inode_info { =20 /* Number of ongoing updates on this inode */ atomic_t i_fc_updates; - atomic_t i_unwritten; /* Nr. of inflight conversions pending */ =20 /* Fast commit wait queue for this inode */ wait_queue_head_t i_fc_wait; @@ -3788,34 +3787,19 @@ static inline void set_bitmap_uptodate(struct buffe= r_head *bh) set_bit(BH_BITMAP_UPTODATE, &(bh)->b_state); } =20 -/* For ioend & aio unwritten conversion wait queues */ -#define EXT4_WQ_HASH_SZ 37 -#define ext4_ioend_wq(v) (&ext4__ioend_wq[((unsigned long)(v)) %\ - EXT4_WQ_HASH_SZ]) -extern wait_queue_head_t ext4__ioend_wq[EXT4_WQ_HASH_SZ]; - extern int ext4_resize_begin(struct super_block *sb); extern int ext4_resize_end(struct super_block *sb, bool update_backups); =20 -static inline void ext4_set_io_unwritten_flag(struct inode *inode, - struct ext4_io_end *io_end) +static inline void ext4_set_io_unwritten_flag(struct ext4_io_end *io_end) { - if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) { + if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) io_end->flag |=3D EXT4_IO_END_UNWRITTEN; - atomic_inc(&EXT4_I(inode)->i_unwritten); - } } =20 static inline void ext4_clear_io_unwritten_flag(ext4_io_end_t *io_end) { - struct inode *inode =3D io_end->inode; - - if (io_end->flag & EXT4_IO_END_UNWRITTEN) { + if (io_end->flag & EXT4_IO_END_UNWRITTEN) io_end->flag &=3D ~EXT4_IO_END_UNWRITTEN; - /* Wake up anyone waiting on unwritten extent conversion */ - if (atomic_dec_and_test(&EXT4_I(inode)->i_unwritten)) - wake_up_all(ext4_ioend_wq(inode)); - } } =20 extern const struct iomap_ops ext4_iomap_ops; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 7c54ae5fcbd4..36b1f9fb690a 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2225,7 +2225,7 @@ static int mpage_map_one_extent(handle_t *handle, str= uct mpage_da_data *mpd) mpd->io_submit.io_end->handle =3D handle->h_rsv_handle; handle->h_rsv_handle =3D NULL; } - ext4_set_io_unwritten_flag(inode, mpd->io_submit.io_end); + ext4_set_io_unwritten_flag(mpd->io_submit.io_end); } =20 BUG_ON(map->m_len =3D=3D 0); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 78f2433f6ca0..187cccb2870a 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1426,7 +1426,6 @@ static struct inode *ext4_alloc_inode(struct super_bl= ock *sb) spin_lock_init(&ei->i_completed_io_lock); ei->i_sync_tid =3D 0; ei->i_datasync_tid =3D 0; - atomic_set(&ei->i_unwritten, 0); INIT_WORK(&ei->i_rsv_conversion_work, ext4_end_io_rsv_work); ext4_fc_init_inode(&ei->vfs_inode); mutex_init(&ei->i_fc_lock); @@ -7393,12 +7392,9 @@ static struct file_system_type ext4_fs_type =3D { }; MODULE_ALIAS_FS("ext4"); =20 -/* Shared across all ext4 file systems */ -wait_queue_head_t ext4__ioend_wq[EXT4_WQ_HASH_SZ]; - static int __init ext4_init_fs(void) { - int i, err; + int err; =20 ratelimit_state_init(&ext4_mount_msg_ratelimit, 30 * HZ, 64); ext4_li_info =3D NULL; @@ -7406,9 +7402,6 @@ static int __init ext4_init_fs(void) /* Build-time check for flags consistency */ ext4_check_flag_values(); =20 - for (i =3D 0; i < EXT4_WQ_HASH_SZ; i++) - init_waitqueue_head(&ext4__ioend_wq[i]); - err =3D ext4_init_es(); if (err) return err; --=20 2.39.2 From nobody Sun Feb 8 23:30:28 2026 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B76431B87F0; Tue, 21 Jan 2025 07:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443803; cv=none; b=kpYGea2XG9cNGjtP9p3/UdnjGKs8V/Sb/yhdCm7KROKqdrfObjum4FXFt24OkyjKutATJvGTXyzatzBuTf7Z4GlfincwuNVdk4s+76gwdAwWG2LXR+5wKH0Jpzq3zoS8qxWxpSPQJtbpfhYHco5xQFeG9UTb1avuOzcpCPj4ecQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737443803; c=relaxed/simple; bh=FQVlNxKEM37oYtJglnt6N+2h7JkbjCYdJY21cDdHci8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UJoqmYuUbj8RZq8I9TV0X+g4+NbGsz9km09ivPSs5XgKbXb/W/XPGeFET84mOJJ+QijF7cNQXXQ9Usqp5fCnMAB57RR6liSJP447zsHuMR49cyY39nEwZt7ltMLb6zQgTN5UadE+dQIIvSXQGi4EwYRR/WSo83rCmj51nml5zF4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YcdmR3bFXz4f3jqy; Tue, 21 Jan 2025 15:16:23 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id E23FC1A17D8; Tue, 21 Jan 2025 15:16:38 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgD3W2DNSY9n3Gg+Bg--.34135S12; Tue, 21 Jan 2025 15:16:38 +0800 (CST) From: libaokun@huaweicloud.com To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, libaokun@huaweicloud.com, Baokun Li Subject: [PATCH v2 8/8] ext4: pack holes in ext4_inode_info Date: Tue, 21 Jan 2025 15:10:50 +0800 Message-Id: <20250121071050.3991249-9-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250121071050.3991249-1-libaokun@huaweicloud.com> References: <20250121071050.3991249-1-libaokun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: gCh0CgD3W2DNSY9n3Gg+Bg--.34135S12 X-Coremail-Antispam: 1UD129KBjvJXoW7uF48Jr1kZF1UJryUCrWruFg_yo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KDUUUUU== X-CM-SenderInfo: 5olet0hnxqqx5xdzvxpfor3voofrz/1tbiAQAPBWeOA-NKzQABsU Content-Type: text/plain; charset="utf-8" From: Baokun Li When CONFIG_DEBUG_SPINLOCK is not enabled (general case), there are four 4 bytes holes and one 2 bytes hole in struct ext4_inode_info. Move the members to pack the four 4 bytes holes. Signed-off-by: Baokun Li Reviewed-by: Jan Kara Reviewed-by: Zhang Yi --- fs/ext4/ext4.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 6fd550fc0c5c..c1693ba836ee 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1062,6 +1062,8 @@ struct ext4_inode_info { /* Number of ongoing updates on this inode */ atomic_t i_fc_updates; =20 + spinlock_t i_raw_lock; /* protects updates to the raw inode */ + /* Fast commit wait queue for this inode */ wait_queue_head_t i_fc_wait; =20 @@ -1099,8 +1101,6 @@ struct ext4_inode_info { struct inode vfs_inode; struct jbd2_inode *jinode; =20 - spinlock_t i_raw_lock; /* protects updates to the raw inode */ - /* * File creation time. Its function is same as that of * struct timespec64 i_{a,c,m}time in the generic inode. @@ -1143,6 +1143,7 @@ struct ext4_inode_info { /* quota space reservation, managed internally by quota code */ qsize_t i_reserved_quota; #endif + spinlock_t i_block_reservation_lock; =20 /* Lock protecting lists below */ spinlock_t i_completed_io_lock; @@ -1153,8 +1154,6 @@ struct ext4_inode_info { struct list_head i_rsv_conversion_list; struct work_struct i_rsv_conversion_work; =20 - spinlock_t i_block_reservation_lock; - /* * Transactions that contain inode's metadata needed to complete * fsync and fdatasync, respectively. --=20 2.39.2