Commit 59294772 authored by Kai Mäkisara's avatar Kai Mäkisara Committed by James Bottomley

[PATCH] SCSI tape sysfs name fixes

- The sysfs directory names are changed from stxmy[n] to the names in
  devices.txt. Below is an example for the first tape drive:
  /sys/class/scsi_tape/
  |-- nst0
  |-- nst0a
  |-- nst0l
  |-- nst0m
  |-- st0
  |-- st0a
  |-- st0l
  `-- st0m

- Name generation for non-default number of modes fixed so that same
  minors get same names even with different number of modes.

- devfs minor generation fixed to work with non-default number of modes

- The alignment requirement is printed in the line logged when a tape is
  attached.
parent d15bf113
......@@ -2,7 +2,7 @@ This file contains brief information about the SCSI tape driver.
The driver is currently maintained by Kai Mäkisara (email
Kai.Makisara@kolumbus.fi)
Last modified: Thu Feb 19 21:57:30 2004 by makisara
Last modified: Wed Feb 25 14:09:08 2004 by makisara
BASICS
......@@ -36,8 +36,9 @@ The user can override the parameters defined by the system
manager. The changes persist until the defaults again come into
effect.
3. Up to four modes can be defined and selected using the minor number
(bits 5 and 6). Mode 0 corresponds to the defaults discussed
3. By default, up to four modes can be defined and selected using the minor
number (bits 5 and 6). The number of modes can be changed by changing
ST_NBR_MODE_BITS in st.h. Mode 0 corresponds to the defaults discussed
above. Additional modes are dormant until they are defined by the
system manager (root). When specification of a new mode is started,
the configuration of mode 0 is used to provide a starting point for
......@@ -107,7 +108,7 @@ The minor numbers consist of the following bit fields:
dev_upper non-rew mode dev-lower
20 - 8 7 6 5 4 0
The non-rewind bit is always bit 7 (the uppermost bit in the lowermost
byte). The bits defining the mode are next to the non-rewind bits. The
byte). The bits defining the mode are below the non-rewind bit. The
remaining bits define the tape device number. This numbering is
backward compatible with the numbering used when the minor number was
only 8 bits wide.
......@@ -117,10 +118,10 @@ SYSFS SUPPORT
The driver creates the directory /sys/class/scsi_tape and populates it with
directories corresponding to the existing tape devices. There are autorewind
and non-rewind entries for each mode. The names are stxmy and stxmyn, where x
is the tape number and y is the mode. For example, the directories for the
first tape device are (assuming four modes): st0m0 st0m0n st0m1 st0m1n
st0m2 st0m2n st0m3 st0m3n.
and non-rewind entries for each mode. The names are stxy and nstxy, where x
is the tape number and y a character corresponding to the mode (none, l, m,
a). For example, the directories for the first tape device are (assuming four
modes): st0 nst0 st0l nst0l st0m nst0m st0a nst0a.
Each directory contains the entries: default_blksize default_compression
default_density defined dev device driver. The file 'defined' contains 1
......@@ -130,7 +131,7 @@ file 'dev' contains the device numbers corresponding to this device. The links
'device' and 'driver' point to the SCSI device and driver entries.
A link named 'tape' is made from the SCSI device directory to the class
directory corresponding to the mode 0 auto-rewind device (e.g., st0m0).
directory corresponding to the mode 0 auto-rewind device (e.g., st0).
BSD AND SYS V SEMANTICS
......
......@@ -17,7 +17,7 @@
Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support
*/
static char *verstr = "20040213";
static char *verstr = "20040226";
#include <linux/module.h>
......@@ -121,7 +121,15 @@ static struct st_dev_parm {
};
#endif
static char *st_formats[ST_NBR_MODES] ={"", "l", "m", "a"};
/* Restrict the number of modes so that names for all are assigned */
#if ST_NBR_MODES > 16
#error "Maximum number of modes is 16"
#endif
/* Bit reversed order to get same names for same minors with all
mode counts */
static char *st_formats[] = {
"", "r", "k", "s", "l", "t", "o", "u",
"m", "v", "p", "x", "a", "y", "q", "z"};
/* The default definitions have been moved to st_options.h */
......@@ -3888,8 +3896,11 @@ static int st_probe(struct device *dev)
dev_num);
goto out_free_tape;
}
snprintf(cdev->kobj.name, KOBJ_NAME_LEN, "%sm%d%s", disk->disk_name,
mode, j ? "n" : "");
/* Make sure that the minor numbers corresponding to the four
first modes always get the same names */
i = mode << (4 - ST_NBR_MODE_BITS);
snprintf(cdev->kobj.name, KOBJ_NAME_LEN, "%s%s%s", j ? "n" : "",
disk->disk_name, st_formats[i]);
cdev->owner = THIS_MODULE;
cdev->ops = &st_fops;
......@@ -3909,22 +3920,26 @@ static int st_probe(struct device *dev)
}
for (mode = 0; mode < ST_NBR_MODES; ++mode) {
/* Make sure that the minor numbers corresponding to the four
first modes always get the same names */
i = mode << (4 - ST_NBR_MODE_BITS);
/* Rewind entry */
devfs_mk_cdev(MKDEV(SCSI_TAPE_MAJOR, dev_num + (mode << 5)),
devfs_mk_cdev(MKDEV(SCSI_TAPE_MAJOR, TAPE_MINOR(dev_num, mode, 0)),
S_IFCHR | S_IRUGO | S_IWUGO,
"%s/mt%s", SDp->devfs_name, st_formats[mode]);
"%s/mt%s", SDp->devfs_name, st_formats[i]);
/* No-rewind entry */
devfs_mk_cdev(MKDEV(SCSI_TAPE_MAJOR, dev_num + (mode << 5) + 128),
devfs_mk_cdev(MKDEV(SCSI_TAPE_MAJOR, TAPE_MINOR(dev_num, mode, 1)),
S_IFCHR | S_IRUGO | S_IWUGO,
"%s/mt%sn", SDp->devfs_name, st_formats[mode]);
"%s/mt%sn", SDp->devfs_name, st_formats[i]);
}
disk->number = devfs_register_tape(SDp->devfs_name);
printk(KERN_WARNING
"Attached scsi tape %s at scsi%d, channel %d, id %d, lun %d\n",
tape_name(tpnt), SDp->host->host_no, SDp->channel, SDp->id, SDp->lun);
printk(KERN_WARNING "%s: try direct i/o: %s, max page reachable by HBA %lu\n",
tape_name(tpnt), tpnt->try_dio ? "yes" : "no", tpnt->max_pfn);
printk(KERN_WARNING "%s: try direct i/o: %s (alignment %d B), max page reachable by HBA %lu\n",
tape_name(tpnt), tpnt->try_dio ? "yes" : "no",
queue_dma_alignment(SDp->request_queue) + 1, tpnt->max_pfn);
return 0;
......@@ -3977,8 +3992,9 @@ static int st_remove(struct device *dev)
sysfs_remove_link(&tpnt->device->sdev_gendev.kobj,
"tape");
for (mode = 0; mode < ST_NBR_MODES; ++mode) {
devfs_remove("%s/mt%s", SDp->devfs_name, st_formats[mode]);
devfs_remove("%s/mt%sn", SDp->devfs_name, st_formats[mode]);
j = mode << (4 - ST_NBR_MODE_BITS);
devfs_remove("%s/mt%s", SDp->devfs_name, st_formats[j]);
devfs_remove("%s/mt%sn", SDp->devfs_name, st_formats[j]);
for (j=0; j < 2; j++) {
class_simple_device_remove(MKDEV(SCSI_TAPE_MAJOR,
TAPE_MINOR(i, mode, j)));
......
......@@ -50,6 +50,8 @@ typedef struct {
struct cdev *cdevs[2]; /* Auto-rewind and non-rewind devices */
} ST_mode;
/* Number of modes can be changed by changing ST_NBR_MODE_BITS. The maximum
number of modes is 16 (ST_NBR_MODE_BITS 4) */
#define ST_NBR_MODE_BITS 2
#define ST_NBR_MODES (1 << ST_NBR_MODE_BITS)
#define ST_MODE_SHIFT (7 - ST_NBR_MODE_BITS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment