mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 10:57:46 +00:00
bdi: add a ->dev_name field to struct backing_dev_info
[ Upstream commit6bd87eec23
] 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:68f23b8906
("memcg: fix a crash in wb_workfn when a device disappears") Reported-by: Yufen Yu <yuyufen@huawei.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
19a845e19d
commit
d6c434ae9d
2 changed files with 4 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue