diff options
author | Boaz Harrosh <bharrosh@panasas.com> | 2009-11-29 09:26:45 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-12-04 13:01:46 -0500 |
commit | 2cdd6410e5a1665823f2a048fc7f8f6a8384be1d (patch) | |
tree | 327ae154abd84aea9c18eb24eb87c9d6f8029d26 /drivers/scsi/osd/osd_initiator.c | |
parent | d6ae4333e648492721a098bdc329bbd82d25eb67 (diff) |
[SCSI] libosd: osd_dev_info: Unique Identification of an OSD device
Define an osd_dev_info structure that Uniquely identifies an OSD
device lun on the network. The identification is built from unique
target attributes and is the same for all network/SAN machines.
osduld_info_lookup() - NEW
New API that will lookup an osd_dev by its osd_dev_info.
This is used by pNFS-objects for cross network global device
identification. And by exofs multy-device support, the device
info is specified in the on-disk exofs device table.
osduld_device_info() - NEW
Given an osd_dev handle returns its associated osd_dev_info.
The ULD fetches this information at startup and hangs it on
each OSD device. (This is a fast operation that can be called
at any condition)
osduld_device_same() - NEW
With a given osd_dev at one hand and an osd_dev_info
at another, we would like to know if they are the same
device.
Two osd_dev handles can be checked by:
osduld_device_same(od1, osduld_device_info(od2));
osd_auto_detect_ver() - REVISED
Now returns an osd_dev_info structure. Is only called once
by ULD as before. See added comments for how to use.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/osd/osd_initiator.c')
-rw-r--r-- | drivers/scsi/osd/osd_initiator.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c index 7a117c18114..60b7ca1e9bc 100644 --- a/drivers/scsi/osd/osd_initiator.c +++ b/drivers/scsi/osd/osd_initiator.c | |||
@@ -73,7 +73,8 @@ static const char *_osd_ver_desc(struct osd_request *or) | |||
73 | 73 | ||
74 | #define ATTR_DEF_RI(id, len) ATTR_DEF(OSD_APAGE_ROOT_INFORMATION, id, len) | 74 | #define ATTR_DEF_RI(id, len) ATTR_DEF(OSD_APAGE_ROOT_INFORMATION, id, len) |
75 | 75 | ||
76 | static int _osd_print_system_info(struct osd_dev *od, void *caps) | 76 | static int _osd_get_print_system_info(struct osd_dev *od, |
77 | void *caps, struct osd_dev_info *odi) | ||
77 | { | 78 | { |
78 | struct osd_request *or; | 79 | struct osd_request *or; |
79 | struct osd_attr get_attrs[] = { | 80 | struct osd_attr get_attrs[] = { |
@@ -137,8 +138,12 @@ static int _osd_print_system_info(struct osd_dev *od, void *caps) | |||
137 | OSD_INFO("PRODUCT_SERIAL_NUMBER [%s]\n", | 138 | OSD_INFO("PRODUCT_SERIAL_NUMBER [%s]\n", |
138 | (char *)pFirst); | 139 | (char *)pFirst); |
139 | 140 | ||
140 | pFirst = get_attrs[a].val_ptr; | 141 | odi->osdname_len = get_attrs[a].len; |
141 | OSD_INFO("OSD_NAME [%s]\n", (char *)pFirst); | 142 | /* Avoid NULL for memcmp optimization 0-length is good enough */ |
143 | odi->osdname = kzalloc(odi->osdname_len + 1, GFP_KERNEL); | ||
144 | if (odi->osdname_len) | ||
145 | memcpy(odi->osdname, get_attrs[a].val_ptr, odi->osdname_len); | ||
146 | OSD_INFO("OSD_NAME [%s]\n", odi->osdname); | ||
142 | a++; | 147 | a++; |
143 | 148 | ||
144 | pFirst = get_attrs[a++].val_ptr; | 149 | pFirst = get_attrs[a++].val_ptr; |
@@ -171,6 +176,14 @@ static int _osd_print_system_info(struct osd_dev *od, void *caps) | |||
171 | sid_dump, sizeof(sid_dump), true); | 176 | sid_dump, sizeof(sid_dump), true); |
172 | OSD_INFO("OSD_SYSTEM_ID(%d)\n" | 177 | OSD_INFO("OSD_SYSTEM_ID(%d)\n" |
173 | " [%s]\n", len, sid_dump); | 178 | " [%s]\n", len, sid_dump); |
179 | |||
180 | if (unlikely(len > sizeof(odi->systemid))) { | ||
181 | OSD_ERR("OSD Target error: OSD_SYSTEM_ID too long(%d). " | ||
182 | "device idetification might not work\n", len); | ||
183 | len = sizeof(odi->systemid); | ||
184 | } | ||
185 | odi->systemid_len = len; | ||
186 | memcpy(odi->systemid, get_attrs[a].val_ptr, len); | ||
174 | a++; | 187 | a++; |
175 | } | 188 | } |
176 | out: | 189 | out: |
@@ -178,16 +191,17 @@ out: | |||
178 | return ret; | 191 | return ret; |
179 | } | 192 | } |
180 | 193 | ||
181 | int osd_auto_detect_ver(struct osd_dev *od, void *caps) | 194 | int osd_auto_detect_ver(struct osd_dev *od, |
195 | void *caps, struct osd_dev_info *odi) | ||
182 | { | 196 | { |
183 | int ret; | 197 | int ret; |
184 | 198 | ||
185 | /* Auto-detect the osd version */ | 199 | /* Auto-detect the osd version */ |
186 | ret = _osd_print_system_info(od, caps); | 200 | ret = _osd_get_print_system_info(od, caps, odi); |
187 | if (ret) { | 201 | if (ret) { |
188 | osd_dev_set_ver(od, OSD_VER1); | 202 | osd_dev_set_ver(od, OSD_VER1); |
189 | OSD_DEBUG("converting to OSD1\n"); | 203 | OSD_DEBUG("converting to OSD1\n"); |
190 | ret = _osd_print_system_info(od, caps); | 204 | ret = _osd_get_print_system_info(od, caps, odi); |
191 | } | 205 | } |
192 | 206 | ||
193 | return ret; | 207 | return ret; |