* ioblock.stp major/minor number patch
@ 2006-10-23 15:37 Mike Mason
2006-10-23 15:56 ` Frank Ch. Eigler
0 siblings, 1 reply; 2+ messages in thread
From: Mike Mason @ 2006-10-23 15:37 UTC (permalink / raw)
To: SystemTAP
The following patch adds major/minor number functions to the ioblock tapset. I found them useful in a block IO script I'm writing. It also fixes a few misleading comments.
- Mike Mason
--- src/tapset/ioblock.stp 2006-08-15 18:54:46.000000000 -0700
+++ src.save2/tapset/ioblock.stp 2006-10-23 08:30:08.000000000 -0700
@@ -10,9 +10,10 @@
%{
#include <linux/bio.h>
#include <linux/genhd.h>
+#include <linux/kdev_t.h>
%}
-/* get i-node number of mapped file */
+/* get i-node number of device file */
function __bio_ino:long(bio:long)
%{
struct bio *bio;
@@ -113,6 +114,52 @@
}
%}
+/* returns block device major number */
+function bio_major:long(bio:long)
+%{
+ struct bio *bio;
+ struct block_device *bi_bdev;
+
+ bio = (struct bio *)(long)THIS->bio;
+ bi_bdev = (struct block_device *)deref(sizeof(bio->bi_bdev),
+ &(bio->bi_bdev));
+ if (bi_bdev == NULL) {
+ THIS->__retvalue = -1;
+ goto end;
+ }
+
+ THIS->__retvalue = MAJOR(bi_bdev->bd_dev);
+
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+end: ;
+%}
+
+/* returns block device minor number */
+function bio_minor:long(bio:long)
+%{
+ struct bio *bio;
+ struct block_device *bi_bdev;
+
+ bio = (struct bio *)(long)THIS->bio;
+ bi_bdev = (struct block_device *)deref(sizeof(bio->bi_bdev),
+ &(bio->bi_bdev));
+ if (bi_bdev == NULL) {
+ THIS->__retvalue = -1;
+ goto end;
+ }
+
+ THIS->__retvalue = MINOR(bi_bdev->bd_dev);
+
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+end: ;
+%}
+
global BIO_READ, BIO_WRITE
probe begin
{
@@ -129,7 +176,7 @@
*
* Variables:
* devname - block device name
- * ino - i-node number of the mapped file
+ * ino - i-node number of the device file
* sector - beginning sector for the entire bio
* flags - see below
* BIO_UPTODATE 0 ok after I/O completion
@@ -184,8 +231,8 @@
*
* Variables:
* devname - block device name
- * ino - i-node number of the mapped file
- * byte_done - number of bytes transferred
+ * ino - i-node number of the device file
+ * bytes_done - number of bytes transferred
* sector - beginning sector for the entire bio
* flags - see below
* BIO_UPTODATE 0 ok after I/O completion
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: ioblock.stp major/minor number patch
2006-10-23 15:37 ioblock.stp major/minor number patch Mike Mason
@ 2006-10-23 15:56 ` Frank Ch. Eigler
0 siblings, 0 replies; 2+ messages in thread
From: Frank Ch. Eigler @ 2006-10-23 15:56 UTC (permalink / raw)
To: Mike Mason; +Cc: SystemTAP
Mike Mason <mmlnx@us.ibm.com> writes:
> The following patch adds major/minor number functions to the ioblock
> tapset. I found them useful in a block IO script I'm writing.
Good stuff, it's especially nice to see the deref() protection.
To complete the work, the new functions will need documentation
in one of the stapprobes* man pages, and test case or two.
(Something triggering those deref_faults too please.)
> It also fixes a few misleading comments.
It sounds like you should get yourself CVS access so that you can
check in small & obvious things like that. (See the web site for
details.)
- FChE
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-10-23 15:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-23 15:37 ioblock.stp major/minor number patch Mike Mason
2006-10-23 15:56 ` Frank Ch. Eigler
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 read-only IMAP folder(s) and NNTP newsgroup(s).