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: 13546595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF8A2C4828D for ; Tue, 6 Feb 2024 03:25:33 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rXC5V-0006t9-E4; Tue, 06 Feb 2024 03:25:33 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rXC5V-0006t2-02 for linux-f2fs-devel@lists.sourceforge.net; Tue, 06 Feb 2024 03:25:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Gk55SXanSrl3dNr9vVQ5VcisBg4T7+mHAzw2xiMXg7s=; b=XEXbjcnqqOEUkaM/CcVawMDQ2m Fi658ynOFqVIUNtIB64NwQusrjY2yBIpICZA8uHc8q8wsHqQ9vqsxaimnvhYmntROOtxkf+pY4DLe qFK2wN7+fOaKyP6kGlsoIpgsbtz4REitqD0T/Bc8863/Aw/ihgnKdHti2WqC1DMvG9+8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=Gk55SXanSrl3dNr9vVQ5VcisBg4T7+mHAzw2xiMXg7s=; b=k MI4L71Kq556YDwL2DeTFhkyVHpub5lgnRuQeEr7dEY6OY+szjyt8qB2xHc0xynKOYCyi//JnzZ7fw O5LsTB2j8xjawyCPpEY5bFS1uGGn+k/pqzdSdPRkpois42p6OnIAs67f+vYN5GBTlrNrI6hGpcj6k UezrGTINdHdWTpos=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rXC5P-0005Fw-S2 for linux-f2fs-devel@lists.sourceforge.net; Tue, 06 Feb 2024 03:25:32 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1D1A960F7C for ; Tue, 6 Feb 2024 03:25:23 +0000 (UTC) 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 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 MIME-Version: 1.0 X-Headers-End: 1rXC5P-0005Fw-S2 Subject: [f2fs-dev] [PATCH] f2fs: fix to return EIO when reading after device removal X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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;