Skip to contentSkip to conversation

raw-posix: improve detection of scsi-generic devices

PATCH In review Bernhard Kohl 4 participants 6 messages Sep 6, 2010 – Sep 7, 2010 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 raw-posix: improve detection of scsi-generic devices

From: Bernhard Kohl <[email protected]>

Allow symbolic links which point to /dev/sgX devices.

---
 block/raw-posix.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
block/raw-posix.c +8 -2
index 72fb8ce..4544a57 100644
@@ -48,6 +48,7 @@
 #endif
 #ifdef __linux__
 #include <sys/ioctl.h>
+#include <sys/param.h>
 #include <linux/cdrom.h>
 #include <linux/fd.h>
 #endif
@@ -868,8 +869,13 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
 
     s->type = FTYPE_FILE;
 #if defined(__linux__)
-    if (strstart(filename, "/dev/sg", NULL)) {
-        bs->sg = 1;
+    {
+        char resolved_path[ MAXPATHLEN ], *temp;
+
+        temp = realpath(filename, resolved_path);
+        if (temp && strstart(temp, "/dev/sg", NULL)) {
+            bs->sg = 1;
+        }
     }
 #endif
 
Signature · 1 line
1.7.2.2
#1 lore raw
Quoted 3 lines · Bernhard Kohl

From: Bernhard Kohl <[email protected]>

Allow symbolic links which point to /dev/sgX devices.

Couldn't you send an SG_IO test ioctl over and see if it works? I really dislike the whole file name magic matching.

Alex

#2 lore raw
Quoted 8 lines · Alexander Graf
Quoted 3 lines · Bernhard Kohl

From: Bernhard Kohl <[email protected]>

Allow symbolic links which point to /dev/sgX devices.

Couldn't you send an SG_IO test ioctl over and see if it works? I really dislike the whole file name magic matching.

You could, but the result would not be what you expect, given that every /dev/sd* device and more in Linux support it.

What we really need is to stop shoe-horning scsi pass through support into the block layer. Once we finally get our generic thread offload facilily there is no need for it anymore at all, scsi-generic can simplify offload the SG_IO ioctl and be done with it. I even have an old prototype for this, just waiting for the generic thread offload to get merged before resurrecting it.

#3 lore raw

Am 07.09.2010 04:04, schrieb ext Christoph Hellwig:

Quoted 14 lines · Alexander Graf
Quoted 10 lines · Bernhard Kohl
Quoted 6 lines

From: Bernhard Kohl<[email protected]>

Allow symbolic links which point to /dev/sgX devices.

Couldn't you send an SG_IO test ioctl over and see if it works? I really dislike the whole file name magic matching.

You could, but the result would not be what you expect, given that every /dev/sd* device and more in Linux support it.

Quoted 7 lines

What we really need is to stop shoe-horning scsi pass through support into the block layer. Once we finally get our generic thread offload facilily there is no need for it anymore at all, scsi-generic can simplify offload the SG_IO ioctl and be done with it. I even have an old prototype for this, just waiting for the generic thread offload to get merged before resurrecting it.

Wouldn't it be OK to apply this patch in the meantime before we get this complete new solution? I need to handle about 15 /dev/sg* disks which are randomly numbered. With this patch I can use the udev generated links in /dev/disk/by*, which makes life much easier.

#4 lore raw
Quoted 23 lines · Bernhard Kohl

Am 07.09.2010 04:04, schrieb ext Christoph Hellwig:

Quoted 14 lines · Alexander Graf
Quoted 10 lines · Bernhard Kohl
Quoted 6 lines

From: Bernhard Kohl<[email protected]>

Allow symbolic links which point to /dev/sgX devices.

Couldn't you send an SG_IO test ioctl over and see if it works? I really dislike the whole file name magic matching.

You could, but the result would not be what you expect, given that every /dev/sd* device and more in Linux support it.

Quoted 7 lines

What we really need is to stop shoe-horning scsi pass through support into the block layer. Once we finally get our generic thread offload facilily there is no need for it anymore at all, scsi-generic can simplify offload the SG_IO ioctl and be done with it. I even have an old prototype for this, just waiting for the generic thread offload to get merged before resurrecting it.

Quoted 5 lines

Wouldn't it be OK to apply this patch in the meantime before we get this complete new solution? I need to handle about 15 /dev/sg* disks which are randomly numbered. With this patch I can use the udev generated links in /dev/disk/by*, which makes life much easier.

I agree. I'd take this one in for now, as it improves the situation and then when all world blossoms we can take Christoph's game-changing framework :).

Kevin, what do you think?

Alex

#5 lore raw
In reply to Christoph Hellwig

Am 07.09.2010 04:04, schrieb Christoph Hellwig:

Quoted 13 lines · Alexander Graf
Quoted 8 lines · Bernhard Kohl
Quoted 4 lines

From: Bernhard Kohl <[email protected]>

Allow symbolic links which point to /dev/sgX devices.

Couldn't you send an SG_IO test ioctl over and see if it works? I really dislike the whole file name magic matching.

You could, but the result would not be what you expect, given that every /dev/sd* device and more in Linux support it.

Quoted 6 lines

What we really need is to stop shoe-horning scsi pass through support into the block layer. Once we finally get our generic thread offload facilily there is no need for it anymore at all, scsi-generic can simplify offload the SG_IO ioctl and be done with it. I even have an old prototype for this, just waiting for the generic thread offload to get merged before resurrecting it.

Let's apply this patch for the time being then, and remove the code altogether as soon as possible.

Kevin