Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp452247pxt; Fri, 6 Aug 2021 06:06:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCyCRRG8I5GmI+Wdg8u6y8ox1ueSWALCDmT65t/Yje5vw0Dey49gPpUr6MMjHMuajkwCaE X-Received: by 2002:a92:c245:: with SMTP id k5mr612214ilo.143.1628255210847; Fri, 06 Aug 2021 06:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628255210; cv=none; d=google.com; s=arc-20160816; b=KYQtnjTOyPhIBOEg4t4DdIDf3WyUniOW556sYlsO9rS9q8XIXq5p3DttKNknsqhGsx CWVkQTUHugLsiPBBQMivU1dQz3XIe+CA/vKhoF3ZX/McxLD8RZzvF2bNEnC0GWRhm5mv gBMnZISEz4D7PK/TnzMI57cx+MptiJJmtMxdXTbdfKY2PxORQjvI/wF0YuhFWwxY/rF7 BJEoRm8SNR9gf7aEPE+gHWbWFIgHlKJ4psKFGv06ee1+1Hl3rVY+2BqZSjeK5S1uylQa 93+B3XoPDfE64UvnMGn58oN3m97FsLVZv7T/ovhV8mrZsE1NP6L/lxK2/RKBY2GeytST cOyA== 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=wNS893RzbD4PcMn+J7QqDaE2Nz/rtLPWQj1TVxjWv4c=; b=Y/qxujVGQUNaFvHOWyB9/XDJ3qpVE2usi9Als/5PK/EKKIndclPbg6sbKGdfkzr9If LNYoJbTdgqLlTHwvk8c6I8LWqQiq74z93tWjHJARu5J6U9aiDhiM0Q1j4KTlR6CHmQRL P7xg1QTZeBKvtiDvY14DM+qWFdrHSrT3enZFXrWJtSgDc9nhCgnpGAOkkwqxCvJfJZbp e2hi7kCLz/mAjxlKLTUWZfXmnG2+gi2WopfRa34nOJVSdDJFyXrHqFCH1p+wQQ9hOGj6 pyQ73+L/O6hDm9GJ4oGEQiN75Gxi5A60FCV9TE+ZkyhX1MYfcpEYS6JmPsJiM0xlBQva iRCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Byus3vdJ; 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 j14si10948432jat.60.2021.08.06.06.06.39; Fri, 06 Aug 2021 06:06:50 -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=Byus3vdJ; 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 S244251AbhHFITb (ORCPT + 99 others); Fri, 6 Aug 2021 04:19:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:47248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230127AbhHFIQw (ORCPT ); Fri, 6 Aug 2021 04:16:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F294361206; Fri, 6 Aug 2021 08:16:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628237797; bh=3zWKVwRhirjKOv35ZgcbGgrFQd2YrnQhzDiHbV3X33E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Byus3vdJy0SVF53T50i53uE8oupnRPOI18nIp/98xGXczL5bqwhTuvstqlOfAeAOy Tzzky4Lo2X332uQbIGmIFY6y4BRxyetPjm+sctCYGeTOzbpC4mt92osp2GtnylDWBM KtkWjXovVO3Ej/qu+HcoV+GCMx5U5RHxj+BkEWVA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yufen Yu , Christoph Hellwig , Jan Kara , Bart Van Assche , Jens Axboe , Sasha Levin Subject: [PATCH 4.19 09/16] bdi: add a ->dev_name field to struct backing_dev_info Date: Fri, 6 Aug 2021 10:15:00 +0200 Message-Id: <20210806081111.442915938@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210806081111.144943357@linuxfoundation.org> References: <20210806081111.144943357@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: Christoph Hellwig [ Upstream commit 6bd87eec23cbc9ed222bed0f5b5b02bf300e9a8d ] Cache a copy of the name for the life time of the backing_dev_info structure so that we can reference it even after unregistering. Fixes: 68f23b89067f ("memcg: fix a crash in wb_workfn when a device disappears") Reported-by: Yufen Yu Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Reviewed-by: Bart Van Assche Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- include/linux/backing-dev-defs.h | 1 + mm/backing-dev.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h index 07e02d6df5ad..65d47522413c 100644 --- a/include/linux/backing-dev-defs.h +++ b/include/linux/backing-dev-defs.h @@ -197,6 +197,7 @@ struct backing_dev_info { wait_queue_head_t wb_waitq; struct device *dev; + char dev_name[64]; struct device *owner; struct timer_list laptop_mode_wb_timer; diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 8501b033bca8..1d37c80d023a 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -880,7 +880,8 @@ int bdi_register_va(struct backing_dev_info *bdi, const char *fmt, va_list args) if (bdi->dev) /* The driver needs to use separate queues per device */ return 0; - dev = device_create_vargs(bdi_class, NULL, MKDEV(0, 0), bdi, fmt, args); + vsnprintf(bdi->dev_name, sizeof(bdi->dev_name), fmt, args); + dev = device_create(bdi_class, NULL, MKDEV(0, 0), bdi, bdi->dev_name); if (IS_ERR(dev)) return PTR_ERR(dev); @@ -980,7 +981,7 @@ const char *bdi_dev_name(struct backing_dev_info *bdi) { if (!bdi || !bdi->dev) return bdi_unknown_name; - return dev_name(bdi->dev); + return bdi->dev_name; } EXPORT_SYMBOL_GPL(bdi_dev_name); -- 2.30.2