diff options
Diffstat (limited to 'drivers/target/target_core_stat.c')
-rw-r--r-- | drivers/target/target_core_stat.c | 312 |
1 files changed, 76 insertions, 236 deletions
diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c index cb6b0036ae95..d154ce797180 100644 --- a/drivers/target/target_core_stat.c +++ b/drivers/target/target_core_stat.c | |||
@@ -1,13 +1,10 @@ | |||
1 | /******************************************************************************* | 1 | /******************************************************************************* |
2 | * Filename: target_core_stat.c | 2 | * Filename: target_core_stat.c |
3 | * | 3 | * |
4 | * Copyright (c) 2011 Rising Tide Systems | ||
5 | * Copyright (c) 2011 Linux-iSCSI.org | ||
6 | * | ||
7 | * Modern ConfigFS group context specific statistics based on original | 4 | * Modern ConfigFS group context specific statistics based on original |
8 | * target_core_mib.c code | 5 | * target_core_mib.c code |
9 | * | 6 | * |
10 | * Copyright (c) 2006-2007 SBE, Inc. All Rights Reserved. | 7 | * (c) Copyright 2006-2012 RisingTide Systems LLC. |
11 | * | 8 | * |
12 | * Nicholas A. Bellinger <nab@linux-iscsi.org> | 9 | * Nicholas A. Bellinger <nab@linux-iscsi.org> |
13 | * | 10 | * |
@@ -80,13 +77,9 @@ static struct target_stat_scsi_dev_attribute \ | |||
80 | static ssize_t target_stat_scsi_dev_show_attr_inst( | 77 | static ssize_t target_stat_scsi_dev_show_attr_inst( |
81 | struct se_dev_stat_grps *sgrps, char *page) | 78 | struct se_dev_stat_grps *sgrps, char *page) |
82 | { | 79 | { |
83 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 80 | struct se_device *dev = |
84 | struct se_subsystem_dev, dev_stat_grps); | 81 | container_of(sgrps, struct se_device, dev_stat_grps); |
85 | struct se_hba *hba = se_subdev->se_dev_hba; | 82 | struct se_hba *hba = dev->se_hba; |
86 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
87 | |||
88 | if (!dev) | ||
89 | return -ENODEV; | ||
90 | 83 | ||
91 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); | 84 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); |
92 | } | 85 | } |
@@ -95,12 +88,8 @@ DEV_STAT_SCSI_DEV_ATTR_RO(inst); | |||
95 | static ssize_t target_stat_scsi_dev_show_attr_indx( | 88 | static ssize_t target_stat_scsi_dev_show_attr_indx( |
96 | struct se_dev_stat_grps *sgrps, char *page) | 89 | struct se_dev_stat_grps *sgrps, char *page) |
97 | { | 90 | { |
98 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 91 | struct se_device *dev = |
99 | struct se_subsystem_dev, dev_stat_grps); | 92 | container_of(sgrps, struct se_device, dev_stat_grps); |
100 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
101 | |||
102 | if (!dev) | ||
103 | return -ENODEV; | ||
104 | 93 | ||
105 | return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); | 94 | return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); |
106 | } | 95 | } |
@@ -109,13 +98,6 @@ DEV_STAT_SCSI_DEV_ATTR_RO(indx); | |||
109 | static ssize_t target_stat_scsi_dev_show_attr_role( | 98 | static ssize_t target_stat_scsi_dev_show_attr_role( |
110 | struct se_dev_stat_grps *sgrps, char *page) | 99 | struct se_dev_stat_grps *sgrps, char *page) |
111 | { | 100 | { |
112 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | ||
113 | struct se_subsystem_dev, dev_stat_grps); | ||
114 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
115 | |||
116 | if (!dev) | ||
117 | return -ENODEV; | ||
118 | |||
119 | return snprintf(page, PAGE_SIZE, "Target\n"); | 101 | return snprintf(page, PAGE_SIZE, "Target\n"); |
120 | } | 102 | } |
121 | DEV_STAT_SCSI_DEV_ATTR_RO(role); | 103 | DEV_STAT_SCSI_DEV_ATTR_RO(role); |
@@ -123,12 +105,8 @@ DEV_STAT_SCSI_DEV_ATTR_RO(role); | |||
123 | static ssize_t target_stat_scsi_dev_show_attr_ports( | 105 | static ssize_t target_stat_scsi_dev_show_attr_ports( |
124 | struct se_dev_stat_grps *sgrps, char *page) | 106 | struct se_dev_stat_grps *sgrps, char *page) |
125 | { | 107 | { |
126 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 108 | struct se_device *dev = |
127 | struct se_subsystem_dev, dev_stat_grps); | 109 | container_of(sgrps, struct se_device, dev_stat_grps); |
128 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
129 | |||
130 | if (!dev) | ||
131 | return -ENODEV; | ||
132 | 110 | ||
133 | return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_port_count); | 111 | return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_port_count); |
134 | } | 112 | } |
@@ -176,13 +154,9 @@ static struct target_stat_scsi_tgt_dev_attribute \ | |||
176 | static ssize_t target_stat_scsi_tgt_dev_show_attr_inst( | 154 | static ssize_t target_stat_scsi_tgt_dev_show_attr_inst( |
177 | struct se_dev_stat_grps *sgrps, char *page) | 155 | struct se_dev_stat_grps *sgrps, char *page) |
178 | { | 156 | { |
179 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 157 | struct se_device *dev = |
180 | struct se_subsystem_dev, dev_stat_grps); | 158 | container_of(sgrps, struct se_device, dev_stat_grps); |
181 | struct se_hba *hba = se_subdev->se_dev_hba; | 159 | struct se_hba *hba = dev->se_hba; |
182 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
183 | |||
184 | if (!dev) | ||
185 | return -ENODEV; | ||
186 | 160 | ||
187 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); | 161 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); |
188 | } | 162 | } |
@@ -191,12 +165,8 @@ DEV_STAT_SCSI_TGT_DEV_ATTR_RO(inst); | |||
191 | static ssize_t target_stat_scsi_tgt_dev_show_attr_indx( | 165 | static ssize_t target_stat_scsi_tgt_dev_show_attr_indx( |
192 | struct se_dev_stat_grps *sgrps, char *page) | 166 | struct se_dev_stat_grps *sgrps, char *page) |
193 | { | 167 | { |
194 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 168 | struct se_device *dev = |
195 | struct se_subsystem_dev, dev_stat_grps); | 169 | container_of(sgrps, struct se_device, dev_stat_grps); |
196 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
197 | |||
198 | if (!dev) | ||
199 | return -ENODEV; | ||
200 | 170 | ||
201 | return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); | 171 | return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); |
202 | } | 172 | } |
@@ -205,13 +175,6 @@ DEV_STAT_SCSI_TGT_DEV_ATTR_RO(indx); | |||
205 | static ssize_t target_stat_scsi_tgt_dev_show_attr_num_lus( | 175 | static ssize_t target_stat_scsi_tgt_dev_show_attr_num_lus( |
206 | struct se_dev_stat_grps *sgrps, char *page) | 176 | struct se_dev_stat_grps *sgrps, char *page) |
207 | { | 177 | { |
208 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | ||
209 | struct se_subsystem_dev, dev_stat_grps); | ||
210 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
211 | |||
212 | if (!dev) | ||
213 | return -ENODEV; | ||
214 | |||
215 | return snprintf(page, PAGE_SIZE, "%u\n", LU_COUNT); | 178 | return snprintf(page, PAGE_SIZE, "%u\n", LU_COUNT); |
216 | } | 179 | } |
217 | DEV_STAT_SCSI_TGT_DEV_ATTR_RO(num_lus); | 180 | DEV_STAT_SCSI_TGT_DEV_ATTR_RO(num_lus); |
@@ -219,60 +182,27 @@ DEV_STAT_SCSI_TGT_DEV_ATTR_RO(num_lus); | |||
219 | static ssize_t target_stat_scsi_tgt_dev_show_attr_status( | 182 | static ssize_t target_stat_scsi_tgt_dev_show_attr_status( |
220 | struct se_dev_stat_grps *sgrps, char *page) | 183 | struct se_dev_stat_grps *sgrps, char *page) |
221 | { | 184 | { |
222 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 185 | struct se_device *dev = |
223 | struct se_subsystem_dev, dev_stat_grps); | 186 | container_of(sgrps, struct se_device, dev_stat_grps); |
224 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
225 | char status[16]; | ||
226 | 187 | ||
227 | if (!dev) | 188 | if (dev->export_count) |
228 | return -ENODEV; | 189 | return snprintf(page, PAGE_SIZE, "activated"); |
229 | 190 | else | |
230 | switch (dev->dev_status) { | 191 | return snprintf(page, PAGE_SIZE, "deactivated"); |
231 | case TRANSPORT_DEVICE_ACTIVATED: | ||
232 | strcpy(status, "activated"); | ||
233 | break; | ||
234 | case TRANSPORT_DEVICE_DEACTIVATED: | ||
235 | strcpy(status, "deactivated"); | ||
236 | break; | ||
237 | case TRANSPORT_DEVICE_SHUTDOWN: | ||
238 | strcpy(status, "shutdown"); | ||
239 | break; | ||
240 | case TRANSPORT_DEVICE_OFFLINE_ACTIVATED: | ||
241 | case TRANSPORT_DEVICE_OFFLINE_DEACTIVATED: | ||
242 | strcpy(status, "offline"); | ||
243 | break; | ||
244 | default: | ||
245 | sprintf(status, "unknown(%d)", dev->dev_status); | ||
246 | break; | ||
247 | } | ||
248 | |||
249 | return snprintf(page, PAGE_SIZE, "%s\n", status); | ||
250 | } | 192 | } |
251 | DEV_STAT_SCSI_TGT_DEV_ATTR_RO(status); | 193 | DEV_STAT_SCSI_TGT_DEV_ATTR_RO(status); |
252 | 194 | ||
253 | static ssize_t target_stat_scsi_tgt_dev_show_attr_non_access_lus( | 195 | static ssize_t target_stat_scsi_tgt_dev_show_attr_non_access_lus( |
254 | struct se_dev_stat_grps *sgrps, char *page) | 196 | struct se_dev_stat_grps *sgrps, char *page) |
255 | { | 197 | { |
256 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 198 | struct se_device *dev = |
257 | struct se_subsystem_dev, dev_stat_grps); | 199 | container_of(sgrps, struct se_device, dev_stat_grps); |
258 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
259 | int non_accessible_lus; | 200 | int non_accessible_lus; |
260 | 201 | ||
261 | if (!dev) | 202 | if (dev->export_count) |
262 | return -ENODEV; | ||
263 | |||
264 | switch (dev->dev_status) { | ||
265 | case TRANSPORT_DEVICE_ACTIVATED: | ||
266 | non_accessible_lus = 0; | 203 | non_accessible_lus = 0; |
267 | break; | 204 | else |
268 | case TRANSPORT_DEVICE_DEACTIVATED: | ||
269 | case TRANSPORT_DEVICE_SHUTDOWN: | ||
270 | case TRANSPORT_DEVICE_OFFLINE_ACTIVATED: | ||
271 | case TRANSPORT_DEVICE_OFFLINE_DEACTIVATED: | ||
272 | default: | ||
273 | non_accessible_lus = 1; | 205 | non_accessible_lus = 1; |
274 | break; | ||
275 | } | ||
276 | 206 | ||
277 | return snprintf(page, PAGE_SIZE, "%u\n", non_accessible_lus); | 207 | return snprintf(page, PAGE_SIZE, "%u\n", non_accessible_lus); |
278 | } | 208 | } |
@@ -281,12 +211,8 @@ DEV_STAT_SCSI_TGT_DEV_ATTR_RO(non_access_lus); | |||
281 | static ssize_t target_stat_scsi_tgt_dev_show_attr_resets( | 211 | static ssize_t target_stat_scsi_tgt_dev_show_attr_resets( |
282 | struct se_dev_stat_grps *sgrps, char *page) | 212 | struct se_dev_stat_grps *sgrps, char *page) |
283 | { | 213 | { |
284 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 214 | struct se_device *dev = |
285 | struct se_subsystem_dev, dev_stat_grps); | 215 | container_of(sgrps, struct se_device, dev_stat_grps); |
286 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
287 | |||
288 | if (!dev) | ||
289 | return -ENODEV; | ||
290 | 216 | ||
291 | return snprintf(page, PAGE_SIZE, "%u\n", dev->num_resets); | 217 | return snprintf(page, PAGE_SIZE, "%u\n", dev->num_resets); |
292 | } | 218 | } |
@@ -335,13 +261,9 @@ static struct target_stat_scsi_lu_attribute target_stat_scsi_lu_##_name = \ | |||
335 | static ssize_t target_stat_scsi_lu_show_attr_inst( | 261 | static ssize_t target_stat_scsi_lu_show_attr_inst( |
336 | struct se_dev_stat_grps *sgrps, char *page) | 262 | struct se_dev_stat_grps *sgrps, char *page) |
337 | { | 263 | { |
338 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 264 | struct se_device *dev = |
339 | struct se_subsystem_dev, dev_stat_grps); | 265 | container_of(sgrps, struct se_device, dev_stat_grps); |
340 | struct se_hba *hba = se_subdev->se_dev_hba; | 266 | struct se_hba *hba = dev->se_hba; |
341 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
342 | |||
343 | if (!dev) | ||
344 | return -ENODEV; | ||
345 | 267 | ||
346 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); | 268 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); |
347 | } | 269 | } |
@@ -350,12 +272,8 @@ DEV_STAT_SCSI_LU_ATTR_RO(inst); | |||
350 | static ssize_t target_stat_scsi_lu_show_attr_dev( | 272 | static ssize_t target_stat_scsi_lu_show_attr_dev( |
351 | struct se_dev_stat_grps *sgrps, char *page) | 273 | struct se_dev_stat_grps *sgrps, char *page) |
352 | { | 274 | { |
353 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 275 | struct se_device *dev = |
354 | struct se_subsystem_dev, dev_stat_grps); | 276 | container_of(sgrps, struct se_device, dev_stat_grps); |
355 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
356 | |||
357 | if (!dev) | ||
358 | return -ENODEV; | ||
359 | 277 | ||
360 | return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); | 278 | return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); |
361 | } | 279 | } |
@@ -364,13 +282,6 @@ DEV_STAT_SCSI_LU_ATTR_RO(dev); | |||
364 | static ssize_t target_stat_scsi_lu_show_attr_indx( | 282 | static ssize_t target_stat_scsi_lu_show_attr_indx( |
365 | struct se_dev_stat_grps *sgrps, char *page) | 283 | struct se_dev_stat_grps *sgrps, char *page) |
366 | { | 284 | { |
367 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | ||
368 | struct se_subsystem_dev, dev_stat_grps); | ||
369 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
370 | |||
371 | if (!dev) | ||
372 | return -ENODEV; | ||
373 | |||
374 | return snprintf(page, PAGE_SIZE, "%u\n", SCSI_LU_INDEX); | 285 | return snprintf(page, PAGE_SIZE, "%u\n", SCSI_LU_INDEX); |
375 | } | 286 | } |
376 | DEV_STAT_SCSI_LU_ATTR_RO(indx); | 287 | DEV_STAT_SCSI_LU_ATTR_RO(indx); |
@@ -378,12 +289,6 @@ DEV_STAT_SCSI_LU_ATTR_RO(indx); | |||
378 | static ssize_t target_stat_scsi_lu_show_attr_lun( | 289 | static ssize_t target_stat_scsi_lu_show_attr_lun( |
379 | struct se_dev_stat_grps *sgrps, char *page) | 290 | struct se_dev_stat_grps *sgrps, char *page) |
380 | { | 291 | { |
381 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | ||
382 | struct se_subsystem_dev, dev_stat_grps); | ||
383 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
384 | |||
385 | if (!dev) | ||
386 | return -ENODEV; | ||
387 | /* FIXME: scsiLuDefaultLun */ | 292 | /* FIXME: scsiLuDefaultLun */ |
388 | return snprintf(page, PAGE_SIZE, "%llu\n", (unsigned long long)0); | 293 | return snprintf(page, PAGE_SIZE, "%llu\n", (unsigned long long)0); |
389 | } | 294 | } |
@@ -392,35 +297,28 @@ DEV_STAT_SCSI_LU_ATTR_RO(lun); | |||
392 | static ssize_t target_stat_scsi_lu_show_attr_lu_name( | 297 | static ssize_t target_stat_scsi_lu_show_attr_lu_name( |
393 | struct se_dev_stat_grps *sgrps, char *page) | 298 | struct se_dev_stat_grps *sgrps, char *page) |
394 | { | 299 | { |
395 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 300 | struct se_device *dev = |
396 | struct se_subsystem_dev, dev_stat_grps); | 301 | container_of(sgrps, struct se_device, dev_stat_grps); |
397 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
398 | 302 | ||
399 | if (!dev) | ||
400 | return -ENODEV; | ||
401 | /* scsiLuWwnName */ | 303 | /* scsiLuWwnName */ |
402 | return snprintf(page, PAGE_SIZE, "%s\n", | 304 | return snprintf(page, PAGE_SIZE, "%s\n", |
403 | (strlen(dev->se_sub_dev->t10_wwn.unit_serial)) ? | 305 | (strlen(dev->t10_wwn.unit_serial)) ? |
404 | dev->se_sub_dev->t10_wwn.unit_serial : "None"); | 306 | dev->t10_wwn.unit_serial : "None"); |
405 | } | 307 | } |
406 | DEV_STAT_SCSI_LU_ATTR_RO(lu_name); | 308 | DEV_STAT_SCSI_LU_ATTR_RO(lu_name); |
407 | 309 | ||
408 | static ssize_t target_stat_scsi_lu_show_attr_vend( | 310 | static ssize_t target_stat_scsi_lu_show_attr_vend( |
409 | struct se_dev_stat_grps *sgrps, char *page) | 311 | struct se_dev_stat_grps *sgrps, char *page) |
410 | { | 312 | { |
411 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 313 | struct se_device *dev = |
412 | struct se_subsystem_dev, dev_stat_grps); | 314 | container_of(sgrps, struct se_device, dev_stat_grps); |
413 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
414 | int i; | 315 | int i; |
415 | char str[sizeof(dev->se_sub_dev->t10_wwn.vendor)+1]; | 316 | char str[sizeof(dev->t10_wwn.vendor)+1]; |
416 | |||
417 | if (!dev) | ||
418 | return -ENODEV; | ||
419 | 317 | ||
420 | /* scsiLuVendorId */ | 318 | /* scsiLuVendorId */ |
421 | for (i = 0; i < sizeof(dev->se_sub_dev->t10_wwn.vendor); i++) | 319 | for (i = 0; i < sizeof(dev->t10_wwn.vendor); i++) |
422 | str[i] = ISPRINT(dev->se_sub_dev->t10_wwn.vendor[i]) ? | 320 | str[i] = ISPRINT(dev->t10_wwn.vendor[i]) ? |
423 | dev->se_sub_dev->t10_wwn.vendor[i] : ' '; | 321 | dev->t10_wwn.vendor[i] : ' '; |
424 | str[i] = '\0'; | 322 | str[i] = '\0'; |
425 | return snprintf(page, PAGE_SIZE, "%s\n", str); | 323 | return snprintf(page, PAGE_SIZE, "%s\n", str); |
426 | } | 324 | } |
@@ -429,19 +327,15 @@ DEV_STAT_SCSI_LU_ATTR_RO(vend); | |||
429 | static ssize_t target_stat_scsi_lu_show_attr_prod( | 327 | static ssize_t target_stat_scsi_lu_show_attr_prod( |
430 | struct se_dev_stat_grps *sgrps, char *page) | 328 | struct se_dev_stat_grps *sgrps, char *page) |
431 | { | 329 | { |
432 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 330 | struct se_device *dev = |
433 | struct se_subsystem_dev, dev_stat_grps); | 331 | container_of(sgrps, struct se_device, dev_stat_grps); |
434 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
435 | int i; | 332 | int i; |
436 | char str[sizeof(dev->se_sub_dev->t10_wwn.model)+1]; | 333 | char str[sizeof(dev->t10_wwn.model)+1]; |
437 | |||
438 | if (!dev) | ||
439 | return -ENODEV; | ||
440 | 334 | ||
441 | /* scsiLuProductId */ | 335 | /* scsiLuProductId */ |
442 | for (i = 0; i < sizeof(dev->se_sub_dev->t10_wwn.vendor); i++) | 336 | for (i = 0; i < sizeof(dev->t10_wwn.vendor); i++) |
443 | str[i] = ISPRINT(dev->se_sub_dev->t10_wwn.model[i]) ? | 337 | str[i] = ISPRINT(dev->t10_wwn.model[i]) ? |
444 | dev->se_sub_dev->t10_wwn.model[i] : ' '; | 338 | dev->t10_wwn.model[i] : ' '; |
445 | str[i] = '\0'; | 339 | str[i] = '\0'; |
446 | return snprintf(page, PAGE_SIZE, "%s\n", str); | 340 | return snprintf(page, PAGE_SIZE, "%s\n", str); |
447 | } | 341 | } |
@@ -450,19 +344,15 @@ DEV_STAT_SCSI_LU_ATTR_RO(prod); | |||
450 | static ssize_t target_stat_scsi_lu_show_attr_rev( | 344 | static ssize_t target_stat_scsi_lu_show_attr_rev( |
451 | struct se_dev_stat_grps *sgrps, char *page) | 345 | struct se_dev_stat_grps *sgrps, char *page) |
452 | { | 346 | { |
453 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 347 | struct se_device *dev = |
454 | struct se_subsystem_dev, dev_stat_grps); | 348 | container_of(sgrps, struct se_device, dev_stat_grps); |
455 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
456 | int i; | 349 | int i; |
457 | char str[sizeof(dev->se_sub_dev->t10_wwn.revision)+1]; | 350 | char str[sizeof(dev->t10_wwn.revision)+1]; |
458 | |||
459 | if (!dev) | ||
460 | return -ENODEV; | ||
461 | 351 | ||
462 | /* scsiLuRevisionId */ | 352 | /* scsiLuRevisionId */ |
463 | for (i = 0; i < sizeof(dev->se_sub_dev->t10_wwn.revision); i++) | 353 | for (i = 0; i < sizeof(dev->t10_wwn.revision); i++) |
464 | str[i] = ISPRINT(dev->se_sub_dev->t10_wwn.revision[i]) ? | 354 | str[i] = ISPRINT(dev->t10_wwn.revision[i]) ? |
465 | dev->se_sub_dev->t10_wwn.revision[i] : ' '; | 355 | dev->t10_wwn.revision[i] : ' '; |
466 | str[i] = '\0'; | 356 | str[i] = '\0'; |
467 | return snprintf(page, PAGE_SIZE, "%s\n", str); | 357 | return snprintf(page, PAGE_SIZE, "%s\n", str); |
468 | } | 358 | } |
@@ -471,12 +361,8 @@ DEV_STAT_SCSI_LU_ATTR_RO(rev); | |||
471 | static ssize_t target_stat_scsi_lu_show_attr_dev_type( | 361 | static ssize_t target_stat_scsi_lu_show_attr_dev_type( |
472 | struct se_dev_stat_grps *sgrps, char *page) | 362 | struct se_dev_stat_grps *sgrps, char *page) |
473 | { | 363 | { |
474 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 364 | struct se_device *dev = |
475 | struct se_subsystem_dev, dev_stat_grps); | 365 | container_of(sgrps, struct se_device, dev_stat_grps); |
476 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
477 | |||
478 | if (!dev) | ||
479 | return -ENODEV; | ||
480 | 366 | ||
481 | /* scsiLuPeripheralType */ | 367 | /* scsiLuPeripheralType */ |
482 | return snprintf(page, PAGE_SIZE, "%u\n", | 368 | return snprintf(page, PAGE_SIZE, "%u\n", |
@@ -487,30 +373,18 @@ DEV_STAT_SCSI_LU_ATTR_RO(dev_type); | |||
487 | static ssize_t target_stat_scsi_lu_show_attr_status( | 373 | static ssize_t target_stat_scsi_lu_show_attr_status( |
488 | struct se_dev_stat_grps *sgrps, char *page) | 374 | struct se_dev_stat_grps *sgrps, char *page) |
489 | { | 375 | { |
490 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 376 | struct se_device *dev = |
491 | struct se_subsystem_dev, dev_stat_grps); | 377 | container_of(sgrps, struct se_device, dev_stat_grps); |
492 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
493 | |||
494 | if (!dev) | ||
495 | return -ENODEV; | ||
496 | 378 | ||
497 | /* scsiLuStatus */ | 379 | /* scsiLuStatus */ |
498 | return snprintf(page, PAGE_SIZE, "%s\n", | 380 | return snprintf(page, PAGE_SIZE, "%s\n", |
499 | (dev->dev_status == TRANSPORT_DEVICE_ACTIVATED) ? | 381 | (dev->export_count) ? "available" : "notavailable"); |
500 | "available" : "notavailable"); | ||
501 | } | 382 | } |
502 | DEV_STAT_SCSI_LU_ATTR_RO(status); | 383 | DEV_STAT_SCSI_LU_ATTR_RO(status); |
503 | 384 | ||
504 | static ssize_t target_stat_scsi_lu_show_attr_state_bit( | 385 | static ssize_t target_stat_scsi_lu_show_attr_state_bit( |
505 | struct se_dev_stat_grps *sgrps, char *page) | 386 | struct se_dev_stat_grps *sgrps, char *page) |
506 | { | 387 | { |
507 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | ||
508 | struct se_subsystem_dev, dev_stat_grps); | ||
509 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
510 | |||
511 | if (!dev) | ||
512 | return -ENODEV; | ||
513 | |||
514 | /* scsiLuState */ | 388 | /* scsiLuState */ |
515 | return snprintf(page, PAGE_SIZE, "exposed\n"); | 389 | return snprintf(page, PAGE_SIZE, "exposed\n"); |
516 | } | 390 | } |
@@ -519,12 +393,8 @@ DEV_STAT_SCSI_LU_ATTR_RO(state_bit); | |||
519 | static ssize_t target_stat_scsi_lu_show_attr_num_cmds( | 393 | static ssize_t target_stat_scsi_lu_show_attr_num_cmds( |
520 | struct se_dev_stat_grps *sgrps, char *page) | 394 | struct se_dev_stat_grps *sgrps, char *page) |
521 | { | 395 | { |
522 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 396 | struct se_device *dev = |
523 | struct se_subsystem_dev, dev_stat_grps); | 397 | container_of(sgrps, struct se_device, dev_stat_grps); |
524 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
525 | |||
526 | if (!dev) | ||
527 | return -ENODEV; | ||
528 | 398 | ||
529 | /* scsiLuNumCommands */ | 399 | /* scsiLuNumCommands */ |
530 | return snprintf(page, PAGE_SIZE, "%llu\n", | 400 | return snprintf(page, PAGE_SIZE, "%llu\n", |
@@ -535,12 +405,8 @@ DEV_STAT_SCSI_LU_ATTR_RO(num_cmds); | |||
535 | static ssize_t target_stat_scsi_lu_show_attr_read_mbytes( | 405 | static ssize_t target_stat_scsi_lu_show_attr_read_mbytes( |
536 | struct se_dev_stat_grps *sgrps, char *page) | 406 | struct se_dev_stat_grps *sgrps, char *page) |
537 | { | 407 | { |
538 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 408 | struct se_device *dev = |
539 | struct se_subsystem_dev, dev_stat_grps); | 409 | container_of(sgrps, struct se_device, dev_stat_grps); |
540 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
541 | |||
542 | if (!dev) | ||
543 | return -ENODEV; | ||
544 | 410 | ||
545 | /* scsiLuReadMegaBytes */ | 411 | /* scsiLuReadMegaBytes */ |
546 | return snprintf(page, PAGE_SIZE, "%u\n", (u32)(dev->read_bytes >> 20)); | 412 | return snprintf(page, PAGE_SIZE, "%u\n", (u32)(dev->read_bytes >> 20)); |
@@ -550,12 +416,8 @@ DEV_STAT_SCSI_LU_ATTR_RO(read_mbytes); | |||
550 | static ssize_t target_stat_scsi_lu_show_attr_write_mbytes( | 416 | static ssize_t target_stat_scsi_lu_show_attr_write_mbytes( |
551 | struct se_dev_stat_grps *sgrps, char *page) | 417 | struct se_dev_stat_grps *sgrps, char *page) |
552 | { | 418 | { |
553 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 419 | struct se_device *dev = |
554 | struct se_subsystem_dev, dev_stat_grps); | 420 | container_of(sgrps, struct se_device, dev_stat_grps); |
555 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
556 | |||
557 | if (!dev) | ||
558 | return -ENODEV; | ||
559 | 421 | ||
560 | /* scsiLuWrittenMegaBytes */ | 422 | /* scsiLuWrittenMegaBytes */ |
561 | return snprintf(page, PAGE_SIZE, "%u\n", (u32)(dev->write_bytes >> 20)); | 423 | return snprintf(page, PAGE_SIZE, "%u\n", (u32)(dev->write_bytes >> 20)); |
@@ -565,12 +427,8 @@ DEV_STAT_SCSI_LU_ATTR_RO(write_mbytes); | |||
565 | static ssize_t target_stat_scsi_lu_show_attr_resets( | 427 | static ssize_t target_stat_scsi_lu_show_attr_resets( |
566 | struct se_dev_stat_grps *sgrps, char *page) | 428 | struct se_dev_stat_grps *sgrps, char *page) |
567 | { | 429 | { |
568 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 430 | struct se_device *dev = |
569 | struct se_subsystem_dev, dev_stat_grps); | 431 | container_of(sgrps, struct se_device, dev_stat_grps); |
570 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
571 | |||
572 | if (!dev) | ||
573 | return -ENODEV; | ||
574 | 432 | ||
575 | /* scsiLuInResets */ | 433 | /* scsiLuInResets */ |
576 | return snprintf(page, PAGE_SIZE, "%u\n", dev->num_resets); | 434 | return snprintf(page, PAGE_SIZE, "%u\n", dev->num_resets); |
@@ -580,13 +438,6 @@ DEV_STAT_SCSI_LU_ATTR_RO(resets); | |||
580 | static ssize_t target_stat_scsi_lu_show_attr_full_stat( | 438 | static ssize_t target_stat_scsi_lu_show_attr_full_stat( |
581 | struct se_dev_stat_grps *sgrps, char *page) | 439 | struct se_dev_stat_grps *sgrps, char *page) |
582 | { | 440 | { |
583 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | ||
584 | struct se_subsystem_dev, dev_stat_grps); | ||
585 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
586 | |||
587 | if (!dev) | ||
588 | return -ENODEV; | ||
589 | |||
590 | /* FIXME: scsiLuOutTaskSetFullStatus */ | 441 | /* FIXME: scsiLuOutTaskSetFullStatus */ |
591 | return snprintf(page, PAGE_SIZE, "%u\n", 0); | 442 | return snprintf(page, PAGE_SIZE, "%u\n", 0); |
592 | } | 443 | } |
@@ -595,13 +446,6 @@ DEV_STAT_SCSI_LU_ATTR_RO(full_stat); | |||
595 | static ssize_t target_stat_scsi_lu_show_attr_hs_num_cmds( | 446 | static ssize_t target_stat_scsi_lu_show_attr_hs_num_cmds( |
596 | struct se_dev_stat_grps *sgrps, char *page) | 447 | struct se_dev_stat_grps *sgrps, char *page) |
597 | { | 448 | { |
598 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | ||
599 | struct se_subsystem_dev, dev_stat_grps); | ||
600 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
601 | |||
602 | if (!dev) | ||
603 | return -ENODEV; | ||
604 | |||
605 | /* FIXME: scsiLuHSInCommands */ | 449 | /* FIXME: scsiLuHSInCommands */ |
606 | return snprintf(page, PAGE_SIZE, "%u\n", 0); | 450 | return snprintf(page, PAGE_SIZE, "%u\n", 0); |
607 | } | 451 | } |
@@ -610,12 +454,8 @@ DEV_STAT_SCSI_LU_ATTR_RO(hs_num_cmds); | |||
610 | static ssize_t target_stat_scsi_lu_show_attr_creation_time( | 454 | static ssize_t target_stat_scsi_lu_show_attr_creation_time( |
611 | struct se_dev_stat_grps *sgrps, char *page) | 455 | struct se_dev_stat_grps *sgrps, char *page) |
612 | { | 456 | { |
613 | struct se_subsystem_dev *se_subdev = container_of(sgrps, | 457 | struct se_device *dev = |
614 | struct se_subsystem_dev, dev_stat_grps); | 458 | container_of(sgrps, struct se_device, dev_stat_grps); |
615 | struct se_device *dev = se_subdev->se_dev_ptr; | ||
616 | |||
617 | if (!dev) | ||
618 | return -ENODEV; | ||
619 | 459 | ||
620 | /* scsiLuCreationTime */ | 460 | /* scsiLuCreationTime */ |
621 | return snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)dev->creation_time - | 461 | return snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)dev->creation_time - |
@@ -662,20 +502,20 @@ static struct config_item_type target_stat_scsi_lu_cit = { | |||
662 | * Called from target_core_configfs.c:target_core_make_subdev() to setup | 502 | * Called from target_core_configfs.c:target_core_make_subdev() to setup |
663 | * the target statistics groups + configfs CITs located in target_core_stat.c | 503 | * the target statistics groups + configfs CITs located in target_core_stat.c |
664 | */ | 504 | */ |
665 | void target_stat_setup_dev_default_groups(struct se_subsystem_dev *se_subdev) | 505 | void target_stat_setup_dev_default_groups(struct se_device *dev) |
666 | { | 506 | { |
667 | struct config_group *dev_stat_grp = &se_subdev->dev_stat_grps.stat_group; | 507 | struct config_group *dev_stat_grp = &dev->dev_stat_grps.stat_group; |
668 | 508 | ||
669 | config_group_init_type_name(&se_subdev->dev_stat_grps.scsi_dev_group, | 509 | config_group_init_type_name(&dev->dev_stat_grps.scsi_dev_group, |
670 | "scsi_dev", &target_stat_scsi_dev_cit); | 510 | "scsi_dev", &target_stat_scsi_dev_cit); |
671 | config_group_init_type_name(&se_subdev->dev_stat_grps.scsi_tgt_dev_group, | 511 | config_group_init_type_name(&dev->dev_stat_grps.scsi_tgt_dev_group, |
672 | "scsi_tgt_dev", &target_stat_scsi_tgt_dev_cit); | 512 | "scsi_tgt_dev", &target_stat_scsi_tgt_dev_cit); |
673 | config_group_init_type_name(&se_subdev->dev_stat_grps.scsi_lu_group, | 513 | config_group_init_type_name(&dev->dev_stat_grps.scsi_lu_group, |
674 | "scsi_lu", &target_stat_scsi_lu_cit); | 514 | "scsi_lu", &target_stat_scsi_lu_cit); |
675 | 515 | ||
676 | dev_stat_grp->default_groups[0] = &se_subdev->dev_stat_grps.scsi_dev_group; | 516 | dev_stat_grp->default_groups[0] = &dev->dev_stat_grps.scsi_dev_group; |
677 | dev_stat_grp->default_groups[1] = &se_subdev->dev_stat_grps.scsi_tgt_dev_group; | 517 | dev_stat_grp->default_groups[1] = &dev->dev_stat_grps.scsi_tgt_dev_group; |
678 | dev_stat_grp->default_groups[2] = &se_subdev->dev_stat_grps.scsi_lu_group; | 518 | dev_stat_grp->default_groups[2] = &dev->dev_stat_grps.scsi_lu_group; |
679 | dev_stat_grp->default_groups[3] = NULL; | 519 | dev_stat_grp->default_groups[3] = NULL; |
680 | } | 520 | } |
681 | 521 | ||
@@ -1161,7 +1001,7 @@ static ssize_t target_stat_scsi_transport_show_attr_dev_name( | |||
1161 | return -ENODEV; | 1001 | return -ENODEV; |
1162 | } | 1002 | } |
1163 | tpg = sep->sep_tpg; | 1003 | tpg = sep->sep_tpg; |
1164 | wwn = &dev->se_sub_dev->t10_wwn; | 1004 | wwn = &dev->t10_wwn; |
1165 | /* scsiTransportDevName */ | 1005 | /* scsiTransportDevName */ |
1166 | ret = snprintf(page, PAGE_SIZE, "%s+%s\n", | 1006 | ret = snprintf(page, PAGE_SIZE, "%s+%s\n", |
1167 | tpg->se_tpg_tfo->tpg_get_wwn(tpg), | 1007 | tpg->se_tpg_tfo->tpg_get_wwn(tpg), |