Commit cc5c516d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: simplify blktrace sysfs attribute creation

Add the trace attributes to the default gendisk attributes, just like
we already do for partitions.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20220628171850.1313069-2-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 8b9ab626
...@@ -810,21 +810,14 @@ int blk_register_queue(struct gendisk *disk) ...@@ -810,21 +810,14 @@ int blk_register_queue(struct gendisk *disk)
struct device *dev = disk_to_dev(disk); struct device *dev = disk_to_dev(disk);
struct request_queue *q = disk->queue; struct request_queue *q = disk->queue;
ret = blk_trace_init_sysfs(dev);
if (ret)
return ret;
mutex_lock(&q->sysfs_dir_lock); mutex_lock(&q->sysfs_dir_lock);
ret = kobject_add(&q->kobj, kobject_get(&dev->kobj), "%s", "queue"); ret = kobject_add(&q->kobj, kobject_get(&dev->kobj), "%s", "queue");
if (ret < 0) { if (ret < 0)
blk_trace_remove_sysfs(dev);
goto unlock; goto unlock;
}
ret = sysfs_create_group(&q->kobj, &queue_attr_group); ret = sysfs_create_group(&q->kobj, &queue_attr_group);
if (ret) { if (ret) {
blk_trace_remove_sysfs(dev);
kobject_del(&q->kobj); kobject_del(&q->kobj);
kobject_put(&dev->kobj); kobject_put(&dev->kobj);
goto unlock; goto unlock;
...@@ -890,7 +883,6 @@ int blk_register_queue(struct gendisk *disk) ...@@ -890,7 +883,6 @@ int blk_register_queue(struct gendisk *disk)
mutex_unlock(&q->sysfs_lock); mutex_unlock(&q->sysfs_lock);
mutex_unlock(&q->sysfs_dir_lock); mutex_unlock(&q->sysfs_dir_lock);
kobject_del(&q->kobj); kobject_del(&q->kobj);
blk_trace_remove_sysfs(dev);
kobject_put(&dev->kobj); kobject_put(&dev->kobj);
return ret; return ret;
...@@ -931,7 +923,6 @@ void blk_unregister_queue(struct gendisk *disk) ...@@ -931,7 +923,6 @@ void blk_unregister_queue(struct gendisk *disk)
if (queue_is_mq(q)) if (queue_is_mq(q))
blk_mq_unregister_dev(disk_to_dev(disk), q); blk_mq_unregister_dev(disk_to_dev(disk), q);
blk_crypto_sysfs_unregister(q); blk_crypto_sysfs_unregister(q);
blk_trace_remove_sysfs(disk_to_dev(disk));
mutex_lock(&q->sysfs_lock); mutex_lock(&q->sysfs_lock);
elv_unregister_queue(q); elv_unregister_queue(q);
......
...@@ -452,6 +452,8 @@ extern struct device_attribute dev_attr_events; ...@@ -452,6 +452,8 @@ extern struct device_attribute dev_attr_events;
extern struct device_attribute dev_attr_events_async; extern struct device_attribute dev_attr_events_async;
extern struct device_attribute dev_attr_events_poll_msecs; extern struct device_attribute dev_attr_events_poll_msecs;
extern struct attribute_group blk_trace_attr_group;
long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg); long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg);
long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg); long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg);
......
...@@ -1134,6 +1134,9 @@ static struct attribute_group disk_attr_group = { ...@@ -1134,6 +1134,9 @@ static struct attribute_group disk_attr_group = {
static const struct attribute_group *disk_attr_groups[] = { static const struct attribute_group *disk_attr_groups[] = {
&disk_attr_group, &disk_attr_group,
#ifdef CONFIG_BLK_DEV_IO_TRACE
&blk_trace_attr_group,
#endif
NULL NULL
}; };
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/blktrace_api.h>
#include <linux/raid/detect.h> #include <linux/raid/detect.h>
#include "check.h" #include "check.h"
......
...@@ -77,10 +77,6 @@ extern int blk_trace_setup(struct request_queue *q, char *name, dev_t dev, ...@@ -77,10 +77,6 @@ extern int blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
char __user *arg); char __user *arg);
extern int blk_trace_startstop(struct request_queue *q, int start); extern int blk_trace_startstop(struct request_queue *q, int start);
extern int blk_trace_remove(struct request_queue *q); extern int blk_trace_remove(struct request_queue *q);
extern void blk_trace_remove_sysfs(struct device *dev);
extern int blk_trace_init_sysfs(struct device *dev);
extern struct attribute_group blk_trace_attr_group;
#else /* !CONFIG_BLK_DEV_IO_TRACE */ #else /* !CONFIG_BLK_DEV_IO_TRACE */
# define blk_trace_ioctl(bdev, cmd, arg) (-ENOTTY) # define blk_trace_ioctl(bdev, cmd, arg) (-ENOTTY)
...@@ -91,13 +87,7 @@ extern struct attribute_group blk_trace_attr_group; ...@@ -91,13 +87,7 @@ extern struct attribute_group blk_trace_attr_group;
# define blk_trace_remove(q) (-ENOTTY) # define blk_trace_remove(q) (-ENOTTY)
# define blk_add_trace_msg(q, fmt, ...) do { } while (0) # define blk_add_trace_msg(q, fmt, ...) do { } while (0)
# define blk_add_cgroup_trace_msg(q, cg, fmt, ...) do { } while (0) # define blk_add_cgroup_trace_msg(q, cg, fmt, ...) do { } while (0)
# define blk_trace_remove_sysfs(dev) do { } while (0)
# define blk_trace_note_message_enabled(q) (false) # define blk_trace_note_message_enabled(q) (false)
static inline int blk_trace_init_sysfs(struct device *dev)
{
return 0;
}
#endif /* CONFIG_BLK_DEV_IO_TRACE */ #endif /* CONFIG_BLK_DEV_IO_TRACE */
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
......
...@@ -1867,17 +1867,6 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev, ...@@ -1867,17 +1867,6 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
out: out:
return ret ? ret : count; return ret ? ret : count;
} }
int blk_trace_init_sysfs(struct device *dev)
{
return sysfs_create_group(&dev->kobj, &blk_trace_attr_group);
}
void blk_trace_remove_sysfs(struct device *dev)
{
sysfs_remove_group(&dev->kobj, &blk_trace_attr_group);
}
#endif /* CONFIG_BLK_DEV_IO_TRACE */ #endif /* CONFIG_BLK_DEV_IO_TRACE */
#ifdef CONFIG_EVENT_TRACING #ifdef CONFIG_EVENT_TRACING
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment