public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* map gendisk (or blockdev) -> scsi_device
@ 2005-07-13  0:38 Edward Falk
  2005-07-13  1:31 ` Chen, Kenneth W
  2005-07-13 14:38 ` Christoph Hellwig
  0 siblings, 2 replies; 8+ messages in thread
From: Edward Falk @ 2005-07-13  0:38 UTC (permalink / raw)
  To: linux-scsi

Hi all; what's the proper way to get the scsi_device structure from a 
gendisk structure?  sd.c uses pointers through scsi_disk, but that 
structure is private to sd.c.  Will I need to add an access function in 
sd.c or something?

-ed falk, efalk@google.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE:  map gendisk (or blockdev) -> scsi_device
  2005-07-13  0:38 map gendisk (or blockdev) -> scsi_device Edward Falk
@ 2005-07-13  1:31 ` Chen, Kenneth W
  2005-07-13 14:38 ` Christoph Hellwig
  1 sibling, 0 replies; 8+ messages in thread
From: Chen, Kenneth W @ 2005-07-13  1:31 UTC (permalink / raw)
  To: 'Edward Falk', linux-scsi

Edward Falk wrote on Tuesday, July 12, 2005 5:38 PM
> Hi all; what's the proper way to get the scsi_device structure from a 
> gendisk structure?  sd.c uses pointers through scsi_disk, but that 
> structure is private to sd.c.  Will I need to add an access function in 
> sd.c or something?

If you are sure gendisk points to a scsi disk, then I think you can get
scsi_device through gendisk->queue->queuedata.

- Ken


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: map gendisk (or blockdev) -> scsi_device
  2005-07-13  0:38 map gendisk (or blockdev) -> scsi_device Edward Falk
  2005-07-13  1:31 ` Chen, Kenneth W
@ 2005-07-13 14:38 ` Christoph Hellwig
  2005-07-13 18:44   ` Edward Falk
  1 sibling, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2005-07-13 14:38 UTC (permalink / raw)
  To: Edward Falk; +Cc: linux-scsi

On Tue, Jul 12, 2005 at 05:38:19PM -0700, Edward Falk wrote:
> Hi all; what's the proper way to get the scsi_device structure from a 
> gendisk structure?

No.

> sd.c uses pointers through scsi_disk, but that 
> structure is private to sd.c.  Will I need to add an access function in 
> sd.c or something?

You should revisit your code to not need access to the scsi_device
structure, and follow the layering of the block and scsi subsystems.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: map gendisk (or blockdev) -> scsi_device
  2005-07-13 14:38 ` Christoph Hellwig
@ 2005-07-13 18:44   ` Edward Falk
  2005-07-13 23:46     ` Patrick Mansfield
  0 siblings, 1 reply; 8+ messages in thread
From: Edward Falk @ 2005-07-13 18:44 UTC (permalink / raw)
  To: linux-scsi


> You should revisit your code to not need access to the scsi_device
> structure, and follow the layering of the block and scsi subsystems.

Maybe I should explain what I'm trying to do here.

Some of our software reads some of the values in /proc/ide/hda/.  We're 
porting this facility to libata-based drivers in 2.6 and moving it to 
/sysfs/block/sda/.  The sysfs show() functions will be given pointers to 
gendisk structures but will need to obtain information from the 
associated scsi_device structure.

Does anybody have any suggestions as to the "right" way to proceed?


meta:

I understand the layering of block vs scsi and so on, but I wonder why 
there's so much isolation in the kernel.  Why should it be impossible to 
obtain the gendisk structure from the scsi_device structure, or to 
obtain the block_device structure from the gendisk?

   -ed falk


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: map gendisk (or blockdev) -> scsi_device
  2005-07-13 18:44   ` Edward Falk
@ 2005-07-13 23:46     ` Patrick Mansfield
  2005-07-14 18:38       ` Edward Falk
  2005-07-14 19:56       ` Christoph Hellwig
  0 siblings, 2 replies; 8+ messages in thread
From: Patrick Mansfield @ 2005-07-13 23:46 UTC (permalink / raw)
  To: Edward Falk; +Cc: linux-scsi

On Wed, Jul 13, 2005 at 11:44:34AM -0700, Edward Falk wrote:
> 
> >You should revisit your code to not need access to the scsi_device
> >structure, and follow the layering of the block and scsi subsystems.
> 
> Maybe I should explain what I'm trying to do here.
> 
> Some of our software reads some of the values in /proc/ide/hda/.  We're 
> porting this facility to libata-based drivers in 2.6 and moving it to 
> /sysfs/block/sda/.  The sysfs show() functions will be given pointers to 
> gendisk structures but will need to obtain information from the 
> associated scsi_device structure.
> 
> Does anybody have any suggestions as to the "right" way to proceed?

Add or use the attributes under the scsi_device, then use the
/sysfs/block/sd/device symlink to find the corresponding scsi_device.

This is similar to what udev and lsscsi use to find device attributes.

udev uses libsysfs (included with udev).

[elm3b79 patman]$ ls -l /sys/block/sdo/device
lrwxrwxrwx    1 root     root            0 Jul 13 16:44 /sys/block/sdo/device -> ../../devices/pci0000:01/0000:01:0c.0/host2/rport-2:0-8/target2:0:8/2:0:8:0

[elm3b79 patman]$ ls /sys/block/sdo/device/
block   device_blocked  iodone_cnt     model        rescan      state vendor
bus     driver          ioerr_cnt      queue_depth  rev         timeout
delete  iocounterbits   iorequest_cnt  queue_type   scsi_level  type

-- Patrick Mansfield

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: map gendisk (or blockdev) -> scsi_device
  2005-07-13 23:46     ` Patrick Mansfield
@ 2005-07-14 18:38       ` Edward Falk
  2005-07-14 19:56       ` Christoph Hellwig
  1 sibling, 0 replies; 8+ messages in thread
From: Edward Falk @ 2005-07-14 18:38 UTC (permalink / raw)
  To: linux-scsi


> Add or use the attributes under the scsi_device, then use the
> /sysfs/block/sd/device symlink to find the corresponding scsi_device.

Perfect!  Thanks.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: map gendisk (or blockdev) -> scsi_device
  2005-07-13 23:46     ` Patrick Mansfield
  2005-07-14 18:38       ` Edward Falk
@ 2005-07-14 19:56       ` Christoph Hellwig
  2005-07-14 22:54         ` Edward Falk
  1 sibling, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2005-07-14 19:56 UTC (permalink / raw)
  To: Patrick Mansfield; +Cc: Edward Falk, linux-scsi

On Wed, Jul 13, 2005 at 04:46:54PM -0700, Patrick Mansfield wrote:
> Add or use the attributes under the scsi_device, then use the
> /sysfs/block/sd/device symlink to find the corresponding scsi_device.

yupp, the /sys/block/* attributes are really only meant to be for
thing related to the actual block device, not the underlying hardware.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: map gendisk (or blockdev) -> scsi_device
  2005-07-14 19:56       ` Christoph Hellwig
@ 2005-07-14 22:54         ` Edward Falk
  0 siblings, 0 replies; 8+ messages in thread
From: Edward Falk @ 2005-07-14 22:54 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Patrick Mansfield, linux-scsi

Christoph Hellwig wrote:
> On Wed, Jul 13, 2005 at 04:46:54PM -0700, Patrick Mansfield wrote:
> 
>>Add or use the attributes under the scsi_device, then use the
>>/sysfs/block/sd/device symlink to find the corresponding scsi_device.
> 
> 
> yupp, the /sys/block/* attributes are really only meant to be for
> thing related to the actual block device, not the underlying hardware.

What is the difference between "actual block device" and "underlying 
hardware"?

	-ed


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-07-14 22:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-13  0:38 map gendisk (or blockdev) -> scsi_device Edward Falk
2005-07-13  1:31 ` Chen, Kenneth W
2005-07-13 14:38 ` Christoph Hellwig
2005-07-13 18:44   ` Edward Falk
2005-07-13 23:46     ` Patrick Mansfield
2005-07-14 18:38       ` Edward Falk
2005-07-14 19:56       ` Christoph Hellwig
2005-07-14 22:54         ` Edward Falk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox