From 19f46dba525a5a88a8da927065b1ec0815e57d2e Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Thu, 5 Aug 2021 10:09:09 -0400 Subject: [PATCH] Fixes for 4.19 Signed-off-by: Sasha Levin --- ...ame-field-to-struct-backing_dev_info.patch | 62 +++++++++ .../bdi-move-bdi_dev_name-out-of-line.patch | 74 +++++++++++ ...-use-bdi_dev_name-to-get-device-name.patch | 121 ++++++++++++++++++ queue-4.19/series | 3 + 4 files changed, 260 insertions(+) create mode 100644 queue-4.19/bdi-add-a-dev_name-field-to-struct-backing_dev_info.patch create mode 100644 queue-4.19/bdi-move-bdi_dev_name-out-of-line.patch create mode 100644 queue-4.19/bdi-use-bdi_dev_name-to-get-device-name.patch diff --git a/queue-4.19/bdi-add-a-dev_name-field-to-struct-backing_dev_info.patch b/queue-4.19/bdi-add-a-dev_name-field-to-struct-backing_dev_info.patch new file mode 100644 index 00000000000..8d39e49c01c --- /dev/null +++ b/queue-4.19/bdi-add-a-dev_name-field-to-struct-backing_dev_info.patch @@ -0,0 +1,62 @@ +From d13bdc6d59dc66c593a8fc21776a607b58345565 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 May 2020 14:47:56 +0200 +Subject: bdi: add a ->dev_name field to struct backing_dev_info + +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 + diff --git a/queue-4.19/bdi-move-bdi_dev_name-out-of-line.patch b/queue-4.19/bdi-move-bdi_dev_name-out-of-line.patch new file mode 100644 index 00000000000..0493c2b2ab8 --- /dev/null +++ b/queue-4.19/bdi-move-bdi_dev_name-out-of-line.patch @@ -0,0 +1,74 @@ +From 7a623c506d14792723bee3b8748f4b57be322d21 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 May 2020 14:47:54 +0200 +Subject: bdi: move bdi_dev_name out of line + +From: Christoph Hellwig + +[ Upstream commit eb7ae5e06bb6e6ac6bb86872d27c43ebab92f6b2 ] + +bdi_dev_name is not a fast path function, move it out of line. This +prepares for using it from modular callers without having to export +an implementation detail like bdi_unknown_name. + +Signed-off-by: Christoph Hellwig +Reviewed-by: Jan Kara +Reviewed-by: Greg Kroah-Hartman +Reviewed-by: Bart Van Assche +Signed-off-by: Jens Axboe +Signed-off-by: Sasha Levin +--- + include/linux/backing-dev.h | 9 +-------- + mm/backing-dev.c | 10 +++++++++- + 2 files changed, 10 insertions(+), 9 deletions(-) + +diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h +index 1ef4aca7b953..d28d57eefe9f 100644 +--- a/include/linux/backing-dev.h ++++ b/include/linux/backing-dev.h +@@ -499,13 +499,6 @@ static inline int bdi_rw_congested(struct backing_dev_info *bdi) + (1 << WB_async_congested)); + } + +-extern const char *bdi_unknown_name; +- +-static inline const char *bdi_dev_name(struct backing_dev_info *bdi) +-{ +- if (!bdi || !bdi->dev) +- return bdi_unknown_name; +- return dev_name(bdi->dev); +-} ++const char *bdi_dev_name(struct backing_dev_info *bdi); + + #endif /* _LINUX_BACKING_DEV_H */ +diff --git a/mm/backing-dev.c b/mm/backing-dev.c +index 2152e85891d1..8501b033bca8 100644 +--- a/mm/backing-dev.c ++++ b/mm/backing-dev.c +@@ -19,7 +19,7 @@ struct backing_dev_info noop_backing_dev_info = { + EXPORT_SYMBOL_GPL(noop_backing_dev_info); + + static struct class *bdi_class; +-const char *bdi_unknown_name = "(unknown)"; ++static const char *bdi_unknown_name = "(unknown)"; + + /* + * bdi_lock protects updates to bdi_list. bdi_list has RCU reader side +@@ -976,6 +976,14 @@ void bdi_put(struct backing_dev_info *bdi) + } + EXPORT_SYMBOL(bdi_put); + ++const char *bdi_dev_name(struct backing_dev_info *bdi) ++{ ++ if (!bdi || !bdi->dev) ++ return bdi_unknown_name; ++ return dev_name(bdi->dev); ++} ++EXPORT_SYMBOL_GPL(bdi_dev_name); ++ + static wait_queue_head_t congestion_wqh[2] = { + __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[0]), + __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1]) +-- +2.30.2 + diff --git a/queue-4.19/bdi-use-bdi_dev_name-to-get-device-name.patch b/queue-4.19/bdi-use-bdi_dev_name-to-get-device-name.patch new file mode 100644 index 00000000000..c5ce7fbc86a --- /dev/null +++ b/queue-4.19/bdi-use-bdi_dev_name-to-get-device-name.patch @@ -0,0 +1,121 @@ +From 2399180d94bb4d7638c0d99a516d0d664d4c7ea1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 May 2020 14:47:55 +0200 +Subject: bdi: use bdi_dev_name() to get device name + +From: Yufen Yu + +[ Upstream commit d51cfc53ade3189455a1b88ec7a2ff0c24597cf8 ] + +Use the common interface bdi_dev_name() to get device name. + +Signed-off-by: Yufen Yu +Signed-off-by: Christoph Hellwig +Reviewed-by: Greg Kroah-Hartman +Reviewed-by: Jan Kara +Reviewed-by: Bart Van Assche + +Add missing include BFQ + +Signed-off-by: Jens Axboe +Signed-off-by: Sasha Levin +--- + block/bfq-iosched.c | 6 ++++-- + block/blk-cgroup.c | 2 +- + fs/ceph/debugfs.c | 2 +- + include/trace/events/wbt.h | 8 ++++---- + 4 files changed, 10 insertions(+), 8 deletions(-) + +diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c +index d984592b0995..5b3e5483c657 100644 +--- a/block/bfq-iosched.c ++++ b/block/bfq-iosched.c +@@ -132,6 +132,7 @@ + #include + #include + #include ++#include + + #include "blk.h" + #include "blk-mq.h" +@@ -4212,8 +4213,9 @@ bfq_set_next_ioprio_data(struct bfq_queue *bfqq, struct bfq_io_cq *bic) + ioprio_class = IOPRIO_PRIO_CLASS(bic->ioprio); + switch (ioprio_class) { + default: +- dev_err(bfqq->bfqd->queue->backing_dev_info->dev, +- "bfq: bad prio class %d\n", ioprio_class); ++ pr_err("bdi %s: bfq: bad prio class %d\n", ++ bdi_dev_name(bfqq->bfqd->queue->backing_dev_info), ++ ioprio_class); + /* fall through */ + case IOPRIO_CLASS_NONE: + /* +diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c +index 85bd46e0a745..ddde117eb2e0 100644 +--- a/block/blk-cgroup.c ++++ b/block/blk-cgroup.c +@@ -474,7 +474,7 @@ const char *blkg_dev_name(struct blkcg_gq *blkg) + { + /* some drivers (floppy) instantiate a queue w/o disk registered */ + if (blkg->q->backing_dev_info->dev) +- return dev_name(blkg->q->backing_dev_info->dev); ++ return bdi_dev_name(blkg->q->backing_dev_info); + return NULL; + } + EXPORT_SYMBOL_GPL(blkg_dev_name); +diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c +index abdf98deeec4..e6b7d43b5077 100644 +--- a/fs/ceph/debugfs.c ++++ b/fs/ceph/debugfs.c +@@ -251,7 +251,7 @@ int ceph_fs_debugfs_init(struct ceph_fs_client *fsc) + goto out; + + snprintf(name, sizeof(name), "../../bdi/%s", +- dev_name(fsc->sb->s_bdi->dev)); ++ bdi_dev_name(fsc->sb->s_bdi)); + fsc->debugfs_bdi = + debugfs_create_symlink("bdi", + fsc->client->debugfs_dir, +diff --git a/include/trace/events/wbt.h b/include/trace/events/wbt.h +index 37342a13c9cb..9996420d7ec4 100644 +--- a/include/trace/events/wbt.h ++++ b/include/trace/events/wbt.h +@@ -33,7 +33,7 @@ TRACE_EVENT(wbt_stat, + ), + + TP_fast_assign( +- strlcpy(__entry->name, dev_name(bdi->dev), ++ strlcpy(__entry->name, bdi_dev_name(bdi), + ARRAY_SIZE(__entry->name)); + __entry->rmean = stat[0].mean; + __entry->rmin = stat[0].min; +@@ -68,7 +68,7 @@ TRACE_EVENT(wbt_lat, + ), + + TP_fast_assign( +- strlcpy(__entry->name, dev_name(bdi->dev), ++ strlcpy(__entry->name, bdi_dev_name(bdi), + ARRAY_SIZE(__entry->name)); + __entry->lat = div_u64(lat, 1000); + ), +@@ -105,7 +105,7 @@ TRACE_EVENT(wbt_step, + ), + + TP_fast_assign( +- strlcpy(__entry->name, dev_name(bdi->dev), ++ strlcpy(__entry->name, bdi_dev_name(bdi), + ARRAY_SIZE(__entry->name)); + __entry->msg = msg; + __entry->step = step; +@@ -141,7 +141,7 @@ TRACE_EVENT(wbt_timer, + ), + + TP_fast_assign( +- strlcpy(__entry->name, dev_name(bdi->dev), ++ strlcpy(__entry->name, bdi_dev_name(bdi), + ARRAY_SIZE(__entry->name)); + __entry->status = status; + __entry->step = step; +-- +2.30.2 + diff --git a/queue-4.19/series b/queue-4.19/series index 61597d72246..f9414c26734 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -4,3 +4,6 @@ asoc-tlv320aic31xx-fix-reversed-bclk-wclk-master-bit.patch r8152-fix-potential-pm-refcount-imbalance.patch qed-fix-possible-unpaired-spin_-un-lock_bh-in-_qed_m.patch net-fix-zero-copy-head-len-calculation.patch +bdi-move-bdi_dev_name-out-of-line.patch +bdi-use-bdi_dev_name-to-get-device-name.patch +bdi-add-a-dev_name-field-to-struct-backing_dev_info.patch -- 2.47.3