Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2752046imj; Mon, 11 Feb 2019 07:58:52 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib3kGBXmA6/gm78l74F72mFYiFBOjkyayN83viiZ2V7RSuhKpL2PAyPm1jnywUbXR+zAADF X-Received: by 2002:a63:5b48:: with SMTP id l8mr29363484pgm.80.1549900732746; Mon, 11 Feb 2019 07:58:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549900732; cv=none; d=google.com; s=arc-20160816; b=ah/ekkjJOBYyjWyCPTTSLgAsJDh/vKbncFNFQ+yNof8sgFmlmly8AJysW+Nfn0YfjO wYkDqKQY9fibGl/3iV47SAHoscyoPV93DZYDESGX+1TH0BY7yjRywqXB3Kj5ahI5w956 s8V02Ap/8I2QYzsfCto2vjnrhsm42PHnysKXDMgp02rKutKcUu7EuCyxIbnA7Ot/umgE DYJi9BWH96Bm0qcEk+cDY0NGIN2QLnOn5Bu+y/29gmNNmIHnSQWN6gRzB1cqeZ13n98a 5bWfF61xknbiBYgPsGjkoE8aTHF71woLMX5C+HUQ5RVztFdUn7mZ/4PsrokfJczs/qj1 xjIw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NlV07gh+yn0V6/1r5223HjxGPTO7KTRXQ5Yhb660iP4=; b=zBhMVWoszHv9x9L99gNkyZKgytkts4zQkqx5TYUAzUivYylGJ8hY8NYgTGSkNgC8Sg K+V7bmFHQIoeY7YffzuyEfvh8Wv5bW8xJQt4ag+eEAa7/HCEPMQ0rHU8/zWbig8C7Ypq GuQxqPov30WP23tfB5JUQa/FYK6VnlaKxhkJAkuZIbRUCNxpsgld9pN/lMQU1RYWKiYk yNORN5Yls86Kml5qJhyv8ZOcJnKiiMyzp/Rohgmdf+IFyswqOwkvT8Af21jZ+fNfI8cD Cx3S1A1NGllKbca6O61AdcVq7rGmlEPJQP9HRh4kQ232eW8uSmQOOMUDjh6ddUMkFLxa +xVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="fv9vPOw/"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bb1si3448950plb.121.2019.02.11.07.58.36; Mon, 11 Feb 2019 07:58:52 -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="fv9vPOw/"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730089AbfBKOd0 (ORCPT + 99 others); Mon, 11 Feb 2019 09:33:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:41118 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730633AbfBKOdY (ORCPT ); Mon, 11 Feb 2019 09:33:24 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2AD1121855; Mon, 11 Feb 2019 14:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895603; bh=7UuqgsOsEIxD6Oe9B2LKwVd+drCYKCPlQ+glR9xkurQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fv9vPOw/nnJebY3XzmnlrvC9uGP+SmS6W/hBsnlIHOV8kpczSo1ITnBmKbiPHScm5 CWzUeFRSgEER1dmRTkZKsjjGxZa5lyDs1jv123qq9DkRVoEoNjt4SxtjU7hBR2hEc2 2ctGQ05V6en5Yxq8QXAIlp8E32RzwQy2gEAsw7+E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sahitya Tummala , Jaegeuk Kim , Sasha Levin Subject: [PATCH 4.20 261/352] f2fs: fix sbi->extent_list corruption issue Date: Mon, 11 Feb 2019 15:18:08 +0100 Message-Id: <20190211141903.658764739@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 ebad864c031c..6713060a59fb 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -2673,10 +2673,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 9e13db994fdf..a467aca29cfe 100644 --- a/fs/f2fs/shrinker.c +++ b/fs/f2fs/shrinker.c @@ -135,6 +135,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