Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1554680pxb; Thu, 16 Sep 2021 09:48:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkO4gT9l20Zg+wM0P6ZCBZ+eMF4v3FwuiWyq978yLJ53jCfqUoIcHZeEKhM5UM4FqOyLx2 X-Received: by 2002:a17:906:32ce:: with SMTP id k14mr7043164ejk.503.1631810912886; Thu, 16 Sep 2021 09:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631810912; cv=none; d=google.com; s=arc-20160816; b=Owbu2rzCsPdkBRQcCwlpF9QhEsJaSkYLPPK0luuvvbzFQSgBuR6VJU39dAwFAy2dGW aEE3ZYxpb3HsMmQegODazBouB7vt5mFp+ZsPF4RFXtDTT4OpyrxfYHs294kwiupFXJ8E Qi9vyvViRLj4HcAvNxT1xINfFMnAGz5vaM+E44VyuVlz0mUByzOVNd8pYtqQWeq/+phL IHwcBulaZ800i3ah6NTZeq3l0ZGE+G3sQk1s1pfemz5r6eS/pjvoyTLMHzHvao29Fapq h3TYeYHy9uKTn93EV1DGbzvjebgj0pholQV+9sDR/Nwozhpmr8DBzsal7pNWDwddo/N7 G69g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oLPYD4Cr0wKX54AMGeLIWoe7TUrv1tVvyvKl8AKUz9Y=; b=gsUWVPZtD6tvirY+xpUy1Gw8uNhCK3g2WN5BRFkQUbXH6zM9ST3ILQce/uB4g/OVt7 efB8YaWx4wIXRe8cb5FmHdzOIWF7VRKEbYiIZOXCMUa44cOZIJYsDXP1G6EGkvzrrS/Z 5Jjyq4T/NwplNiYh7jvn2wXvEahCHifq6+a0HQo3kuVA3mzRG5YOEdq+Ms/sZHLtNGaY IqXHJw0eFmFTQi/PBzGlSWVp82hPaIbPpAcVP5cYrMJt8ASmJHaA2pNAlP0hAEWIM6K+ lp316JasGy4dKGr1sw2cKo47eyIQazcs+0u7jj2wbYNO/tsnnZ8INnXY4HgkZiC2Lj2z 9JBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GbwchRVM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j22si5249335ejt.173.2021.09.16.09.48.06; Thu, 16 Sep 2021 09:48:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GbwchRVM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343777AbhIPQoJ (ORCPT + 99 others); Thu, 16 Sep 2021 12:44:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:51058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243795AbhIPQjC (ORCPT ); Thu, 16 Sep 2021 12:39:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AA21761A05; Thu, 16 Sep 2021 16:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809377; bh=Wy5U/PX3PAjJpE10nXELb82V+GepA1r0QtsFfLxxq3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GbwchRVMabijfRlXqSyoRqguuXTlZ7/D1tKcpJZvwlaPBRBR8BGnyvIm+8bKTXio+ knVpMmF6p0x9NOXPyWYySLujEhSVlqvAknBn5ye19myPId95B89WdgSxIQHsgMQNcr P09ZF+D9o8t1bgyN1QFIN1wtS3k9Lo8HDSNLKRrY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 5.13 132/380] f2fs: fix unexpected ENOENT comes from f2fs_map_blocks() Date: Thu, 16 Sep 2021 17:58:09 +0200 Message-Id: <20210916155808.530894951@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chao Yu [ Upstream commit adf9ea89c719c1d23794e363f631e376b3ff8cbc ] In below path, it will return ENOENT if filesystem is shutdown: - f2fs_map_blocks - f2fs_get_dnode_of_data - f2fs_get_node_page - __get_node_page - read_node_page - is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN) return -ENOENT - force return value from ENOENT to 0 It should be fine for read case, since it indicates a hole condition, and caller could use .m_next_pgofs to skip the hole and continue the lookup. However it may cause confusing for write case, since leaving a hole there, and said nothing was wrong doesn't help. There is at least one case from dax_iomap_actor() will complain that, so fix this in prior to supporting dax in f2fs. xfstest generic/388 reports below warning: ubuntu godown: xfstests-induced forced shutdown of /mnt/scratch_f2fs: ------------[ cut here ]------------ WARNING: CPU: 0 PID: 485833 at fs/dax.c:1127 dax_iomap_actor+0x339/0x370 Call Trace: iomap_apply+0x1c4/0x7b0 ? dax_iomap_rw+0x1c0/0x1c0 dax_iomap_rw+0xad/0x1c0 ? dax_iomap_rw+0x1c0/0x1c0 f2fs_file_write_iter+0x5ab/0x970 [f2fs] do_iter_readv_writev+0x273/0x2e0 do_iter_write+0xab/0x1f0 vfs_iter_write+0x21/0x40 iter_file_splice_write+0x287/0x540 do_splice+0x37c/0xa60 __x64_sys_splice+0x15f/0x3a0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae ubuntu godown: xfstests-induced forced shutdown of /mnt/scratch_f2fs: ------------[ cut here ]------------ RIP: 0010:dax_iomap_pte_fault.isra.0+0x72e/0x14a0 Call Trace: dax_iomap_fault+0x44/0x70 f2fs_dax_huge_fault+0x155/0x400 [f2fs] f2fs_dax_fault+0x18/0x30 [f2fs] __do_fault+0x4e/0x120 do_fault+0x3cf/0x7a0 __handle_mm_fault+0xa8c/0xf20 ? find_held_lock+0x39/0xd0 handle_mm_fault+0x1b6/0x480 do_user_addr_fault+0x320/0xcd0 ? rcu_read_lock_sched_held+0x67/0xc0 exc_page_fault+0x77/0x3f0 ? asm_exc_page_fault+0x8/0x30 asm_exc_page_fault+0x1e/0x30 Fixes: 83a3bfdb5a8a ("f2fs: indicate shutdown f2fs to allow unmount successfully") Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/data.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 3058c7e28b11..3cd509b085f2 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1490,7 +1490,21 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, if (err) { if (flag == F2FS_GET_BLOCK_BMAP) map->m_pblk = 0; + if (err == -ENOENT) { + /* + * There is one exceptional case that read_node_page() + * may return -ENOENT due to filesystem has been + * shutdown or cp_error, so force to convert error + * number to EIO for such case. + */ + if (map->m_may_create && + (is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN) || + f2fs_cp_error(sbi))) { + err = -EIO; + goto unlock_out; + } + err = 0; if (map->m_next_pgofs) *map->m_next_pgofs = -- 2.30.2