@@ -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 ));
0 commit comments