Skip to content

Fix/write soft error handling - #630

Closed
madjesc wants to merge 8 commits into
mainfrom
fix/write-soft-error-handling
Closed

Fix/write soft error handling#630
madjesc wants to merge 8 commits into
mainfrom
fix/write-soft-error-handling

Conversation

@madjesc

@madjesc madjesc commented Aug 10, 2026

Copy link
Copy Markdown

Summary of changes

This pull request includes the following changes:

  • Fix retry logic for write operations after drive repositioning
  • Implement power-on-reset (POR) handling with retry mechanism
  • Refactor block allocation failure handling across multiple tape drivers
  • Add generic block write failure handling function
  • Fix indentation and code formatting issues
  • Correct return value handling in write operations

Description

This PR addresses issues with write operation failures in tape drivers by implementing a more robust retry mechanism. The changes focus on properly handling buffer allocation errors and host errors (particularly power-on-reset conditions) by:

  1. Separating retry counters for different error types (buffer allocation vs POR)
  2. Implementing a _clear_por() function that returns status instead of void
  3. Creating a generic _handle_block_write_failure() function to consolidate retry logic
  4. Adding appropriate sleep delays before retries to allow kernel garbage collection
  5. Ensuring correct return values are propagated through the call stack

The changes affect three tape drivers:

  • Linux sg driver (sg_tape.c)
  • Linux lin_tape driver (lin_tape_ibmtape.c)
  • NetBSD scsipi driver (scsipi_ibmtape.c)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Refactoring

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have confirmed my fix is effective or that my feature works

@rangelmx
rangelmx requested review from XV02, amissael95 and syaoraang and removed request for syaoraang August 10, 2026 20:32
} else if (errno == ENOMEM && retry < MAX_WRITE_RETRY) {
rc = _handle_block_allocation_failure(device, pos, &retry);
ltfsmsg(LTFS_WARN, 30440W, ++retry);
sleep(3); // Wait for kernel GC

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using nanosleep? This does not use signals, such as SIGALRM.

@madjesc madjesc closed this Aug 10, 2026
@rangelmx
rangelmx deleted the fix/write-soft-error-handling branch August 10, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants