From patchwork Fri Aug 30 05:37:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhangshida X-Patchwork-Id: 1978741 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=MnoSVZ/Q; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=gt/z=p5=vger.kernel.org=linux-ext4+bounces-3975-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Ww6PW6fZcz1yZ9 for ; Fri, 30 Aug 2024 15:38:07 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Ww6PS403Gz4wcp for ; Fri, 30 Aug 2024 15:38:04 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Ww6PS3yDnz4wny; Fri, 30 Aug 2024 15:38:04 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=MnoSVZ/Q; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=linux-ext4+bounces-3975-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Ww6PS1cnRz4wcp for ; Fri, 30 Aug 2024 15:38:04 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0418E284BA7 for ; Fri, 30 Aug 2024 05:38:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0385B14F9CD; Fri, 30 Aug 2024 05:37:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MnoSVZ/Q" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75AC7136351; Fri, 30 Aug 2024 05:37:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724996270; cv=none; b=ATsmAXjnQz1pXk0NthpXP2SozETgfU/BIXQMtlXqnLHPMiPs/hAhy9NOeEYxrdZmZkeObrKmgqjzgupGigfL2aPN0MjzFneSRfAkhONYQZ13ONSainRJfXplnwhSeHvnWfmxk/0nmEIoyXEa5YPP3ESzTTrd2AfSfg91qFBVmP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724996270; c=relaxed/simple; bh=nuQv1OLBf2ugiCywOpIdcyS0cvAkW50Sitj+r8HjmIw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AdHM0ofxZ4enSI1PWOLr5UPFcr+4C5zpRiwUCTZiVfr1pUQmWV9JvvWKtUX/C9nlipiuvvJZOL7dleV9b2WlkFMc723RD/RD8zNh1T+KWf6rtIs6fHIRKuZFjW2Wx7TgHpwEyIBTVfN3fsO0En1fTAM3WEr+gK4nnX3THIZiMF8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MnoSVZ/Q; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-202089e57d8so10353015ad.0; Thu, 29 Aug 2024 22:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724996269; x=1725601069; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RdVUpClNZhLv7aynuPjXbG3fkC0bU3f1/3YjjjbDagc=; b=MnoSVZ/QcU9yxA2PisMyHVOSAbhFrD8nYi7aoubT0VnXtKviBqPWUEzIA13H1L5JsI CjLSlXfqOJy63tDVOvTZ6o5XkKFavFjDBU59+OkXwzrd+Fr9XCpgfNFnK1jwVLMY0rw5 6lMc/ao9n42YlodCw3GHiqQ5YlxsrZ8NXpFGMYpxLhoBOLXkQcyfAjUKlrVSriaDd9WP HYHR7rcMqWV3WD30FjVl/Y72hV8KB+4dr+w6EJvScF8Iqk6Qwf9tt0tSwf8nUNRn0LA6 94ZBqQadLwdRFY/S6qOSKnj8lGoC7owPKs4PfQ74T5xc9L85Kwmn1UTsMt72lR3QPkWn NJtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724996269; x=1725601069; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RdVUpClNZhLv7aynuPjXbG3fkC0bU3f1/3YjjjbDagc=; b=cL7dBRyXUM9q98sFz0cAJUrXhBpN1GiIHg16XsVkcZCsrf8KAHFkdwR1mnwSrB0DFm l9jHTAZ5B/c4+5xhi65ULPZ8Kf5bUlIrxFlxvPKc60yeIc4a/zQk5tIH1WB63qEUxv4r SCXcSH6wmQYlm2h/EudvjqcCQ2mV3opmcZHkLUKzF7y6cN/OKDyrvEmvq1gcBzW/oJl9 /RkoqE67tx8y/lXBGrxNcnTsA90nja/FvoKELkGNtN9MAy9nIXMee90QbZ27xVMc2ftu DxCzTOCxtxZCeRC1aWB4Il8FQJFDm0zAe50BN7X2siMQQvPXZCcnEj7GiEOEUNGBIuKS eCaQ== X-Forwarded-Encrypted: i=1; AJvYcCWbCkkksPBrIYcbAFDwBAK7fl70XzkIqBfKAEtPrnsmjMspvxfqnC5aIiS9qvIq63xCoIbl1V54wziFOa0=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9L10BjdVgRI66noTu0DifIBKoaq71ql8nKxYpNEsXYoLjFm5O AnSnuApwGXMPMqxMKJnGcSnreNGkRp6KjZUXCoET3aJghVpJzrAb X-Google-Smtp-Source: AGHT+IFpWsVes4diSrUdlF9BJ1BIG9NfIS8lOK21oPRW1rgU8knTSpNvsLNnAnM6puQn3y280G76Tw== X-Received: by 2002:a17:902:e5cf:b0:202:2f0:3b83 with SMTP id d9443c01a7336-2050e9804e1mr71789405ad.13.1724996268556; Thu, 29 Aug 2024 22:37:48 -0700 (PDT) Received: from localhost.localdomain ([163.53.18.10]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20515534801sm19784075ad.154.2024.08.29.22.37.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 22:37:48 -0700 (PDT) From: zhangshida X-Google-Original-From: zhangshida To: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, ebiggers@kernel.org Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, zhangshida@kylinos.cn, starzhangzsd@gmail.com, Jan Kara Subject: [PATCH 1/4] ext4: persist the new uptodate buffers in ext4_journalled_zero_new_buffers Date: Fri, 30 Aug 2024 13:37:36 +0800 Message-Id: <20240830053739.3588573-2-zhangshida@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240830053739.3588573-1-zhangshida@kylinos.cn> References: <20240830053739.3588573-1-zhangshida@kylinos.cn> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Shida Zhang For new uptodate buffers we also need to call write_end_fn() to persist the uptodate content, similarly as folio_zero_new_buffers() does it. Suggested-by: Jan Kara Signed-off-by: Shida Zhang Reviewed-by: Jan Kara --- fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 941c1c0d5c6e..a0a55cb8db53 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1389,9 +1389,9 @@ static void ext4_journalled_zero_new_buffers(handle_t *handle, size = min(to, block_end) - start; folio_zero_range(folio, start, size); - write_end_fn(handle, inode, bh); } clear_buffer_new(bh); + write_end_fn(handle, inode, bh); } } block_start = block_end; From patchwork Fri Aug 30 05:37:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: zhangshida X-Patchwork-Id: 1978742 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=FnrlRLIx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=bdj3=p5=vger.kernel.org=linux-ext4+bounces-3976-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Ww6Pt2ykJz1yZ9 for ; Fri, 30 Aug 2024 15:38:26 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Ww6Pt2pv0z4wcp for ; Fri, 30 Aug 2024 15:38:26 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Ww6Pt2mpnz4wnw; Fri, 30 Aug 2024 15:38:26 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=FnrlRLIx; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.48.161; helo=sy.mirrors.kernel.org; envelope-from=linux-ext4+bounces-3976-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [147.75.48.161]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Ww6Pt2hmnz4wcp for ; Fri, 30 Aug 2024 15:38:26 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E3566B23A8A for ; Fri, 30 Aug 2024 05:38:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D81DC1531DC; Fri, 30 Aug 2024 05:37:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FnrlRLIx" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07D46152DF5; Fri, 30 Aug 2024 05:37:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724996274; cv=none; b=U7cYZBsCqQOK4CtzQmygu0tlitcDquh1Yd9Ruq2uqjYlW/+bEx2teky0+a2oSa9+uOLOCDb+1kcgQc54MQxtMRzBK2tpEWYW6RWPwmDuwXLnBf7OTQ7/V+2sCb9g6INRwgQsRKki44BMx/F/nBeMRg35L5jfJ+RN2wA0TyFbff8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724996274; c=relaxed/simple; bh=BzLfhI5kqpS2KTzpMtsOujy405L5fAsQSsJ9SRU8C7Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=k3+KB3eY6H+DdMdZFPfxtIhZ8cFrS7UuQm/anQ2Vs6jeZxKQOrAK+yJYV+zaAzQkUbaY9FdfFi0vfQlGhSICWMiasCVlU8lOiJwKV12L4gJTtYgBJSYVXnJ+bTmRfWSckMjCwEr6ziZtPcFAApUThJ5fKK1N+3fIDz5WuIvo6FI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FnrlRLIx; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-7142a93ea9cso1216569b3a.3; Thu, 29 Aug 2024 22:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724996271; x=1725601071; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QPGJ08ZeJjCpmoz/bGbkq2klJXuedkm7eCcxXYnusQE=; b=FnrlRLIxAW4D2C5fqgdW0bDmovC/UsAizQTMgYso1TkEAykt1ovF1snpqCCGX4L5sw LLH1/J1X6uu16I9B6PL/Rmm4zyHx4h7GH3j7s6bYpPLp6kCOMIiki6wf0DRo27oqEcrc dPaBHWRPTXtyLrOSS9x2Hq0sFkgCE6hiJI7OQH4tNmh1Ju5g421K7zzJ0fzfLu9gv6pm hsX03syGGRIQ9g67jdVyGw6O765Ql1QAMhMWM/ojr9lUcUoqGW9p7Rr0fs9s8kwWFsy5 5PfN6mXeFALkkkpsw+c0MruBVxU9ASPc9RgEDjzDk5RLuzM+5n4eNWS7pIxel0/nC1fC un5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724996271; x=1725601071; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QPGJ08ZeJjCpmoz/bGbkq2klJXuedkm7eCcxXYnusQE=; b=sIoWvkz8AkaxVQHdTnwldssmfpmA77LUzfuNJnbxHTXBzVnuB+x7KFn6tQ5rDL30KO tlKl91XvDVgCmkMo6ENEzaSSSnOI/XDDwcMS7opkaTk0UiAzCqKDmdMgB0mfKDvn9kuq rdpz/NBeYRBoz+8RPNSFs175nuN9cgQL8ibofmuIhoX2L/cFVkK/3fBhnYyUKdjmuEtf ILATrXWVuWgoBwCeU5aPrg56GkF80+/QB7PhG8XtLd4LfhNq0yyHvSn/61pqy2YTNon4 hDaUmYgZWZSPXdxGXtpC6FMuyOyRfwtDIuaGVlvi6bdvpavKebiEwxLMLc1t/nF2ikcv iTFQ== X-Forwarded-Encrypted: i=1; AJvYcCWAJiWpcpdZoqzKa7dem+ugqZR/+1I/Voskrywpxnwamo4Rq5PbDFSg/7EjY5SjcVrXUP5CJFQ7Vgbvk1s=@vger.kernel.org X-Gm-Message-State: AOJu0Yxc+q36Ox14I3DgC1x8PnRu86q1B2SglFcxGQDbGVel16hhyt69 ON308gJSykAZZPEA8NVrkC1LzmDsTU5AyI74LMbz8l4D3TmwLq8f X-Google-Smtp-Source: AGHT+IEgET23reRNRQf9VJhSqIuOoOqLbFV1EHBZOfqchq7fRrXPDMWCQbbWx35doBgsVKafNJhKDw== X-Received: by 2002:a05:6a20:9e49:b0:1ca:edd5:9254 with SMTP id adf61e73a8af0-1cce100b937mr4388048637.16.1724996270936; Thu, 29 Aug 2024 22:37:50 -0700 (PDT) Received: from localhost.localdomain ([163.53.18.10]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20515534801sm19784075ad.154.2024.08.29.22.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 22:37:50 -0700 (PDT) From: zhangshida X-Google-Original-From: zhangshida To: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, ebiggers@kernel.org Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, zhangshida@kylinos.cn, starzhangzsd@gmail.com, Jan Kara Subject: [PATCH 2/4] ext4: hoist ext4_block_write_begin and replace the __block_write_begin Date: Fri, 30 Aug 2024 13:37:37 +0800 Message-Id: <20240830053739.3588573-3-zhangshida@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240830053739.3588573-1-zhangshida@kylinos.cn> References: <20240830053739.3588573-1-zhangshida@kylinos.cn> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Shida Zhang Using __block_write_begin() make it inconvenient to journal the user data dirty process. We can't tell the block layer maintainer, ‘Hey, we want to trace the dirty user data in ext4, can we add some special code for ext4 in __block_write_begin?’:P So use ext4_block_write_begin() instead. The two functions are basically doing the same thing except for the fscrypt related code. Remove the unnecessary #ifdef since fscrypt_inode_uses_fs_layer_crypto() returns false (and it's known at compile time) when !CONFIG_FS_ENCRYPTION. And hoist the ext4_block_write_begin so that it can be used in other files. Suggested-by: Jan Kara Suggested-by: Eric Biggers Signed-off-by: Shida Zhang Reviewed-by: Jan Kara --- fs/ext4/ext4.h | 2 ++ fs/ext4/inline.c | 10 +++++----- fs/ext4/inode.c | 24 +++++------------------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 08acd152261e..5f8257b68190 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -3851,6 +3851,8 @@ static inline int ext4_buffer_uptodate(struct buffer_head *bh) return buffer_uptodate(bh); } +extern int ext4_block_write_begin(struct folio *folio, loff_t pos, unsigned len, + get_block_t *get_block); #endif /* __KERNEL__ */ #define EFSBADCRC EBADMSG /* Bad CRC detected */ diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index e7a09a99837b..0a1a8431e281 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -601,10 +601,10 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping, goto out; if (ext4_should_dioread_nolock(inode)) { - ret = __block_write_begin(&folio->page, from, to, - ext4_get_block_unwritten); + ret = ext4_block_write_begin(folio, from, to, + ext4_get_block_unwritten); } else - ret = __block_write_begin(&folio->page, from, to, ext4_get_block); + ret = ext4_block_write_begin(folio, from, to, ext4_get_block); if (!ret && ext4_should_journal_data(inode)) { ret = ext4_walk_page_buffers(handle, inode, @@ -856,8 +856,8 @@ static int ext4_da_convert_inline_data_to_extent(struct address_space *mapping, goto out; } - ret = __block_write_begin(&folio->page, 0, inline_size, - ext4_da_get_block_prep); + ret = ext4_block_write_begin(folio, 0, inline_size, + ext4_da_get_block_prep); if (ret) { up_read(&EXT4_I(inode)->xattr_sem); folio_unlock(folio); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index a0a55cb8db53..4964c67e029e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1024,10 +1024,10 @@ int do_journal_get_write_access(handle_t *handle, struct inode *inode, if (!buffer_mapped(bh) || buffer_freed(bh)) return 0; /* - * __block_write_begin() could have dirtied some buffers. Clean + * ext4_block_write_begin() could have dirtied some buffers. Clean * the dirty bit as jbd2_journal_get_write_access() could complain * otherwise about fs integrity issues. Setting of the dirty bit - * by __block_write_begin() isn't a real problem here as we clear + * by ext4_block_write_begin() isn't a real problem here as we clear * the bit before releasing a page lock and thus writeback cannot * ever write the buffer. */ @@ -1041,9 +1041,8 @@ int do_journal_get_write_access(handle_t *handle, struct inode *inode, return ret; } -#ifdef CONFIG_FS_ENCRYPTION -static int ext4_block_write_begin(struct folio *folio, loff_t pos, unsigned len, - get_block_t *get_block) +int ext4_block_write_begin(struct folio *folio, loff_t pos, unsigned len, + get_block_t *get_block) { unsigned from = pos & (PAGE_SIZE - 1); unsigned to = from + len; @@ -1134,7 +1133,6 @@ static int ext4_block_write_begin(struct folio *folio, loff_t pos, unsigned len, return err; } -#endif /* * To preserve ordering, it is essential that the hole instantiation and @@ -1216,19 +1214,11 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping, /* In case writeback began while the folio was unlocked */ folio_wait_stable(folio); -#ifdef CONFIG_FS_ENCRYPTION if (ext4_should_dioread_nolock(inode)) ret = ext4_block_write_begin(folio, pos, len, ext4_get_block_unwritten); else ret = ext4_block_write_begin(folio, pos, len, ext4_get_block); -#else - if (ext4_should_dioread_nolock(inode)) - ret = __block_write_begin(&folio->page, pos, len, - ext4_get_block_unwritten); - else - ret = __block_write_begin(&folio->page, pos, len, ext4_get_block); -#endif if (!ret && ext4_should_journal_data(inode)) { ret = ext4_walk_page_buffers(handle, inode, folio_buffers(folio), from, to, @@ -1241,7 +1231,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping, folio_unlock(folio); /* - * __block_write_begin may have instantiated a few blocks + * ext4_block_write_begin may have instantiated a few blocks * outside i_size. Trim these off again. Don't need * i_size_read because we hold i_rwsem. * @@ -2961,11 +2951,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, if (IS_ERR(folio)) return PTR_ERR(folio); -#ifdef CONFIG_FS_ENCRYPTION ret = ext4_block_write_begin(folio, pos, len, ext4_da_get_block_prep); -#else - ret = __block_write_begin(&folio->page, pos, len, ext4_da_get_block_prep); -#endif if (ret < 0) { folio_unlock(folio); folio_put(folio); From patchwork Fri Aug 30 05:37:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhangshida X-Patchwork-Id: 1978743 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Von9vg47; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=ynf3=p5=vger.kernel.org=linux-ext4+bounces-3977-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Ww6Q26RWCz1yZ9 for ; Fri, 30 Aug 2024 15:38:34 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Ww6Q263nWz4wnw for ; Fri, 30 Aug 2024 15:38:34 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Ww6Q2622Qz4wny; Fri, 30 Aug 2024 15:38:34 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Von9vg47; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-ext4+bounces-3977-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Ww6Q23ntrz4wnw for ; Fri, 30 Aug 2024 15:38:34 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4B3CF285F89 for ; Fri, 30 Aug 2024 05:38:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4CD941531EF; Fri, 30 Aug 2024 05:37:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Von9vg47" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B153136351; Fri, 30 Aug 2024 05:37:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724996276; cv=none; b=r6X9IPWGD58/aJTHsy+meXs+IpmBNQ0766mvpRGhG5gDYPcXARCEo8xwSITmGsuv95d2ic1wSiuyFgFR+k7jN63Lf6dQsrpycLOPZayBbzK/7MnWBJN0StEHK4a2CHiT8iwAtNeTC/+oRVnNpZqajm7iKt4I6ic4eESwUTxWYys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724996276; c=relaxed/simple; bh=o8Y5ytUvlYj85U4LvQ9BLdLnfjD/2YlafDawCcihM3Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=e6cm9b1DVhVAZ50KYUZP+/YMXBOC6OVZCbf2xcC2R2AjZgk3NiV5E28YebHKKAvhqVJqQDpMZFgwBl5eIFhP1SRDLcNfw404t6vLmY6xV7UXIfUkJcTEsZJ+nB8hje+pYrE+CGvAkclk5fb3GWOemE1FzHBtKumwA9hJeqeLXJ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Von9vg47; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-7cd8803fe0aso901284a12.0; Thu, 29 Aug 2024 22:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724996274; x=1725601074; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EZE3w5xcdYxq7R8uMMW9Ui1xfRyk6LmkP5wh78+WNYQ=; b=Von9vg47207v0yRvoBMaShqnSsF7t/XBUswnD3W4Rhpgzr1YVOAiZW8Wtlsl5Zzt/t 4nO6dKCXGwVmAESvKLmiGUCbI0jEELG7YSYABSi/hTsJedc/rJCwJm2ZaQw3L+lSUM56 pE+P/7DzkF1Ac1Evg9BD9omcOg2OuMrVg/SNYB94vHfeanGY9og2Hw2iabNWcVqMH727 CDGS2o0RuLsFdknXLuWF7AtS2ar9tG53p8AzmHXpj20mj/QVPtC7WW4KkC01n1Y5I9UL xXCJ3rAH8xpYkPz68gP2dnn4Pp347NSJC7x9Q0v0vCkey+qB5Esd+995IGXcpQHe5ZCX IBPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724996274; x=1725601074; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EZE3w5xcdYxq7R8uMMW9Ui1xfRyk6LmkP5wh78+WNYQ=; b=hekHJofCGHzWNIZ8LhjH6arLLBmTxfD2GfMIb69iIpDpP3tVdFaiB+GuQ3S57zUt+Q KTwmX8T38U1oASpjAiUiBBz01HUSllaPFTMXsdGyJYdjjiaVAZrfvLX+8zOpucOfmEQd MiSuLlGsNe3Vnz0TJXic73ju7nFs7gO3z3UHaMS7qO99zS5dYqR/jvQD+f3WEW6AvWvh HdnN1/OHG/Cd+f/Nz1oA4fOF3cgESynYK6im8PIX+DAz7QDcj4azCYq5vd3LSL3CF9vp ASQoomkJIFVbn/vFuzv4ZHfsHHEUkod9+fABab8sV7eS4wgt4EMwF8pf/Zx5Q4rzIVRd sAVQ== X-Forwarded-Encrypted: i=1; AJvYcCXtcfRrIb2e2nM/Ox47GRnNN3jhxF7/z4LfoTbTPU4wsMfk/dJgBnT2I3AtP3zAqumi8lnWZHAtWVec85M=@vger.kernel.org X-Gm-Message-State: AOJu0YwRtlziKP/icT6DhfUCZcIc/L4sZmVoUn8Ac/TdozCLJB92DUDC rN00Wn9XZBz/GZ0zNna/6OSP3TJ7xU3smqI6wGw7b/8YCs2GWxL+ X-Google-Smtp-Source: AGHT+IHcu1RYo4NUt6URZZToo91Zs42//QbIp7vnbmPJflLz8ldH2Soc3QNHxeom6HV60lcDXqzpEg== X-Received: by 2002:a05:6a21:6f83:b0:1c2:8af6:31d3 with SMTP id adf61e73a8af0-1cce0ff185cmr5486770637.10.1724996273515; Thu, 29 Aug 2024 22:37:53 -0700 (PDT) Received: from localhost.localdomain ([163.53.18.10]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20515534801sm19784075ad.154.2024.08.29.22.37.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 22:37:53 -0700 (PDT) From: zhangshida X-Google-Original-From: zhangshida To: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, ebiggers@kernel.org Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, zhangshida@kylinos.cn, starzhangzsd@gmail.com, Baolin Liu , Jan Kara Subject: [PATCH 3/4] ext4: fix a potential assertion failure due to improperly dirtied buffer Date: Fri, 30 Aug 2024 13:37:38 +0800 Message-Id: <20240830053739.3588573-4-zhangshida@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240830053739.3588573-1-zhangshida@kylinos.cn> References: <20240830053739.3588573-1-zhangshida@kylinos.cn> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Shida Zhang On an old kernel version(4.19, ext3, data=journal, pagesize=64k), an assertion failure will occasionally be triggered by the line below: ----------- jbd2_journal_commit_transaction { ... J_ASSERT_BH(bh, !buffer_dirty(bh)); /* * The buffer on BJ_Forget list and not jbddirty means ... } ----------- The same condition may also be applied to the lattest kernel version. When blocksize < pagesize and we truncate a file, there can be buffers in the mapping tail page beyond i_size. These buffers will be filed to transaction's BJ_Forget list by ext4_journalled_invalidatepage() during truncation. When the transaction doing truncate starts committing, we can grow the file again. This calls __block_write_begin() which allocates new blocks under these buffers in the tail page we go through the branch: if (buffer_new(bh)) { clean_bdev_bh_alias(bh); if (folio_test_uptodate(folio)) { clear_buffer_new(bh); set_buffer_uptodate(bh); mark_buffer_dirty(bh); continue; } ... } Hence buffers on BJ_Forget list of the committing transaction get marked dirty and this triggers the jbd2 assertion. Teach ext4_block_write_begin() to properly handle files with data journalling by avoiding dirtying them directly. Instead of folio_zero_new_buffers() we use ext4_journalled_zero_new_buffers() which takes care of handling journalling. We also don't need to mark new uptodate buffers as dirty in ext4_block_write_begin(). That will be either done either by block_commit_write() in case of success or by folio_zero_new_buffers() in case of failure. Reported-by: Baolin Liu Suggested-by: Jan Kara Signed-off-by: Shida Zhang Reviewed-by: Jan Kara --- fs/ext4/ext4.h | 3 ++- fs/ext4/inline.c | 7 ++++--- fs/ext4/inode.c | 42 ++++++++++++++++++++++++++++++++++-------- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 5f8257b68190..b653bd423b11 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -3851,7 +3851,8 @@ static inline int ext4_buffer_uptodate(struct buffer_head *bh) return buffer_uptodate(bh); } -extern int ext4_block_write_begin(struct folio *folio, loff_t pos, unsigned len, +extern int ext4_block_write_begin(handle_t *handle, struct folio *folio, + loff_t pos, unsigned len, get_block_t *get_block); #endif /* __KERNEL__ */ diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index 0a1a8431e281..8d5599d5af27 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -601,10 +601,11 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping, goto out; if (ext4_should_dioread_nolock(inode)) { - ret = ext4_block_write_begin(folio, from, to, + ret = ext4_block_write_begin(handle, folio, from, to, ext4_get_block_unwritten); } else - ret = ext4_block_write_begin(folio, from, to, ext4_get_block); + ret = ext4_block_write_begin(handle, folio, from, to, + ext4_get_block); if (!ret && ext4_should_journal_data(inode)) { ret = ext4_walk_page_buffers(handle, inode, @@ -856,7 +857,7 @@ static int ext4_da_convert_inline_data_to_extent(struct address_space *mapping, goto out; } - ret = ext4_block_write_begin(folio, 0, inline_size, + ret = ext4_block_write_begin(NULL, folio, 0, inline_size, ext4_da_get_block_prep); if (ret) { up_read(&EXT4_I(inode)->xattr_sem); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 4964c67e029e..a28f279fd02f 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -49,6 +49,11 @@ #include +static void ext4_journalled_zero_new_buffers(handle_t *handle, + struct inode *inode, + struct folio *folio, + unsigned from, unsigned to); + static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw, struct ext4_inode_info *ei) { @@ -1041,7 +1046,8 @@ int do_journal_get_write_access(handle_t *handle, struct inode *inode, return ret; } -int ext4_block_write_begin(struct folio *folio, loff_t pos, unsigned len, +int ext4_block_write_begin(handle_t *handle, struct folio *folio, + loff_t pos, unsigned len, get_block_t *get_block) { unsigned from = pos & (PAGE_SIZE - 1); @@ -1055,6 +1061,7 @@ int ext4_block_write_begin(struct folio *folio, loff_t pos, unsigned len, struct buffer_head *bh, *head, *wait[2]; int nr_wait = 0; int i; + bool should_journal_data = ext4_should_journal_data(inode); BUG_ON(!folio_test_locked(folio)); BUG_ON(from > PAGE_SIZE); @@ -1084,10 +1091,22 @@ int ext4_block_write_begin(struct folio *folio, loff_t pos, unsigned len, if (err) break; if (buffer_new(bh)) { + /* + * We may be zeroing partial buffers or all new + * buffers in case of failure. Prepare JBD2 for + * that. + */ + if (should_journal_data) + do_journal_get_write_access(handle, + inode, bh); if (folio_test_uptodate(folio)) { - clear_buffer_new(bh); + /* + * Unlike __block_write_begin() we leave + * dirtying of new uptodate buffers to + * ->write_end() time or + * folio_zero_new_buffers(). + */ set_buffer_uptodate(bh); - mark_buffer_dirty(bh); continue; } if (block_end > to || block_start < from) @@ -1117,7 +1136,11 @@ int ext4_block_write_begin(struct folio *folio, loff_t pos, unsigned len, err = -EIO; } if (unlikely(err)) { - folio_zero_new_buffers(folio, from, to); + if (should_journal_data) + ext4_journalled_zero_new_buffers(handle, inode, folio, + from, to); + else + folio_zero_new_buffers(folio, from, to); } else if (fscrypt_inode_uses_fs_layer_crypto(inode)) { for (i = 0; i < nr_wait; i++) { int err2; @@ -1215,10 +1238,11 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping, folio_wait_stable(folio); if (ext4_should_dioread_nolock(inode)) - ret = ext4_block_write_begin(folio, pos, len, + ret = ext4_block_write_begin(handle, folio, pos, len, ext4_get_block_unwritten); else - ret = ext4_block_write_begin(folio, pos, len, ext4_get_block); + ret = ext4_block_write_begin(handle, folio, pos, len, + ext4_get_block); if (!ret && ext4_should_journal_data(inode)) { ret = ext4_walk_page_buffers(handle, inode, folio_buffers(folio), from, to, @@ -2951,7 +2975,8 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, if (IS_ERR(folio)) return PTR_ERR(folio); - ret = ext4_block_write_begin(folio, pos, len, ext4_da_get_block_prep); + ret = ext4_block_write_begin(NULL, folio, pos, len, + ext4_da_get_block_prep); if (ret < 0) { folio_unlock(folio); folio_put(folio); @@ -6205,7 +6230,8 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf) if (folio_pos(folio) + len > size) len = size - folio_pos(folio); - err = __block_write_begin(&folio->page, 0, len, ext4_get_block); + err = ext4_block_write_begin(handle, folio, 0, len, + ext4_get_block); if (!err) { ret = VM_FAULT_SIGBUS; if (ext4_journal_folio_buffers(handle, folio, len)) From patchwork Fri Aug 30 05:37:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhangshida X-Patchwork-Id: 1978744 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=UE4f94JZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=tvk7=p5=vger.kernel.org=linux-ext4+bounces-3978-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Ww6QQ6f6Vz1yZ9 for ; Fri, 30 Aug 2024 15:38:54 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Ww6QQ6DB7z4wcp for ; Fri, 30 Aug 2024 15:38:54 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Ww6QQ6BM5z4wnw; Fri, 30 Aug 2024 15:38:54 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=UE4f94JZ; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=linux-ext4+bounces-3978-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Ww6QQ2ZDKz4wcp for ; Fri, 30 Aug 2024 15:38:54 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AD73F1F23967 for ; Fri, 30 Aug 2024 05:38:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74E15153BE3; Fri, 30 Aug 2024 05:37:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UE4f94JZ" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D58131531FA; Fri, 30 Aug 2024 05:37:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724996278; cv=none; b=L9IeuXd0D3Fp7+L7yWJi3g6B1h1eEFUphuwofRm38x21jbqu7ZeRffRvze/s65zcAY5S0JOPmq6w1mtXuyuVtgOcaAhILBRM1qUq3ul3Hw2ml+zUmUJzV/jzYO+R5E1Jzv9gFU43CiqDn4ucMMZGJXtKoXSQjz3fgOy8eu4xHts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724996278; c=relaxed/simple; bh=jacIqIDAkBs2UQ8mkVzFuVyqYc1Wu3C41rsKkRp86oM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ElzwpHMQONdT7RNsqCh4vGDvW75cq/6xGovxVZxVEXfhAeUAKaWh0Bk4QhD0cYuIz4bkkZ9DzsLmOl1MwrdaBL1ZODVem2h0D1Z4biohXEPI2G8Y2GvQp9AzAXKtfZT173vII5cY13DUR14bJNZiwoUk+X6CB3UksglXxSkepq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UE4f94JZ; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-7140ff4b1e9so1223459b3a.3; Thu, 29 Aug 2024 22:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724996276; x=1725601076; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HbWYJDjhX3IfCHXHqjD1zEsVDG4teXMTYrTd6zW/Kz8=; b=UE4f94JZg+qJN5sved0TGDHlb3iVHZwfqZGXHFkOJ6Fm/QcPTPKya1od4aB+/FernZ kSfvoKFvZ1Be5SgCY4fMeXW6JYcsiKyF4awY8SwCXCHyBBk9urkKo3+nU/Y4OEN5MpAy 3ZgVrsww3cFOZqayDtU+vL7EZz/bp+YgGC8wKrpFBaDj+GrrEgQCmeYYm0sd6RRW5tC8 i/WOH2CJxThjHGAfCHveH31I855PtNbHJDvbqdIWpMoVa8kiDE+96ln+qFkSTHgKt1Mt 6zbnZQWf775+8hkX3El0Y8zwWuR/lzaHUtgCaaDbj2yXx13G1g/wpG1rpskReiQgCOBT 7BCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724996276; x=1725601076; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HbWYJDjhX3IfCHXHqjD1zEsVDG4teXMTYrTd6zW/Kz8=; b=vEoBtiLl6r9Yas7Z7rodQaoadZXeLPWbnVd38ShhHN+Jc1Rjf8eGgITOedfE+7qkXh CrQOaTvSFUapY1lYQiPmdpVj3hcUuZdZiG0jly3jk3IfiQzDYWm7nW41M6bpKvO6V84Y Ti7gNYlZ+qNQ91T9cTtOgBsdu4zV9idAjpjQ628ypb/3F/ej+BZMI3NOrjnPDx1mQ4Vo 5cilnLCCKyS5LbziiWttg56GAk+Fc2sV4/F/Em0CWpfuX4qRA6CpttPSLB4FAq/4gXjE owK36413bH3cNM4K3l2SyCFenIbrxANHXk25brhIEuZNxSlUmXkzTKC40SBQBKYLf1ud L5Kw== X-Forwarded-Encrypted: i=1; AJvYcCXuS1TCgCGcqwqwj0L9RFPYbxCq//S5FS5tHixqvFHJZ5yI5UQLY0IZ9wrkYrpOLQoYHojvqWMyQOtYP74=@vger.kernel.org X-Gm-Message-State: AOJu0YxSKoTD2NSyJNdMKiIqIz8JOkOa0j3tw/bufHLYN0LdErrW3iWJ VxCGYF+Tn1sfCVpYz30cyI+A8z/4K7NHw2e5MNIf/8iFo+Sgl+kq X-Google-Smtp-Source: AGHT+IH3OlfqR5/+QqgNBUDnmzafAo5QJb9yjWI6aNRjz+2dn4fgQProfDobalZmqy9vFvVFRP41sA== X-Received: by 2002:a05:6a21:920a:b0:1c0:e69f:f237 with SMTP id adf61e73a8af0-1cce100ef98mr5424726637.21.1724996275818; Thu, 29 Aug 2024 22:37:55 -0700 (PDT) Received: from localhost.localdomain ([163.53.18.10]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20515534801sm19784075ad.154.2024.08.29.22.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 22:37:55 -0700 (PDT) From: zhangshida X-Google-Original-From: zhangshida To: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, ebiggers@kernel.org Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, zhangshida@kylinos.cn, starzhangzsd@gmail.com, Jan Kara Subject: [PATCH 4/4] ext4: remove the special buffer dirty handling in do_journal_get_write_access Date: Fri, 30 Aug 2024 13:37:39 +0800 Message-Id: <20240830053739.3588573-5-zhangshida@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240830053739.3588573-1-zhangshida@kylinos.cn> References: <20240830053739.3588573-1-zhangshida@kylinos.cn> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Shida Zhang This kinda revert the commit 56d35a4cd13e("ext4: Fix dirtying of journalled buffers in data=journal mode") made by Jan 14 years ago, since the do_get_write_access() itself can deal with the extra unexpected buf dirting things in a proper way now. Suggested-by: Jan Kara Signed-off-by: Shida Zhang Reviewed-by: Jan Kara --- fs/ext4/inode.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index a28f279fd02f..2687bf451a25 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1023,27 +1023,11 @@ static int ext4_dirty_journalled_data(handle_t *handle, struct buffer_head *bh) int do_journal_get_write_access(handle_t *handle, struct inode *inode, struct buffer_head *bh) { - int dirty = buffer_dirty(bh); - int ret; - if (!buffer_mapped(bh) || buffer_freed(bh)) return 0; - /* - * ext4_block_write_begin() could have dirtied some buffers. Clean - * the dirty bit as jbd2_journal_get_write_access() could complain - * otherwise about fs integrity issues. Setting of the dirty bit - * by ext4_block_write_begin() isn't a real problem here as we clear - * the bit before releasing a page lock and thus writeback cannot - * ever write the buffer. - */ - if (dirty) - clear_buffer_dirty(bh); BUFFER_TRACE(bh, "get write access"); - ret = ext4_journal_get_write_access(handle, inode->i_sb, bh, + return ext4_journal_get_write_access(handle, inode->i_sb, bh, EXT4_JTR_NONE); - if (!ret && dirty) - ret = ext4_dirty_journalled_data(handle, bh); - return ret; } int ext4_block_write_begin(handle_t *handle, struct folio *folio,