From: Bart Van Assche <Bart.VanAssche@wdc.com>
To: "maier@linux.ibm.com" <maier@linux.ibm.com>,
"osandov@osandov.com" <osandov@osandov.com>
Cc: "lizefan@huawei.com" <lizefan@huawei.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"rostedt@goodmis.org" <rostedt@goodmis.org>,
"mingo@redhat.com" <mingo@redhat.com>,
"axboe@kernel.dk" <axboe@kernel.dk>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Subject: Re: [PATCH 2/2] tracing/events: block: dev_t via driver core for plug and unplug events
Date: Fri, 27 Apr 2018 16:38:05 +0000 [thread overview]
Message-ID: <9b5e43db06f6516f7c0e9cc379e0c2964000d4e1.camel@wdc.com> (raw)
In-Reply-To: <056d8ee9-5e1d-8219-c24c-9130d6c1dcbf@linux.ibm.com>
On Tue, 2018-04-24 at 16:49 +0200, Steffen Maier wrote:
> The object life cycle seems to be:
>
> (1) blk_alloc_queue() also creates gendisk kobj
I think this is a misinterpretation. blk_alloc_queue_node() initializes the
request queue kobj as follows:
kobject_init(&q->kobj, &blk_queue_ktype);
register_disk() creates the /sys/class/block/<disk> node and /sys/block/<disk>
link as follows:
if (device_add(ddev))
return;
if (!sysfs_deprecated) {
err = sysfs_create_link(block_depr, &ddev->kobj,
kobject_name(&ddev->kobj));
if (err) {
device_del(ddev);
return;
}
}
> (1a) SCSI does LUN probing I/O
> most of that is blktrace RWBS field value 'N' i.e. non-R/W with dev_t==0
> since q->kobj.parent is still NULL we cannot get gendisk and thus dev_t
> near the end is the first regular read block I/O with dev_t!=0
> as bio!=NULL and bi_disk or rq_disk are non-NULL
> (2) blk_register_queue() also creates queue kobj with gendisk parent
> now we can follow q->kobj.parent to gendisk to get dev_t,
> e.g. for RWBS 'N' such as implicit SCSI test unit ready on blk dev close
Please have a look at the device_add_disk() call in sd_probe_async(). I think
that function triggers a call of blk_register_queue(). That last function
associates the request queue with the gendisk as follows:
ret = kobject_add(&q->kobj, kobject_get(&dev->kobj), "%s", "queue");
> (3) optionally "regular" I/O
> (4) blk_unregister_queue() called by del_gendisk()
> does kobject_del(&q->kobj) which NULLifies q->kobj.parent again
> the last put of gendisk reference releases gendisk kobj
> (5) blk_cleanup_queue()
> the last put of queue (/mq) reference releases queue (/mq) kobj
The /mq directory corresponds to q->mq_kobj. The block layer core drops its
reference to the queue kobject (q->kobj) by calling blk_put_queue() at the
end of blk_cleanup_queue().
> Since I cannot prove it's always like this, I followed Bart's suggestion
> and added another refcount get at (2) blk_register_queue().
> However, when I want to put that additional refcount at (5) blk_cleanup_queue(),
> we only get a queue pointer argument as context
> and q->kobj.parent==NULL since (4),
> so I don't know how to get to the gendisk object for the refcount put.
Have you tried to modify blk_register_queue() such that it stores the disk
pointer in a new struct request_queue member?
Thanks,
Bart.
next prev parent reply other threads:[~2018-04-27 16:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-13 13:07 [PATCH 0/2] tracing/events: block: bring more on a par with blktrace Steffen Maier
2018-04-13 13:07 ` [PATCH 1/2] tracing/events: block: track and print if unplug was explicit or schedule Steffen Maier
2018-04-13 14:16 ` Steven Rostedt
2018-04-13 13:07 ` [PATCH 2/2] tracing/events: block: dev_t via driver core for plug and unplug events Steffen Maier
2018-04-15 8:31 ` Greg Kroah-Hartman
2018-04-16 16:33 ` Steffen Maier
2018-04-19 19:24 ` Omar Sandoval
2018-04-19 20:56 ` Bart Van Assche
2018-04-24 14:49 ` Steffen Maier
2018-04-27 16:38 ` Bart Van Assche [this message]
2018-04-13 13:07 ` [RFC] tracing/events: block: also try to get dev_t via driver core for some events Steffen Maier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9b5e43db06f6516f7c0e9cc379e0c2964000d4e1.camel@wdc.com \
--to=bart.vanassche@wdc.com \
--cc=axboe@kernel.dk \
--cc=gregkh@linuxfoundation.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=maier@linux.ibm.com \
--cc=mingo@redhat.com \
--cc=osandov@osandov.com \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).