Message ID | 20200605145840.1145-1-jack@suse.cz (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | blktrace: Fix sparse annotations and warn if enabling multiple traces | expand |
On 6/5/20 7:58 AM, Jan Kara wrote: > + > +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > + > #include <linux/kernel.h> > #include <linux/blkdev.h> > #include <linux/blktrace_api.h> > @@ -494,6 +497,16 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, > */ > strreplace(buts->name, '/', '_'); > > + /* > + * bdev can be NULL, as with scsi-generic, this is a helpful as > + * we can be. > + */ > + if (q->blk_trace) { > + pr_warn("Concurrent blktraces are not allowed on %s\n", > + buts->name); > + return -EBUSY; > + } > + > bt = kzalloc(sizeof(*bt), GFP_KERNEL); > if (!bt) > return -ENOMEM; > -- 2.16.4 Looks good. Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index ea47f2084087..1a1943d39802 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -3,6 +3,9 @@ * Copyright (C) 2006 Jens Axboe <axboe@kernel.dk> * */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/kernel.h> #include <linux/blkdev.h> #include <linux/blktrace_api.h> @@ -494,6 +497,16 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, */ strreplace(buts->name, '/', '_'); + /* + * bdev can be NULL, as with scsi-generic, this is a helpful as + * we can be. + */ + if (q->blk_trace) { + pr_warn("Concurrent blktraces are not allowed on %s\n", + buts->name); + return -EBUSY; + } + bt = kzalloc(sizeof(*bt), GFP_KERNEL); if (!bt) return -ENOMEM;