From patchwork Wed Jun 15 21:48:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 12882964 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F5FFC43334 for ; Wed, 15 Jun 2022 21:48:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E18C66B0071; Wed, 15 Jun 2022 17:48:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC7666B0072; Wed, 15 Jun 2022 17:48:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9A456B0074; Wed, 15 Jun 2022 17:48:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B8E286B0071 for ; Wed, 15 Jun 2022 17:48:23 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 874B31CC for ; Wed, 15 Jun 2022 21:48:23 +0000 (UTC) X-FDA: 79581809286.19.3130C9A Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf05.hostedemail.com (Postfix) with ESMTP id 16CF010007B for ; Wed, 15 Jun 2022 21:48:22 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A8FED21C78; Wed, 15 Jun 2022 21:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1655329701; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=+AQQSlVk+fSJITgKnnsJ5wBaPXuhI3QTlk71W+lS3oc=; b=m+75E/r6wBapN8CETWbwyPqvABVKjUrOKzFg+pXI56Vk73Ob+DNU8Z+WfkWIx+YiImqoQg YXO1IMYIph0tjM0Zmr1FL34L69zbmVe53ih2+aSCY1LCxeE7GIEEHj5FcPC6VSnlzipjJT lhb5UU0Z6nZXsz0h5C0taAaZCY2DkKw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1655329701; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=+AQQSlVk+fSJITgKnnsJ5wBaPXuhI3QTlk71W+lS3oc=; b=UTvo1zeOPEy7YZAasBZv//49ZTZBekcWIXfCmsMhvGaCVCQBtJ4eYP+99ZypkezGZ6VEGe hi9fVCrr+NGq9wDQ== Received: from quack3.suse.cz (unknown [10.163.28.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 7FEA52C141; Wed, 15 Jun 2022 21:48:21 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id 488C5A062E; Wed, 15 Jun 2022 23:48:21 +0200 (CEST) From: Jan Kara To: LKML Cc: Christoph Hellwig , Greg Kroah-Hartman , , Suzuki K Poulose , Guenter Roeck , Alexandru Elisei , Jan Kara Subject: [PATCH] init: Initialize noop_backing_dev_info early Date: Wed, 15 Jun 2022 23:48:15 +0200 Message-Id: <20220615214815.6901-1-jack@suse.cz> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3017; h=from:subject; bh=CpJWbSIYFZYcag4s2az1UMRk8wDOxjizLqrAjKGRp3k=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBiqlOWxMUw9dJBYt29kpYriHaWIDduB7ePRtEiPYh7 ZIrpgjeJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYqpTlgAKCRCcnaoHP2RA2dcJCA Db4aB2N/z0lLRkbNukzUm1gEmycT/P+u2H//CdmC658dFoBqbuwjnDQNQu1Wks8ptiEw5Xxz65a7wA J19W2fqEKg/9Y1LcPS0XOWFMZyD41UOIFCbHHXOMIIqNvBSYLRAsD8cy79RFOIIk1N7SCE6niAgaGg vzVYwsiVv+S48UHU2fb7zAHl6/l4Wa5oUqORFegex4WlWA9dkknjFie0Q/86Xx+qpjBG2gzoYIWojI 0Adz1tI7PCdZrugOQKvVI1ccxnj1Tc6V3vLE2zhy5ww3zWKXgi8R3MQFy4VSx+s8bMLU1WgdwS4YrO Z5NtjdxG3AFRkvQppxvefq+ZrZM/jK X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655329703; a=rsa-sha256; cv=none; b=QdyouM1I1I4ImjHWlqbsANh7bfw7sPvzEv+7HwubOnV20FCUHcMz9fJBVoRHRV+2ybnAnL +9Xg3wIIIufjlTZrs14+z8VjB0NkNdCTu7f+Ih2nr7RzcndyLEgWCb4lW7uQcTbz/9bfqC g2LfBYtjsT+0FsyLKYyDmnGJY+fE2io= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="m+75E/r6"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=UTvo1zeO; dmarc=none; spf=pass (imf05.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655329703; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=+AQQSlVk+fSJITgKnnsJ5wBaPXuhI3QTlk71W+lS3oc=; b=wxLMaTEswf46IFbkr+AFzznS22ZcQtp71jRvPTiDrk3NsmV+dDmYiMaUxP8+Z84LJw3Qsn zGxKEFHaCN5/nGA1yvtg405+XrUJmGxrlYFU6TqwzV2+ggmgPR9LuHenCluciz+NHiQncv w0Z0MLCC16ZFhrFqGF/hlP5SCJ/84cc= X-Rspamd-Queue-Id: 16CF010007B X-Rspam-User: Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="m+75E/r6"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=UTvo1zeO; dmarc=none; spf=pass (imf05.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz X-Rspamd-Server: rspam06 X-Stat-Signature: agzbdcxjqtbdhq1i5xa31wumgqaa8ygp X-HE-Tag: 1655329702-471418 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: noop_backing_dev_info is used by superblocks of various pseudofilesystems such as kdevtmpfs. After commit 10e14073107d ("writeback: Fix inode->i_io_list not be protected by inode->i_lock error") this broke because __mark_inode_dirty() started to access more fields from noop_backing_dev_info and this led to crashes inside locked_inode_to_wb_and_lock_list() called from __mark_inode_dirty(). Fix the problem by initializing noop_backing_dev_info before the filesystems get mounted. Fixes: 10e14073107d ("writeback: Fix inode->i_io_list not be protected by inode->i_lock error") Reported-by: Suzuki K Poulose Reported-and-tested-by: Alexandru Elisei Reported-and-tested-by: Guenter Roeck Signed-off-by: Jan Kara Reviewed-by: Christoph Hellwig Tested-by: Suzuki K Poulose --- drivers/base/init.c | 2 ++ include/linux/backing-dev.h | 2 ++ mm/backing-dev.c | 11 ++--------- 3 files changed, 6 insertions(+), 9 deletions(-) Since this bug prevents some machines from booting, I plan to push this patch to Linus unless someone objects soon... Review is welcome :). diff --git a/drivers/base/init.c b/drivers/base/init.c index d8d0fe687111..397eb9880cec 100644 --- a/drivers/base/init.c +++ b/drivers/base/init.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "base.h" @@ -20,6 +21,7 @@ void __init driver_init(void) { /* These are the core pieces */ + bdi_init(&noop_backing_dev_info); devtmpfs_init(); devices_init(); buses_init(); diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 2bd073fa6bb5..f0baef68f90f 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -119,6 +119,8 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); extern struct backing_dev_info noop_backing_dev_info; +extern int bdi_init(struct backing_dev_info *bdi); + /** * writeback_in_progress - determine whether there is writeback in progress * @wb: bdi_writeback of interest diff --git a/mm/backing-dev.c b/mm/backing-dev.c index ff60bd7d74e0..95550b8fa7fe 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -231,20 +231,13 @@ static __init int bdi_class_init(void) } postcore_initcall(bdi_class_init); -static int bdi_init(struct backing_dev_info *bdi); - static int __init default_bdi_init(void) { - int err; - bdi_wq = alloc_workqueue("writeback", WQ_MEM_RECLAIM | WQ_UNBOUND | WQ_SYSFS, 0); if (!bdi_wq) return -ENOMEM; - - err = bdi_init(&noop_backing_dev_info); - - return err; + return 0; } subsys_initcall(default_bdi_init); @@ -781,7 +774,7 @@ static void cgwb_remove_from_bdi_list(struct bdi_writeback *wb) #endif /* CONFIG_CGROUP_WRITEBACK */ -static int bdi_init(struct backing_dev_info *bdi) +int bdi_init(struct backing_dev_info *bdi) { int ret;