{"id":2190724,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2190724/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260130031232.60780-3-me@linux.beauty/","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/1.2/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260130031232.60780-3-me@linux.beauty>","list_archive_url":null,"date":"2026-01-30T03:12:31","name":"[2/3] ext4: use READ_ONCE for lockless jinode reads","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"433be12c70858d2228b845b7ff704a2a1a9586a7","submitter":{"id":84264,"url":"http://patchwork.ozlabs.org/api/1.2/people/84264/?format=json","name":"Li Chen","email":"me@linux.beauty"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260130031232.60780-3-me@linux.beauty/mbox/","series":[{"id":490324,"url":"http://patchwork.ozlabs.org/api/1.2/series/490324/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/list/?series=490324","date":"2026-01-30T03:12:31","name":"jbd2/ext4/ocfs2: READ_ONCE for lockless jinode reads","version":1,"mbox":"http://patchwork.ozlabs.org/series/490324/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2190724/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2190724/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <SRS0=pzSN=AD=vger.kernel.org=linux-ext4+bounces-13435-patchwork-incoming=ozlabs.org@ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-ext4@vger.kernel.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","patchwork-incoming@ozlabs.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=linux.beauty header.i=me@linux.beauty\n header.a=rsa-sha256 header.s=zmail header.b=RC0Gvuh4;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org\n (client-ip=150.107.74.76; helo=mail.ozlabs.org;\n envelope-from=srs0=pzsn=ad=vger.kernel.org=linux-ext4+bounces-13435-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)","gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=172.105.105.114\n arc.chain=\"subspace.kernel.org:zohomail.com\"","gandalf.ozlabs.org;\n dmarc=none (p=none dis=none) header.from=linux.beauty","gandalf.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=linux.beauty header.i=me@linux.beauty\n header.a=rsa-sha256 header.s=zmail header.b=RC0Gvuh4;\n\tdkim-atps=neutral","gandalf.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-ext4+bounces-13435-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty\n header.b=\"RC0Gvuh4\"","smtp.subspace.kernel.org;\n arc=pass smtp.client-ip=136.143.188.112","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=linux.beauty","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=linux.beauty"],"Received":["from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4f2Lgk0Wymz1xtd\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 30 Jan 2026 14:13:37 +1100 (AEDT)","from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4f2Lgj25qnz4wCk\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 30 Jan 2026 14:13:37 +1100 (AEDT)","by gandalf.ozlabs.org (Postfix)\n\tid 4f2Lgj22skz4wDG; Fri, 30 Jan 2026 14:13:37 +1100 (AEDT)","from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby gandalf.ozlabs.org (Postfix) with ESMTPS id 4f2Lgd23t4z4wCk\n\tfor <patchwork-incoming@ozlabs.org>; Fri, 30 Jan 2026 14:13:33 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 0F4EA301372E\n\tfor <patchwork-incoming@ozlabs.org>; Fri, 30 Jan 2026 03:13:28 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id C38FA349B0C;\n\tFri, 30 Jan 2026 03:13:26 +0000 (UTC)","from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com\n [136.143.188.112])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B3FD2FDC5C;\n\tFri, 30 Jan 2026 03:13:25 +0000 (UTC)","by mx.zohomail.com with SMTPS id 1769742774598265.0356064896463;\n\tThu, 29 Jan 2026 19:12:54 -0800 (PST)"],"ARC-Seal":["i=3; a=rsa-sha256; d=ozlabs.org; s=201707; t=1769742817; cv=pass;\n\tb=lAqEN45bhvtSRsdbb9poY5rvGnR53uh6MLBfSqB60BR+NTRcb2CBp5lwMxQcygI0AO4pyghXrdGWfUyprFuph7gUkLKpdb88HT4Sr0oBVdfWE4ROabBgc5mzI0KhBG+6ojG4jEaKNR6XPKyINUyHcqLFSvyLXe2fTCGPpesLCtnEkyd0Z4DmOY09Ztm74Hc8codX8Pdpd+PQt8Z7Aou7NcZ/FAWcHJ4e0tSDw5Mjj1J97prqeugEa9HtxaKU+9glh1cpqebNfDSPhKOUs21lLY1UpKVFgVr1d1PPAcWM2Vv1n8bzaTCnfKxGcU7Ilf8uNDMjL900Y6BRPs25WhsAsQ==","i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1769742806; cv=pass;\n b=sEMoPeX+Dg6scb7X6MJjmNRmh7ZGldj7/GQ1sTHfGcmIX1toHpf4ohZjEwx9MRLQpCqr9gP1B6iSnfvp+HDu7XwzF5c6pq/UM+DeIWLPQp0FWifU1F0/bre2p9cv6+Bd6dmyCqnAMpVSlkpAQPZDnXQ0MloP9aUDBNx3niWU4ZY=","i=1; a=rsa-sha256; t=1769742780; cv=none;\n\td=zohomail.com; s=zohoarc;\n\tb=Uy540XI0jTOgxnBzThN7hEL1F8VkpkpGY4ZMGEwvTGxBDKL9DoFG66nM/1ltiSjfjXE06Vho58d0MjqDiwN7GJ18FdgdTMsE8aioBbIiHY9FJiKbiBcHEudO8E+TGN/IG5x3K4GvArT5Pld0hjj9jij75IpaeQml4FBZ0Hd8Cso="],"ARC-Message-Signature":["i=3; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1769742817; c=relaxed/relaxed;\n\tbh=avd/AUZNm7D9+j9YRkdHx4VzxdkkFbvm2wfnuocDPVo=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=oHJjwqH2w8J4vpxWJgTlC9Z5pSjyDN9ld6tuFMmWXxeTR5kn00hbrUmhqH7EbsaIAIjFsKxHbinlU2IGM5CzLlcBJnRHsNgZpsga/xmS2CaUe/zoB4Gu2gQE8tMmeLeozQasjx+J43UFLLcpchpEA1mEgfGRpWpPSJYAtpCxx6t83OiCk1XweHsjAEs15iw7QC4CWdOIWxiNaNkwNzy7ObXN97fj5uW/V8CDzAxoxgjIqNEl76THgMHrM/YTmXf3nUV1WeisscHD539pDdr+wIPnBXnGDRNwzzTqZiTxBxBgCdaDhveNjmIma50LFITIRlXuzm7w3WxjPagHq5f1AA==","i=2; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1769742806; c=relaxed/simple;\n\tbh=j/7YFkVlx9cqucXzcCMuVijXkSl7DCvIHMyg6bKq/Rg=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=NExq14ZRfsYyL1YuQonHlEKu+J6yDVwFg+w3emWEGqEOZik36PkxSdU5wHnjd4S4mQ0PWjm7k0zvEl/+zIXAhj45UaDZPW/OivPLvBvVw6uCwZrlrJGQT1Qc9o5+eHu567P8f4SKMbQv3Ck072Yhyf9cMCMBRkBOxxc0czv5Y/g=","i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;\n s=zohoarc;\n\tt=1769742780;\n h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To;\n\tbh=avd/AUZNm7D9+j9YRkdHx4VzxdkkFbvm2wfnuocDPVo=;\n\tb=DBQdyvAU+x6sQtJWDPSOIpn36jh2HQGRhObqgLCGbYQZwYa+k+UvF4JQeCeDdOvXBmINr2w/b93/TkbQ0bm/4hHZ9O+GXxazdVA9vYdWVyACnsIMSjjWH0uZxnYzVU2sqNDYgwasfFKEV+rn2mWnS9WMkFfoQc2gRgzJiOCZhjM="],"ARC-Authentication-Results":["i=3; gandalf.ozlabs.org;\n dmarc=none (p=none dis=none) header.from=linux.beauty;\n dkim=pass (1024-bit key;\n unprotected) header.d=linux.beauty header.i=me@linux.beauty\n header.a=rsa-sha256 header.s=zmail header.b=RC0Gvuh4; dkim-atps=neutral;\n spf=pass (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-ext4+bounces-13435-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org","i=2; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=linux.beauty;\n spf=pass smtp.mailfrom=linux.beauty;\n dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty\n header.b=RC0Gvuh4; arc=pass smtp.client-ip=136.143.188.112","i=1; mx.zohomail.com;\n\tdkim=pass  header.i=linux.beauty;\n\tspf=pass  smtp.mailfrom=me@linux.beauty;\n\tdmarc=pass header.from=<me@linux.beauty>"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1769742780;\n\ts=zmail; d=linux.beauty; i=me@linux.beauty;\n\th=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To;\n\tbh=avd/AUZNm7D9+j9YRkdHx4VzxdkkFbvm2wfnuocDPVo=;\n\tb=RC0Gvuh4MNWJZfwXsVBH5PbnA51XJddqMxkpo1mLYHfHRsbOTNmOnoFjkJ65AkIT\n\tsHsYaaCOe3tF+qlaZgDLq4vVk6x1b9CTD9UWno5GJ3qKNf4tmkuEago/cj8BmSOgFiV\n\t7Fn2GjQh8BX5yXOlUGJ8CBCI157pQloE3z8qP3Kg=","From":"Li Chen <me@linux.beauty>","To":"\"Theodore Ts'o\" <tytso@mit.edu>,\n\tAndreas Dilger <adilger.kernel@dilger.ca>,\n\tlinux-ext4@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org","Cc":"Jan Kara <jack@suse.com>,\n\tLi Chen <me@linux.beauty>","Subject":"[PATCH 2/3] ext4: use READ_ONCE for lockless jinode reads","Date":"Fri, 30 Jan 2026 11:12:31 +0800","Message-ID":"<20260130031232.60780-3-me@linux.beauty>","X-Mailer":"git-send-email 2.52.0","In-Reply-To":"<20260130031232.60780-1-me@linux.beauty>","References":"<20260130031232.60780-1-me@linux.beauty>","Precedence":"bulk","X-Mailing-List":"linux-ext4@vger.kernel.org","List-Id":"<linux-ext4.vger.kernel.org>","List-Subscribe":"<mailto:linux-ext4+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-ext4+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-ZohoMailClient":"External","X-Spam-Status":"No, score=-1.2 required=5.0 tests=ARC_SIGNED,ARC_VALID,\n\tDKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_MISSING,\n\tHEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,\n\tSPF_PASS autolearn=disabled version=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org"},"content":"ext4 journal commit callbacks access jbd2_inode fields such as\ni_transaction and i_dirty_start/end without holding journal->j_list_lock.\n\nUse READ_ONCE() for these reads to correct the concurrency assumptions.\n\nSuggested-by: Jan Kara <jack@suse.com>\nSigned-off-by: Li Chen <me@linux.beauty>\n---\n fs/ext4/inode.c |  6 ++++--\n fs/ext4/super.c | 13 ++++++++-----\n 2 files changed, 12 insertions(+), 7 deletions(-)","diff":"diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c\nindex d99296d7315f..2d451388e080 100644\n--- a/fs/ext4/inode.c\n+++ b/fs/ext4/inode.c\n@@ -3033,11 +3033,13 @@ static int ext4_writepages(struct address_space *mapping,\n \n int ext4_normal_submit_inode_data_buffers(struct jbd2_inode *jinode)\n {\n+\tloff_t dirty_start = READ_ONCE(jinode->i_dirty_start);\n+\tloff_t dirty_end = READ_ONCE(jinode->i_dirty_end);\n \tstruct writeback_control wbc = {\n \t\t.sync_mode = WB_SYNC_ALL,\n \t\t.nr_to_write = LONG_MAX,\n-\t\t.range_start = jinode->i_dirty_start,\n-\t\t.range_end = jinode->i_dirty_end,\n+\t\t.range_start = dirty_start,\n+\t\t.range_end = dirty_end,\n \t};\n \tstruct mpage_da_data mpd = {\n \t\t.inode = jinode->i_vfs_inode,\ndiff --git a/fs/ext4/super.c b/fs/ext4/super.c\nindex 5cf6c2b54bbb..acb2bc016fd4 100644\n--- a/fs/ext4/super.c\n+++ b/fs/ext4/super.c\n@@ -521,6 +521,7 @@ static bool ext4_journalled_writepage_needs_redirty(struct jbd2_inode *jinode,\n {\n \tstruct buffer_head *bh, *head;\n \tstruct journal_head *jh;\n+\ttransaction_t *trans = READ_ONCE(jinode->i_transaction);\n \n \tbh = head = folio_buffers(folio);\n \tdo {\n@@ -539,7 +540,7 @@ static bool ext4_journalled_writepage_needs_redirty(struct jbd2_inode *jinode,\n \t\t */\n \t\tjh = bh2jh(bh);\n \t\tif (buffer_dirty(bh) ||\n-\t\t    (jh && (jh->b_transaction != jinode->i_transaction ||\n+\t\t    (jh && (jh->b_transaction != trans ||\n \t\t\t    jh->b_next_transaction)))\n \t\t\treturn true;\n \t} while ((bh = bh->b_this_page) != head);\n@@ -550,12 +551,14 @@ static bool ext4_journalled_writepage_needs_redirty(struct jbd2_inode *jinode,\n static int ext4_journalled_submit_inode_data_buffers(struct jbd2_inode *jinode)\n {\n \tstruct address_space *mapping = jinode->i_vfs_inode->i_mapping;\n+\tloff_t dirty_start = READ_ONCE(jinode->i_dirty_start);\n+\tloff_t dirty_end = READ_ONCE(jinode->i_dirty_end);\n \tstruct writeback_control wbc = {\n-\t\t.sync_mode =  WB_SYNC_ALL,\n+\t\t.sync_mode = WB_SYNC_ALL,\n \t\t.nr_to_write = LONG_MAX,\n-\t\t.range_start = jinode->i_dirty_start,\n-\t\t.range_end = jinode->i_dirty_end,\n-        };\n+\t\t.range_start = dirty_start,\n+\t\t.range_end = dirty_end,\n+\t};\n \tstruct folio *folio = NULL;\n \tint error;\n \n","prefixes":["2/3"]}