Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3635259imu; Mon, 28 Jan 2019 08:11:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN6KTG02JVWbn5e/80XhQbCeD6mZtC4gJRuwiH+m00pkx45UFJwymDi3w3Nweg6TKWQehD/N X-Received: by 2002:a62:8d4f:: with SMTP id z76mr23131404pfd.2.1548691900865; Mon, 28 Jan 2019 08:11:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691900; cv=none; d=google.com; s=arc-20160816; b=ijh2TMqC4uxf9mW1puGfeoFn0Rw0K/wupZHi2C+0TpCH5+no0Jhpwx6Ng/+XOvhnV/ AkGg3hNlXVpQmTvTn1BTSa1YvhBWBxiG6xmSOzMsYaU6x8B8waG2bNKT8YDP7jVVb0vI GOd6boejTNQyY/c+QQ5f3n0SmzjRFRpc8SHlTsFrEtCTnQ+x8dH+McPljSAVZf0tgnY0 kRL+DUYmSghQSuiWjLr00/Mz9m1SBUgdbZQYkudQnjr3IabZ8nq0rxbJrTmzFl5LM82K pG0V6uGqYs1ziXD1eteSsUYAXWSRmjeEQoTanxNlj3NJ/vvV5lc3mc0I8mzfWo7l+s3r F9/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ANtutAhU3IjlncC5W/eeWBbGis8LypP8HJlrp29G2cs=; b=QzY48gQ/eOcX1PFuTsgaGG/b3FuftqfDR286aM3KF0SYUKOZJecHcoAdeUlZrzI7WO VzJPSTIfhUL6rFgbF30MyGX3+qSF1zXbDqSZ4vNBsScKnI06377kFTnHAWly9wFKccGx v+XfHKScFYW11XjgXXgm/xPvDWMjbFU07f6SqVUirRRtOCKm4MxCI+I0yzsxuJHUv32O uo6lMjesePEfNCkwp5zWrxPPNUua5NOm7Y0Y+LNPyG1/ez1reZmEvKwiVaU0MMYf8pjG jxJq7y4BZUAbUTFgzZvMop3UttP0TbZtaBG5CnkuvxnW6UlGDWBfM/mQUTdnxeCfxkgj 51Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="vv89/boT"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s62si3374824pgc.113.2019.01.28.08.11.25; Mon, 28 Jan 2019 08:11:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="vv89/boT"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732799AbfA1QK2 (ORCPT + 99 others); Mon, 28 Jan 2019 11:10:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:36372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732345AbfA1QK1 (ORCPT ); Mon, 28 Jan 2019 11:10:27 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9E5362084A; Mon, 28 Jan 2019 16:10:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691826; bh=8mWLSI+wfm0dnxoM2hrNW1M+E1Q2SWH6YYo900osoZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vv89/boT3pH2ep89u90gFgqZraYWeK43K5+ijyH6zBi/aUQipQ2hlZzgZg4PK+Umu 1GhwzmIA6Zb5UHaHApqM1ENt87Jd1fEYnnPa6+fMYue+ii7IDcxacMPZLDw+98YBH5 E/7dcScuY9bteQLkqeuv14alqyFxBxPRB6rg0OvY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sahitya Tummala , Jaegeuk Kim , Sasha Levin , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH AUTOSEL 4.19 230/258] f2fs: fix sbi->extent_list corruption issue Date: Mon, 28 Jan 2019 10:58:56 -0500 Message-Id: <20190128155924.51521-230-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sahitya Tummala [ Upstream commit e4589fa545e0020dbbc3c9bde35f35f949901392 ] When there is a failure in f2fs_fill_super() after/during the recovery of fsync'd nodes, it frees the current sbi and retries again. This time the mount is successful, but the files that got recovered before retry, still holds the extent tree, whose extent nodes list is corrupted since sbi and sbi->extent_list is freed up. The list_del corruption issue is observed when the file system is getting unmounted and when those recoverd files extent node is being freed up in the below context. list_del corruption. prev->next should be fffffff1e1ef5480, but was (null) <...> kernel BUG at kernel/msm-4.14/lib/list_debug.c:53! lr : __list_del_entry_valid+0x94/0xb4 pc : __list_del_entry_valid+0x94/0xb4 <...> Call trace: __list_del_entry_valid+0x94/0xb4 __release_extent_node+0xb0/0x114 __free_extent_tree+0x58/0x7c f2fs_shrink_extent_tree+0xdc/0x3b0 f2fs_leave_shrinker+0x28/0x7c f2fs_put_super+0xfc/0x1e0 generic_shutdown_super+0x70/0xf4 kill_block_super+0x2c/0x5c kill_f2fs_super+0x44/0x50 deactivate_locked_super+0x60/0x8c deactivate_super+0x68/0x74 cleanup_mnt+0x40/0x78 __cleanup_mnt+0x1c/0x28 task_work_run+0x48/0xd0 do_notify_resume+0x678/0xe98 work_pending+0x8/0x14 Fix this by not creating extents for those recovered files if shrinker is not registered yet. Once mount is successful and shrinker is registered, those files can have extents again. Signed-off-by: Sahitya Tummala Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/f2fs.h | 11 ++++++++++- fs/f2fs/shrinker.c | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 462a2fb8aa69..eea2811dc672 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -2614,10 +2614,19 @@ static inline bool is_dot_dotdot(const struct qstr *str) static inline bool f2fs_may_extent_tree(struct inode *inode) { - if (!test_opt(F2FS_I_SB(inode), EXTENT_CACHE) || + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); + + if (!test_opt(sbi, EXTENT_CACHE) || is_inode_flag_set(inode, FI_NO_EXTENT)) return false; + /* + * for recovered files during mount do not create extents + * if shrinker is not registered. + */ + if (list_empty(&sbi->s_list)) + return false; + return S_ISREG(inode->i_mode); } diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c index 36cfd816c160..29042e6d5126 100644 --- a/fs/f2fs/shrinker.c +++ b/fs/f2fs/shrinker.c @@ -138,6 +138,6 @@ void f2fs_leave_shrinker(struct f2fs_sb_info *sbi) f2fs_shrink_extent_tree(sbi, __count_extent_cache(sbi)); spin_lock(&f2fs_list_lock); - list_del(&sbi->s_list); + list_del_init(&sbi->s_list); spin_unlock(&f2fs_list_lock); } -- 2.19.1