Skip to content

Commit 1d1990b

Browse files
committed
Merge branch 'pauljevans-pevans-merge'
2 parents b995d5d + 81a4ae4 commit 1d1990b

3 files changed

Lines changed: 62 additions & 59 deletions

File tree

qa/1397.out

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4284,7 +4284,7 @@ Help:
42844284
Contains the number of read commands completed by the controller
42854285
No value(s) available!
42864286

4287-
smart.wwid.nvme_attributes.host_write_commands PMID: 150.1255.8 [Contains the number of write commands completed by the controller ]
4287+
smart.wwid.nvme_attributes.host_write_commands PMID: 150.1255.8 [Contains the number of write commands completed by the controller]
42884288
Data Type: 64-bit unsigned int InDom: 150.1 0x25800001
42894289
Semantics: instant Units: byte
42904290
Help:
@@ -7178,7 +7178,7 @@ smart.nvme_attributes.host_write_commands PMID: 150.255.8 [Contains the number o
71787178
Data Type: 64-bit unsigned int InDom: 150.0 0x25800000
71797179
Semantics: instant Units: byte
71807180
Help:
7181-
Contains the number of write commands completed by the controller
7181+
Contains the number of write commands completed by the controller
71827182
No value(s) available!
71837183

71847184
smart.nvme_attributes.media_and_data_integrity_errors PMID: 150.255.13 [Contains the number of error occurances by the controller]
@@ -9675,7 +9675,7 @@ Help:
96759675
Contains the number of read commands completed by the controller
96769676
No value(s) available!
96779677

9678-
smart.wwid.nvme_attributes.host_write_commands PMID: 150.1255.8 [Contains the number of write commands completed by the controller ]
9678+
smart.wwid.nvme_attributes.host_write_commands PMID: 150.1255.8 [Contains the number of write commands completed by the controller]
96799679
Data Type: 64-bit unsigned int InDom: 150.1 0x25800001
96809680
Semantics: instant Units: byte
96819681
Help:
@@ -12231,7 +12231,7 @@ smart.nvme_attributes.host_write_commands PMID: 150.255.8 [Contains the number o
1223112231
Data Type: 64-bit unsigned int InDom: 150.0 0x25800000
1223212232
Semantics: instant Units: byte
1223312233
Help:
12234-
Contains the number of write commands completed by the controller
12234+
Contains the number of write commands completed by the controller
1223512235
inst [0 or "nvme0n1"] value 94922330
1223612236

1223712237
smart.nvme_attributes.media_and_data_integrity_errors PMID: 150.255.13 [Contains the number of error occurances by the controller]
@@ -14728,11 +14728,11 @@ Help:
1472814728
Contains the number of read commands completed by the controller
1472914729
inst [0 or "8ce38e0500882b63"] value 77209705
1473014730

14731-
smart.wwid.nvme_attributes.host_write_commands PMID: 150.1255.8 [Contains the number of write commands completed by the controller ]
14731+
smart.wwid.nvme_attributes.host_write_commands PMID: 150.1255.8 [Contains the number of write commands completed by the controller]
1473214732
Data Type: 64-bit unsigned int InDom: 150.1 0x25800001
1473314733
Semantics: instant Units: byte
1473414734
Help:
14735-
Contains the number of write commands completed by the controller
14735+
Contains the number of write commands completed by the controller
1473614736
inst [0 or "8ce38e0500882b63"] value 94922330
1473714737

1473814738
smart.wwid.nvme_attributes.media_and_data_integrity_errors PMID: 150.1255.13 [Contains the number of error occurances by the controller]
@@ -19772,11 +19772,11 @@ Help:
1977219772
Contains the number of read commands completed by the controller
1977319773
inst [0 or "8ce38e0500882b63"] value 16961700
1977419774

19775-
smart.wwid.nvme_attributes.host_write_commands PMID: 150.1255.8 [Contains the number of write commands completed by the controller ]
19775+
smart.wwid.nvme_attributes.host_write_commands PMID: 150.1255.8 [Contains the number of write commands completed by the controller]
1977619776
Data Type: 64-bit unsigned int InDom: 150.1 0x25800001
1977719777
Semantics: instant Units: byte
1977819778
Help:
19779-
Contains the number of write commands completed by the controller
19779+
Contains the number of write commands completed by the controller
1978019780
inst [0 or "8ce38e0500882b63"] value 170550277
1978119781

1978219782
smart.wwid.nvme_attributes.media_and_data_integrity_errors PMID: 150.1255.13 [Contains the number of error occurances by the controller]

src/pmdas/smart/pmda.c

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,44 +2998,42 @@ uuid_instance_refresh(void)
29982998
/* at this point dev_name contains our device name, we now need to store
29992999
this and find out the UUID for the drive. The UUID will be used to
30003000
map stats to disk drive instances */
3001-
3001+
30023002
if ((env_command = getenv("SMART_SETUP_UUID")) != NULL) {
3003-
//pmsprintf(buffer, sizeof(buffer), "%s", env_command);
30043003
sscanf(env_command, "%s", buffer);
3005-
n = 1;
3006-
} else {
3007-
n = pmsprintf(buffer, sizeof(buffer), "/sys/block/%s/device/wwid", dev_name);
3008-
if (n <= 0 || access(buffer, F_OK) != 0) /* try alternate path */
3009-
n = pmsprintf(buffer, sizeof(buffer), "/sys/block/%s/wwid", dev_name);
3010-
3011-
if (n <= 0 || access(buffer, F_OK) != 0) { /* alternative path also bad */
3004+
if ((fd = open(buffer, O_RDONLY)) < 0) {
3005+
/* env_command path fail */
30123006
pclose(pf);
3013-
return 0;
3007+
return -oserror();
3008+
}
3009+
}else {
3010+
pmsprintf(buffer, sizeof(buffer), "/sys/block/%s/device/wwid", dev_name);
3011+
if ((fd = open(buffer, O_RDONLY)) < 0) {
3012+
/* try alternate path */
3013+
pmsprintf(buffer, sizeof(buffer), "/sys/block/%s/wwid", dev_name);
3014+
if ((fd = open(buffer, O_RDONLY)) < 0) {
3015+
/* alternative path also bad */
3016+
pclose(pf);
3017+
return -oserror();
3018+
}
30143019
}
30153020
}
3021+
3022+
n = read(fd, buffer, sizeof(buffer));
3023+
close(fd);
30163024

3017-
if (n > 0 && (fd = open(buffer, O_RDONLY)) >= 0) {
3018-
n = read(fd, buffer, sizeof(buffer));
3019-
close(fd);
3020-
3021-
if (n > 0) {
3022-
buffer[n-1] = '\0';
3023-
3024-
if (strlen(buffer) == 0)
3025-
continue;
3026-
3027-
if (strncmp(buffer, "t10.", 4) == 0) {
3028-
sscanf(buffer, "t10.%s", dev_uuid);
3025+
if (n >= 0) {
3026+
if (strncmp(buffer, "t10.", 4) == 0) {
3027+
sscanf(buffer, "t10.%s", dev_uuid);
30293028

3030-
} else if (strncmp(buffer, "eui.", 4) == 0) {
3031-
sscanf(buffer, "eui.%s", dev_uuid);
3029+
} else if (strncmp(buffer, "eui.", 4) == 0) {
3030+
sscanf(buffer, "eui.%s", dev_uuid);
30323031

3033-
} else if (strncmp(buffer, "naa.", 4) == 0) {
3034-
sscanf(buffer, "naa.%s", dev_uuid);
3032+
} else if (strncmp(buffer, "naa.", 4) == 0) {
3033+
sscanf(buffer, "naa.%s", dev_uuid);
30353034

3036-
} else {
3037-
sscanf(buffer, "%s", dev_uuid);
3038-
}
3035+
} else {
3036+
sscanf(buffer, "%s", dev_uuid);
30393037
}
30403038
}
30413039

src/pmdas/smart/smart_stats.c

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ smart_refresh_device_info(const char *name, struct device_info *device_info, int
487487
{
488488
char buffer[4096], capacity[64] = {'\0'};
489489
FILE *pf;
490-
int n, fd = 0;
490+
int fd, n = 0;
491491

492492
pmsprintf(buffer, sizeof(buffer), "%s -Hi /dev/%s", smart_setup_stats, name);
493493
buffer[sizeof(buffer)-1] = '\0';
@@ -543,27 +543,32 @@ smart_refresh_device_info(const char *name, struct device_info *device_info, int
543543
sscanf(name, "%s", device_info->device);
544544

545545
/* Get disk UUID if not already populated */
546-
n = pmsprintf(buffer, sizeof(buffer), "/sys/block/%s/device/wwid", name);
547-
if (n <= 0 || access(buffer, F_OK) != 0) /* try alternate path */
548-
n = pmsprintf(buffer, sizeof(buffer), "/sys/block/%s/wwid", name);
549-
if (n > 0 && (fd = open(buffer, O_RDONLY)) >= 0) {
550-
n = read(fd, buffer, sizeof(buffer));
551-
close(fd);
552-
553-
if (n > 0) {
554-
buffer[n-1] = '\0';
555-
if (strncmp(buffer, "t10.", 4) == 0) {
556-
sscanf(buffer, "t10.%s", device_info->uuid);
557-
558-
} else if (strncmp(buffer, "eui.", 4) == 0) {
559-
sscanf(buffer, "eui.%s", device_info->uuid);
560-
561-
} else if (strncmp(buffer, "naa.", 4) == 0) {
562-
sscanf(buffer, "naa.%s", device_info->uuid);
563-
564-
} else {
565-
sscanf(buffer, "%s", device_info->uuid);
566-
}
546+
547+
pmsprintf(buffer, sizeof(buffer), "/sys/block/%s/device/wwid", name);
548+
if ((fd = open(buffer, O_RDONLY)) < 0) {
549+
/* try alternate path */
550+
pmsprintf(buffer, sizeof(buffer), "/sys/block/%s/wwid", name);
551+
if ((fd = open(buffer, O_RDONLY)) < 0) {
552+
/* alternative path also bad */
553+
return 0;
554+
}
555+
}
556+
557+
n = read(fd, buffer, sizeof(buffer));
558+
close(fd);
559+
560+
if (n >= 0) {
561+
if (strncmp(buffer, "t10.", 4) == 0) {
562+
sscanf(buffer, "t10.%s", device_info->uuid);
563+
564+
} else if (strncmp(buffer, "eui.", 4) == 0) {
565+
sscanf(buffer, "eui.%s", device_info->uuid);
566+
567+
} else if (strncmp(buffer, "naa.", 4) == 0) {
568+
sscanf(buffer, "naa.%s", device_info->uuid);
569+
570+
} else {
571+
sscanf(buffer, "%s", device_info->uuid);
567572
}
568573
}
569574
return 0;

0 commit comments

Comments
 (0)