Add chkconfig configuration to tgtd service script

Signed-off-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
iscsi: Fix IPv6 discovery by stripping Zone ID

This strips off the "%ZONEID" that can be at the end of IPv6
addresses returned by getnameinfo(). Without this, IPv6 discovery
fails because the address has something like "%eth0" appended to it.

Signed of by: Lee Duncan <lduncan@suse.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Trim the letter v from the version tag for the rpm spec

The rpm package should not have the v for version in the version tag.

Signed-off-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
sbc: READ6/10/12/16: Add handling of residual overflow/underflow.

Version 2:
Simplify the patch based on Alexanders comments.

This patch adds support to return overflow/underflow residuals
for the cases where the transport layer (iSCSI, ...) specifies
an EDTL that is not matching the SCSI transdfer length.

Additionally, in case of residual underflow it will also clamp the size of
returned DATA-IN to the amount of data that was actually read and not the
EDTL that was requested.

This is from RFC 3720, 10.4.1 :
     bit 6 - (U) set for Residual Underflow.  In this case, the Residual
     Count indicates the number of bytes that were not transferred out
     of the number of bytes that were expected to be transferred.  For
     a bidirectional operation, the Residual Count contains the
     residual for the write operation.

I have added a specific test for this condition to the testsute in
libiscsi :

    ./bin/iscsi-test-cu -t "TestRead10.testRead10Residuals" \
        iscsi://127.0.0.1/iqn.ronnie.test/1 -V

    Suite: TestRead10
      Test: testRead10Residuals ...
        Test invalid READ10 commands
        Block size is 512
        Try reading one block but with iSCSI expected transfer length==0
        Verify that the target returned SUCCESS
        Verify residual overflow flag is set
        Verify we got 512 bytes of residual overflow
        Try reading one block but with iSCSI expected transfer length==10000
        Verify that the target returned SUCCESS
        Verify we got one whole block back from the target
        Verify residual underflow flag is set
        Verify we got 9488 bytes of residual underflow
        Try reading one block but with iSCSI expected transfer length==200
        Verify that the target returned SUCCESS
        Verify we got 200 bytes back from the target
        Verify residual overflow flag is set
        Verify we got 312 bytes of residual overflow
        Try reading two blocks but iSCSI expected transfer length==512 (==one bl
        Verify that the target returned SUCCESS
        Verify we got one whole block back from the target
        Verify residual overflow flag is set
        Verify we got one block of residual overflow
    passed

    --Run Summary: Type      Total     Ran  Passed  Failed
                   suites        1       1     n/a       0
                   tests         1       1       1       0
                   asserts      24      24      24       0

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
sbc: Add residual handling for WRITE6/10/12/16 and WRITEVERIFY10/12/16

This patch adds proper residual handling and reporting for the WRITE and
WRITEVERIFY commands.
In addition to setting the residual, for the case of underflow we have
to clamp the DATA-IN buffer so that the bs-backends will not write
more than what is specified in the SCSI TL.

Tests for these conditions are availabel in the libiscsi testsuite.

Test for WRITE10 follows :
$ ./bin/iscsi-test-cu -t "TestWrite10.testWrite10Residuals" iscsi://127.0.0.1/iqn.ronnie.test/1 -V --dataloss

     CUnit - A Unit testing framework for C - Version 2.1-0
     http://cunit.sourceforge.net/

Suite: TestWrite10
  Test: testWrite10Residuals ...
    Test WRITE10 commands with residuals
    Block size is 512
    Try writing one block but with iSCSI expected transfer length==0
    Verify that the target returned SUCCESS
    Verify residual overflow flag is set
    Verify we got 512 bytes of residual overflow
    Try writing one block but with iSCSI expected transfer length==10000
    Verify that the target returned SUCCESS
    Verify residual underflow flag is set
    Verify we got 9488 bytes of residual underflow
    Try writing one block but with iSCSI expected transfer length==200
    Verify that the target returned SUCCESS
    Verify residual overflow flag is set
    Verify we got 312 bytes of residual overflow
    Try writing two blocks but iSCSI expected transfer length==512 (==one block)
    Verify that the target returned SUCCESS
    Verify residual overflow flag is set
    Verify we got one block of residual overflow
    Verify that if iSCSI EDTL > SCSI TL then we only write SCSI TL amount of data
    Write two blocks of 'a'
    Send WRITE10 LBA:0 blocks:2 wrprotect:0 dpo:0 fua:0 fua_nv:0 group:0
    [OK] WRITE10 returned SUCCESS.
    Write one block of 'b' but set iSCSI EDTL to 2 blocks.
    Verify that the target returned SUCCESS
    Verify residual underflow flag is set
    Verify we got one block of residual underflow
    Read the two blocks
    Send READ10 LBA:0 blocks:2 rdprotect:0 dpo:0 fua:0 fua_nv:0 group:0
    [OK] READ10 returned SUCCESS.
    Verify that the first block was changed to 'b'
    Verify that the second block was NOT overwritten and still contains 'a'
    Verify that if iSCSI EDTL < SCSI TL then we only write iSCSI EDTL amount of data
    Write two blocks of 'a'
    Send WRITE10 LBA:0 blocks:2 wrprotect:0 dpo:0 fua:0 fua_nv:0 group:0
    [OK] WRITE10 returned SUCCESS.
    Write two blocks of 'b' but set iSCSI EDTL to 1 blocks.
    Verify that the target returned SUCCESS
    Verify residual overflow flag is set
    Verify we got one block of residual overflow
    Read the two blocks
    Send READ10 LBA:0 blocks:2 rdprotect:0 dpo:0 fua:0 fua_nv:0 group:0
    [OK] READ10 returned SUCCESS.
    Verify that the first block was changed to 'b'
    Verify that the second block was NOT overwritten and still contains 'a'
passed

--Run Summary: Type      Total     Ran  Passed  Failed
               suites        1       1     n/a       0
               tests         1       1       1       0
               asserts      35      35      35       0
Tests completed with return value: 0

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
tgt 1.0.36

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>