From: Jens Axboe <axboe@suse.de>
To: linux-scsi@vger.kernel.org, tommaso.m@tiscalinet.it
Subject: Re: extracting infos from struct scsi_cmnd
Date: Sat, 27 Nov 2004 16:48:49 +0100 [thread overview]
Message-ID: <20041127154849.GA24460@suse.de> (raw)
In-Reply-To: <20041127124222.GA1200@abulafia>
On Sat, Nov 27 2004, Tommaso Moroni wrote:
> Hi!
>
> I'm writing a module for the 2.6.9 kernel which tracks accesses on a
> usb-storage device; in particular I'm interested in extracting from a
> struct scsi_cmnd the data read/written and the associated sector.
>
>
> The code I'vr written till now looks like the following:
>
>
> struct scsi_cmnd * cmd;
> [...]
> if (cmd->use_sg == 0)
> {
> buf = cmd->buffer;
> buflen = cmd->bufflen;
> sector = cmd->request->sector;
->request_bufflen and ->request_buffer.
> } else {
> struct scatterlist * sl = (struct scatterlist *) cmd->buffer;
> for (i = 0; i < cmd->use_sg; i++)
> {
> buf = page_address(sl[i].page) + sl[i].offset;
> buflen = sl[i].length;
> /* sector? */
> }
> }
This only works on non-highmem pages, you should use kmap/kmap_atomic
instead.
> Is it correct?
> Where can I find the sector involved in the operation if the
> scatter-gather is used?
It's ->request->sector as well. The total length is just the sum of the
sg elements.
--
Jens Axboe
next prev parent reply other threads:[~2004-11-27 15:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-27 12:42 extracting infos from struct scsi_cmnd Tommaso Moroni
2004-11-27 15:48 ` Jens Axboe [this message]
2004-11-28 2:02 ` extracting resid " Douglas Gilbert
2004-11-28 9:12 ` Jens Axboe
2004-11-28 13:01 ` [PATCH] " Douglas Gilbert
2004-11-28 14:59 ` Jens Axboe
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=20041127154849.GA24460@suse.de \
--to=axboe@suse.de \
--cc=linux-scsi@vger.kernel.org \
--cc=tommaso.m@tiscalinet.it \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.