stgt.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* VTL: Data block may return twice
@ 2021-01-08 22:02 Michael Ablassmeier
  2021-01-09  9:41 ` [PATCH] " Michael Ablassmeier
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Ablassmeier @ 2021-01-08 22:02 UTC (permalink / raw)
  To: stgt

hi,

while running the bacula tape test via btape, the append suite failed
against TGT Tape (6bd8382 tgt 1.0.80), it would expect 4 blocks on
tape but discovers 5:

 >  ./btape -c /etc/bacula/bacula-sd.conf /dev/nst1
 >  End scanning the tape.
 >  We should be in file 4. I am at file 5. This is NOT correct!!!!

it seems reading the blocks from the VTL tape if the next position is
Filemark and then EOD, returns it twice ..  which is reproducible via
dd:

Write one block to tape and rewind:

 dd if=/dev/zero of=/dev/nst1 bs=65536 count=1
 mt -f /dev/nst1 rewind

Now attempt reads:

  dd if=/dev/nst1 of=/dev/zero bs=65536 count=1
  1+0 records in
  1+0 records out
  65536 bytes (66 kB, 64 KiB) copied, 0.000753197 s, 87.0 MB/s
  dd if=/dev/nst1 of=/dev/zero bs=65536 count=1
  0+0 records in
  0+0 records out
  0 bytes copied, 0.000803429 s, 0.0 kB/s
  dd if=/dev/nst1 of=/dev/zero bs=65536 count=1
  1+0 records in
  1+0 records out
  65536 bytes (66 kB, 64 KiB) copied, 0.0005939 s, 110 MB/s
  -> this block here, should never been returned, there is
  no more data on the VTL

as far as i had time to take a look, the second read operation in
resp_var_read notices file mark position:

  bs_ssc.c
  346  if (!length) {
  347   if (h->blk_type == BLK_FILEMARK)
  348       goto skip_and_out;                                                                                                                                                       

which in turn calls 

  361 skip_and_out:
  362    ret = skip_next_header(cmd->dev); 

basically moving the position inside the VTL to the wrong place,
..making the third read from the tape to return data from the
same block again :)

bye,
    - michael

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] VTL: Data block may return twice
  2021-01-08 22:02 VTL: Data block may return twice Michael Ablassmeier
@ 2021-01-09  9:41 ` Michael Ablassmeier
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ablassmeier @ 2021-01-09  9:41 UTC (permalink / raw)
  To: stgt

[-- Attachment #1: Type: text/plain, Size: 702 bytes --]

hi,

see attached patch, makes the bacula btape test be
successful, hope it makes sense.

On Fri, Jan 08, 2021 at 11:02:59PM +0100, Michael Ablassmeier wrote:
>   bs_ssc.c
>   346  if (!length) {
>   347   if (h->blk_type == BLK_FILEMARK)
>   348       goto skip_and_out;                                                                                                                                                       
> 
> which in turn calls 
> 
>   361 skip_and_out:
>   362    ret = skip_next_header(cmd->dev); 
> 
> basically moving the position inside the VTL to the wrong place,
> ..making the third read from the tape to return data from the
> same block again :)
> 
> bye,
>     - michael

[-- Attachment #2: eod_read.diff --]
[-- Type: text/x-diff, Size: 885 bytes --]

diff --git a/usr/bs_ssc.c b/usr/bs_ssc.c
index 5119163..ad47417 100644
--- a/usr/bs_ssc.c
+++ b/usr/bs_ssc.c
@@ -322,16 +322,17 @@ static int resp_var_read(struct scsi_cmd *cmd, uint8_t *buf, uint32_t length,
 
 		put_unaligned_be32(val, info);
 
-		if (h->blk_type == BLK_EOD)
-			sense_data_build(cmd, 0x40 | BLANK_CHECK,
-					 NO_ADDITIONAL_SENSE);
-		else if (h->blk_type == BLK_FILEMARK)
+		if (h->blk_type == BLK_EOD) {
+			sense_data_build(cmd, NO_SENSE, ASC_END_OF_DATA);
+			return SAM_STAT_CHECK_CONDITION;
+		} else if (h->blk_type == BLK_FILEMARK) {
 			ssc_sense_data_build(cmd, NO_SENSE | SENSE_FILEMARK,
 					     ASC_MARK, info, sizeof(info));
-		else
+		} else {
 			ssc_sense_data_build(cmd, NO_SENSE | 0x20,
 					     NO_ADDITIONAL_SENSE,
 					     info, sizeof(info));
+		}
 
 		if (length > h->blk_sz)
 			scsi_set_in_resid_by_actual(cmd, length - h->blk_sz);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-09  9:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 22:02 VTL: Data block may return twice Michael Ablassmeier
2021-01-09  9:41 ` [PATCH] " Michael Ablassmeier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).