Skip to content

Commit b24237b

Browse files
committed
Failing against mismatch, make tape to require validation
1 parent 0cc254e commit b24237b

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

messages/libltfs/root.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ v
834834
17290I:string { "Partitioning the medium with the destructive method." }
835835
17291I:string { "Unpartitioning the medium with the destructive method." }
836836
17292I:string { "Current position is (%llu, %llu), Error position is (%llu, %llu)." }
837+
17293I:string { "Position mismatch. Cached tape position = %llu. Current tape position = %llu." }
837838
17294I:string { "Continue signal (%d) received" }
838839

839840
// For Debug 19999I:string { "%s %s %d." }

src/libltfs/ltfs.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,16 +2536,18 @@ int ltfs_write_index(char partition, char *reason, struct ltfs_volume *vol)
25362536
/* Get the tape position from the tape drive by using the SCSI command READPOS*/
25372537
ret = tape_update_position(vol->device, &current_position);
25382538
if (ret < 0) {
2539+
/* Return error since the current tape position was unable to be determined, so there could be an undetected position mismatch */
25392540
ltfsmsg(LTFS_ERR, 11081E, ret);
2541+
return -1;
25402542
}
25412543

25422544
/* Prior to writing the index, compare the current location of the head position to the head location
25432545
that is kept in the cache of ltfs (physical_selfptr). If they are different return error (-1) */
2544-
ltfsmsg(LTFS_INFO, 11334I, "compare offset", (unsigned long long)physical_selfptr.block, (unsigned long long)current_position.block);
25452546
diff = ((unsigned long long)physical_selfptr.block - (unsigned long long)current_position.block);
2546-
if (abs(diff)) {
2547-
ltfsmsg(LTFS_DEBUG, 16503D, "diff not equal zero", "");
2548-
//return -1;
2547+
if (diff) {
2548+
/* Position mismatch, diff not equal zero */
2549+
ltfsmsg(LTFS_INFO, 17293I, (unsigned long long)physical_selfptr.block, (unsigned long long)current_position.block);
2550+
return -1;
25492551
}
25502552

25512553
old_selfptr = vol->index->selfptr;

src/libltfs/tape.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,11 +1248,16 @@ ssize_t tape_write(struct device_data *dev, const char *buf, size_t count, bool
12481248
ltfsmsg(LTFS_DEBUG, 16503D, "ltfs_caught_sigcont", "tape_write");
12491249
ret_for_update_position = tape_update_position(dev, &current_position);
12501250
if (ret_for_update_position) {
1251-
// Implement the error handling
1251+
/* Return error since the current tape position was unable to be determined, so there could be an undetected position mismatch */
1252+
ltfsmsg(LTFS_ERR, 11081E, ret);
1253+
return -LTFS_WRITE_ERROR;
12521254
}
1255+
12531256
ltfsmsg(LTFS_INFO, 11334I, "compare offset in tape_write", (unsigned long long)dev->position.block, (unsigned long long)current_position.block);
12541257
diff = ((unsigned long long)dev->position.block - (unsigned long long)current_position.block);
12551258
if (diff) {
1259+
/* Position mismatch, diff not equal zero */
1260+
ltfsmsg(LTFS_INFO, 17293I, (unsigned long long)dev->position.block, (unsigned long long)current_position.block);
12561261
return -LTFS_WRITE_ERROR;
12571262
}
12581263
}

0 commit comments

Comments
 (0)