Skip to content

Commit c219c2f

Browse files
author
mcardenas
committed
fix: retry operations _clear_por changes
- clear the previous power on reset status and retry - retry in both ibmtape netbsd driver and the sg one - make _clear_por return an int
1 parent 9a24577 commit c219c2f

2 files changed

Lines changed: 22 additions & 10 deletions

File tree

src/tape_drivers/linux/sg/sg_tape.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ int _raw_tur(const int fd)
605605

606606
#define _clear_por(p) _clear_por_raw((p)->dev.fd);
607607

608-
void _clear_por_raw(const int fd)
608+
int _clear_por_raw(const int fd)
609609
{
610610
int i = 0, ret = -1;
611611

@@ -625,6 +625,7 @@ void _clear_por_raw(const int fd)
625625
}
626626
i++;
627627
}
628+
return ret;
628629
}
629630

630631
#define _get_stable_tur_response(p) _get_stable_tur_response_raw((p)->dev.fd)
@@ -2099,8 +2100,7 @@ int sg_write(void *device, const char *buf, size_t count, struct tc_position *po
20992100
struct sg_data *priv = (struct sg_data*)device;
21002101
struct tc_position cur_pos;
21012102
size_t datacount = count;
2102-
int reconnect_retry_count = 0, soft_error_retry_count = 0;
2103-
int TBL_SLEEP_SECS[SOFT_ERROR_MAX_RETRIES] = {45, 60, 75}; // Hardcoded exponentially increasing sleep time
2103+
int retry_count = 0;
21042104

21052105
ltfs_profiler_add_entry(priv->profiler, NULL, TAPEBEND_REQ_ENTER(REQ_TC_WRITE));
21062106

@@ -2147,15 +2147,18 @@ int sg_write(void *device, const char *buf, size_t count, struct tc_position *po
21472147
} else
21482148
ret = -EDEV_POR_OR_BUS_RESET;
21492149
}
2150-
} else if (ret == -EDEV_BUFFER_ALLOCATE_ERROR && reconnect_retry_count < MAX_RETRY) {
2151-
ret = _handle_block_allocation_failure(device, pos, &reconnect_retry_count, "write");
2152-
if (ret == -EDEV_RETRY)
2153-
goto start_write;
2154-
} else if (ret == -EDEV_HOST_ERROR && soft_error_retry_count < SOFT_ERROR_MAX_RETRIES) {
2155-
sleep(TBL_SLEEP_SECS[soft_error_retry_count]);
2150+
} else if (ret == -EDEV_BUFFER_ALLOCATE_ERROR && retry_count < MAX_RETRY) {
21562151
ret = _handle_block_allocation_failure(device, pos, &retry_count, "write");
21572152
if (ret == -EDEV_RETRY)
21582153
goto start_write;
2154+
} else if (ret == -EDEV_HOST_ERROR && retry_count < SOFT_ERROR_MAX_RETRIES) {
2155+
sleep(5);
2156+
ret = _clear_por(priv);
2157+
if (!ret) {
2158+
ret = _handle_block_allocation_failure(device, pos, &retry_count, "write");
2159+
if (ret == -EDEV_RETRY)
2160+
goto start_write;
2161+
}
21592162
}
21602163

21612164
ltfs_profiler_add_entry(priv->profiler, NULL, TAPEBEND_REQ_EXIT(REQ_TC_WRITE));

src/tape_drivers/netbsd/scsipi-ibmtape/scsipi_ibmtape.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ int _raw_tur(const int fd)
569569

570570
#define _clear_por(p) _clear_por_raw((p)->dev.fd);
571571

572-
void _clear_por_raw(const int fd)
572+
int _clear_por_raw(const int fd)
573573
{
574574
int i = 0, ret = -1;
575575

@@ -589,6 +589,7 @@ void _clear_por_raw(const int fd)
589589
}
590590
i++;
591591
}
592+
return ret;
592593
}
593594

594595
/* Forward reference */
@@ -1707,6 +1708,14 @@ int scsipi_ibmtape_write(void *device, const char *buf, size_t count, struct tc_
17071708
ret = _handle_block_allocation_failure(device, pos, &retry_count, "write");
17081709
if (ret == -EDEV_RETRY)
17091710
goto start_write;
1711+
} else if (ret == -EDEV_HOST_ERROR && retry_count < SOFT_ERROR_MAX_RETRIES) {
1712+
sleep(5);
1713+
ret = _clear_por(priv);
1714+
if (!ret) {
1715+
ret = _handle_block_allocation_failure(device, pos, &retry_count, "write");
1716+
if (ret == -EDEV_RETRY)
1717+
goto start_write;
1718+
}
17101719
}
17111720

17121721
ltfs_profiler_add_entry(priv->profiler, NULL, TAPEBEND_REQ_EXIT(REQ_TC_WRITE));

0 commit comments

Comments
 (0)