From nobody Sun Feb 8 17:41: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 2B3FD1411DE; Fri, 20 Dec 2024 06:11:48 +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=1734675110; cv=none; b=MA5Qcdm5KYVD1dCuvXlvlP+Eb31YyGoEOvBaetBbEZXlld3uJfoOQNPYAi9uuQNopf/iSz+/HTAL7rxwpC4mSKs2Pxsno8SULhHah3ktf+/wpHOGJKASuQ8Nk2MieRs0GyhGQjHYbSATrIn5xJvtYMDMHqax9V2IxWUS7KWup3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734675110; c=relaxed/simple; bh=MQKV7cYcJvBtQc2tk8V6P23oIsF9QtnmqqOp5zXKpD8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=O/A8XoCYeEk5OrKjTvdSXEQiX/A9qupfPgZd28dSTydT6opv+l7Qth6Yq8Zhad7GaG8Zi8pI0o0CGoMAidocnqp2kKxC2UNJrnL6XDevD19aE1RCCQqiMjGl9cetVnjjLC+72wvlVEYVHCYInsBbZAPrYHvB/wPuxgAw2Y2V5rc= 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.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YDxrD51nZz4f3l24; Fri, 20 Dec 2024 14:11:24 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 4E7851A0568; Fri, 20 Dec 2024 14:11:45 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgA3XoKeCmVn6SRyFA--.26943S5; Fri, 20 Dec 2024 14:11:45 +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 1/5] ext4: replace opencoded ext4_end_io_end() in ext4_put_io_end() Date: Fri, 20 Dec 2024 14:07:53 +0800 Message-Id: <20241220060757.1781418-2-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220060757.1781418-1-libaokun@huaweicloud.com> References: <20241220060757.1781418-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: gCh0CgA3XoKeCmVn6SRyFA--.26943S5 X-Coremail-Antispam: 1UD129KBjvdXoW7GF43CF1fAFW8Ar15Cw4Uurg_yoWDKFX_Zr yfWrn7CF1ayws2ka47Aa17XF1DtFn5Gr1fuF1rursIv3W3A3s0kF1kArZ8Ar4xuF47Aa17 CrZ5Zw1fXF10qjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-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/1tbiAgALBWc52qUdMQACsD 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 --- 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.46.1 From nobody Sun Feb 8 17:41: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 C9F1318593A; Fri, 20 Dec 2024 06:11:48 +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=1734675111; cv=none; b=GvdsBRvu7IaO1VFJUOS1x3GGE2OfrJP0tu4piQNY2k2HLmBHEaCpIw5bWdxHFNTknoUNLQIXzBYlVJ8lja7im2voFKbXA5ny/ILy0UqbNumvQcGvGSBrqf1vU8DkE0C+RAPTdL7bPUrwQony2PThL3UXsfcoldB6mZdIqQGTEWY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734675111; c=relaxed/simple; bh=soNT91NOP1r3tKw7LIvCkvVknDuqMKqLHUr0uz1qG5o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uu4ZItQC2BrBM5SWNZ5xHMUjl0sL2erIRnmNw7q+muIEVV9nJoIQV1T7DxijarKvydBHj96mjoN4qUOsrcZWsMFRqFhl4IBZDxrB0yHAQU27CuE2iGyzCFKp4ns7o27UCYbfm7B/q2pVvnrRYMwe+TABW2VYa1WctqlvhzVbVxI= 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.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YDxrM1vbgz4f3jqy; Fri, 20 Dec 2024 14:11:31 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id BE2E11A058E; Fri, 20 Dec 2024 14:11:45 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgA3XoKeCmVn6SRyFA--.26943S6; Fri, 20 Dec 2024 14:11:45 +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 2/5] ext4: do not convert the unwritten extents if data writeback fails Date: Fri, 20 Dec 2024 14:07:54 +0800 Message-Id: <20241220060757.1781418-3-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220060757.1781418-1-libaokun@huaweicloud.com> References: <20241220060757.1781418-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: gCh0CgA3XoKeCmVn6SRyFA--.26943S6 X-Coremail-Antispam: 1UD129KBjvJXo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a73UjIFyTuY vjfU1lkVUUUUU X-CM-SenderInfo: 5olet0hnxqqx5xdzvxpfor3voofrz/1tbiAQADBWdkCnU2wQAAsM 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 --- 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.46.1 From nobody Sun Feb 8 17:41: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 6651C19D070; Fri, 20 Dec 2024 06:11:50 +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=1734675112; cv=none; b=ZLOQgqA+ljBHHxp4KjZytVmFQ4tcaK9XMtpjQaew70ey8f9tvd6kHCW6yxl7csKRj0ZL2yNwhnbuHGwGGagidh1jDSojokibUuIvKqTIxMvMR/IWZ7r4sXmqBBf56GWcwOUCiU0tlHNcGwCvNLuJONkN9qpVK/nwXquQRHTkRNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734675112; c=relaxed/simple; bh=kYV5+VVWdUm+4WTBKwN+YzStOD/3ZS1El4V9nKsyH7E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Md1kAcfp3eC5rw8CWeHA5OPSy1bTmhZJ/D5UBMOcduIfw75FkztHv7UzAAXd71ChOfYNi5XwiTJcWolbzHXN6zPuMQLm4JFE5xD7kNHA5kcz28KYxEW9GN2447seycOCQwTlx23NNTTGQotsbZf4rJFm9YH9zwES1KhTMVoVUK4= 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 4YDxrF456dz4f3lDG; Fri, 20 Dec 2024 14:11:25 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 307BB1A0197; Fri, 20 Dec 2024 14:11:46 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgA3XoKeCmVn6SRyFA--.26943S7; Fri, 20 Dec 2024 14:11:45 +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 3/5] ext4: abort journal on data writeback failure if in data_err=abort mode Date: Fri, 20 Dec 2024 14:07:55 +0800 Message-Id: <20241220060757.1781418-4-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220060757.1781418-1-libaokun@huaweicloud.com> References: <20241220060757.1781418-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: gCh0CgA3XoKeCmVn6SRyFA--.26943S7 X-Co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F7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuY vjfUOnmRUUUUU X-CM-SenderInfo: 5olet0hnxqqx5xdzvxpfor3voofrz/1tbiAQADBWdkCnU2wgABsO Content-Type: text/plain; charset="utf-8" From: Baokun Li If we mount an ext4 fs with data_err=3Dabort option, it should abort on file data write error. But if the extent is unwritten, we won't add a JI_WAIT_DATA bit to the inode, so jbd2 won't wait for the inode's data to be written back and check the inode mapping for errors. The data writeback failures are not sensed unless the log is watched or fsync is called. Therefore, when data_err=3Dabort is enabled, the journal is aborted when an I/O error is detected in ext4_end_io_end() to make users who are concerned about the contents of the file happy. Signed-off-by: Baokun Li --- fs/ext4/page-io.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 6054ec27fb48..058bf4660d7b 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -175,6 +175,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 +191,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) && + !ext4_is_quota_file(inode) && + ext4_should_order_data(inode)) + 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)) { + ext4_msg(sb, KERN_EMERG, "failed to convert unwritten extents to written " "extents -- potential data loss! " "(inode %lu, error %d)", inode->i_ino, ret); --=20 2.46.1 From nobody Sun Feb 8 17:41: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 792E2198823; Fri, 20 Dec 2024 06:11:49 +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=1734675111; cv=none; b=Ndi8XRw593tTIN4egbgR0bBKH3M24xpe5L4rSJJhNL7KGjArQg5nTpxoxWAChTG4qqJHcZ0vHvsKx5E+rDdc0cDkFLNVw7Ezw1WXdsb/3wTBSn2zkbxi8rax6UCQrCru2Owt0xpc8n6ME8/ZGFc5E5kqFetsrU/FoXvhhOz7UOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734675111; c=relaxed/simple; bh=CDsugzs9fMErtron0AUYuJv0qUoJmjRYH6VU5AQkHJw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZukUQ0txqNBONNRS0/g0tOxZRTGN2qComz3YlstLfJPhHYwyYKygz4r3nD6/hCAx0i+admk089IVUz6wzYCJRsmbWS6flWtDDlWr6T4t6fKOeFB8zz9Ju43DrajRcvHsEeX/TVwrMTW/hygJ3FujgEyuSNr9+FN+AMeB5mPADes= 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 4YDxrG0810z4f3l2C; Fri, 20 Dec 2024 14:11:26 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 9A9271A0359; Fri, 20 Dec 2024 14:11:46 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgA3XoKeCmVn6SRyFA--.26943S8; Fri, 20 Dec 2024 14:11:46 +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 4/5] ext4: remove unused member 'i_unwritten' from 'ext4_inode_info' Date: Fri, 20 Dec 2024 14:07:56 +0800 Message-Id: <20241220060757.1781418-5-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220060757.1781418-1-libaokun@huaweicloud.com> References: <20241220060757.1781418-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: gCh0CgA3XoKeCmVn6SRyFA--.26943S8 X-Coremail-Antispam: 1UD129KBjvJXoWxur1DArWxGw1fXw4UtF13urg_yoWrWr43pF WakFy8GF47Xa4qg397GFs7ZF1xtw1xKFWDXry7GayUXasxuryFgF1rtFy5AFyjvFWxAayx XF48CryUZr13CrJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 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/1tbiAgADBWdkCqk2IQAAsz 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 --- 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 9da0e32af02a..203a900fd789 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1059,7 +1059,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; @@ -3786,34 +3785,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 a50e5c31b937..853997655e40 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); @@ -7381,12 +7380,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; @@ -7394,9 +7390,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.46.1 From nobody Sun Feb 8 17:41: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 9673319DF61; Fri, 20 Dec 2024 06:11:50 +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=1734675112; cv=none; b=bPOdWyDW6GjHGuNW6LHWj5UOluhCfZnC2Yv5lKigYvTroEJwXJx95fTDPRMLM62QSDxPEhbFFs8iBa8v3amrV4AZzpC12Ts6TEfOEdmm2QJB4RueGjavxj6mGWFkU6ueZeX7QjO3nmTyPvRDTRv7Z+P+xOj+lA9ygJLNHASpUQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734675112; c=relaxed/simple; bh=ueM1X/xSGjNBPS3ReWmEhuDW3GBKAd4aA2k7fghZO18=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OAWtIeJjQEJjn3uO06SB0KgO9017sBjbT470AWpnvg5gWW1U1QkYjMM3YmKn4hOiY89Fb3Ob1WP+/94SWBLRJSktFuJg/bSL0YNYO9o2IDqRSL7YuxiGTMHLjuRksydjE2pSZtA/IiXfywcx37zsJzFZI4aIvURtUliCPbfRx8Y= 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 4YDxrH3CLvz4f3jsC; Fri, 20 Dec 2024 14:11:27 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 049901A06D7; Fri, 20 Dec 2024 14:11:47 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgA3XoKeCmVn6SRyFA--.26943S9; Fri, 20 Dec 2024 14:11:46 +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 5/5] ext4: pack holes in ext4_inode_info Date: Fri, 20 Dec 2024 14:07:57 +0800 Message-Id: <20241220060757.1781418-6-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220060757.1781418-1-libaokun@huaweicloud.com> References: <20241220060757.1781418-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: gCh0CgA3XoKeCmVn6SRyFA--.26943S9 X-Coremail-Antispam: 1UD129KBjvJXoW7uF48Jr1kZrWkKFW5WFy7trb_yoW8WrW8pF 98K34xGr40q3yq9rW8GF45Zr1Sva1Sgw47Jw4DJw45uryUWr1FqF4ktF1FvFyY9FWxCFyS vF1UKryUZ3W2y3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 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/1tbiAQADBWdkCnU2wwAAsO 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 --- 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 203a900fd789..345dda2310d0 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1060,6 +1060,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 @@ -1097,8 +1099,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. @@ -1141,6 +1141,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; @@ -1151,8 +1152,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.46.1