GithubHelp home page GithubHelp logo

Comments (2)

mykaul avatar mykaul commented on August 15, 2024

Thought there's a way to attach files here...
I'll see what I can do, how I can copy-paste it here without formatting.

from libiscsi.

mykaul avatar mykaul commented on August 15, 2024
diff --git a/test-tool/test_unmap_simple.c b/test-tool/test_unmap_simple.c
index d080ae5..a546123 100644
--- a/test-tool/test_unmap_simple.c
+++ b/test-tool/test_unmap_simple.c
@@ -39,10 +39,12 @@ init_lun_with_data(unsigned char *buf, uint64_t lba)
 void
 test_unmap_simple(void)
 {
-   int i, ret;
+   int i, ret,max_unmap_bdc, max_unmap;
    struct unmap_list list[257];
    unsigned char *buf = alloca(256 * block_size);
    unsigned char *zbuf = alloca(256 * block_size);
+   struct scsi_inquiry_block_limits *bl;
+   struct scsi_task *bl_task = NULL;
         memset(zbuf, 0, 256 * block_size);

    logging(LOG_VERBOSE, LOG_BLANK_LINE);
@@ -52,6 +54,22 @@ test_unmap_simple(void)
    CHECK_FOR_THIN_PROVISIONING;
    CHECK_FOR_SBC;

+   ret = inquiry(iscsic, tgt_lun,
+           1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS,
+           64, &bl_task);
+   CU_ASSERT_EQUAL(ret, 0);
+   bl = scsi_datain_unmarshall(bl_task);
+
+   if (bl && bl->max_unmap_bdc && bl->max_unmap_bdc <= 256) {
+       max_unmap_bdc = bl->max_unmap_bdc;
+   } else {
+       max_unmap_bdc = 256;
+   }
+   if (bl && bl->max_unmap) {
+       max_unmap = bl->max_unmap;
+   } else {
+       max_unmap = 8192;
+   }

    logging(LOG_VERBOSE, "Test UNMAP of 1-256 blocks at the start of the "
        "LUN as a single descriptor");
@@ -86,14 +104,14 @@ test_unmap_simple(void)
        }
    }

-   logging(LOG_VERBOSE, "Test UNMAP of 1-256 blocks at the start of the "
+   logging(LOG_VERBOSE, "Test UNMAP of 1 to maximum unmap block descriptor count blocks at the start of the "
        "LUN with one descriptor per block");

    logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
    init_lun_with_data(buf, 0);

    CU_ASSERT_EQUAL(ret, 0);
-   for (i = 0; i < 256; i++) {
+   for (i = 0; i < max_unmap_bdc; i++) {
        list[i].lba = i;
        list[i].num = 1;
        ret = unmap(iscsic, tgt_lun, 0, list, i + 1);
@@ -118,4 +136,22 @@ test_unmap_simple(void)
            }
        }
    }
+
+   logging(LOG_VERBOSE, "Test UNMAP of more than maximum unmap block descriptor count blocks");
+
+   i++;
+   list[i].lba = i;
+   list[i].num = 1;
+   ret = unmap(iscsic, tgt_lun, 0, list, i + 1);
+   /* we expect to fail unmapping with more than the maximum unmap block descriptor count blocks */
+   CU_ASSERT_NOT_EQUAL(ret, 0);
+
+   logging(LOG_VERBOSE, "Write more than the Maximum unmap LBA count");
+
+   list[0].lba = 0;
+   list[0].num = (max_unmap + 1);
+   ret = unmap(iscsic, tgt_lun, 0, list, 1);
+   /* We expect to fail unmapping with more than the maximum unmap LBA count" */
+   CU_ASSERT_NOT_EQUAL(ret, 0);
+
 }

from libiscsi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.