diff options
author | mav <mav@FreeBSD.org> | 2011-04-26 17:01:49 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2011-04-26 17:01:49 +0000 |
commit | 519a30551e314539bf947c982c6407ccfa2a1fc7 (patch) | |
tree | c2addcf01914b57db809b818c842c9fb3345fe25 /sys/cam | |
parent | e19591c5077914564e9818802d634404fc9e3808 (diff) | |
download | FreeBSD-src-519a30551e314539bf947c982c6407ccfa2a1fc7.zip FreeBSD-src-519a30551e314539bf947c982c6407ccfa2a1fc7.tar.gz |
- Add shim to simplify migration to the CAM-based ATA. For each new adaX
device in /dev/ create symbolic link with adY name, trying to mimic old ATA
numbering. Imitation is not complete, but should be enough in most cases to
mount file systems without touching /etc/fstab.
- To know what behavior to mimic, restore ATA_STATIC_ID option in cases
where it was present before.
- Add some more details to UPDATING.
Diffstat (limited to 'sys/cam')
-rw-r--r-- | sys/cam/ata/ata_da.c | 35 | ||||
-rw-r--r-- | sys/cam/cam_xpt.c | 36 | ||||
-rw-r--r-- | sys/cam/cam_xpt.h | 1 |
3 files changed, 71 insertions, 1 deletions
diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 0e8b273..128bb8b 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ada.h" +#include "opt_ata.h" #include <sys/param.h> @@ -183,6 +184,14 @@ static void adashutdown(void *arg, int howto); static void adasuspend(void *arg); static void adaresume(void *arg); +#ifndef ADA_DEFAULT_LEGACY_ALIASES +#ifdef ATA_CAM +#define ADA_DEFAULT_LEGACY_ALIASES 1 +#else +#define ADA_DEFAULT_LEGACY_ALIASES 0 +#endif +#endif + #ifndef ADA_DEFAULT_TIMEOUT #define ADA_DEFAULT_TIMEOUT 30 /* Timeout in seconds */ #endif @@ -215,6 +224,7 @@ static void adaresume(void *arg); #define ata_disk_firmware_geom_adjust(disk) #endif +static int ada_legacy_aliases = ADA_DEFAULT_LEGACY_ALIASES; static int ada_retry_count = ADA_DEFAULT_RETRY; static int ada_default_timeout = ADA_DEFAULT_TIMEOUT; static int ada_send_ordered = ADA_DEFAULT_SEND_ORDERED; @@ -224,6 +234,9 @@ static int ada_write_cache = ADA_DEFAULT_WRITE_CACHE; SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD, 0, "CAM Direct Access Disk driver"); +SYSCTL_INT(_kern_cam_ada, OID_AUTO, legacy_aliases, CTLFLAG_RW, + &ada_legacy_aliases, 0, "Create legacy-like device aliases"); +TUNABLE_INT("kern.cam.ada.legacy_aliases", &ada_legacy_aliases); SYSCTL_INT(_kern_cam_ada, OID_AUTO, retry_count, CTLFLAG_RW, &ada_retry_count, 0, "Normal I/O retry count"); TUNABLE_INT("kern.cam.ada.retry_count", &ada_retry_count); @@ -723,10 +736,11 @@ adaregister(struct cam_periph *periph, void *arg) struct ada_softc *softc; struct ccb_pathinq cpi; struct ccb_getdev *cgd; - char announce_buf[80]; + char announce_buf[80], buf1[32]; struct disk_params *dp; caddr_t match; u_int maxio; + int legacy_id; cgd = (struct ccb_getdev *)arg; if (periph == NULL) { @@ -861,6 +875,22 @@ adaregister(struct cam_periph *periph, void *arg) softc->disk->d_fwheads = softc->params.heads; ata_disk_firmware_geom_adjust(softc->disk); + if (ada_legacy_aliases) { +#ifdef ATA_STATIC_ID + legacy_id = xpt_path_legacy_ata_id(periph->path); +#else + legacy_id = softc->disk->d_unit; +#endif + if (legacy_id >= 0) { + snprintf(announce_buf, sizeof(announce_buf), + "kern.devalias.%s%d", + softc->disk->d_name, softc->disk->d_unit); + snprintf(buf1, sizeof(buf1), + "ad%d", legacy_id); + setenv(announce_buf, buf1); + } + } else + legacy_id = -1; disk_create(softc->disk, DISK_VERSION); mtx_lock(periph->sim->mtx); cam_periph_unhold(periph); @@ -874,6 +904,9 @@ adaregister(struct cam_periph *periph, void *arg) dp->secsize, dp->heads, dp->secs_per_track, dp->cylinders); xpt_announce_periph(periph, announce_buf); + if (legacy_id >= 0) + printf("%s%d: Previously was known as ad%d\n", + periph->periph_name, periph->unit_number, legacy_id); /* * Create our sysctl variables, now that we know diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index a348800..0c7576d 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -3569,6 +3569,42 @@ xpt_path_periph(struct cam_path *path) return (path->periph); } +int +xpt_path_legacy_ata_id(struct cam_path *path) +{ + struct cam_eb *bus; + int bus_id; + + if ((strcmp(path->bus->sim->sim_name, "ata") != 0) && + strcmp(path->bus->sim->sim_name, "ahcich") != 0 && + strcmp(path->bus->sim->sim_name, "mvsch") != 0 && + strcmp(path->bus->sim->sim_name, "siisch") != 0) + return (-1); + + if (strcmp(path->bus->sim->sim_name, "ata") == 0 && + path->bus->sim->unit_number < 2) { + bus_id = path->bus->sim->unit_number; + } else { + bus_id = 2; + xpt_lock_buses(); + TAILQ_FOREACH(bus, &xsoftc.xpt_busses, links) { + if (bus == path->bus) + break; + if ((strcmp(bus->sim->sim_name, "ata") == 0 && + bus->sim->unit_number >= 2) || + strcmp(bus->sim->sim_name, "ahcich") == 0 || + strcmp(bus->sim->sim_name, "mvsch") == 0 || + strcmp(bus->sim->sim_name, "siisch") == 0) + bus_id++; + } + xpt_unlock_buses(); + } + if (path->target != NULL) + return (bus_id * 2 + path->target->target_id); + else + return (bus_id * 2); +} + /* * Release a CAM control block for the caller. Remit the cost of the structure * to the device referenced by the path. If the this device had no 'credits' diff --git a/sys/cam/cam_xpt.h b/sys/cam/cam_xpt.h index 61a7f3f..9355be4 100644 --- a/sys/cam/cam_xpt.h +++ b/sys/cam/cam_xpt.h @@ -113,6 +113,7 @@ int xpt_path_string(struct cam_path *path, char *str, path_id_t xpt_path_path_id(struct cam_path *path); target_id_t xpt_path_target_id(struct cam_path *path); lun_id_t xpt_path_lun_id(struct cam_path *path); +int xpt_path_legacy_ata_id(struct cam_path *path); struct cam_sim *xpt_path_sim(struct cam_path *path); struct cam_periph *xpt_path_periph(struct cam_path *path); void xpt_async(u_int32_t async_code, struct cam_path *path, |