From patchwork Tue Feb 6 03:25:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 197155 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1297114dyb; Mon, 5 Feb 2024 19:26:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHT+4jpNUmigOWb2iVyWrluR75uL/TafceF4w1wCoAiCYDegk/ymWNAnMMiVVg2icbCYKmf X-Received: by 2002:a05:6358:290d:b0:178:fe3e:1e35 with SMTP id y13-20020a056358290d00b00178fe3e1e35mr585459rwb.13.1707190011631; Mon, 05 Feb 2024 19:26:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707190011; cv=pass; d=google.com; s=arc-20160816; b=vQoMee1RDu47xHz8NA5Xm+23uHmsMdcffu13raFg8fQMQWMqAr5COfA2A+DhcWT2w9 yhwxT3+LHEJMNAGcSHmvWTvsl72pq69rZDD1gyW6AiOF5oOVqFmwWvpDC/3T4Yvc1K6S g4PLqdokYFovikdANmpg7m4jAGtlgQR5tZiCTkoUIb5I6jNKKYCYmnBIzR+42WsjuFc7 +HgsIOutUHsYWraTgkoKGP9p6/rjp4kpnUy6IWcQNWSL/DUkYQTqP1fC1E8hWHWewWcN Xfo31bxFI+rE0DeYZtAjACuwAy0KQObgL8OhSE/FQPqIpSZHdcMghqPEoKRumGpwBMOy 3meA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Gk55SXanSrl3dNr9vVQ5VcisBg4T7+mHAzw2xiMXg7s=; fh=Tb/pIeKdIae+To90sgp3HODimlsVPEbEhky1tL1pHcU=; b=mE6xLIsIfIjh1m7SHEBFs5xiUpa7OXanbcEihPY2mGIRmP9C5z0ldFNO3UNKfncucy 1ikIjNW/1U4RmePf0Sm8XtBDh2vxIGNVQE3rQoAE9wnHHT1JUWZsdKhgxyycwtBS3UJj 4sHADbwni+o3CfhvCVD5+p4I0SCgcPXCDkZTdsPFf2mClcdhJxZuaWtPGAKg7ieGn930 snofEk/28eXUVpmDQqWYAvFuNY1DKo1wsfmbPnQI7i79aKI1IRrV1zi5DzRkEDCljjBV /xEtXBcHRrTIPJmXqzIPTnGlR9AXnHgbPwld+VEEI6l2U4jgPEg4UKsDJQmE1baqBRrh JxJA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Acy3YkND; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-54250-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54250-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWN4Ksd70c2thU+ckhj10DHV3Rf7dqCfJXHZGBGXTwCga91bb/hKP3iAX6yBppQIO2xSMJQGqk5NYX/ltnWsoQXmPFO7w== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d8-20020a634f08000000b005d24ebc7f36si937941pgb.406.2024.02.05.19.26.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 19:26:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54250-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Acy3YkND; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-54250-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54250-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 03B3CB23A12 for ; Tue, 6 Feb 2024 03:25:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B7B5745C9; Tue, 6 Feb 2024 03:25:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Acy3YkND" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3AE1A7428A for ; Tue, 6 Feb 2024 03:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707189923; cv=none; b=njTD3Ts4/JjEo8rhdlS3HtUpieJPwYzbpj3AhGfb5JD7yeki28K3KQ/BhgWXhiPcmSPUkn4fC9vuw2TX1RGsddarUN4YiI2wI3Ynk3tB49fgbLvLTdTE1h96PwBEjAl2mg0PdBM8xI4fu1siX5x8gwLZgACVN5I4+926tNXPWhE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707189923; c=relaxed/simple; bh=uWUoGxk1soKi48WeLbyMNDv0+uwWzfBe0kdt6djUZXk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=nv7yBTM9fr0kGoYfDviNZwv1JxMQJgkX79ai2BHzRwuZe+85uQ+KqyzlrwESzNil04XlADDjg3U7oKCRTTbHnkn7LkRDnaK46c2geaWT8XaFoLTGbf2wovCJxuHCS3eS31aZsHpDRuAa2/1s/pKg8oA14NASaeYVICNU4V1BB0Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Acy3YkND; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A3B1C433C7; Tue, 6 Feb 2024 03:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707189922; bh=uWUoGxk1soKi48WeLbyMNDv0+uwWzfBe0kdt6djUZXk=; h=From:To:Cc:Subject:Date:From; b=Acy3YkNDuxj0k6ZMio91/8HBDLFbZMAD77t8Vpoye+CQ4GnJrqzKOxmFrvIQXXKo+ b6TDErA8CiwanzVyrVxTqYftQ6tpTjb3xi690zFFU2r884vKRdihQEiv94iNP2Nzyc Mw53ZHehZoEGncbAsIXn4WiIzSX+2ZtoK161ZDgAiy8WsjrZ2HgUgJnkdhwwoHIcpW y6HlkQsxvEDbn7iZe2hjMRxrbCSp8DtUnaRr61m1C1WNzW/4MuOLPTfIM42thFgHDl OesCfYKU+YnXJZQ8jtnfWmxNnlhXTJy9h3BxgAflQMNgDpZ003vHSUDzr3Mxs8n0zx t4KBvflZ1v2SA== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH] f2fs: fix to return EIO when reading after device removal Date: Tue, 6 Feb 2024 11:25:13 +0800 Message-Id: <20240206032513.2495025-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790118473658929689 X-GMAIL-MSGID: 1790118473658929689 generic/730 2s ... - output mismatch (see /media/fstests/results//generic/730.out.bad) --- tests/generic/730.out 2023-08-07 01:39:51.055568499 +0000 +++ /media/fstests/results//generic/730.out.bad 2024-02-06 02:26:43.000000000 +0000 @@ -1,2 +1 @@ QA output created by 730 -cat: -: Input/output error ... (Run 'diff -u /media/fstests/tests/generic/730.out /media/fstests/results//generic/730.out.bad' to see the entire diff) Ran: generic/730 Failures: generic/730 Failed 1 of 1 tests This patch adds a check condition in f2fs_file_read_iter() to detect cp_error status after device removal, and retrurn -EIO for such case. Signed-off-by: Chao Yu --- fs/f2fs/file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 45b7e3610b0f..9e4386d4144c 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4462,6 +4462,9 @@ static ssize_t f2fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) const loff_t pos = iocb->ki_pos; ssize_t ret; + if (unlikely(f2fs_cp_error(F2FS_I_SB(inode)))) + return -EIO; + if (!f2fs_is_compress_backend_ready(inode)) return -EOPNOTSUPP;