Skip to content

Commit 2897a5a

Browse files
authored
bugfix: cannot mount LTFS tapes under Rocky Linux with lin_tape driver (#399)
* bugfix: all of the functions calling lin_tape_ibmtape_logsense() need to evaluate the return code according to the new semantic, which is negative for error, or positive page size for success * return rc instead of -1 from lin_tape_ibmtape_logsense() in case _sioc_stioc_command() returns with non-zero code
1 parent 2e41bf5 commit 2897a5a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/tape_drivers/linux/lin_tape/lin_tape_ibmtape.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,7 @@ int lin_tape_ibmtape_format(void *device, TC_FORMAT_TYPE format, const char *vol
22052205
* @param page page code of log sense
22062206
* @param buf pointer to buffer to store log data
22072207
* @param size length of the buffer
2208-
* @return 0 on success or a negative value on error
2208+
* @return Page length on success or a negative value on error.
22092209
*/
22102210
#define MAX_UINT16 (0x0000FFFF)
22112211

@@ -2231,6 +2231,7 @@ int lin_tape_ibmtape_logsense(void *device, const uint8_t page, const uint8_t su
22312231

22322232
if (rc != DEVICE_GOOD) {
22332233
lin_tape_ibmtape_process_errors(device, rc, msg, "logsense page", true);
2234+
return rc;
22342235
} else {
22352236
memcpy(buf, log_page.data, size);
22362237
}
@@ -2263,7 +2264,7 @@ int lin_tape_ibmtape_remaining_capacity(void *device, struct tc_remaining_cap *c
22632264
if (IS_LTO(priv->drive_type) && (DRIVE_GEN(priv->drive_type) == 0x05)) {
22642265
/* Issue LogPage 0x31 */
22652266
rc = lin_tape_ibmtape_logsense(device, LOG_TAPECAPACITY, (uint8_t)0, logdata, LOGSENSEPAGE);
2266-
if (rc) {
2267+
if (rc < 0) {
22672268
ltfsmsg(LTFS_INFO, 30457I, LOG_TAPECAPACITY, rc);
22682269
ltfs_profiler_add_entry(priv->profiler, NULL, TAPEBEND_REQ_EXIT(REQ_TC_REMAINCAP));
22692270
return rc;
@@ -2303,7 +2304,7 @@ int lin_tape_ibmtape_remaining_capacity(void *device, struct tc_remaining_cap *c
23032304
else {
23042305
/* Issue LogPage 0x17 */
23052306
rc = lin_tape_ibmtape_logsense(device, LOG_VOLUMESTATS, (uint8_t)0, logdata, LOGSENSEPAGE);
2306-
if (rc) {
2307+
if (rc < 0) {
23072308
ltfsmsg(LTFS_INFO, 30457I, LOG_VOLUMESTATS, rc);
23082309
ltfs_profiler_add_entry(priv->profiler, NULL, TAPEBEND_REQ_EXIT(REQ_TC_REMAINCAP));
23092310
return rc;
@@ -2926,7 +2927,7 @@ int lin_tape_ibmtape_get_cartridge_health(void *device, struct tc_cartridge_heal
29262927
/* Issue LogPage 0x37 */
29272928
cart_health->tape_efficiency = UNSUPPORTED_CARTRIDGE_HEALTH;
29282929
rc = lin_tape_ibmtape_logsense(device, LOG_PERFORMANCE, (uint8_t)0, logdata, LOGSENSEPAGE);
2929-
if (rc)
2930+
if (rc < 0)
29302931
ltfsmsg(LTFS_INFO, 30461I, LOG_PERFORMANCE, rc, "get cart health");
29312932
else {
29322933
for(i = 0; i < (int)((sizeof(perfstats)/sizeof(perfstats[0]))); i++) { /* BEAM: loop doesn't iterate - Use loop for future enhancement. */
@@ -2978,7 +2979,7 @@ int lin_tape_ibmtape_get_cartridge_health(void *device, struct tc_cartridge_heal
29782979
cart_health->passes_middle = UNSUPPORTED_CARTRIDGE_HEALTH;
29792980

29802981
rc = lin_tape_ibmtape_logsense(device, LOG_VOLUMESTATS, (uint8_t)0, logdata, LOGSENSEPAGE);
2981-
if (rc)
2982+
if (rc < 0)
29822983
ltfsmsg(LTFS_INFO, 30461I, LOG_VOLUMESTATS, rc, "get cart health");
29832984
else {
29842985
for(i = 0; i < (int)((sizeof(volstats)/sizeof(volstats[0]))); i++) {
@@ -3075,7 +3076,7 @@ int lin_tape_ibmtape_get_tape_alert(void *device, uint64_t *tape_alert)
30753076
/* Issue LogPage 0x2E */
30763077
ta = 0;
30773078
rc = lin_tape_ibmtape_logsense(device, LOG_TAPE_ALERT, (uint8_t)0, logdata, LOGSENSEPAGE);
3078-
if (rc)
3079+
if (rc < 0)
30793080
ltfsmsg(LTFS_INFO, 30461I, LOG_TAPE_ALERT, rc, "get tape alert");
30803081
else {
30813082
for(i = 1; i <= 64; i++) {
@@ -3416,7 +3417,7 @@ int lin_tape_ibmtape_get_eod_status(void *device, int part)
34163417
ltfs_profiler_add_entry(priv->profiler, NULL, TAPEBEND_REQ_ENTER(REQ_TC_GETEODSTAT));
34173418
/* Issue LogPage 0x17 */
34183419
rc = lin_tape_ibmtape_logsense(device, LOG_VOL_STATISTICS, (uint8_t)0, logdata, LOGSENSEPAGE);
3419-
if (rc) {
3420+
if (rc < 0) {
34203421
ltfsmsg(LTFS_WARN, 30464W, LOG_VOL_STATISTICS, rc);
34213422
ltfs_profiler_add_entry(priv->profiler, NULL, TAPEBEND_REQ_EXIT(REQ_TC_GETEODSTAT));
34223423
return EOD_UNKNOWN;
@@ -3486,7 +3487,7 @@ int lin_tape_ibmtape_get_xattr(void *device, const char *name, char **buf)
34863487
((priv->fetch_sec_acq_loss_w + 60 < now.tv_sec) && priv->dirty_acq_loss_w)) {
34873488
rc = lin_tape_ibmtape_logsense(device, LOG_PERFORMANCE, LOG_PERFORMANCE_CAPACITY_SUB,
34883489
logdata, LOGSENSEPAGE);
3489-
if (rc)
3490+
if (rc < 0)
34903491
ltfsmsg(LTFS_INFO, 30461I, LOG_PERFORMANCE, rc, "get xattr");
34913492
else {
34923493
if (parse_logPage(logdata, PERF_ACTIVE_CQ_LOSS_W, &param_size, logbuf, 16)) {

0 commit comments

Comments
 (0)