From patchwork Mon Oct 7 09:28:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luis Henriques (SUSE)" X-Patchwork-Id: 1993511 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=PGqSyBcb; 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=8l72=rd=vger.kernel.org=linux-ext4+bounces-4521-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 4XMYjv1tnMz1xsn for ; Mon, 7 Oct 2024 20:28:35 +1100 (AEDT) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4XMYjt3nMvz4wb5 for ; Mon, 7 Oct 2024 20:28:34 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4XMYjt3XQvz4wyk; Mon, 7 Oct 2024 20:28:34 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=147.75.48.161 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1728293314; cv=pass; b=LMAdVJJInHr82KbglNJTw2rw0M30wE8lZArm94fn/xDxny5SGT4wgqYtb0tUwJK34L058uP4hyNDsEuuzVZwMPcKKOBj9HbKGl0DTi3mofIgI/HT5hEaoTAPIJtuojhEDOUpizJF3/NJPgqVsD8oIZ9yvnDdelp35/zv4h6nA/CfQLWuZdRM94h/e4dRq+yN0YRY/UhSfaStWFDrAHcUSck9YZsKqYwKoFsR6wJ5f0ueLRGFjdYgw8hmwcI+FOAbEziSVh9jfU0Whuu+EGEk8M73ze2Ft7YbgSG6Uf5xywHUH+nJIwITtWPDCAfNYHZGRfpJ2LfvrU6TlD0tvPLb9g== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1728293314; c=relaxed/relaxed; bh=KhBPqv0HMgy+V3l1ZeOmzP6ci5enJC1cEdRgXVzEEQo=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=dhArVW5LtUH3EZCafRfucFj4BQ7VIEXgY6AWo6DFR9Z2NtEc8y36hJd/ys7pEnGCNxnL3aZ4XnfZUnzvIdB0NGmui2kDQ3zLxUp577a2ZQZvaXeya2u9HYb3eKijR51MtvPmB5O3noAPc+GhDQu6UpGRMf8uON4d1WOtzpJJ9zSdNM7fxg4Io2LkzYS0FM73msggMVO+L3HLwS4A29vc3tmCGGpvImgJzgEgVkybWA23I/6Q1g5GZrsJcp0Kzlzx5yJKL5H1tVZ+HxlGOcur9/vPkJcJKqlcEsfKQr7WgyJjRl/J2XnXm/qIAoAdfalO2eePbl/Oeb6mkMkS72SrDw== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.dev; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=PGqSyBcb; dkim-atps=neutral; spf=pass (client-ip=147.75.48.161; helo=sy.mirrors.kernel.org; envelope-from=linux-ext4+bounces-4521-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=PGqSyBcb; 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-4521-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) server-digest SHA256) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4XMYjr2Dnlz4wb5 for ; Mon, 7 Oct 2024 20:28:32 +1100 (AEDT) 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 A9F07B210BF for ; Mon, 7 Oct 2024 09:28:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 37CD718CC0A; Mon, 7 Oct 2024 09:28:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="PGqSyBcb" X-Original-To: linux-ext4@vger.kernel.org Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) (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 C7C2E1741E0 for ; Mon, 7 Oct 2024 09:28:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728293307; cv=none; b=rwsGqICR1VJgodn+MwUeuf7cCC/kInYZcTaO6iFtpns8hbKSjDoMvI0z5zrK+7dX4i4FvpPWU+wwcD6g2s46KrzNbWzu8WUMSIrsl36tPkSJeR7PrNK+IohGAMMLo3SnVms92H8Z9Vcm/rRg2haUjMPfixS+QgM4uxc9DYcXeSQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728293307; c=relaxed/simple; bh=xwxOXNQDdG5K10egox0O/MdReACVFRWs4FU1c46jVcQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=F5JA4lDq4v0BzBAL4fj2PVaSi8NF5vUSAtN4BfBUFEMDA/HRJr2YBHGXBqHhYkJp4wkYwTXI+cyfKkN6xI92Z8tZcvdcR22gqnqL1ApDdpYaetay36JybMlxFp8BpNlprDBYst37YB5MRKdV4DVJejaIY7K3fPDvukQOpjkDnoM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=PGqSyBcb; arc=none smtp.client-ip=95.215.58.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1728293297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KhBPqv0HMgy+V3l1ZeOmzP6ci5enJC1cEdRgXVzEEQo=; b=PGqSyBcbcSeop5dUkizYp76JQC+QyTt/hStSIzoPgRqmpi7w8z9y9j/2Q1G543FMjoVd5c nqYWiuu/vbe42gTDd41+kcLNoba0hlqYXKvD4uq7++SS4d5Fn1cIQ15MIuzLnkSfrWcO4p A+nJMJ6zipMcNJc0KG/tAd2ugjfkRxM= From: Luis Henriques To: linux-ext4@vger.kernel.org Subject: Old inline-data bug with small block sizes Date: Mon, 07 Oct 2024 10:28:02 +0100 Message-ID: <87h69oclel.fsf@linux.dev> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Hi! I have a local branch where, some time ago, I tried to fix an old inline_data bug[1]. The reproducer is easy to run, it just requires a filesystem with a small block size (I've used 1024). Looking at it again with fresh eyes I believe the bug could be easily fixed with the patch below. My understanding is that, when we are doing a ->read_folio() and there's inlined data, that inlined data has to be in the first page. However, if we get a different page (i.e. not the first one), then we are zero'ing it and marking it up-to-date. And that doesn't sound right to me. The patch bellow fixes things by reverting back to do a regular read in those cases, because it's not inlined data. Does it make sense? Or am I missing something and not seeing the real bug here? [1] https://bugzilla.kernel.org/show_bug.cgi?id=200681 Cheers, diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index 3536ca7e4fcc..ec96038dd75f 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -516,7 +516,8 @@ int ext4_readpage_inline(struct inode *inode, struct folio *folio) int ret = 0; down_read(&EXT4_I(inode)->xattr_sem); - if (!ext4_has_inline_data(inode)) { + if (!ext4_has_inline_data(inode) || + ((folio->index > 0) && !folio_test_uptodate(folio))) { up_read(&EXT4_I(inode)->xattr_sem); return -EAGAIN; } @@ -527,10 +528,6 @@ int ext4_readpage_inline(struct inode *inode, struct folio *folio) */ if (!folio->index) ret = ext4_read_inline_folio(inode, folio); - else if (!folio_test_uptodate(folio)) { - folio_zero_segment(folio, 0, folio_size(folio)); - folio_mark_uptodate(folio); - } up_read(&EXT4_I(inode)->xattr_sem);