[stgt] [PATCH] Make virtual tapes more closely emulate physical ones

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Mon Jan 14 13:02:34 CET 2013

On Thu, 10 Jan 2013 11:36:44 -0500
Jay Fenlason <fenlason at redhat.com> wrote:

> On my physical drive (a Sony AIT-2 drive, if it matters) when
> userspace reads a file mark, it gets an EOF, and the tape is advanced
> past the file mark so that a subsequent read will return data from the
> next file on the tape.  With a virtual drive, the file mark is
> sticky--reads continue to return EOF until the tape is manually
> advanced with a FSF ioctl.  I wrote this quick patch to make the
> virtual tape behave like my physical one.
> I'm not sure about the sense_data_build hunk, but it matches the code
> for fixed blocksize, and did no harm in my testing.
> 		-- JF
> --- tgt-1.0.32/usr/bs_ssc.c.filemark	2012-09-30 18:39:21.000000000 -0400
> +++ tgt-1.0.32/usr/bs_ssc.c	2013-01-09 15:32:43.000000000 -0500
> @@ -325,6 +325,9 @@
>  		if (h->blk_type == BLK_EOD)
>  			sense_data_build(cmd, 0x40 | BLANK_CHECK,
> +		else if (h->blk_type == BLK_FILEMARK)
> +			ssc_sense_data_build(cmd, NO_SENSE | SENSE_FILEMARK,
> +					     ASC_MARK, info, sizeof(info));
>  		else
>  			ssc_sense_data_build(cmd, NO_SENSE | 0x20,
> @@ -339,8 +342,13 @@
> -		if (!length)
> +		if (!length) {
> +			if (h->blk_type == BLK_FILEMARK) {
> +				ret = skip_next_header(cmd->dev);
> +				/* FIXME: ??? */

Thanks, the patch looks correct. What's 'FIXME' part?

ssc2 says the following. Looks this patch is correct.

If the device server encounters a filemark during a READ(16) command,
CHECK CONDITION status shall be returned and the FILEMARK and VALID
bits shall be set to one in the sense data. The sense key shall be set
to NO SENSE or RECOVERED ERROR, as appropriate, and the additional
sense code shall be set to FILEMARK DETECTED. Upon termination, the
logical position shall be after the filemark (end-of-partition
side). If the FIXED bit is one, the INFORMATION field shall be set to
the requested transfer length minus the actual number of logical
blocks read. If the FIXED bit is zero, the INFORMATION field shall be
set to the requested transfer length.

To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

More information about the stgt mailing list