本文整理汇总了C++中scsi_free_scsi_task函数的典型用法代码示例。如果您正苦于以下问题:C++ scsi_free_scsi_task函数的具体用法?C++ scsi_free_scsi_task怎么用?C++ scsi_free_scsi_task使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scsi_free_scsi_task函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: write10_cb
void write10_cb(struct iscsi_context *iscsi, int status, void *command_data, void *private_data)
{
struct write_task *wt = (struct write_task *)private_data;
struct scsi_task *task = command_data;
struct client *client = wt->client;
if (status == SCSI_STATUS_CHECK_CONDITION) {
printf("Write10 failed with sense key:%d ascq:%04x\n", task->sense.key, task->sense.ascq);
scsi_free_scsi_task(task);
exit(10);
}
if (status != SCSI_STATUS_GOOD) {
printf("Write10 failed with %s\n", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
exit(10);
}
client->in_flight--;
fill_read_queue(client);
if ((client->in_flight == 0) && (client->pos == client->src_num_blocks)) {
client->finished = 1;
}
scsi_free_scsi_task(wt->rt);
scsi_free_scsi_task(task);
free(wt);
}
开发者ID:Jiangliuer,项目名称:libiscsi,代码行数:27,代码来源:iscsi-dd.c
示例2: iscsi_aio_read10_cb
static void
iscsi_aio_read10_cb(struct iscsi_context *iscsi, int status,
void *command_data, void *opaque)
{
IscsiAIOCB *acb = opaque;
trace_iscsi_aio_read10_cb(iscsi, status, acb, acb->canceled);
if (acb->canceled != 0) {
qemu_aio_release(acb);
scsi_free_scsi_task(acb->task);
acb->task = NULL;
return;
}
acb->status = 0;
if (status != 0) {
error_report("Failed to read10 data from iSCSI lun. %s",
iscsi_get_error(iscsi));
acb->status = -EIO;
}
iscsi_schedule_bh(iscsi_readv_writev_bh_cb, acb);
scsi_free_scsi_task(acb->task);
acb->task = NULL;
}
开发者ID:breuerr,项目名称:qemu,代码行数:26,代码来源:iscsi.c
示例3: iscsi_readcapacity10_cb
static void
iscsi_readcapacity10_cb(struct iscsi_context *iscsi, int status,
void *command_data, void *opaque)
{
struct IscsiTask *itask = opaque;
struct scsi_readcapacity10 *rc10;
struct scsi_task *task = command_data;
if (status != 0) {
error_report("iSCSI: Failed to read capacity of iSCSI lun. %s",
iscsi_get_error(iscsi));
itask->status = 1;
itask->complete = 1;
scsi_free_scsi_task(task);
return;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
error_report("iSCSI: Failed to unmarshall readcapacity10 data.");
itask->status = 1;
itask->complete = 1;
scsi_free_scsi_task(task);
return;
}
itask->iscsilun->block_size = rc10->block_size;
itask->iscsilun->num_blocks = rc10->lba;
itask->bs->total_sectors = (uint64_t)rc10->lba *
rc10->block_size / BDRV_SECTOR_SIZE ;
itask->status = 0;
itask->complete = 1;
scsi_free_scsi_task(task);
}
开发者ID:breuerr,项目名称:qemu,代码行数:35,代码来源:iscsi.c
示例4: list_luns
void list_luns(const char *target, const char *portal)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_reportluns_list *list;
int full_report_size;
int i;
iscsi = iscsi_create_context(initiator);
if (iscsi == NULL) {
printf("Failed to create context\n");
exit(10);
}
if (iscsi_set_targetname(iscsi, target)) {
fprintf(stderr, "Failed to set target name\n");
exit(10);
}
iscsi_set_session_type(iscsi, ISCSI_SESSION_NORMAL);
iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C);
if (iscsi_connect_sync(iscsi, portal) != 0) {
printf("iscsi_connect failed. %s\n", iscsi_get_error(iscsi));
exit(10);
}
if (iscsi_login_sync(iscsi) != 0) {
fprintf(stderr, "login failed :%s\n", iscsi_get_error(iscsi));
exit(10);
}
/* get initial reportluns data, all targets can report 16 bytes but some
* fail if we ask for too much.
*/
if ((task = iscsi_reportluns_sync(iscsi, 0, 16)) == NULL) {
fprintf(stderr, "reportluns failed : %s\n", iscsi_get_error(iscsi));
exit(10);
}
full_report_size = scsi_datain_getfullsize(task);
if (full_report_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_reportluns_sync(iscsi, 0, full_report_size)) == NULL) {
fprintf(stderr, "reportluns failed : %s\n", iscsi_get_error(iscsi));
exit(10);
}
}
list = scsi_datain_unmarshall(task);
if (list == NULL) {
fprintf(stderr, "failed to unmarshall reportluns datain blob\n");
exit(10);
}
for (i=0; i < (int)list->num; i++) {
show_lun(iscsi, list->luns[i]);
}
scsi_free_scsi_task(task);
iscsi_destroy_context(iscsi);
}
开发者ID:stefanha,项目名称:libiscsi,代码行数:60,代码来源:iscsi-ls.c
示例5: do_inquiry
void do_inquiry(struct iscsi_context *iscsi, int lun, int evpd, int pc)
{
struct scsi_task *task;
int full_size;
void *inq;
/* See how big this inquiry data is */
task = iscsi_inquiry_sync(iscsi, lun, evpd, pc, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
fprintf(stderr, "Inquiry command failed : %s\n", iscsi_get_error(iscsi));
exit(10);
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsi, lun, evpd, pc, full_size)) == NULL) {
fprintf(stderr, "Inquiry command failed : %s\n", iscsi_get_error(iscsi));
exit(10);
}
}
inq = scsi_datain_unmarshall(task);
if (inq == NULL) {
fprintf(stderr, "failed to unmarshall inquiry datain blob\n");
exit(10);
}
if (evpd == 0) {
inquiry_standard(inq);
} else {
switch (pc) {
case SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES:
inquiry_supported_pages(inq);
break;
case SCSI_INQUIRY_PAGECODE_UNIT_SERIAL_NUMBER:
inquiry_unit_serial_number(inq);
break;
case SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION:
inquiry_device_identification(inq);
break;
case SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS:
inquiry_block_limits(inq);
break;
case SCSI_INQUIRY_PAGECODE_BLOCK_DEVICE_CHARACTERISTICS:
inquiry_block_device_characteristics(inq);
break;
case SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING:
inquiry_logical_block_provisioning(inq);
break;
default:
fprintf(stderr, "Usupported pagecode:0x%02x\n", pc);
}
}
scsi_free_scsi_task(task);
}
开发者ID:sahlberg,项目名称:libiscsi,代码行数:58,代码来源:iscsi-inq.c
示例6: test_report_supported_opcodes_servactv
void
test_report_supported_opcodes_servactv(void)
{
int i, ret;
struct scsi_task *rso_task;
struct scsi_report_supported_op_codes *rsoc;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES SERVACTV flag");
ret = report_supported_opcodes(
sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
65535,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not "
"implemented.");
CU_PASS("READ_SUPPORTED_OPCODES is not implemented.");
scsi_free_scsi_task(rso_task);
return;
}
CU_ASSERT_EQUAL(ret, 0);
if (ret != 0) {
scsi_free_scsi_task(rso_task);
return;
}
logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
rsoc = scsi_datain_unmarshall(rso_task);
CU_ASSERT_NOT_EQUAL(rsoc, NULL);
if (!rsoc) {
logging(LOG_NORMAL, "[FAILED] Target did not return any data "
"for ReportSupportedOpcodes\n");
CU_FAIL("Target did not return any data for "
"ReportSupportedOpcodes");
return;
}
logging(LOG_VERBOSE, "Verify that when SERVACTV is clear then "
"ServiceAction must be zero.");
for (i = 0; i < rsoc->num_descriptors; i++) {
if (!rsoc->descriptors[i].servactv && rsoc->descriptors[i].sa) {
logging(LOG_NORMAL, "[FAILED] ServiceAction is "
"non-zero but SERVACTV is clear");
CU_FAIL("[FAILED] ServiceAction is "
"non-zero but SERVACTV is clear");
}
}
scsi_free_scsi_task(rso_task);
}
开发者ID:daodewang,项目名称:libiscsi,代码行数:54,代码来源:test_report_supported_opcodes_servactv.c
示例7: T0211_read12_rdprotect
int T0211_read12_rdprotect(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
int ret = 0, i, lun;
printf("0211_read12_rdprotect:\n");
printf("======================\n");
if (show_info) {
printf("Test how READ12 handles the rdprotect bits\n");
printf("1, Any non-zero valued for rdprotect should fail.\n");
printf("\n");
return 0;
}
iscsi = iscsi_context_login(initiator, url, &lun);
if (iscsi == NULL) {
printf("Failed to login to target\n");
return -1;
}
printf("Read12 with RDPROTECT ");
for (i = 1; i <= 7; i++) {
task = iscsi_read12_sync(iscsi, lun, 0, block_size, block_size, i, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send read12 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) {
printf("[FAILED]\n");
printf("Read12 with RDPROTECT!=0 should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n");
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);
return ret;
}
开发者ID:redlicha,项目名称:libiscsi,代码行数:50,代码来源:0211_read12_rdprotect.c
示例8: iscsi_aio_readv
static BlockDriverAIOCB *
iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num,
QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb,
void *opaque)
{
IscsiLun *iscsilun = bs->opaque;
IscsiAIOCB *acb;
acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);
trace_iscsi_aio_readv(iscsilun->iscsi, sector_num, nb_sectors, opaque, acb);
acb->nb_sectors = nb_sectors;
acb->sector_num = sector_num;
acb->iscsilun = iscsilun;
acb->qiov = qiov;
acb->read_size = BDRV_SECTOR_SIZE * (size_t)acb->nb_sectors;
acb->retries = ISCSI_CMD_RETRIES;
if (iscsi_aio_readv_acb(acb) != 0) {
if (acb->task) {
scsi_free_scsi_task(acb->task);
}
qemu_aio_release(acb);
return NULL;
}
iscsi_set_events(iscsilun);
return &acb->common;
}
开发者ID:nvgreensocs,项目名称:qemu-virtio,代码行数:30,代码来源:iscsi.c
示例9: iscsi_aio_discard
static BlockDriverAIOCB *
iscsi_aio_discard(BlockDriverState *bs,
int64_t sector_num, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
IscsiLun *iscsilun = bs->opaque;
IscsiAIOCB *acb;
acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);
acb->iscsilun = iscsilun;
acb->nb_sectors = nb_sectors;
acb->sector_num = sector_num;
acb->retries = ISCSI_CMD_RETRIES;
if (iscsi_aio_discard_acb(acb) != 0) {
if (acb->task) {
scsi_free_scsi_task(acb->task);
}
qemu_aio_release(acb);
return NULL;
}
iscsi_set_events(iscsilun);
return &acb->common;
}
开发者ID:nvgreensocs,项目名称:qemu-virtio,代码行数:27,代码来源:iscsi.c
示例10: iscsi_unmap_cb
static void
iscsi_unmap_cb(struct iscsi_context *iscsi, int status,
void *command_data, void *opaque)
{
IscsiAIOCB *acb = opaque;
if (acb->canceled != 0) {
return;
}
acb->status = 0;
if (status != 0) {
if (status == SCSI_STATUS_CHECK_CONDITION
&& acb->task->sense.key == SCSI_SENSE_UNIT_ATTENTION
&& acb->retries-- > 0) {
scsi_free_scsi_task(acb->task);
acb->task = NULL;
if (iscsi_aio_discard_acb(acb) == 0) {
iscsi_set_events(acb->iscsilun);
return;
}
}
error_report("Failed to unmap data on iSCSI lun. %s",
iscsi_get_error(iscsi));
acb->status = -EIO;
}
iscsi_schedule_bh(acb);
}
开发者ID:JaonLin,项目名称:hypershell,代码行数:29,代码来源:iscsi.c
示例11: read10_cb
void read10_cb(struct iscsi_context *iscsi, int status, void *command_data, void *private_data)
{
struct client *client = (struct client *)private_data;
struct scsi_task *task = command_data;
struct write_task *wt;
if (status == SCSI_STATUS_CHECK_CONDITION) {
printf("Read10 failed with sense key:%d ascq:%04x\n", task->sense.key, task->sense.ascq);
exit(10);
}
wt = malloc(sizeof(struct write_task));
wt->rt = task;
wt->client = client;
if (iscsi_write10_task(client->dst_iscsi,
client->dst_lun,
task->params.read10.lba,
task->datain.data,
task->datain.size,
client->dst_blocksize,
0, 0, 0, 0, 0,
write10_cb, wt) == NULL) {
printf("failed to send read10 command\n");
scsi_free_scsi_task(task);
exit(10);
}
}
开发者ID:jongrimm,项目名称:libiscsi,代码行数:28,代码来源:iscsi-dd.c
示例12: test_teardown
void
test_teardown(void)
{
free(read_write_buf);
read_write_buf = NULL;
scsi_free_scsi_task(task);
task = NULL;
}
开发者ID:gcbirzan,项目名称:libiscsi,代码行数:8,代码来源:iscsi-test-cu.c
示例13: iscsi_free_scsi_cbdata
void iscsi_free_scsi_cbdata(struct iscsi_scsi_cbdata *scsi_cbdata)
{
if (scsi_cbdata == NULL) {
return;
}
if (scsi_cbdata->task == NULL) {
scsi_free_scsi_task(scsi_cbdata->task);
scsi_cbdata->task = NULL;
}
free(scsi_cbdata);
}
开发者ID:dooglus,项目名称:ccan,代码行数:11,代码来源:scsi-command.c
示例14: write
ssize_t write(int fd, const void *buf, size_t count)
{
if ((iscsi_fd_list[fd].is_iscsi == 1) && (iscsi_fd_list[fd].in_flight == 0)) {
uint64_t offset;
uint64_t num_blocks, lba;
struct scsi_task *task;
if (iscsi_fd_list[fd].dup2fd >= 0) {
return write(iscsi_fd_list[fd].dup2fd, buf, count);
}
if (iscsi_fd_list[fd].offset%iscsi_fd_list[fd].block_size) {
errno = EINVAL;
return -1;
}
if (count%iscsi_fd_list[fd].block_size) {
errno = EINVAL;
return -1;
}
iscsi_fd_list[fd].lbasd_cache_valid = 0;
offset = iscsi_fd_list[fd].offset;
num_blocks = count/iscsi_fd_list[fd].block_size;
lba = offset / iscsi_fd_list[fd].block_size;
/* Don't try to read beyond the last LBA */
if (lba >= iscsi_fd_list[fd].num_blocks) {
return 0;
}
/* Trim num_blocks requested to last lba */
if ((lba + num_blocks) > iscsi_fd_list[fd].num_blocks) {
num_blocks = iscsi_fd_list[fd].num_blocks - lba;
count = num_blocks * iscsi_fd_list[fd].block_size;
}
iscsi_fd_list[fd].in_flight = 1;
LD_ISCSI_DPRINTF(4,"write16_sync: lun %d, lba %"PRIu64", num_blocks: %"PRIu64", block_size: %d, offset: %"PRIu64" count: %lu",iscsi_fd_list[fd].lun,lba,num_blocks,iscsi_fd_list[fd].block_size,offset,(unsigned long)count);
task = iscsi_write16_sync(iscsi_fd_list[fd].iscsi, iscsi_fd_list[fd].lun, lba, (unsigned char *) buf, count, iscsi_fd_list[fd].block_size, 0, 0, 0, 0, 0);
iscsi_fd_list[fd].in_flight = 0;
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
LD_ISCSI_DPRINTF(0,"failed to send write16 command");
errno = EIO;
return -1;
}
iscsi_fd_list[fd].offset += count;
scsi_free_scsi_task(task);
return count;
}
return real_write(fd, buf, count);
}
开发者ID:agrare,项目名称:libiscsi,代码行数:53,代码来源:ld_iscsi.c
示例15: iscsi_bh_cb
static void
iscsi_bh_cb(void *p)
{
IscsiAIOCB *acb = p;
qemu_bh_delete(acb->bh);
if (acb->canceled == 0) {
acb->common.cb(acb->common.opaque, acb->status);
}
if (acb->task != NULL) {
scsi_free_scsi_task(acb->task);
acb->task = NULL;
}
qemu_aio_release(acb);
}
开发者ID:nvgreensocs,项目名称:qemu-arm-mmio,代码行数:18,代码来源:iscsi.c
示例16: iscsi_bh_cb
static void
iscsi_bh_cb(void *p)
{
IscsiAIOCB *acb = p;
qemu_bh_delete(acb->bh);
g_free(acb->buf);
acb->buf = NULL;
acb->common.cb(acb->common.opaque, acb->status);
if (acb->task != NULL) {
scsi_free_scsi_task(acb->task);
acb->task = NULL;
}
qemu_aio_unref(acb);
}
开发者ID:MollyZhang,项目名称:esesc,代码行数:19,代码来源:iscsi.c
示例17: test_receive_copy_results_op_params
void
test_receive_copy_results_op_params(void)
{
struct scsi_task *op_task = NULL;
struct scsi_copy_results_op_params *opp;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test RECEIVE COPY RESULTS, OPERATING PARAMS");
RECEIVE_COPY_RESULTS(&op_task, sd, SCSI_COPY_RESULTS_OP_PARAMS, 0,
(void **)&opp, EXPECT_STATUS_GOOD);
logging(LOG_NORMAL,
"max_target_desc=%d, max_seg_desc=%d",
opp->max_target_desc_count,
opp->max_segment_desc_count);
scsi_free_scsi_task(op_task);
}
开发者ID:bonzini,项目名称:libiscsi,代码行数:19,代码来源:test_receive_copy_results_op_params.c
示例18: test_inquiry_supported_vpd
void
test_inquiry_supported_vpd(void)
{
int ret, i;
struct scsi_inquiry_supported_pages *sup_inq;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test INQUIRY supported VPD pages");
logging(LOG_VERBOSE, "Verify we can read the SUPPORTED VPD page");
ret = inquiry(sd, &task,
1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, 255,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we got at least 4 bytes of data");
CU_ASSERT(task->datain.size >= 4);
logging(LOG_VERBOSE, "Verify we can unmarshall the DATA-IN buffer");
sup_inq = scsi_datain_unmarshall(task);
CU_ASSERT_NOT_EQUAL(sup_inq, NULL);
if (sup_inq == NULL) {
logging(LOG_NORMAL, "[FAILED] Failed to unmarshall DATA-IN "
"buffer");
return;
}
logging(LOG_VERBOSE, "Verify we read all the supported pages");
for (i = 0; i < sup_inq->num_pages; i++) {
logging(LOG_VERBOSE, "Verify we can read page 0x%02x",
sup_inq->pages[i]);
ret = inquiry(sd, NULL, 1, sup_inq->pages[i], 255,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
}
if (task != NULL) {
scsi_free_scsi_task(task);
task = NULL;
}
}
开发者ID:agrare,项目名称:libiscsi,代码行数:42,代码来源:test_inquiry_supported_vpd.c
示例19: T0234_write12_beyondeol
int T0234_write12_beyondeol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
int ret, i, lun;
unsigned char data[4096 * 258];
printf("0234_write12_beyond_eol:\n");
printf("=======================\n");
if (show_info) {
printf("Test that WRITE12 fails if writing beyond end-of-lun.\n");
printf("This test is skipped for LUNs with more than 2^31 blocks\n");
printf("1, Writing 1-256 blocks beyond end-of-lun should fail.\n");
printf("\n");
return 0;
}
iscsi = iscsi_context_login(initiator, url, &lun);
if (iscsi == NULL) {
printf("Failed to login to target\n");
return -1;
}
if (!data_loss) {
printf("--dataloss flag is not set. Skipping test\n");
ret = -2;
goto finished;
}
ret = 0;
if (num_blocks >= 0x80000000) {
printf("[SKIPPED]\n");
printf("LUN is too big for read-beyond-eol tests with WRITE12. Skipping test.\n");
ret = -2;
goto finished;
}
/* read 1 - 256 blocks beyond the end of the device */
printf("Writing 1-256 blocks beyond end-of-device ... ");
for (i = 2; i <= 257; i++) {
task = iscsi_write12_sync(iscsi, lun, num_blocks, data, i * block_size, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send write12 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Write12 command should fail when writing beyond end of device\n");
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);
return ret;
}
开发者ID:Jiangliuer,项目名称:libiscsi,代码行数:66,代码来源:0234_write12_beyondeol.c
示例20: iscsi_readcapacity_sync
static int iscsi_readcapacity_sync(IscsiLun *iscsilun)
{
struct scsi_task *task = NULL;
struct scsi_readcapacity10 *rc10 = NULL;
struct scsi_readcapacity16 *rc16 = NULL;
int ret = 0;
int retries = ISCSI_CMD_RETRIES;
do {
if (task != NULL) {
scsi_free_scsi_task(task);
task = NULL;
}
switch (iscsilun->type) {
case TYPE_DISK:
task = iscsi_readcapacity16_sync(iscsilun->iscsi, iscsilun->lun);
if (task != NULL && task->status == SCSI_STATUS_GOOD) {
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
error_report("iSCSI: Failed to unmarshall readcapacity16 data.");
ret = -EINVAL;
} else {
iscsilun->block_size = rc16->block_length;
iscsilun->num_blocks = rc16->returned_lba + 1;
}
}
break;
case TYPE_ROM:
task = iscsi_readcapacity10_sync(iscsilun->iscsi, iscsilun->lun, 0, 0);
if (task != NULL && task->status == SCSI_STATUS_GOOD) {
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
error_report("iSCSI: Failed to unmarshall readcapacity10 data.");
ret = -EINVAL;
} else {
iscsilun->block_size = rc10->block_size;
if (rc10->lba == 0) {
/* blank disk loaded */
iscsilun->num_blocks = 0;
} else {
iscsilun->num_blocks = rc10->lba + 1;
}
}
}
break;
default:
return 0;
}
} while (task != NULL && task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_UNIT_ATTENTION
&& retries-- > 0);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
error_report("iSCSI: failed to send readcapacity10 command.");
ret = -EINVAL;
}
if (task) {
scsi_free_scsi_task(task);
}
return ret;
}
开发者ID:JaonLin,项目名称:hypershell,代码行数:62,代码来源:iscsi.c
注:本文中的scsi_free_scsi_task函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论