diff --git a/dist/iscsi/include/parameters.h b/dist/iscsi/include/parameters.h index 624a4c628776..397fad77a79c 100644 --- a/dist/iscsi/include/parameters.h +++ b/dist/iscsi/include/parameters.h @@ -146,25 +146,25 @@ void set_session_parameters(iscsi_parameter_t * , iscsi_sess_param_t #define PARAM_LIST_DESTROY(LIST, ELSE) \ if (param_list_destroy(LIST)!=0) { \ - TRACE_ERROR("param_list_destroy() failed\n"); \ + iscsi_trace_error("param_list_destroy() failed\n"); \ ELSE; \ } #define PARAM_LIST_ADD(LIST, TYPE, KEY, DFLT, VALID, ELSE) \ if (param_list_add(LIST, TYPE, KEY, DFLT, VALID)!=0) { \ - TRACE_ERROR("param_list_add() failed\n"); \ + iscsi_trace_error("param_list_add() failed\n"); \ ELSE; \ } #define PARAM_TEXT_ADD(LIST, KEY, VAL, TEXT, LEN, SIZE, OFFER, ELSE ) \ if (param_text_add(LIST, KEY, VAL, TEXT, LEN, SIZE, OFFER)!=0) { \ - TRACE_ERROR("param_text_add() failed\n"); \ + iscsi_trace_error("param_text_add() failed\n"); \ ELSE; \ } #define PARAM_TEXT_PARSE(LIST, CRED, TEXT, LEN, TEXT_OUT, LEN_OUT, SIZE, OFFER, ELSE ) \ if (param_text_parse(LIST, CRED, TEXT, LEN, TEXT_OUT, LEN_OUT, SIZE, OFFER)!=0) { \ - TRACE_ERROR("param_text_parse_offer() failed\n"); \ + iscsi_trace_error("param_text_parse_offer() failed\n"); \ ELSE; \ } #endif diff --git a/dist/iscsi/include/util.h b/dist/iscsi/include/util.h index e156288540f6..a0cc006177f5 100644 --- a/dist/iscsi/include/util.h +++ b/dist/iscsi/include/util.h @@ -129,69 +129,15 @@ EXTERN uint32_t iscsi_debug_level; -void set_debug(const char *); - /* * Debugging Functions */ +void set_debug(const char *); +void iscsi_trace(const int, const char *, ...); +void iscsi_trace_warning(const char *, ...); +void iscsi_trace_error(const char *, ...); +void iscsi_print_buffer(const char *, const size_t); -#ifdef CONFIG_ISCSI_DEBUG - -#define TRACE(trace, args...) do { \ - if (iscsi_debug_level & trace) { \ - char _iscsi_trace_buf[8192]; \ - (void) snprintf(_iscsi_trace_buf, sizeof(_iscsi_trace_buf), args); \ - PRINT("pid %i:%s:%d: %s", \ - ISCSI_GETPID, __FILE__, __LINE__, \ - _iscsi_trace_buf); \ - } \ -} while (/* CONSTCOND */ 0) - -#define PRINT_BUFF(buf, len) do { \ - if (iscsi_debug_level & TRACE_NET_BUFF) { \ - int _i; \ - for (_i=0 ; _i < len; _i++) { \ - if (_i % 4 == 0) { \ - if (_i) { \ - PRINT("\n"); \ - } \ - PRINT("%4i:", _i); \ - } \ - PRINT("%2x ", (uint8_t) (buf)[_i]); \ - } \ - if ((len + 1) % 32) { \ - PRINT("\n"); \ - } \ - } \ -} while (/* CONSTCOND */ 0) - -#define TRACE_WARNING(args...) do { \ - if (iscsi_debug_level & TRACE_WARN) { \ - char _iscsi_trace_buf[8192]; \ - (void) snprintf(_iscsi_trace_buf, sizeof(_iscsi_trace_buf), args); \ - PRINT("pid %i:%s:%i: ***WARNING*** %s", \ - ISCSI_GETPID, __FILE__, __LINE__, \ - _iscsi_trace_buf); \ - } \ -} while (/* CONSTCOND */ 0) -#define PRINT printf -#else -#define TRACE(trace, args...) -#define TRACE_WARNING(args...) -#define PRINT_BUFF(buf, len) -#define PRINT(args...) -#endif - -#define TRACE_ERROR(args...) do { \ - char _iscsi_trace_buf[8192]; \ - (void) snprintf(_iscsi_trace_buf, sizeof(_iscsi_trace_buf), args); \ - PRINT("pid %i:%s:%i: ***ERROR*** %s", \ - ISCSI_GETPID, __FILE__, __LINE__, \ - _iscsi_trace_buf); \ - syslog(LOG_ERR, "pid %d:%s:%d: ***ERROR*** %s", \ - ISCSI_GETPID, __FILE__, __LINE__, \ - _iscsi_trace_buf); \ -} while (/* CONSTCOND */ 0) /* * Byte Order @@ -240,15 +186,7 @@ void set_debug(const char *); /* #endif .* !linux */ -/* - * Process ID - */ - -#ifdef __KERNEL__ -#define ISCSI_GETPID current->pid -#else #define ISCSI_GETPID getpid() -#endif #ifndef HAVE_SOCKLEN_T typedef int socklen_t; @@ -414,28 +352,28 @@ int iscsi_mutex_destroy(iscsi_mutex_t * ); #define ISCSI_LOCK(M, ELSE) do { \ if (iscsi_mutex_lock(M) != 0) { \ - TRACE_ERROR("iscsi_mutex_lock() failed\n"); \ + iscsi_trace_error("iscsi_mutex_lock() failed\n"); \ ELSE; \ } \ } while (/* CONSTCOND */ 0) #define ISCSI_UNLOCK(M, ELSE) do { \ if (iscsi_mutex_unlock(M) != 0) { \ - TRACE_ERROR("iscsi_mutex_unlock() failed\n"); \ + iscsi_trace_error("iscsi_mutex_unlock() failed\n"); \ ELSE; \ } \ } while (/* CONSTCOND */ 0) #define ISCSI_MUTEX_INIT(M, ELSE) do { \ if (iscsi_mutex_init(M) != 0) { \ - TRACE_ERROR("iscsi_mutex_init() failed\n"); \ + iscsi_trace_error("iscsi_mutex_init() failed\n"); \ ELSE; \ } \ } while (/* CONSTCOND */ 0) #define ISCSI_MUTEX_DESTROY(M, ELSE) do { \ if (iscsi_mutex_destroy(M) != 0) { \ - TRACE_ERROR("iscsi_mutex_destroy() failed\n"); \ + iscsi_trace_error("iscsi_mutex_destroy() failed\n"); \ ELSE; \ } \ } while (/* CONSTCOND */ 0) @@ -557,26 +495,26 @@ typedef struct { #define NO_CLEANUP {} #define RETURN_GREATER(NAME, V1, V2, CU, RC) \ if ((V1)>(V2)) { \ - TRACE_ERROR("Bad \"%s\": %u > %u.\n", NAME, (unsigned)V1, (unsigned)V2); \ + iscsi_trace_error("Bad \"%s\": %u > %u.\n", NAME, (unsigned)V1, (unsigned)V2); \ CU; \ return RC; \ } #define RETURN_NOT_EQUAL(NAME, V1, V2, CU, RC) \ if ((V1)!=(V2)) { \ - TRACE_ERROR("Bad \"%s\": Got %u expected %u.\n", NAME, V1, V2); \ + iscsi_trace_error("Bad \"%s\": Got %u expected %u.\n", NAME, V1, V2); \ CU; \ return RC; \ } #define WARN_NOT_EQUAL(NAME, V1, V2) \ if ((V1)!=(V2)) { \ - TRACE_WARNING("Bad \"%s\": Got %u expected %u.\n", NAME, V1, V2); \ + iscsi_trace_warning("Bad \"%s\": Got %u expected %u.\n", NAME, V1, V2); \ } #define RETURN_EQUAL(NAME, V1, V2, CU, RC) \ if ((V1)==(V2)) { \ - TRACE_ERROR("Bad \"%s\": %u == %u.\n", NAME, V1, V2); \ + iscsi_trace_error("Bad \"%s\": %u == %u.\n", NAME, V1, V2); \ CU; \ return RC; \ } diff --git a/dist/iscsi/src/disk.c b/dist/iscsi/src/disk.c index 4df8eeee92c4..47a2b5e225cd 100644 --- a/dist/iscsi/src/disk.c +++ b/dist/iscsi/src/disk.c @@ -1,4 +1,4 @@ -/* $NetBSD: disk.c,v 1.5 2006/02/24 20:47:30 agc Exp $ */ +/* $NetBSD: disk.c,v 1.6 2006/03/12 18:47:28 agc Exp $ */ /* * Copyright © 2006 Alistair Crooks. All rights reserved. @@ -441,13 +441,13 @@ device_write(disc_device_t *dp, void *buf, size_t cc) switch (dp->xv[d].type) { case DE_DEVICE: if ((ret = device_write(dp->xv[d].u.dp, buf, cc)) < 0) { - TRACE_ERROR("device_write RAID1 device write failure\n"); + iscsi_trace_error("device_write RAID1 device write failure\n"); return -1; } break; case DE_EXTENT: if ((ret = extent_write(dp->xv[d].u.xp, buf, cc)) < 0) { - TRACE_ERROR("device_write RAID1 extent write failure\n"); + iscsi_trace_error("device_write RAID1 extent write failure\n"); return -1; } break; @@ -672,15 +672,15 @@ de_allocate(disc_de_t *de, char *filename) size = de_getsize(de); if (de_lseek(de, size - 1, SEEK_SET) == -1) { - TRACE_ERROR("error seeking \"%s\"\n", filename); + iscsi_trace_error("error seeking \"%s\"\n", filename); return 0; } if (de_read(de, &ch, 1) == -1) { - TRACE_ERROR("error reading \"%s\"", filename); + iscsi_trace_error("error reading \"%s\"", filename); return 0; } if (de_write(de, &ch, 1) == -1) { - TRACE_ERROR("error writing \"%s\"", filename); + iscsi_trace_error("error writing \"%s\"", filename); return 0; } return 1; @@ -732,7 +732,7 @@ device_init(globals_t *gp, targv_t *tvp, disc_target_t *tp) case 4096: break; default: - TRACE_ERROR("Invalid block len %" PRIu64 ". Choose one of 512, 1024, 2048, 4096.\n", disks.v[disks.c].blocklen); + iscsi_trace_error("Invalid block len %" PRIu64 ". Choose one of 512, 1024, 2048, 4096.\n", disks.v[disks.c].blocklen); return -1; } #if 0 @@ -742,31 +742,31 @@ device_init(globals_t *gp, targv_t *tvp, disc_target_t *tp) #else disks.v[disks.c].type = ISCSI_FS; #endif - PRINT("DISK: %" PRIu64 " logical units (%" PRIu64 " blocks, %" PRIu64 " bytes/block), type %s\n", + printf("DISK: %" PRIu64 " logical units (%" PRIu64 " blocks, %" PRIu64 " bytes/block), type %s\n", disks.v[disks.c].luns, disks.v[disks.c].blockc, disks.v[disks.c].blocklen, (disks.v[disks.c].type == ISCSI_FS) ? "iscsi fs" : (disks.v[disks.c].type == ISCSI_FS_MMAP) ? "iscsi fs mmap" : "iscsi ramdisk"); for (i = 0; i < disks.v[disks.c].luns; i++) { - PRINT("DISK: LU %i: ", i); + printf("DISK: LU %i: ", i); if (disks.v[disks.c].type == ISCSI_RAMDISK) { if ((disks.v[disks.c].ramdisk[i] = iscsi_malloc((unsigned)disks.v[disks.c].size)) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); return -1; } - TRACE(TRACE_ISCSI_DEBUG, "allocated %" PRIu64 " bytes at %p\n", disks.v[disks.c].size, disks.v[disks.c].ramdisk[i]); - PRINT("%" PRIu64 " MB ramdisk\n", disks.v[disks.c].size / MB(1)); + iscsi_trace(TRACE_ISCSI_DEBUG, "allocated %" PRIu64 " bytes at %p\n", disks.v[disks.c].size, disks.v[disks.c].ramdisk[i]); + printf("%" PRIu64 " MB ramdisk\n", disks.v[disks.c].size / MB(1)); } else { (void) strlcpy(disks.v[disks.c].filename, disc_get_filename(&tp->de), sizeof(disks.v[disks.c].filename)); if (de_open(&tp->de, O_CREAT | O_RDWR, 0666) == -1) { - TRACE_ERROR("error opening \"%s\"\n", disks.v[disks.c].filename); + iscsi_trace_error("error opening \"%s\"\n", disks.v[disks.c].filename); return -1; } if (!allocate_space(tp)) { - TRACE_ERROR("error allocating space for \"%s\"", tp->target); + iscsi_trace_error("error allocating space for \"%s\"", tp->target); return -1; } - PRINT("%" PRIu64 " MB disk storage for \"%s\"\n", (de_getsize(&tp->de) / MB(1)), tp->target); + printf("%" PRIu64 " MB disk storage for \"%s\"\n", (de_getsize(&tp->de) / MB(1)), tp->target); } } return disks.c++; @@ -796,7 +796,7 @@ device_command(target_session_t * sess, target_cmd_t * cmd) initialized = 1; } if (!flag[lun]) { - PRINT("DISK: Simulating CHECK CONDITION with sense data (cdb 0x%x, lun %i)\n", cdb[0], lun); + printf("DISK: Simulating CHECK CONDITION with sense data (cdb 0x%x, lun %i)\n", cdb[0], lun); flag[lun]++; args->status = 0x02; args->length = 1024; @@ -822,18 +822,18 @@ device_command(target_session_t * sess, target_cmd_t * cmd) args->status = 0; return 0; } - TRACE(TRACE_SCSI_CMD, "SCSI op 0x%x (lun %i): \n", cdb[0], lun); + iscsi_trace(TRACE_SCSI_CMD, "SCSI op 0x%x (lun %i): \n", cdb[0], lun); switch (cdb[0]) { case TEST_UNIT_READY: - TRACE(TRACE_SCSI_CMD, "TEST_UNIT_READY\n"); + iscsi_trace(TRACE_SCSI_CMD, "TEST_UNIT_READY\n"); args->status = 0; args->length = 0; break; case INQUIRY: - TRACE(TRACE_SCSI_CMD, "INQUIRY\n"); + iscsi_trace(TRACE_SCSI_CMD, "INQUIRY\n"); data = args->send_data; (void) memset(data, 0x0, (unsigned) cdb[4]); /* Clear allocated buffer */ data[0] = 0; /* Peripheral Device Type */ @@ -862,14 +862,14 @@ device_command(target_session_t * sess, target_cmd_t * cmd) case LOAD_UNLOAD: - TRACE(TRACE_SCSI_CMD, "LOAD_UNLOAD\n"); + iscsi_trace(TRACE_SCSI_CMD, "LOAD_UNLOAD\n"); args->status = 0; args->length = 0; break; case READ_CAPACITY: - TRACE(TRACE_SCSI_CMD, "READ_CAPACITY\n"); + iscsi_trace(TRACE_SCSI_CMD, "READ_CAPACITY\n"); data = args->send_data; *((uint32_t *) (void *)data) = (uint32_t) ISCSI_HTONL((uint32_t) disks.v[sess->d].blockc - 1); /* Max LBA */ *((uint32_t *) (void *)(data + 4)) = (uint32_t) ISCSI_HTONL((uint32_t) disks.v[sess->d].blocklen); /* Block len */ @@ -885,9 +885,9 @@ device_command(target_session_t * sess, target_cmd_t * cmd) if (!len) { len = 256; } - TRACE(TRACE_SCSI_CMD, "WRITE_6(lba %u, len %u blocks)\n", lba, len); + iscsi_trace(TRACE_SCSI_CMD, "WRITE_6(lba %u, len %u blocks)\n", lba, len); if (disk_write(sess, args, lun, lba, (unsigned) len) != 0) { - TRACE_ERROR("disk_write() failed\n"); + iscsi_trace_error("disk_write() failed\n"); args->status = 0x01; } args->length = 0; @@ -900,9 +900,9 @@ device_command(target_session_t * sess, target_cmd_t * cmd) len = cdb[4]; if (!len) len = 256; - TRACE(TRACE_SCSI_CMD, "READ_6(lba %u, len %u blocks)\n", lba, len); + iscsi_trace(TRACE_SCSI_CMD, "READ_6(lba %u, len %u blocks)\n", lba, len); if (disk_read(sess, args, lba, len, lun) != 0) { - TRACE_ERROR("disk_read() failed\n"); + iscsi_trace_error("disk_read() failed\n"); args->status = 0x01; } args->input = 1; @@ -914,7 +914,7 @@ device_command(target_session_t * sess, target_cmd_t * cmd) len = ISCSI_MODE_SENSE_LEN; mode_data_len = len + 3; - TRACE(TRACE_SCSI_CMD, "MODE_SENSE_6(len %u blocks)\n", len); + iscsi_trace(TRACE_SCSI_CMD, "MODE_SENSE_6(len %u blocks)\n", len); (void) memset(cp, 0x0, (size_t) mode_data_len); /* magic constants courtesy of some values in the Lunix UNH iSCSI target */ cp[0] = mode_data_len; @@ -950,9 +950,9 @@ device_command(target_session_t * sess, target_cmd_t * cmd) ((uint8_t *) (void *) &len)[1] = cdb[7]; #endif - TRACE(TRACE_SCSI_CMD, "WRITE_10(lba %u, len %u blocks)\n", lba, len); + iscsi_trace(TRACE_SCSI_CMD, "WRITE_10(lba %u, len %u blocks)\n", lba, len); if (disk_write(sess, args, lun, lba, (unsigned) len) != 0) { - TRACE_ERROR("disk_write() failed\n"); + iscsi_trace_error("disk_write() failed\n"); args->status = 0x01; } args->length = 0; @@ -981,9 +981,9 @@ device_command(target_session_t * sess, target_cmd_t * cmd) ((uint8_t *) (void *) &len)[1] = cdb[7]; #endif - TRACE(TRACE_SCSI_CMD, "READ_10(lba %u, len %u blocks)\n", lba, len); + iscsi_trace(TRACE_SCSI_CMD, "READ_10(lba %u, len %u blocks)\n", lba, len); if (disk_read(sess, args, lba, len, lun) != 0) { - TRACE_ERROR("disk_read() failed\n"); + iscsi_trace_error("disk_read() failed\n"); args->status = 0x01; } args->input = 1; @@ -996,27 +996,27 @@ device_command(target_session_t * sess, target_cmd_t * cmd) case SYNC_CACHE: - TRACE(TRACE_SCSI_CMD, "SYNC_CACHE\n"); + iscsi_trace(TRACE_SCSI_CMD, "SYNC_CACHE\n"); args->status = 0; args->length = 0; break; case LOG_SENSE: - TRACE(TRACE_SCSI_CMD, "LOG_SENSE\n"); + iscsi_trace(TRACE_SCSI_CMD, "LOG_SENSE\n"); args->status = 0; args->length = 0; break; case UNKNOWN_5E: - TRACE(TRACE_SCSI_CMD, "UNKNOWN_5E\n"); + iscsi_trace(TRACE_SCSI_CMD, "UNKNOWN_5E\n"); args->status = 0; args->length = 0; break; case REPORT_LUNS: - TRACE(TRACE_SCSI_CMD, "REPORT LUNS\n"); + iscsi_trace(TRACE_SCSI_CMD, "REPORT LUNS\n"); data = args->send_data; data[3] = CONFIG_DISK_MAX_LUNS; /* just report CONFIG_DISK_MAX_LUNS LUNs and be done with it */ @@ -1026,12 +1026,12 @@ device_command(target_session_t * sess, target_cmd_t * cmd) break; default: - TRACE_ERROR("UNKNOWN OPCODE 0x%x\n", cdb[0]); + iscsi_trace_error("UNKNOWN OPCODE 0x%x\n", cdb[0]); /* to not cause confusion with some initiators */ args->status = 0x02; break; } - TRACE(TRACE_SCSI_DEBUG, "SCSI op 0x%x: done (status 0x%x)\n", cdb[0], args->status); + iscsi_trace(TRACE_SCSI_DEBUG, "SCSI op 0x%x: done (status 0x%x)\n", cdb[0], args->status); return 0; } @@ -1042,7 +1042,7 @@ device_shutdown(target_session_t *sess) if (disks.v[sess->d].type == ISCSI_RAMDISK) { for (i = 0; i < disks.v[sess->d].luns; i++) { - TRACE(TRACE_ISCSI_DEBUG, "freeing ramdisk[%i] (%p)\n", i, disks.v[sess->d].ramdisk[i]); + iscsi_trace(TRACE_ISCSI_DEBUG, "freeing ramdisk[%i] (%p)\n", i, disks.v[sess->d].ramdisk[i]); iscsi_free(disks.v[sess->d].ramdisk[i]); } } @@ -1062,7 +1062,7 @@ disk_write(target_session_t *sess, iscsi_scsi_cmd_args_t *args, uint8_t lun, uin struct iovec sg; uint64_t extra = 0; - TRACE(TRACE_SCSI_DATA, "writing %" PRIu64 " bytes from socket into device at byte offset %" PRIu64 "\n", num_bytes, byte_offset); + iscsi_trace(TRACE_SCSI_DATA, "writing %" PRIu64 " bytes from socket into device at byte offset %" PRIu64 "\n", num_bytes, byte_offset); /* Assign ptr for write data */ @@ -1077,7 +1077,7 @@ disk_write(target_session_t *sess, iscsi_scsi_cmd_args_t *args, uint8_t lun, uin case ISCSI_FS_MMAP: extra = byte_offset % 4096; if ((ptr = de_mmap(0, (size_t) (num_bytes + extra), PROT_WRITE, MAP_SHARED, &disks.v[sess->d].tv->v[sess->d].de, (off_t)(byte_offset - extra))) == NULL) { - TRACE_ERROR("mmap() failed\n"); + iscsi_trace_error("mmap() failed\n"); return -1; } else { ptr += (uint32_t) extra; @@ -1089,32 +1089,32 @@ disk_write(target_session_t *sess, iscsi_scsi_cmd_args_t *args, uint8_t lun, uin sg.iov_base = ptr; sg.iov_len = (unsigned)num_bytes; if (target_transfer_data(sess, args, &sg, 1) != 0) { - TRACE_ERROR("target_transfer_data() failed\n"); + iscsi_trace_error("target_transfer_data() failed\n"); } /* Finish up write */ switch(disks.v[sess->d].type) { case ISCSI_FS: if (de_lseek(&disks.v[sess->d].tv->v[sess->d].de, (off_t) byte_offset, SEEK_SET) == -1) { - TRACE_ERROR("lseek() to offset %" PRIu64 " failed\n", byte_offset); + iscsi_trace_error("lseek() to offset %" PRIu64 " failed\n", byte_offset); return -1; } if (!target_writable(&disks.v[sess->d].tv->v[sess->d])) { - TRACE_ERROR("write() of %" PRIu64 " bytes failed at offset %" PRIu64 ", size %" PRIu64 "[READONLY TARGET]\n", num_bytes, byte_offset, de_getsize(&disks.v[sess->d].tv->v[0].de)); + iscsi_trace_error("write() of %" PRIu64 " bytes failed at offset %" PRIu64 ", size %" PRIu64 "[READONLY TARGET]\n", num_bytes, byte_offset, de_getsize(&disks.v[sess->d].tv->v[0].de)); return -1; } if (de_write(&disks.v[sess->d].tv->v[sess->d].de, ptr, (unsigned) num_bytes) != num_bytes) { - TRACE_ERROR("write() of %" PRIu64 " bytes failed at offset %" PRIu64 ", size %" PRIu64 "\n", num_bytes, byte_offset, de_getsize(&disks.v[sess->d].tv->v[0].de)); + iscsi_trace_error("write() of %" PRIu64 " bytes failed at offset %" PRIu64 ", size %" PRIu64 "\n", num_bytes, byte_offset, de_getsize(&disks.v[sess->d].tv->v[0].de)); return -1; } break; case ISCSI_FS_MMAP: ptr -= (uint32_t) extra; if (de_munmap(&disks.v[sess->d].tv->v[sess->d].de, ptr, (size_t)(num_bytes + extra)) != 0) { - TRACE_ERROR("munmap() failed\n"); + iscsi_trace_error("munmap() failed\n"); return -1; } } - TRACE(TRACE_SCSI_DATA, "wrote %" PRIu64 " bytes to device OK\n", num_bytes); + iscsi_trace(TRACE_SCSI_DATA, "wrote %" PRIu64 " bytes to device OK\n", num_bytes); return 0; } @@ -1147,8 +1147,8 @@ disk_read(target_session_t * sess, iscsi_scsi_cmd_args_t * args, uint32_t lba, u RETURN_EQUAL("len", len, 0, NO_CLEANUP, -1); if ((lba > (disks.v[sess->d].blockc - 1)) || ((lba + len) > disks.v[sess->d].blockc)) { - TRACE_ERROR("attempt to read beyond end of media\n"); - TRACE_ERROR("max_lba = %" PRIu64 ", requested lba = %u, len = %u\n", disks.v[sess->d].blockc - 1, lba, len); + iscsi_trace_error("attempt to read beyond end of media\n"); + iscsi_trace_error("max_lba = %" PRIu64 ", requested lba = %u, len = %u\n", disks.v[sess->d].blockc - 1, lba, len); return -1; } switch (disks.v[sess->d].type) { @@ -1161,24 +1161,24 @@ disk_read(target_session_t * sess, iscsi_scsi_cmd_args_t * args, uint32_t lba, u n = 0; do { if (de_lseek(&disks.v[sess->d].tv->v[sess->d].de, (off_t)(n + byte_offset), SEEK_SET) == -1) { - TRACE_ERROR("lseek() failed\n"); + iscsi_trace_error("lseek() failed\n"); return -1; } rc = de_read(&disks.v[sess->d].tv->v[sess->d].de, ptr + n, (size_t)(num_bytes - n)); if (rc <= 0) { - TRACE_ERROR("read() failed: rc %i errno %i\n", rc, errno); + iscsi_trace_error("read() failed: rc %i errno %i\n", rc, errno); return -1; } n += rc; if (n < num_bytes) { - TRACE_ERROR("Got partial file read: %i bytes of %" PRIu64 "\n", rc, num_bytes - n + rc); + iscsi_trace_error("Got partial file read: %i bytes of %" PRIu64 "\n", rc, num_bytes - n + rc); } } while (n < num_bytes); break; case ISCSI_FS_MMAP: if (last_ptr[lun]) { if (de_munmap(&disks.v[sess->d].tv->v[sess->d].de, last_ptr[lun], (unsigned)(last_extra[lun] + last_num_bytes[lun])) != 0) { - TRACE_ERROR("munmap() failed\n"); + iscsi_trace_error("munmap() failed\n"); return -1; } last_ptr[lun] = NULL; @@ -1187,7 +1187,7 @@ disk_read(target_session_t * sess, iscsi_scsi_cmd_args_t * args, uint32_t lba, u } extra = byte_offset % 4096; if ((ptr = de_mmap(0, (size_t)(num_bytes + extra), PROT_READ, MAP_SHARED, &disks.v[sess->d].tv->v[0].de, (off_t)(byte_offset - extra))) == NULL) { - TRACE_ERROR("mmap() failed\n"); + iscsi_trace_error("mmap() failed\n"); return -1; } /* Need to replace this with a callback */ diff --git a/dist/iscsi/src/driver.c b/dist/iscsi/src/driver.c index 03821e7f4e26..78dff15517b5 100644 --- a/dist/iscsi/src/driver.c +++ b/dist/iscsi/src/driver.c @@ -102,13 +102,13 @@ MODULE_LICENSE("Dual BSD/GPL"); /* This source is under BSD License. This is th static int driver_init(void) { int i; - TRACE(TRACE_SCSI_DEBUG, "initializing iSCSI driver\n"); + iscsi_trace(TRACE_SCSI_DEBUG, "initializing iSCSI driver\n"); if ((g_cmd=iscsi_malloc_atomic(sizeof(initiator_cmd_t)*CONFIG_INITIATOR_QUEUE_DEPTH))==NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } if ((g_iov=iscsi_malloc_atomic(sizeof(struct iovec*)*CONFIG_INITIATOR_QUEUE_DEPTH))==NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); iscsi_free_atomic(g_cmd); return -1; } @@ -129,50 +129,50 @@ static int driver_init(void) { } for (i=0; imax_id = CONFIG_INITIATOR_NUM_TARGETS; ptr->max_lun = CONFIG_DRIVER_MAX_LUNS; ptr->max_cmd_len = 255; - TRACE(TRACE_SCSI_DEBUG, "iSCSI host detected\n"); + iscsi_trace(TRACE_SCSI_DEBUG, "iSCSI host detected\n"); spin_lock(&io_request_lock); return 1; } int iscsi_release(struct Scsi_Host *host) { - TRACE(TRACE_SCSI_DEBUG, "releasing iSCSI host\n"); + iscsi_trace(TRACE_SCSI_DEBUG, "releasing iSCSI host\n"); driver_shutdown(); - TRACE(TRACE_SCSI_DEBUG, "iSCSI host released\n"); + iscsi_trace(TRACE_SCSI_DEBUG, "iSCSI host released\n"); return 0; } @@ -228,15 +228,15 @@ int iscsi_bios_param(Disk *disk, kdev_t dev, int *ip) { ip[1] = 63; /* sectors */ ip[2] = disk->capacity / (255 * 63); /* cylinders */ } - TRACE(TRACE_SCSI_DEBUG, "%u sectors, H/S/C: %u/%u/%u\n", disk->capacity, ip[0], ip[1], ip[2]); + iscsi_trace(TRACE_SCSI_DEBUG, "%u sectors, H/S/C: %u/%u/%u\n", disk->capacity, ip[0], ip[1], ip[2]); return 0; } int iscsi_command(Scsi_Cmnd *SCpnt) { - TRACE(TRACE_SCSI_DEBUG, "0x%p: op 0x%x, chan %i, target %i, lun %i, bufflen %i, sg %i\n", + iscsi_trace(TRACE_SCSI_DEBUG, "0x%p: op 0x%x, chan %i, target %i, lun %i, bufflen %i, sg %i\n", SCpnt, SCpnt->cmnd[0], SCpnt->channel, SCpnt->target, SCpnt->lun, SCpnt->request_bufflen, SCpnt->use_sg); - TRACE_ERROR("NOT IMPLEMENTED\n"); + iscsi_trace_error("NOT IMPLEMENTED\n"); return -1; } @@ -253,10 +253,10 @@ int iscsi_done(void *ptr) { } else { SCpnt->result = -1; } - TRACE(TRACE_SCSI_DEBUG, "scsi_arg 0x%p SCpnt 0x%p op 0x%x done (result %i)\n", + iscsi_trace(TRACE_SCSI_DEBUG, "scsi_arg 0x%p SCpnt 0x%p op 0x%x done (result %i)\n", scsi_cmd, SCpnt, SCpnt->cmnd[0], SCpnt->result); if ((scsi_cmd->input)&&(scsi_cmd->output)) { - TRACE_ERROR("bidi xfers not implemented\n"); + iscsi_trace_error("bidi xfers not implemented\n"); return -1; } else if (scsi_cmd->input) { iscsi_spin_lock_irqsave(&g_stats.lock, &flags); @@ -284,13 +284,13 @@ int iscsi_done(void *ptr) { hs = SCpnt->host_scribble; SCpnt->host_scribble = NULL; /* for abort */ if (iscsi_queue_insert(&g_iovec_q, hs)!=0) { - TRACE_ERROR("iscsi_queue_insert() failed\n"); + iscsi_trace_error("iscsi_queue_insert() failed\n"); return -1; } } iscsi_free_atomic(scsi_cmd->ahs); if (iscsi_queue_insert(&g_cmd_q, cmd)!=0) { - TRACE_ERROR("iscsi_queue_insert() failed\n"); + iscsi_trace_error("iscsi_queue_insert() failed\n"); cmd->callback_arg = NULL; /* for abort */ return -1; } @@ -298,7 +298,7 @@ int iscsi_done(void *ptr) { if (SCpnt->result==0) { SCpnt->scsi_done(SCpnt); } else { - TRACE_ERROR("SCSI cmd 0x%x failed at iSCSI level (ignoring)\n", SCpnt->cmnd[0]); + iscsi_trace_error("SCSI cmd 0x%x failed at iSCSI level (ignoring)\n", SCpnt->cmnd[0]); } return 0; } @@ -317,7 +317,7 @@ int iscsi_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) { spin_unlock(&io_request_lock); - TRACE(TRACE_SCSI_DEBUG, "SCpnt %p: tid %i lun %i op 0x%x tag %u len %i sg %i buff 0x%p\n", + iscsi_trace(TRACE_SCSI_DEBUG, "SCpnt %p: tid %i lun %i op 0x%x tag %u len %i sg %i buff 0x%p\n", SCpnt, SCpnt->target, SCpnt->lun, SCpnt->cmnd[0], SCpnt->tag, SCpnt->request_bufflen, SCpnt->use_sg, SCpnt->buffer); @@ -352,7 +352,7 @@ int iscsi_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) { iov = iscsi_queue_remove(&g_iovec_q); if (iov == NULL) { - TRACE_ERROR("iscsi_queue_remove() failed\n"); + iscsi_trace_error("iscsi_queue_remove() failed\n"); spin_lock(&io_request_lock); return -1; } @@ -369,7 +369,7 @@ int iscsi_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) { /* Get free cmd structure */ if ((cmd=iscsi_queue_remove(&g_cmd_q))==NULL) { - TRACE_ERROR("iscsi_queue_remove() failed\n"); + iscsi_trace_error("iscsi_queue_remove() failed\n"); spin_lock(&io_request_lock); return -1; } @@ -390,9 +390,9 @@ int iscsi_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) { /* AHS for CDBs larget than 16 bytes */ if (SCpnt->cmd_len>16) { - TRACE(TRACE_ISCSI_DEBUG, "creating AHS for extended CDB (%i bytes)\n", SCpnt->cmd_len); + iscsi_trace(TRACE_ISCSI_DEBUG, "creating AHS for extended CDB (%i bytes)\n", SCpnt->cmd_len); if ((scsi_cmd->ahs=iscsi_malloc_atomic(SCpnt->cmd_len-16))==NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); spin_lock(&io_request_lock); return -1; } @@ -409,7 +409,7 @@ int iscsi_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) { cmd->callback_arg = SCpnt; cmd->isid = SCpnt->target; if (initiator_enqueue(cmd)!=0) { - TRACE_ERROR("initiator_enqueue() failed\n"); + iscsi_trace_error("initiator_enqueue() failed\n"); if (SCpnt->cmd_len>16) iscsi_free_atomic(scsi_cmd->ahs); spin_lock(&io_request_lock); return -1; @@ -423,7 +423,7 @@ int iscsi_proc_info (char *buffer, char **start, off_t offset, int length, int h uint32_t infolen = 8192; int len = 0; - TRACE(TRACE_SCSI_DEBUG, "buffer = 0x%p, offset %u, length = %i, hostno %i, writing %i\n", + iscsi_trace(TRACE_SCSI_DEBUG, "buffer = 0x%p, offset %u, length = %i, hostno %i, writing %i\n", buffer, (unsigned) offset, length, hostno, writing); /* writing resets counters */ @@ -440,7 +440,7 @@ int iscsi_proc_info (char *buffer, char **start, off_t offset, int length, int h return 0; } else { if ((info=iscsi_malloc_atomic(infolen))==NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } len += snprintf(info, infolen, "%s\n\n", driver_template.name); @@ -479,7 +479,7 @@ int iscsi_proc_info (char *buffer, char **start, off_t offset, int length, int h len += snprintf(&info[len], infolen - len, "--------------------\n\n"); if ((len += initiator_info(&info[len], infolen, len))==-1) { - TRACE_ERROR("initiator_info() failed\n"); + iscsi_trace_error("initiator_info() failed\n"); if (info != NULL) iscsi_free_atomic(info); return -1; } @@ -505,7 +505,7 @@ int iscsi_ioctl (Scsi_Device *dev, int cmd, void *argp) { for (i=0; inext) { if (device->host != host) { - TRACE_ERROR("got device for different host\n"); + iscsi_trace_error("got device for different host\n"); continue; } if (device->tagged_supported) { - TRACE(TRACE_SCSI_DEBUG, "target %i lun %i supports TCQ\n", device->id, device->lun); + iscsi_trace(TRACE_SCSI_DEBUG, "target %i lun %i supports TCQ\n", device->id, device->lun); device->tagged_queue = 1; device->current_tag = 0; device->queue_depth = CONFIG_INITIATOR_QUEUE_DEPTH; - TRACE(TRACE_SCSI_DEBUG, "device queue depth set to %i\n", device->queue_depth); + iscsi_trace(TRACE_SCSI_DEBUG, "device queue depth set to %i\n", device->queue_depth); } else { - TRACE(TRACE_SCSI_DEBUG, "target %i lun %i does NOT support TCQ\n", device->id, device->lun); + iscsi_trace(TRACE_SCSI_DEBUG, "target %i lun %i does NOT support TCQ\n", device->id, device->lun); device->queue_depth = 1; } } @@ -545,7 +545,7 @@ int iscsi_abort_handler (Scsi_Cmnd *SCpnt) { unsigned long flags; spin_unlock_irq(&io_request_lock); - TRACE_ERROR("aborting SCSI cmd 0x%p (op 0x%x, tid %i, lun %i)\n", + iscsi_trace_error("aborting SCSI cmd 0x%p (op 0x%x, tid %i, lun %i)\n", SCpnt, SCpnt->cmnd[0], SCpnt->target, SCpnt->lun); @@ -561,7 +561,7 @@ int iscsi_abort_handler (Scsi_Cmnd *SCpnt) { /* Abort the command */ if (initiator_abort(&g_cmd[i])!=0) { - TRACE_ERROR("initiator_abort() failed\n"); + iscsi_trace_error("initiator_abort() failed\n"); spin_lock_irq(&io_request_lock); return FAILED; } @@ -570,7 +570,7 @@ int iscsi_abort_handler (Scsi_Cmnd *SCpnt) { scsi_cmd = (iscsi_scsi_cmd_args_t *) g_cmd[i].ptr; if ((scsi_cmd->input)&&(scsi_cmd->output)) { - TRACE_ERROR("bidi xfers not implemented\n"); + iscsi_trace_error("bidi xfers not implemented\n"); spin_lock_irq(&io_request_lock); return FAILED; } else if (scsi_cmd->input) { @@ -595,58 +595,58 @@ int iscsi_abort_handler (Scsi_Cmnd *SCpnt) { #if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0) if (in_interrupt()) { - TRACE_ERROR("aborting within interrupt (killing Tx and Rx threads)\n"); + iscsi_trace_error("aborting within interrupt (killing Tx and Rx threads)\n"); #endif - TRACE_ERROR("killing Tx and Rx threads\n"); + iscsi_trace_error("killing Tx and Rx threads\n"); kill_proc(sess->rx_worker.pid, SIGKILL, 1); kill_proc(sess->tx_worker.pid, SIGKILL, 1); sess->tx_worker.state = 0; sess->rx_worker.state = 0; #if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0) } else { - TRACE_ERROR("aborting outside interrupt (gracefully ending Tx and Rx)\n"); + iscsi_trace_error("aborting outside interrupt (gracefully ending Tx and Rx)\n"); } #endif - TRACE(TRACE_ISCSI_DEBUG, "destroying session\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "destroying session\n"); if (session_destroy_i(sess)!=0) { - TRACE_ERROR("session_destroy() failed\n"); + iscsi_trace_error("session_destroy() failed\n"); g_stats.aborts_failed++; spin_lock_irq(&io_request_lock); return FAILED; } } else { - TRACE(TRACE_ISCSI_DEBUG, "no session\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "no session\n"); } g_stats.aborts_success++; - TRACE_ERROR("successfully aborted SCSI cmd 0x%p (op 0x%x, tid %i, lun %i)\n", + iscsi_trace_error("successfully aborted SCSI cmd 0x%p (op 0x%x, tid %i, lun %i)\n", SCpnt, SCpnt->cmnd[0], SCpnt->target, SCpnt->lun); spin_lock_irq(&io_request_lock); return SUCCESS; } int iscsi_device_reset_handler (Scsi_Cmnd *SCpnt) { - TRACE_ERROR("***********************\n"); - TRACE_ERROR("*** DEVICE %i RESET ***\n", SCpnt->target); - TRACE_ERROR("***********************\n"); + iscsi_trace_error("***********************\n"); + iscsi_trace_error("*** DEVICE %i RESET ***\n", SCpnt->target); + iscsi_trace_error("***********************\n"); g_stats.device_resets++; return SUCCESS; } int iscsi_bus_reset_handler (Scsi_Cmnd *SCpnt) { - TRACE_ERROR("********************\n"); - TRACE_ERROR("*** BUS %i RESET ***\n", SCpnt->target); - TRACE_ERROR("********************\n"); + iscsi_trace_error("********************\n"); + iscsi_trace_error("*** BUS %i RESET ***\n", SCpnt->target); + iscsi_trace_error("********************\n"); g_stats.bus_resets++; return SUCCESS; } int iscsi_host_reset_handler(Scsi_Cmnd *SCpnt) { - TRACE_ERROR("*********************\n"); - TRACE_ERROR("*** HOST RESET %i ***\n", SCpnt->target); - TRACE_ERROR("*********************\n"); + iscsi_trace_error("*********************\n"); + iscsi_trace_error("*** HOST RESET %i ***\n", SCpnt->target); + iscsi_trace_error("*********************\n"); g_stats.host_resets++; return SUCCESS; } diff --git a/dist/iscsi/src/initiator.c b/dist/iscsi/src/initiator.c index 168a204edb60..af39a71d8ef2 100644 --- a/dist/iscsi/src/initiator.c +++ b/dist/iscsi/src/initiator.c @@ -175,11 +175,11 @@ session_init_i(initiator_session_t ** sess, uint64_t isid) int mutual_auth; int one = 1; - TRACE(TRACE_ISCSI_DEBUG, "initializing session %llu\n", isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "initializing session %llu\n", isid); /* Get free session */ if ((*sess = iscsi_queue_remove(&g_session_q)) == NULL) { - TRACE_ERROR("iscsi_queue_remove() failed\n"); + iscsi_trace_error("iscsi_queue_remove() failed\n"); return -1; } s = *sess; @@ -203,11 +203,11 @@ session_init_i(initiator_session_t ** sess, uint64_t isid) /* Create socket */ if (iscsi_sock_create(&s->sock) != 0) { - TRACE_ERROR("iscsi_sock_create() failed\n"); + iscsi_trace_error("iscsi_sock_create() failed\n"); return -1; } if (iscsi_sock_setsockopt(&s->sock, SOL_TCP, TCP_NODELAY, &one, sizeof(one)) != 0) { - TRACE_ERROR("iscsi_sock_setsockopt() failed\n"); + iscsi_trace_error("iscsi_sock_setsockopt() failed\n"); return -1; } /* Initialize wait queues */ @@ -268,27 +268,27 @@ session_init_i(initiator_session_t ** sess, uint64_t isid) /* Start Tx worker */ - TRACE(TRACE_ISCSI_DEBUG, "starting Tx worker %llu\n", isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "starting Tx worker %llu\n", isid); if (iscsi_queue_init(&s->tx_queue, CONFIG_INITIATOR_QUEUE_DEPTH) == -1) { - TRACE_ERROR("iscsi_queue_init() failed\n"); + iscsi_trace_error("iscsi_queue_init() failed\n"); return -1; } ISCSI_LOCK(&s->tx_worker.exit_mutex, return -1); if (iscsi_thread_create(&s->tx_worker.thread, (void *) tx_worker_proc_i, &s->tx_worker) != 0) { - TRACE_ERROR("iscsi_threads_create() failed\n"); + iscsi_trace_error("iscsi_threads_create() failed\n"); return -1; } ISCSI_WAIT(&s->tx_worker.exit_cond, &s->tx_worker.exit_mutex, return -1); ISCSI_UNLOCK(&s->tx_worker.exit_mutex, return -1); if (s->state == INITIATOR_SESSION_STATE_DESTROYING) { - TRACE(TRACE_ISCSI_DEBUG, "session %llu is being destroyed, exiting\n", isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "session %llu is being destroyed, exiting\n", isid); return -1; } if (s->tx_worker.state & ISCSI_WORKER_STATE_ERROR) { - TRACE_ERROR("Tx worker %llu started with an error\n", isid); + iscsi_trace_error("Tx worker %llu started with an error\n", isid); return -1; } - TRACE(TRACE_ISCSI_DEBUG, "got signal from Tx worker\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "got signal from Tx worker\n"); s->state = INITIATOR_SESSION_STATE_INITIALIZED; return 0; @@ -301,11 +301,11 @@ session_destroy_i(initiator_session_t * sess) uint64_t isid = sess->isid; if (sess == NULL) { - TRACE_ERROR("session pointer is NULL\n"); + iscsi_trace_error("session pointer is NULL\n"); return -1; } if (g_target[sess->isid].has_session == 0) { - TRACE_ERROR("g_target[%llu].has_session==0??\n", sess->isid); + iscsi_trace_error("g_target[%llu].has_session==0??\n", sess->isid); return -1; } sess->state = INITIATOR_SESSION_STATE_DESTROYING; @@ -314,64 +314,64 @@ session_destroy_i(initiator_session_t * sess) for (ptr = sess->cmds; ptr != NULL; ptr = ptr->next) { if (initiator_abort(ptr) != 0) { - TRACE_ERROR("initiator_abort() failed\n"); + iscsi_trace_error("initiator_abort() failed\n"); return -1; } } if (sess->tx_worker.state & ISCSI_WORKER_STATE_STARTED) { if (sess->tx_worker.state & ISCSI_WORKER_STATE_EXITING) { - TRACE(TRACE_ISCSI_DEBUG, "Tx worker %llu already signalled for exit\n", sess->isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "Tx worker %llu already signalled for exit\n", sess->isid); } else { - TRACE(TRACE_ISCSI_DEBUG, "signaling Tx worker %llu into exiting state\n", sess->isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "signaling Tx worker %llu into exiting state\n", sess->isid); ISCSI_LOCK(&sess->tx_worker.work_mutex, return -1); - TRACE(TRACE_ISCSI_DEBUG, "signaling socket shutdown to Tx worker %llu\n", sess->isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "signaling socket shutdown to Tx worker %llu\n", sess->isid); if (iscsi_sock_shutdown(sess->sock, 1) != 0) { - TRACE_ERROR("iscsi_sock_shutdown() failed\n"); + iscsi_trace_error("iscsi_sock_shutdown() failed\n"); } ISCSI_SIGNAL(&sess->tx_worker.work_cond, return -1); ISCSI_UNLOCK(&sess->tx_worker.work_mutex, return -1); } - TRACE(TRACE_ISCSI_DEBUG, "Checking exit condition of Tx worker\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "Checking exit condition of Tx worker\n"); while ((sess->tx_worker.state & ISCSI_WORKER_STATE_EXITING) != ISCSI_WORKER_STATE_EXITING) { ISCSI_SPIN; } - TRACE(TRACE_ISCSI_DEBUG, "Tx worker %llu has exited\n", sess->isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "Tx worker %llu has exited\n", sess->isid); } else { - TRACE(TRACE_ISCSI_DEBUG, "Tx worker was not started. Nothing to signal\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "Tx worker was not started. Nothing to signal\n"); } /* Destroy Tx state */ while ((ptr = iscsi_queue_remove(&sess->tx_queue)) != NULL) { ptr->status = -1; if (ptr->callback && ((*ptr->callback)(ptr) != 0)) { - TRACE_ERROR("callback() failed\n"); + iscsi_trace_error("callback() failed\n"); } } iscsi_queue_destroy(&sess->tx_queue); if (sess->rx_worker.state & ISCSI_WORKER_STATE_STARTED) { if (sess->rx_worker.state & ISCSI_WORKER_STATE_EXITING) { - TRACE(TRACE_ISCSI_DEBUG, "Rx worker %llu already signalled for exit\n", sess->isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "Rx worker %llu already signalled for exit\n", sess->isid); } else { - TRACE(TRACE_ISCSI_DEBUG, "signaling Rx worker %llu into exiting state\n", sess->isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "signaling Rx worker %llu into exiting state\n", sess->isid); if (iscsi_sock_shutdown(sess->sock, 0) != 0) { - TRACE_ERROR("iscsi_sock_shutdown() failed\n"); + iscsi_trace_error("iscsi_sock_shutdown() failed\n"); } } - TRACE(TRACE_ISCSI_DEBUG, "Checking exit condition of Rx worker\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "Checking exit condition of Rx worker\n"); while ((sess->rx_worker.state & ISCSI_WORKER_STATE_EXITING) != ISCSI_WORKER_STATE_EXITING) { ISCSI_SPIN; } - TRACE(TRACE_ISCSI_DEBUG, "Rx worker %llu has exited\n", sess->isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "Rx worker %llu has exited\n", sess->isid); } else { - TRACE(TRACE_ISCSI_DEBUG, "Rx worker was not started. Nothing to signal\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "Rx worker was not started. Nothing to signal\n"); } /* Close socket */ if (iscsi_sock_close(sess->sock) != 0) { - TRACE_ERROR("iscsi_sock_close() failed\n"); + iscsi_trace_error("iscsi_sock_close() failed\n"); return -1; } /* Destroy wait queues */ @@ -391,10 +391,10 @@ session_destroy_i(initiator_session_t * sess) /* Enqueue session to free list */ if (iscsi_queue_insert(&g_session_q, sess) == -1) { - TRACE_ERROR("iscsi_queue_insert() failed\n"); + iscsi_trace_error("iscsi_queue_insert() failed\n"); return -1; } - TRACE(TRACE_ISCSI_DEBUG, "session %p destroyed and requeued\n", sess); + iscsi_trace(TRACE_ISCSI_DEBUG, "session %p destroyed and requeued\n", sess); g_target[isid].has_session = 0; @@ -458,12 +458,12 @@ full_feature_negotiation_phase_i(initiator_session_t * sess, char *text, int tex /* Allocate command pointers */ if ((cmd = iscsi_malloc_atomic(sizeof(initiator_cmd_t))) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); return -1; } (void) memset(cmd, 0x0, sizeof(*cmd)); if ((text_cmd = iscsi_malloc_atomic(sizeof(iscsi_text_cmd_args_t))) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); if (cmd != NULL) iscsi_free_atomic(cmd); /* initiator command */ return -1; @@ -503,26 +503,26 @@ full_feature_negotiation_phase_i(initiator_session_t * sess, char *text, int tex /* Enqueue initiator command to Tx worker */ - TRACE(TRACE_ISCSI_DEBUG, "enqueing text command to tx worker %llu\n", sess->isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueing text command to tx worker %llu\n", sess->isid); ISCSI_LOCK(&wait.mutex, FFN_ERROR); ISCSI_LOCK(&sess->tx_worker.work_mutex, FFN_ERROR); if (iscsi_queue_insert(&sess->tx_queue, cmd) == -1) { ISCSI_UNLOCK(&wait.mutex, ); - TRACE_ERROR("iscsi_queue_insert() failed\n"); + iscsi_trace_error("iscsi_queue_insert() failed\n"); FFN_ERROR; } ISCSI_SIGNAL(&sess->tx_worker.work_cond, FFN_ERROR); ISCSI_UNLOCK(&sess->tx_worker.work_mutex, FFN_ERROR); - TRACE(TRACE_ISCSI_DEBUG, "enqueued text command ok\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueued text command ok\n"); /* Wait for callback */ - TRACE(TRACE_ISCSI_DEBUG, "waiting on text callback\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "waiting on text callback\n"); ISCSI_WAIT(&wait.cond, &wait.mutex, FFN_ERROR); ISCSI_UNLOCK(&wait.mutex, FFN_ERROR); ISCSI_COND_DESTROY(&wait.cond, FFN_ERROR); ISCSI_MUTEX_DESTROY(&wait.mutex, FFN_ERROR); - TRACE(TRACE_ISCSI_DEBUG, "received text callback ok\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "received text callback ok\n"); /* * See if we're done. text_response_i() overwrites @@ -531,7 +531,7 @@ full_feature_negotiation_phase_i(initiator_session_t * sess, char *text, int tex /* with the final bit in the text response from the target. */ if (!text_cmd->final) { - TRACE(TRACE_ISCSI_PARAM, "more negotiation needed (sending %i bytes response parameters)\n", + iscsi_trace(TRACE_ISCSI_PARAM, "more negotiation needed (sending %i bytes response parameters)\n", text_cmd->length); } } while (!text_cmd->final); @@ -556,24 +556,24 @@ discovery_phase(int target, strv_t *svp) int text_len = 0; if ((text = iscsi_malloc_atomic(1024)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } #define DP_CLEANUP {if (text != NULL) iscsi_free_atomic(text);} #define DP_ERROR {DP_CLEANUP; return -1;} /* Login to target */ - TRACE(TRACE_ISCSI_DEBUG, "entering Discovery login phase with target %i (sock 0x%x)\n", target, (int) sess->sock); + iscsi_trace(TRACE_ISCSI_DEBUG, "entering Discovery login phase with target %i (sock 0x%x)\n", target, (int) sess->sock); text[0] = 0x0; if (params_out(sess, text, &text_len, 1024, SESS_TYPE_DISCOVERY, IS_SECURITY) != 0) { - TRACE_ERROR("params_out() failed\n"); + iscsi_trace_error("params_out() failed\n"); DP_ERROR; } if (login_phase_i(sess, text, text_len) != 0) { - TRACE_ERROR("login_phase_i() failed\n"); + iscsi_trace_error("login_phase_i() failed\n"); DP_ERROR; } - TRACE(TRACE_ISCSI_DEBUG, "now full feature for Discovery with target %i\n", target); + iscsi_trace(TRACE_ISCSI_DEBUG, "now full feature for Discovery with target %i\n", target); /* Full Feature Phase Negotiation (for SendTargets) */ @@ -582,7 +582,7 @@ discovery_phase(int target, strv_t *svp) PARAM_TEXT_ADD(sess->params, "SendTargets", "all", text, &text_len, 1024, 1, DP_ERROR); PARAM_TEXT_PARSE(sess->params, &sess->sess_params.cred, text, text_len, NULL, NULL, 1024, 1, DP_ERROR); if (full_feature_negotiation_phase_i(sess, text, text_len) != 0) { - TRACE_ERROR("full_feature_negotiation_phase_i() failed\n"); + iscsi_trace_error("full_feature_negotiation_phase_i() failed\n"); DP_ERROR; } @@ -593,7 +593,7 @@ discovery_phase(int target, strv_t *svp) if (param_val(sess->params, "TargetName") != NULL) { strlcpy(g_target[target].TargetName, param_val(sess->params, "TargetName"), sizeof(g_target[target].TargetName)); } else { - TRACE_ERROR("SendTargets failed\n"); + iscsi_trace_error("SendTargets failed\n"); DP_ERROR; } @@ -614,7 +614,7 @@ discovery_phase(int target, strv_t *svp) ptr = param_val(sess->params, "TargetAddress"); colon_ptr = strchr(ptr, ':'); if ((comma_ptr = strchr(ptr, ',')) == NULL) { - TRACE_ERROR("portal group tag is missing in \"%s\"\n", param_val(sess->params, "TargetAddress")); + iscsi_trace_error("portal group tag is missing in \"%s\"\n", param_val(sess->params, "TargetAddress")); DP_ERROR; } if (colon_ptr) { @@ -627,21 +627,21 @@ discovery_phase(int target, strv_t *svp) g_target[target].port = ISCSI_PORT; } } else { - TRACE_ERROR("SendTargets failed\n"); + iscsi_trace_error("SendTargets failed\n"); DP_ERROR; } - TRACE(TRACE_ISCSI_DEBUG, "Discovered \"%s\" at \"%s:%u\"\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "Discovered \"%s\" at \"%s:%u\"\n", g_target[target].TargetName, g_target[target].ip, g_target[target].port); /* Logout from target */ - TRACE(TRACE_ISCSI_DEBUG, "entering logout phase with target %i\n", target); + iscsi_trace(TRACE_ISCSI_DEBUG, "entering logout phase with target %i\n", target); if (logout_phase_i(sess) != 0) { - TRACE_ERROR("logout_phase_i() failed\n"); + iscsi_trace_error("logout_phase_i() failed\n"); DP_ERROR; } - TRACE(TRACE_ISCSI_DEBUG, "target %i logout phase complete\n", target); + iscsi_trace(TRACE_ISCSI_DEBUG, "target %i logout phase complete\n", target); DP_CLEANUP; return 0; @@ -654,7 +654,7 @@ full_feature_phase(initiator_session_t * sess) int text_len; if ((text = iscsi_malloc_atomic(1024)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } #define FFP_CLEANUP {if (text != NULL) iscsi_free_atomic(text);} @@ -664,17 +664,17 @@ full_feature_phase(initiator_session_t * sess) text[0] = 0x0; text_len = 0; if (params_out(sess, text, &text_len, 1024, SESS_TYPE_NORMAL, IS_SECURITY) != 0) { - TRACE_ERROR("params_out() failed\n"); + iscsi_trace_error("params_out() failed\n"); FFP_ERROR; } /* Send login command */ - TRACE(TRACE_ISCSI_DEBUG, "entering login phase\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "entering login phase\n"); if (login_phase_i(sess, text, text_len) != 0) { - TRACE_ERROR("login_phase_i() failed\n"); + iscsi_trace_error("login_phase_i() failed\n"); FFP_ERROR; } - TRACE(TRACE_ISCSI_DEBUG, "login phase successful\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "login phase successful\n"); FFP_CLEANUP; return 0; @@ -688,24 +688,24 @@ initiator_init(const char *hostname, const char *user, int auth_type, int mutual #define INIT_CLEANUP {if (sess != NULL) iscsi_free_atomic(sess);} #define INIT_ERROR {INIT_CLEANUP; return -1;} - TRACE(TRACE_ISCSI_DEBUG, "initializing initiator\n"); - TRACE(TRACE_ISCSI_DEBUG, "target config filename to read from:%s\n", gfilename); + iscsi_trace(TRACE_ISCSI_DEBUG, "initializing initiator\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "target config filename to read from:%s\n", gfilename); if (get_target_config(hostname) != 0) { - TRACE_ERROR("Error getting target configuration from config file\n"); + iscsi_trace_error("Error getting target configuration from config file\n"); return -1; } g_initiator_state = 0; if (iscsi_queue_init(&g_session_q, CONFIG_INITIATOR_MAX_SESSIONS) != 0) { - TRACE_ERROR("iscsi_queue_init() failed\n"); + iscsi_trace_error("iscsi_queue_init() failed\n"); return -1; } for (i = 0; i < CONFIG_INITIATOR_MAX_SESSIONS; i++) { if ((sess = iscsi_malloc_atomic(sizeof(initiator_session_t))) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } if (iscsi_queue_insert(&g_session_q, sess) != 0) { - TRACE_ERROR("iscsi_queue_init() failed\n"); + iscsi_trace_error("iscsi_queue_init() failed\n"); INIT_CLEANUP; return -1; } @@ -714,16 +714,16 @@ initiator_init(const char *hostname, const char *user, int auth_type, int mutual sess->sess_params.mutual_auth = mutual_auth; sess->sess_params.digest_wanted = digest_type; } - TRACE(TRACE_ISCSI_DEBUG, "%i free sessions available\n", CONFIG_INITIATOR_MAX_SESSIONS); + iscsi_trace(TRACE_ISCSI_DEBUG, "%i free sessions available\n", CONFIG_INITIATOR_MAX_SESSIONS); g_tag = 0xabc123; if (hash_init(&g_tag_hash, CONFIG_INITIATOR_QUEUE_DEPTH) != 0) { - TRACE_ERROR("hash_init() failed\n"); + iscsi_trace_error("hash_init() failed\n"); INIT_CLEANUP; return -1; } iscsi_spin_init(&g_tag_spin); - TRACE(TRACE_ISCSI_DEBUG, "tag hash table initialized with queue depth %i\n", CONFIG_INITIATOR_QUEUE_DEPTH); + iscsi_trace(TRACE_ISCSI_DEBUG, "tag hash table initialized with queue depth %i\n", CONFIG_INITIATOR_QUEUE_DEPTH); /* * Start enqueue worker. This thread accepts scsi commands from @@ -731,31 +731,31 @@ initiator_init(const char *hostname, const char *user, int auth_type, int mutual */ /* and queues them onto one of the tx worker queues. */ - TRACE(TRACE_ISCSI_DEBUG, "starting enqueue worker\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "starting enqueue worker\n"); if (iscsi_queue_init(&g_enqueue_q, CONFIG_INITIATOR_QUEUE_DEPTH) != 0) { - TRACE_ERROR("iscsi_queue_init() failed\n"); + iscsi_trace_error("iscsi_queue_init() failed\n"); INIT_CLEANUP; return -1; } - TRACE(TRACE_ISCSI_DEBUG, "about to initialize mutex\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "about to initialize mutex\n"); ISCSI_MUTEX_INIT(&g_enqueue_worker.work_mutex, INIT_ERROR); ISCSI_COND_INIT(&g_enqueue_worker.work_cond, INIT_ERROR); ISCSI_MUTEX_INIT(&g_enqueue_worker.exit_mutex, INIT_ERROR); ISCSI_COND_INIT(&g_enqueue_worker.exit_cond, INIT_ERROR); ISCSI_LOCK(&g_enqueue_worker.exit_mutex, INIT_ERROR); - TRACE(TRACE_ISCSI_DEBUG, "spawning thread for enqueue worker\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "spawning thread for enqueue worker\n"); if (iscsi_thread_create(&g_enqueue_worker.thread, (void *) &enqueue_worker_proc, &g_enqueue_worker) != 0) { - TRACE_ERROR("iscsi_threads_create() failed\n"); + iscsi_trace_error("iscsi_threads_create() failed\n"); INIT_CLEANUP; return -1; } - TRACE(TRACE_ISCSI_DEBUG, "thread spawned, waiting for signal\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "thread spawned, waiting for signal\n"); ISCSI_WAIT(&g_enqueue_worker.exit_cond, &g_enqueue_worker.exit_mutex, INIT_ERROR); ISCSI_UNLOCK(&g_enqueue_worker.exit_mutex, INIT_ERROR); - TRACE(TRACE_ISCSI_DEBUG, "successfully started enqueue worker\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "successfully started enqueue worker\n"); - TRACE(TRACE_ISCSI_DEBUG, "initiator initialization complete\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "initiator initialization complete\n"); return 0; } @@ -765,42 +765,42 @@ initiator_shutdown(void) initiator_session_t *sess; int i; - TRACE(TRACE_ISCSI_DEBUG, "shutting down initiator\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "shutting down initiator\n"); for (i = 0; i < CONFIG_INITIATOR_NUM_TARGETS; i++) { if (g_target[i].has_session) { - TRACE(TRACE_ISCSI_DEBUG, "entering logout phase for target %i\n", i); + iscsi_trace(TRACE_ISCSI_DEBUG, "entering logout phase for target %i\n", i); if (g_target[i].sess->rx_worker.state & ISCSI_WORKER_STATE_ERROR) { - TRACE_WARNING("rx worker exited abnormal, skipping logout phase\n"); + iscsi_trace_warning("rx worker exited abnormal, skipping logout phase\n"); } else { if (logout_phase_i(g_target[i].sess) != 0) { - TRACE_ERROR("logout_phase_i() failed for target %i\n", i); + iscsi_trace_error("logout_phase_i() failed for target %i\n", i); } - TRACE(TRACE_ISCSI_DEBUG, "logout phase complete for target %i (state 0x%x)\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "logout phase complete for target %i (state 0x%x)\n", i, g_target[i].sess->state); } - TRACE(TRACE_ISCSI_DEBUG, "destroying session for target %i\n", i); + iscsi_trace(TRACE_ISCSI_DEBUG, "destroying session for target %i\n", i); if (session_destroy_i(g_target[i].sess) != 0) { - TRACE_ERROR("session_destroy_i() failed for target %i\n", i); + iscsi_trace_error("session_destroy_i() failed for target %i\n", i); } - TRACE(TRACE_ISCSI_DEBUG, "session destroyed for target %i\n", i); + iscsi_trace(TRACE_ISCSI_DEBUG, "session destroyed for target %i\n", i); } } g_initiator_state = INITIATOR_STATE_SHUTDOWN; if (g_enqueue_worker.state & ISCSI_WORKER_STATE_EXITING) { - TRACE(TRACE_ISCSI_DEBUG, "enqueue already exiting\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue already exiting\n"); } else { - TRACE(TRACE_ISCSI_DEBUG, "signaling enqueue worker into exiting state\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "signaling enqueue worker into exiting state\n"); ISCSI_LOCK(&g_enqueue_worker.work_mutex, return -1); ISCSI_SIGNAL(&g_enqueue_worker.work_cond, return -1); ISCSI_UNLOCK(&g_enqueue_worker.work_mutex, return -1); } - TRACE(TRACE_ISCSI_DEBUG, "Checking exit condition of enqueue worker\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "Checking exit condition of enqueue worker\n"); while ((g_enqueue_worker.state & ISCSI_WORKER_STATE_EXITING) != ISCSI_WORKER_STATE_EXITING) { ISCSI_SPIN; } - TRACE(TRACE_ISCSI_DEBUG, "enqueue worker has exited\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue worker has exited\n"); iscsi_queue_destroy(&g_enqueue_q); ISCSI_MUTEX_DESTROY(&g_enqueue_worker.work_mutex, return -1); @@ -814,7 +814,7 @@ initiator_shutdown(void) iscsi_queue_destroy(&g_session_q); iscsi_spin_destroy(&g_tag_spin); hash_destroy(&g_tag_hash); - TRACE(TRACE_ISCSI_DEBUG, "initiator shutdown complete\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "initiator shutdown complete\n"); return 0; } @@ -835,7 +835,7 @@ initiator_abort(initiator_cmd_t * cmd) initiator_cmd_t *ptr, *prev; initiator_session_t *sess; - TRACE_ERROR("aborting iSCSI cmd 0x%p (type %i, isid %llu)\n", + iscsi_trace_error("aborting iSCSI cmd 0x%p (type %i, isid %llu)\n", cmd, cmd->type, cmd->isid); hash_remove(&g_tag_hash, cmd->key); @@ -858,16 +858,16 @@ initiator_abort(initiator_cmd_t * cmd) } iscsi_spin_unlock(&sess->cmds_spin); } else { - TRACE_ERROR("cmd 0x%p has no session\n", cmd); + iscsi_trace_error("cmd 0x%p has no session\n", cmd); } cmd->status = -1; if (cmd->callback) { if ((*cmd->callback)(cmd) != 0) { - TRACE_ERROR("cmd->callback() failed\n"); + iscsi_trace_error("cmd->callback() failed\n"); return -1; } } - TRACE_ERROR("successfully aborted iSCSI cmd 0x%p (type %i, isid %llu)\n", + iscsi_trace_error("successfully aborted iSCSI cmd 0x%p (type %i, isid %llu)\n", cmd, cmd->type, cmd->isid); return 0; } @@ -884,12 +884,12 @@ initiator_command(initiator_cmd_t * cmd) cmd->callback_arg = &wait; cmd->status = -1; if (initiator_enqueue(cmd) != 0) { - TRACE_ERROR("initiator_enqueue() failed\n"); + iscsi_trace_error("initiator_enqueue() failed\n"); return -1; } else { - TRACE(TRACE_ISCSI_DEBUG, "command (type %i) enqueued, waiting on condition\n", cmd->type); + iscsi_trace(TRACE_ISCSI_DEBUG, "command (type %i) enqueued, waiting on condition\n", cmd->type); ISCSI_WAIT(&wait.cond, &wait.mutex, return -1); - TRACE(TRACE_ISCSI_DEBUG, "condition signaled\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "condition signaled\n"); } ISCSI_UNLOCK(&wait.mutex, return -1); ISCSI_COND_DESTROY(&wait.cond, return -1); @@ -933,17 +933,17 @@ initiator_enqueue(initiator_cmd_t * cmd) } break; default: - TRACE_ERROR("enqueue_worker: unknown command type %i\n", cmd->type); + iscsi_trace_error("enqueue_worker: unknown command type %i\n", cmd->type); return -1; } if (iscsi_queue_insert(&sess->tx_queue, cmd) == -1) { - TRACE_ERROR("iscsi_queue_insert() failed\n"); + iscsi_trace_error("iscsi_queue_insert() failed\n"); return -1; } ISCSI_LOCK(&sess->tx_worker.work_mutex, return -1); ISCSI_SIGNAL(&sess->tx_worker.work_cond, return -1); ISCSI_UNLOCK(&sess->tx_worker.work_mutex, return -1); - TRACE(TRACE_ISCSI_DEBUG, "initiator_cmd_t 0x%p given to tx_worker[%llu]\n", cmd, cmd->isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "initiator_cmd_t 0x%p given to tx_worker[%llu]\n", cmd, cmd->isid); } else { /* @@ -953,13 +953,13 @@ initiator_enqueue(initiator_cmd_t * cmd) /* to one of the tx workers. */ if (iscsi_queue_insert(&g_enqueue_q, cmd) == -1) { - TRACE_ERROR("iscsi_queue_insert() failed\n"); + iscsi_trace_error("iscsi_queue_insert() failed\n"); return -1; } ISCSI_LOCK(&g_enqueue_worker.work_mutex, return -1); ISCSI_SIGNAL(&g_enqueue_worker.work_cond, return -1); ISCSI_UNLOCK(&g_enqueue_worker.work_mutex, return -1); - TRACE(TRACE_ISCSI_DEBUG, "initiator_cmd_t 0x%p given to enqueue worker\n", cmd); + iscsi_trace(TRACE_ISCSI_DEBUG, "initiator_cmd_t 0x%p given to enqueue worker\n", cmd); } return 0; } @@ -987,23 +987,23 @@ enqueue_worker_proc(void *arg) me->state = ISCSI_WORKER_STATE_STARTED; ISCSI_SIGNAL(&me->exit_cond, goto done); ISCSI_UNLOCK(&me->exit_mutex, goto done); - TRACE(TRACE_ISCSI_DEBUG, "enqueue_worker: started\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue_worker: started\n"); ISCSI_LOCK(&g_enqueue_worker.work_mutex, goto done); for (;;) { if (iscsi_queue_depth(&g_enqueue_q) || (g_initiator_state == INITIATOR_STATE_SHUTDOWN)) { - TRACE(TRACE_ISCSI_DEBUG, "enqueu, start to work\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueu, start to work\n"); ISCSI_UNLOCK(&g_enqueue_worker.work_mutex, goto done); if (g_initiator_state == INITIATOR_STATE_SHUTDOWN) { - TRACE(TRACE_ISCSI_DEBUG, "got shutdown signal\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "got shutdown signal\n"); goto done; } if ((cmd = iscsi_queue_remove(&g_enqueue_q)) == NULL) { - TRACE_ERROR("enqueue_worker: iscsi_queue_remove() failed\n"); + iscsi_trace_error("enqueue_worker: iscsi_queue_remove() failed\n"); goto done; } ISCSI_SET_TAG(&tag); target = cmd->isid; - TRACE(TRACE_ISCSI_CMD, "enqueue_worker: dequeued initiator_cmd_t 0x%p (type %i, target %llu)\n", cmd, cmd->type, target); + iscsi_trace(TRACE_ISCSI_CMD, "enqueue_worker: dequeued initiator_cmd_t 0x%p (type %i, target %llu)\n", cmd, cmd->type, target); switch (cmd->type) { case ISCSI_SCSI_CMD: scsi_cmd = (iscsi_scsi_cmd_args_t *) cmd->ptr; @@ -1016,34 +1016,34 @@ enqueue_worker_proc(void *arg) } break; default: - TRACE_ERROR("enqueue_worker: unknown command type %i\n", cmd->type); + iscsi_trace_error("enqueue_worker: unknown command type %i\n", cmd->type); goto done; } /* Initialize session (if not already) */ initialize: if (!g_target[target].has_session) { - TRACE(TRACE_ISCSI_DEBUG, "enqueue_worker: initializing target %llu session\n", target); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue_worker: initializing target %llu session\n", target); if (session_init_i(&g_target[target].sess, target) != 0) { - TRACE_ERROR("session_init_i() failed (ignoring command)\n"); + iscsi_trace_error("session_init_i() failed (ignoring command)\n"); goto next; } - TRACE(TRACE_ISCSI_DEBUG, "enqueue_worker: target %llu session initialized\n", target); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue_worker: target %llu session initialized\n", target); } else { - TRACE(TRACE_ISCSI_DEBUG, "enqueue_worker: target %llu session already initialized\n", target); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue_worker: target %llu session already initialized\n", target); } sess = g_target[target].sess; - TRACE(TRACE_ISCSI_DEBUG, "enqueue_worker: session 0x%p\n", sess); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue_worker: session 0x%p\n", sess); /* Discovery login if TargetName is zero length */ if (strlen(g_target[target].TargetName) == 0) { - TRACE(TRACE_ISCSI_DEBUG, "enqueue_worker: entering Discovery phase with target %llu\n", target); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue_worker: entering Discovery phase with target %llu\n", target); rc = discovery_phase(target, &sv); - TRACE(TRACE_ISCSI_DEBUG, "enqueue_worker: Discovery phase complete\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue_worker: Discovery phase complete\n"); for (i = 0 ; i < sv.c ; i += 2) { - PRINT("%s: %s %s\n", cmd->targetname, sv.v[i + 1], sv.v[i]); + printf("%s: %s %s\n", cmd->targetname, sv.v[i + 1], sv.v[i]); } /* Destroy session */ @@ -1051,7 +1051,7 @@ initialize: if (sess->state != INITIATOR_SESSION_STATE_DESTROYING) { if (g_target[target].has_session) { if (session_destroy_i(g_target[target].sess) != 0) { - TRACE_ERROR("enqueue_worker: session_destroy_i() failed\n"); + iscsi_trace_error("enqueue_worker: session_destroy_i() failed\n"); goto done; } } @@ -1067,22 +1067,22 @@ initialize: */ if (rc == 0) { - TRACE(TRACE_ISCSI_DEBUG, "enqueue_worker: discovery_phase() succeeded, entering full feature\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue_worker: discovery_phase() succeeded, entering full feature\n"); goto initialize; } else { - TRACE_ERROR("enqueue_worker: discovery_phase() failed (ignoring command)\n"); + iscsi_trace_error("enqueue_worker: discovery_phase() failed (ignoring command)\n"); goto next; } } /* Get into full feature if we're not already */ if (sess->state != INITIATOR_SESSION_STATE_LOGGED_IN_NORMAL) { - TRACE(TRACE_ISCSI_DEBUG, "enqueue_worker: entering full feature with target %llu (sock 0x%x)\n", target, (int) sess->sock); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue_worker: entering full feature with target %llu (sock 0x%x)\n", target, (int) sess->sock); if (full_feature_phase(sess) != 0) { - TRACE_ERROR("enqueue_worker: full_feature_phase() failed (ignoring command)\n"); + iscsi_trace_error("enqueue_worker: full_feature_phase() failed (ignoring command)\n"); goto next; } else { - TRACE(TRACE_ISCSI_DEBUG, "enqueue_worker: now full feature with target %llu\n", target); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue_worker: now full feature with target %llu\n", target); } } /* @@ -1097,18 +1097,18 @@ initialize: ISCSI_LOCK(&sess->tx_worker.work_mutex, goto done); if (iscsi_queue_insert(&sess->tx_queue, cmd) == -1) { ISCSI_UNLOCK(&sess->tx_worker.work_mutex, goto done); - TRACE_ERROR("iscsi_queue_insert() failed\n"); + iscsi_trace_error("iscsi_queue_insert() failed\n"); goto done; } ISCSI_SIGNAL(&sess->tx_worker.work_cond, goto done); ISCSI_UNLOCK(&sess->tx_worker.work_mutex, goto done); - TRACE(TRACE_ISCSI_CMD, "enqueue_worker: gave initiator_cmd_t 0x%p to tx_worker[%llu]\n", cmd, cmd->isid); + iscsi_trace(TRACE_ISCSI_CMD, "enqueue_worker: gave initiator_cmd_t 0x%p to tx_worker[%llu]\n", cmd, cmd->isid); next: ISCSI_LOCK(&g_enqueue_worker.work_mutex, goto done); } else { - TRACE(TRACE_ISCSI_DEBUG, "enqueue_worker: queue empty, awaiting condition\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue_worker: queue empty, awaiting condition\n"); ISCSI_WAIT(&g_enqueue_worker.work_cond, &g_enqueue_worker.work_mutex, goto done); - TRACE(TRACE_ISCSI_DEBUG, "enqueue_worker: condition signaled\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue_worker: condition signaled\n"); } } done: @@ -1140,11 +1140,11 @@ tx_worker_proc_i(void *arg) /* Connect to target */ - TRACE(TRACE_ISCSI_DEBUG, "tx_worker[%i]: connecting to %s:%d\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "tx_worker[%i]: connecting to %s:%d\n", me->id, g_target[me->id].ip, g_target[me->id].port); sess->state = INITIATOR_SESSION_STATE_CONNECTING; if (iscsi_sock_connect(sess->sock, g_target[me->id].ip, g_target[me->id].port) != 0) { - TRACE_ERROR("iscsi_sock_connect() failed\n"); + iscsi_trace_error("iscsi_sock_connect() failed\n"); ISCSI_LOCK(&me->exit_mutex, return -1); me->state |= ISCSI_WORKER_STATE_ERROR; @@ -1154,26 +1154,26 @@ tx_worker_proc_i(void *arg) } sess->state = INITIATOR_SESSION_STATE_CONNECTED; - TRACE(TRACE_ISCSI_DEBUG, "tx_worker[%i]: connected to %s:%d\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "tx_worker[%i]: connected to %s:%d\n", me->id, g_target[me->id].ip, g_target[me->id].port); /* Start Rx worker */ - TRACE(TRACE_ISCSI_DEBUG, "tx_worker[%i]: starting Rx worker\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "tx_worker[%i]: starting Rx worker\n", me->id); ISCSI_LOCK(&sess->rx_worker.exit_mutex, return -1); if (iscsi_thread_create(&sess->rx_worker.thread, (void *) rx_worker_proc_i, sess) != 0) { - TRACE_ERROR("iscsi_thread_create() failed\n"); + iscsi_trace_error("iscsi_thread_create() failed\n"); goto done; } ISCSI_WAIT(&sess->rx_worker.exit_cond, &sess->rx_worker.exit_mutex, return -1); ISCSI_UNLOCK(&sess->rx_worker.exit_mutex, return -1); - TRACE(TRACE_ISCSI_DEBUG, "tx_worker[%i]: Rx worker started\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "tx_worker[%i]: Rx worker started\n", me->id); /* Signal that we've started */ ISCSI_LOCK(&me->exit_mutex, return -1); ISCSI_SIGNAL(&me->exit_cond, return -1); ISCSI_UNLOCK(&me->exit_mutex, return -1); - TRACE(TRACE_ISCSI_DEBUG, "tx_worker[%i]: successfully started\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "tx_worker[%i]: successfully started\n", me->id); /* This Tx loop will exit when both the g_tx_queue is empty and */ /* sess->state != INITIATOR_SESSION_STATE_DESTROYING */ @@ -1184,24 +1184,24 @@ tx_worker_proc_i(void *arg) if (iscsi_queue_depth(&g_target[me->id].sess->tx_queue) || (sess->state == INITIATOR_SESSION_STATE_DESTROYING)) { if (sess->state == INITIATOR_SESSION_STATE_DESTROYING) { - TRACE(TRACE_ISCSI_DEBUG, "tx_worker[%i]: session is being destroyed, exiting\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "tx_worker[%i]: session is being destroyed, exiting\n", me->id); ISCSI_UNLOCK(&me->work_mutex, return -1); goto done; } /* Get initiator command */ if ((cmd = iscsi_queue_remove(&g_target[me->id].sess->tx_queue)) == NULL) { - TRACE_ERROR("tx_worker[%i]: iscsi_queue_remove() failed\n", me->id); + iscsi_trace_error("tx_worker[%i]: iscsi_queue_remove() failed\n", me->id); ISCSI_UNLOCK(&me->work_mutex, return -1); goto done; } ISCSI_UNLOCK(&me->work_mutex, return -1); - TRACE(TRACE_ISCSI_CMD, "tx_worker[%i]: dequeued initiator_cmd_t 0x%p (type %i, target %llu)\n", me->id, cmd, cmd->type, cmd->isid); + iscsi_trace(TRACE_ISCSI_CMD, "tx_worker[%i]: dequeued initiator_cmd_t 0x%p (type %i, target %llu)\n", me->id, cmd, cmd->type, cmd->isid); /* Make sure we've got the right command */ if (cmd->isid != me->id) { - TRACE_ERROR("got command 0x%x for target %llu, expected %i\n", cmd->type, cmd->isid, me->id); + iscsi_trace_error("got command 0x%x for target %llu, expected %i\n", cmd->type, cmd->isid, me->id); goto done; } /* @@ -1224,42 +1224,42 @@ tx_worker_proc_i(void *arg) cmd->tx_done = 0; switch (cmd->type) { case ISCSI_LOGIN_CMD: - TRACE(TRACE_ISCSI_CMD, "tx_worker[%i]: ISCSI_LOGIN_CMD\n", me->id); + iscsi_trace(TRACE_ISCSI_CMD, "tx_worker[%i]: ISCSI_LOGIN_CMD\n", me->id); if (login_command_i(cmd) != 0) { - TRACE_ERROR("tx_worker[%i]: login_command_i() failed\n", me->id); + iscsi_trace_error("tx_worker[%i]: login_command_i() failed\n", me->id); goto done; } break; case ISCSI_TEXT_CMD: - TRACE(TRACE_ISCSI_CMD, "tx_worker[%i]: ISCSI_TEXT_CMD\n", me->id); + iscsi_trace(TRACE_ISCSI_CMD, "tx_worker[%i]: ISCSI_TEXT_CMD\n", me->id); if (text_command_i(cmd) != 0) { - TRACE_ERROR("tx_worker[%i]: text_command_i() failed\n", me->id); + iscsi_trace_error("tx_worker[%i]: text_command_i() failed\n", me->id); goto done; } break; case ISCSI_SCSI_CMD: - TRACE(TRACE_ISCSI_CMD, "tx_worker[%i]: ISCSI_SCSI_CMD\n", me->id); + iscsi_trace(TRACE_ISCSI_CMD, "tx_worker[%i]: ISCSI_SCSI_CMD\n", me->id); if (scsi_command_i(cmd) != 0) { - TRACE_ERROR("tx_worker[%i]: scsi_command_i() failed\n", me->id); + iscsi_trace_error("tx_worker[%i]: scsi_command_i() failed\n", me->id); goto done; } break; case ISCSI_NOP_OUT: - TRACE(TRACE_ISCSI_CMD, "tx_worker[%i]: ISCSI_NOP_OUT\n", me->id); + iscsi_trace(TRACE_ISCSI_CMD, "tx_worker[%i]: ISCSI_NOP_OUT\n", me->id); if (nop_out_i(cmd) != 0) { - TRACE_ERROR("tx_worker[%i]: nop_out_i() failed\n", me->id); + iscsi_trace_error("tx_worker[%i]: nop_out_i() failed\n", me->id); goto done; } break; case ISCSI_LOGOUT_CMD: - TRACE(TRACE_ISCSI_CMD, "tx_worker[%i]: ISCSI_LOGOUT_CMD\n", me->id); + iscsi_trace(TRACE_ISCSI_CMD, "tx_worker[%i]: ISCSI_LOGOUT_CMD\n", me->id); if (logout_command_i(cmd) != 0) { - TRACE_ERROR("tx_worker[%i]: logout_command_i() failed\n", me->id); + iscsi_trace_error("tx_worker[%i]: logout_command_i() failed\n", me->id); goto done; } break; default: - TRACE_ERROR("tx_worker[%i]: unknown iSCSI command 0x%x\n", me->id, cmd->type); + iscsi_trace_error("tx_worker[%i]: unknown iSCSI command 0x%x\n", me->id, cmd->type); cmd->status = -1; break; } @@ -1295,9 +1295,9 @@ tx_worker_proc_i(void *arg) /* the callback directly. */ if ((cmd->type == ISCSI_NOP_OUT) && (((iscsi_nop_out_args_t *) (cmd->ptr))->tag == 0xffffffff)) { - TRACE(TRACE_ISCSI_DEBUG, "executing callback() function directly for NOP_OUT (no NOP_IN)\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "executing callback() function directly for NOP_OUT (no NOP_IN)\n"); if (cmd->callback(cmd) != 0) { - TRACE_ERROR("cmd->callback() failed\n"); + iscsi_trace_error("cmd->callback() failed\n"); return -1; } } else { @@ -1307,14 +1307,14 @@ tx_worker_proc_i(void *arg) ISCSI_UNLOCK(&sess->rx_worker.work_mutex, return -1); } } else { - TRACE(TRACE_ISCSI_DEBUG, "tx_worker[%i]: awaiting condition\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "tx_worker[%i]: awaiting condition\n", me->id); ISCSI_WAIT(&me->work_cond, &me->work_mutex, return -1); - TRACE(TRACE_ISCSI_DEBUG, "tx_worker[%i]: condition signaled\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "tx_worker[%i]: condition signaled\n", me->id); } } done: if (sess->state != INITIATOR_SESSION_STATE_DESTROYING) { - TRACE_ERROR("tx_worker[%i]: session exited prematurely (state 0x%x)\n", me->id, sess->state); + iscsi_trace_error("tx_worker[%i]: session exited prematurely (state 0x%x)\n", me->id, sess->state); me->state |= ISCSI_WORKER_STATE_ERROR; } ISCSI_WORKER_EXIT(me); @@ -1343,17 +1343,17 @@ rx_worker_proc_i(void *arg) ISCSI_SIGNAL(&me->exit_cond, return -1); ISCSI_UNLOCK(&me->exit_mutex, return -1); - TRACE(TRACE_ISCSI_DEBUG, "rx_worker[%i]: started (sess %p)\n", me->id, sess); + iscsi_trace(TRACE_ISCSI_DEBUG, "rx_worker[%i]: started (sess %p)\n", me->id, sess); for (;;) { - TRACE(TRACE_ISCSI_DEBUG, "rx_worker[%i]: reading iscsi header (sock 0x%x) \n", + iscsi_trace(TRACE_ISCSI_DEBUG, "rx_worker[%i]: reading iscsi header (sock 0x%x) \n", me->id, (int) sess->sock); if (iscsi_sock_msg(sess->sock, 0, ISCSI_HEADER_LEN, header, 0) != ISCSI_HEADER_LEN) { - TRACE(TRACE_ISCSI_DEBUG, "rx_worker[%i]: iscsi_sock_msg() failed\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "rx_worker[%i]: iscsi_sock_msg() failed\n", me->id); goto done; } if (sess->state == INITIATOR_SESSION_STATE_DESTROYING) { - TRACE_ERROR("rx_worker[%i]: session is being destroyed\n", me->id); + iscsi_trace_error("rx_worker[%i]: session is being destroyed\n", me->id); goto done; } /* Get cmd ptr from hash table */ @@ -1369,10 +1369,10 @@ rx_worker_proc_i(void *arg) */ if ((cmd = hash_remove(&g_tag_hash, tag)) == NULL) { - TRACE_ERROR("hash_remove() failed\n"); - TRACE(TRACE_ISCSI_DEBUG, "no cmd ptr associated with tag 0x%x\n", tag); + iscsi_trace_error("hash_remove() failed\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "no cmd ptr associated with tag 0x%x\n", tag); } else { - TRACE(TRACE_ISCSI_DEBUG, "cmd ptr %p associated with tag 0x%x\n", cmd, tag); + iscsi_trace(TRACE_ISCSI_DEBUG, "cmd ptr %p associated with tag 0x%x\n", cmd, tag); ISCSI_LOCK(&sess->rx_worker.work_mutex, return -1); if (!cmd->tx_done) { @@ -1381,7 +1381,7 @@ rx_worker_proc_i(void *arg) ISCSI_UNLOCK(&sess->rx_worker.work_mutex, return -1); } } else { - TRACE(TRACE_ISCSI_DEBUG, "no command associated with tag 0x%x\n", tag); + iscsi_trace(TRACE_ISCSI_DEBUG, "no command associated with tag 0x%x\n", tag); } } /* Remove cmd ptr from outstanding list */ @@ -1403,77 +1403,77 @@ rx_worker_proc_i(void *arg) iscsi_spin_unlock(&sess->cmds_spin); switch (ISCSI_OPCODE(header)) { case ISCSI_SCSI_RSP: - TRACE(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_SCSI_RSP\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_SCSI_RSP\n", me->id); if (scsi_response_i(sess, cmd, header) != 0) { - TRACE_ERROR("rx_worker[%i]: scsi_response_i() failed\n", me->id); + iscsi_trace_error("rx_worker[%i]: scsi_response_i() failed\n", me->id); goto done; } break; case ISCSI_READ_DATA: - TRACE(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_READ_DATA\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_READ_DATA\n", me->id); if (scsi_read_data_i(sess, cmd, header) != 0) { - TRACE_ERROR("rx_worker[%i]: scsi_read_data_i() failed\n", me->id); + iscsi_trace_error("rx_worker[%i]: scsi_read_data_i() failed\n", me->id); goto done; } break; case ISCSI_R2T: - TRACE(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_R2T\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_R2T\n", me->id); if (scsi_r2t_i(sess, cmd, header) != 0) { - TRACE_ERROR("rx_worker[%i]: scsi_r2t_i() failed\n", me->id); + iscsi_trace_error("rx_worker[%i]: scsi_r2t_i() failed\n", me->id); goto done; } break; case ISCSI_NOP_IN: - TRACE(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_NOP_IN\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_NOP_IN\n", me->id); if (nop_in_i(sess, cmd, header) != 0) { - TRACE_ERROR("nop_in_i() failed\n"); + iscsi_trace_error("nop_in_i() failed\n"); return -1; } break; case ISCSI_LOGIN_RSP: - TRACE(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_LOGIN_RSP\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_LOGIN_RSP\n", me->id); if (login_response_i(sess, cmd, header) != 0) { - TRACE_ERROR("rx_worker[%i]: login_response_i() failed\n", me->id); + iscsi_trace_error("rx_worker[%i]: login_response_i() failed\n", me->id); goto done; } break; case ISCSI_TEXT_RSP: - TRACE(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_TEXT_RSP\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_TEXT_RSP\n", me->id); if (text_response_i(sess, cmd, header) != 0) { - TRACE_ERROR("rx_worker[%i]: text_response_i() failed\n", me->id); + iscsi_trace_error("rx_worker[%i]: text_response_i() failed\n", me->id); goto done; } break; case ISCSI_LOGOUT_RSP: - TRACE(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_LOGOUT_RSP\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_LOGOUT_RSP\n", me->id); if (logout_response_i(sess, cmd, header) != 0) { - TRACE_ERROR("rx_worker[%i]: logout_response_i() failed\n", me->id); + iscsi_trace_error("rx_worker[%i]: logout_response_i() failed\n", me->id); goto done; } break; case ISCSI_REJECT: - TRACE(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_REJECT\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_REJECT\n", me->id); if (reject_i(sess, header) != 0) { - TRACE_ERROR("reject_i() failed\n"); + iscsi_trace_error("reject_i() failed\n"); return -1; } break; case ISCSI_ASYNC: - TRACE(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_ASYNC\n", me->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "rx_worker[%i]: ISCSI_ASYNC\n", me->id); if (async_msg_i(sess, header) != 0) { - TRACE_ERROR("async_msg_i() failed\n"); + iscsi_trace_error("async_msg_i() failed\n"); goto done; } break; default: - TRACE_ERROR("rx_worker[%i]: unexpected iSCSI op 0x%x\n", me->id, ISCSI_OPCODE(header)); + iscsi_trace_error("rx_worker[%i]: unexpected iSCSI op 0x%x\n", me->id, ISCSI_OPCODE(header)); goto done; } } done: if (sess->state != INITIATOR_SESSION_STATE_DESTROYING) { - TRACE(TRACE_ISCSI_DEBUG, "rx_worker[%i]: session exited prematurely (state 0x%x)\n", me->id, sess->state); + iscsi_trace(TRACE_ISCSI_DEBUG, "rx_worker[%i]: session exited prematurely (state 0x%x)\n", me->id, sess->state); me->state |= ISCSI_WORKER_STATE_ERROR; } ISCSI_WORKER_EXIT(me); @@ -1493,24 +1493,24 @@ text_command_i(initiator_cmd_t * cmd) /* retreive the cmd ptr using the tag from the response PDU. */ if (hash_insert(&g_tag_hash, cmd, text_cmd->tag) != 0) { - TRACE_ERROR("hash_insert() failed\n"); + iscsi_trace_error("hash_insert() failed\n"); return -1; } /* Send text command PDU */ text_cmd->ExpStatSN = sess->ExpStatSN; text_cmd->CmdSN = sess->CmdSN++; - TRACE(TRACE_ISCSI_DEBUG, "sending text command\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "sending text command\n"); if (iscsi_text_cmd_encap(header, text_cmd) != 0) { - TRACE_ERROR("(iscsi_text_cmd_encap() failed\n"); + iscsi_trace_error("(iscsi_text_cmd_encap() failed\n"); return -1; } if (iscsi_sock_send_header_and_data(sess->sock, header, ISCSI_HEADER_LEN, text_cmd->text, text_cmd->length, 0) != ISCSI_HEADER_LEN + text_cmd->length) { - TRACE_ERROR("iscsi_sock_send_header_and_data() failed.\n"); + iscsi_trace_error("iscsi_sock_send_header_and_data() failed.\n"); return -1; } - TRACE(TRACE_ISCSI_DEBUG, "text command sent ok\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "text command sent ok\n"); return 0; } @@ -1529,22 +1529,22 @@ login_command_i(initiator_cmd_t * cmd) /* retreive the cmd ptr using the tag from the response PDU. */ if (hash_insert(&g_tag_hash, cmd, login_cmd->tag) != 0) { - TRACE_ERROR("hash_insert() failed\n"); + iscsi_trace_error("hash_insert() failed\n"); return -1; } /* Send login command PDU */ login_cmd->ExpStatSN = sess->ExpStatSN; - TRACE(TRACE_ISCSI_DEBUG, "sending login command\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "sending login command\n"); if (iscsi_login_cmd_encap(header, login_cmd) != 0) { - TRACE_ERROR("(iscsi_login_cmd_encap() failed\n"); + iscsi_trace_error("(iscsi_login_cmd_encap() failed\n"); return -1; } if (iscsi_sock_send_header_and_data(sess->sock, header, ISCSI_HEADER_LEN, login_cmd->text, login_cmd->length, 0) != ISCSI_HEADER_LEN + login_cmd->length) { - TRACE_ERROR("iscsi_sock_send_header_and_data() failed.\n"); + iscsi_trace_error("iscsi_sock_send_header_and_data() failed.\n"); return -1; } - TRACE(TRACE_ISCSI_DEBUG, "login command sent ok\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "login command sent ok\n"); return 0; } @@ -1561,12 +1561,12 @@ logout_phase_i(initiator_session_t * sess) /* Allocate command pointers */ if ((cmd = iscsi_malloc_atomic(sizeof(initiator_cmd_t))) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); return -1; } (void) memset(cmd, 0x0, sizeof(*cmd)); if ((logout_cmd = iscsi_malloc_atomic(sizeof(iscsi_logout_cmd_args_t))) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); if (cmd != NULL) iscsi_free_atomic(cmd); return -1; @@ -1598,26 +1598,26 @@ logout_phase_i(initiator_session_t * sess) /* Enqueue to Tx worker */ - TRACE(TRACE_ISCSI_DEBUG, "enqueing logout command to tx worker %llu\n", sess->isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueing logout command to tx worker %llu\n", sess->isid); ISCSI_LOCK(&wait.mutex, LO_ERROR); ISCSI_LOCK(&sess->tx_worker.work_mutex, LO_ERROR); if (iscsi_queue_insert(&sess->tx_queue, cmd) == -1) { ISCSI_UNLOCK(&sess->tx_worker.work_mutex, LO_ERROR); - TRACE_ERROR("iscsi_queue_insert() failed\n"); + iscsi_trace_error("iscsi_queue_insert() failed\n"); LO_ERROR; } ISCSI_SIGNAL(&sess->tx_worker.work_cond, LO_ERROR); ISCSI_UNLOCK(&sess->tx_worker.work_mutex, LO_ERROR); - TRACE(TRACE_ISCSI_DEBUG, "enqueued logout command ok\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueued logout command ok\n"); /* Wait for callback */ - TRACE(TRACE_ISCSI_DEBUG, "waiting on logout callback\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "waiting on logout callback\n"); ISCSI_WAIT(&wait.cond, &wait.mutex, LO_ERROR); ISCSI_UNLOCK(&wait.mutex, LO_ERROR); ISCSI_COND_DESTROY(&wait.cond, LO_ERROR); ISCSI_MUTEX_DESTROY(&wait.mutex, LO_ERROR); - TRACE(TRACE_ISCSI_DEBUG, "received logout callback ok\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "received logout callback ok\n"); sess->state = INITIATOR_SESSION_STATE_LOGGED_OUT; @@ -1628,9 +1628,9 @@ logout_phase_i(initiator_session_t * sess) static void alarm_handler(int arg) { - TRACE_ERROR("***aborting cmd 0x%p***\n", g_cmd); + iscsi_trace_error("***aborting cmd 0x%p***\n", g_cmd); if (initiator_abort(g_cmd) != 0) { - TRACE_ERROR("initiator_abort() failed\n"); + iscsi_trace_error("initiator_abort() failed\n"); } } @@ -1647,12 +1647,12 @@ login_phase_i(initiator_session_t * sess, char *text, int text_len) /* Allocate command pointers */ if ((cmd = iscsi_malloc_atomic(sizeof(initiator_cmd_t))) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); return -1; } (void) memset(cmd, 0x0, sizeof(*cmd)); if ((login_cmd = iscsi_malloc_atomic(sizeof(iscsi_login_cmd_args_t))) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); if (cmd != NULL) iscsi_free_atomic(cmd); return -1; @@ -1719,40 +1719,40 @@ login_phase_i(initiator_session_t * sess, char *text, int text_len) /* Enqueue initiator command to Tx worker */ - TRACE(TRACE_ISCSI_DEBUG, "enqueing login command to tx worker %llu\n", sess->isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueing login command to tx worker %llu\n", sess->isid); ISCSI_LOCK(&wait.mutex, LI_ERROR); ISCSI_LOCK(&sess->tx_worker.work_mutex, LI_ERROR); if (iscsi_queue_insert(&sess->tx_queue, cmd) == -1) { ISCSI_UNLOCK(&sess->tx_worker.work_mutex, LI_ERROR); - TRACE_ERROR("iscsi_queue_insert() failed\n"); + iscsi_trace_error("iscsi_queue_insert() failed\n"); LI_ERROR; } ISCSI_SIGNAL(&sess->tx_worker.work_cond, LI_ERROR); ISCSI_UNLOCK(&sess->tx_worker.work_mutex, LI_ERROR); - TRACE(TRACE_ISCSI_DEBUG, "enqueued login command ok\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "enqueued login command ok\n"); /* Wait for callback */ - TRACE(TRACE_ISCSI_DEBUG, "waiting on login callback\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "waiting on login callback\n"); ISCSI_WAIT(&wait.cond, &wait.mutex, LI_ERROR); ISCSI_UNLOCK(&wait.mutex, LI_ERROR); ISCSI_COND_DESTROY(&wait.cond, LI_ERROR); ISCSI_MUTEX_DESTROY(&wait.mutex, LI_ERROR); - TRACE(TRACE_ISCSI_DEBUG, "received login callback ok\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "received login callback ok\n"); alarm(0); if (cmd->status != 0) { - TRACE_ERROR("initiator_cmd_t failed\n"); + iscsi_trace_error("initiator_cmd_t failed\n"); LI_ERROR; } if (sess->state == INITIATOR_SESSION_STATE_LOGGING_IN) { - TRACE(TRACE_ISCSI_PARAM, "more negotiation needed (sending %i bytes response parameters)\n", + iscsi_trace(TRACE_ISCSI_PARAM, "more negotiation needed (sending %i bytes response parameters)\n", login_cmd->length); } } while (sess->state == INITIATOR_SESSION_STATE_LOGGING_IN); - TRACE(TRACE_ISCSI_DEBUG, "login phase completed successfully\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "login phase completed successfully\n"); LI_CLEANUP; return 0; @@ -1775,14 +1775,14 @@ text_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *head if (cmd) { text_cmd = (iscsi_text_cmd_args_t *) cmd->ptr; } else { - TRACE_ERROR("no initiator_cmd_t specified for iscsi_text_cmd_args_t??\n"); + iscsi_trace_error("no initiator_cmd_t specified for iscsi_text_cmd_args_t??\n"); return -1; } /* Check arguments & update numbering */ if (iscsi_text_rsp_decap(header, &text_rsp) != 0) { - TRACE_ERROR("text_response_decap() failed\n"); + iscsi_trace_error("text_response_decap() failed\n"); TI_ERROR; } RETURN_NOT_EQUAL("Tag", text_rsp.tag, text_cmd->tag, TI_ERROR, -1); @@ -1794,32 +1794,32 @@ text_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *head /* Parse input text parameters and generate any response */ if ((len_in = text_rsp.length) != 0) { - TRACE(TRACE_ISCSI_PARAM, "allocating %i bytes input parameters\n", len_in); + iscsi_trace(TRACE_ISCSI_PARAM, "allocating %i bytes input parameters\n", len_in); if ((text_in = iscsi_malloc_atomic(len_in + 1)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); TI_ERROR; } if ((text_out = iscsi_malloc_atomic(2048)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); if (text_in != NULL) iscsi_free_atomic(text_in); TI_ERROR; } if (iscsi_sock_msg(sess->sock, 0, len_in, text_in, 0) != len_in) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); TI_ERROR; } text_in[len_in] = 0x0; - TRACE(TRACE_ISCSI_PARAM, "read %i bytes input parameters ok\n", len_in); + iscsi_trace(TRACE_ISCSI_PARAM, "read %i bytes input parameters ok\n", len_in); /* Reset the value lists for TargetName and TargetAddress */ if (param_val_reset(sess->params, "TargetName") != 0) { - TRACE_ERROR("parm_val_reset() failed\n"); + iscsi_trace_error("parm_val_reset() failed\n"); TI_ERROR; } if (param_val_reset(sess->params, "TargetAddress") != 0) { - TRACE_ERROR("parm_val_reset() failed\n"); + iscsi_trace_error("parm_val_reset() failed\n"); TI_ERROR; } /* Parse the incoming answer */ @@ -1842,7 +1842,7 @@ text_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *head PARAM_TEXT_PARSE(l, &sess->sess_params.cred, text_out, len_out, NULL, NULL, 2048, 1, TI_ERROR); - TRACE(TRACE_ISCSI_PARAM, "need to send %i bytes response back to target\n", len_out); + iscsi_trace(TRACE_ISCSI_PARAM, "need to send %i bytes response back to target\n", len_out); text_cmd->length = len_out; memcpy(text_cmd->text, text_out, len_out); } else { @@ -1853,13 +1853,13 @@ text_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *head /* Issue callback */ - TRACE(TRACE_ISCSI_DEBUG, "iscsi_text_cmd_args_t done\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "iscsi_text_cmd_args_t done\n"); callback: if (cmd->status == -1) ret = -1; if (cmd->callback(cmd) != 0) { ret = -1; - TRACE_ERROR("callback() failed\n"); + iscsi_trace_error("callback() failed\n"); } TI_CLEANUP; return ret; @@ -1877,7 +1877,7 @@ login_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea int len_out = 0; if ((text_out = iscsi_malloc_atomic(2048)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); cmd->status = -1; goto callback; } @@ -1886,14 +1886,14 @@ login_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea if (cmd) { login_cmd = (iscsi_login_cmd_args_t *) cmd->ptr; } else { - TRACE_ERROR("no initiator_cmd_t specified for iscsi_login_cmd_args_t??\n"); + iscsi_trace_error("no initiator_cmd_t specified for iscsi_login_cmd_args_t??\n"); LIR_ERROR; } /* Read login response */ if (iscsi_login_rsp_decap(header, &login_rsp) != 0) { - TRACE_ERROR("login_response_decap() failed\n"); + iscsi_trace_error("login_response_decap() failed\n"); LIR_ERROR; } RETURN_GREATER("Length (should this be hardcoded?)", login_rsp.length, 8192, LIR_CLEANUP, -1); /* XXX - agc */ @@ -1902,11 +1902,11 @@ login_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea if ((len_in = login_rsp.length) != 0) { if ((text_in = iscsi_malloc_atomic(len_in + 1)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); LIR_ERROR; } if (iscsi_sock_msg(sess->sock, 0, len_in, text_in, 0) != len_in) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); LIR_ERROR; } text_in[len_in] = 0x0; @@ -1918,11 +1918,11 @@ login_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea /* Check args */ if (login_rsp.status_class != 0) { - TRACE_ERROR("Bad Status-Class: got %i, expected %i\n", login_rsp.status_class, 0); + iscsi_trace_error("Bad Status-Class: got %i, expected %i\n", login_rsp.status_class, 0); LIR_ERROR; } if (login_rsp.tag != login_cmd->tag) { - TRACE_ERROR("Bad Tag: got %x, expected %x\n", login_rsp.tag, login_cmd->tag); + iscsi_trace_error("Bad Tag: got %x, expected %x\n", login_rsp.tag, login_cmd->tag); LIR_ERROR; } sess->ExpStatSN = login_rsp.StatSN + 1; @@ -1931,7 +1931,7 @@ login_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea if (login_rsp.transit) { if (login_cmd->transit != 1) - TRACE_WARNING("incoming packet transit bit not set, csg = %d, nsg = %d\n", + iscsi_trace_warning("incoming packet transit bit not set, csg = %d, nsg = %d\n", login_cmd->csg, login_cmd->nsg); switch (login_rsp.nsg) { @@ -1939,7 +1939,7 @@ login_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea login_cmd->csg = login_cmd->nsg; login_cmd->nsg = ISCSI_LOGIN_STAGE_FULL_FEATURE; if (params_out(sess, text_out, &len_out, 2048, SESS_TYPE_NONE, !IS_SECURITY) != 0) { - TRACE_ERROR("params_out() failed\n"); + iscsi_trace_error("params_out() failed\n"); LIR_ERROR; } login_cmd->length = len_out; @@ -1966,28 +1966,28 @@ login_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea } else if (param_equiv(sess->params, "SessionType", "Discovery")) { sess->state = INITIATOR_SESSION_STATE_LOGGED_IN_DISCOVERY; } else { - TRACE_ERROR("Unknown SessionType \"%s\"\n", param_val(sess->params, "SessionType")); + iscsi_trace_error("Unknown SessionType \"%s\"\n", param_val(sess->params, "SessionType")); LIR_ERROR; } #if ISCSI_DEBUG - PRINT("*********************************************\n"); - PRINT("* LOGIN SUCCESSFUL *\n"); - PRINT("* *\n"); - PRINT("* %20s:%20u *\n", "CID", sess->cid); - PRINT("* %20s:%20llu *\n", "ISID", sess->isid); - PRINT("* %20s:%20u *\n", "TSIH", sess->tsih); - PRINT("* %20s:%20u *\n", "CmdSN", sess->CmdSN); - PRINT("* %20s:%20u *\n", "MaxCmdSN", sess->MaxCmdSN); - PRINT("* %20s:%20u *\n", "ExpStatSN", sess->ExpStatSN); - PRINT("*********************************************\n"); + printf("*********************************************\n"); + printf("* LOGIN SUCCESSFUL *\n"); + printf("* *\n"); + printf("* %20s:%20u *\n", "CID", sess->cid); + printf("* %20s:%20llu *\n", "ISID", sess->isid); + printf("* %20s:%20u *\n", "TSIH", sess->tsih); + printf("* %20s:%20u *\n", "CmdSN", sess->CmdSN); + printf("* %20s:%20u *\n", "MaxCmdSN", sess->MaxCmdSN); + printf("* %20s:%20u *\n", "ExpStatSN", sess->ExpStatSN); + printf("*********************************************\n"); #endif break; default: LIR_ERROR; } } else { - TRACE(TRACE_ISCSI_DEBUG, "received partial login response\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "received partial login response\n"); /* Copy response text into login_cmd->text and update the */ /* length login_cmd->length. This will be sent out on the */ @@ -1995,7 +1995,7 @@ login_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea if (len_out) { PARAM_TEXT_PARSE(l, &sess->sess_params.cred, text_out, len_out, NULL, NULL, 0, 1, LIR_ERROR); - TRACE(TRACE_ISCSI_PARAM, "need to send %i bytes response back to target\n", len_out); + iscsi_trace(TRACE_ISCSI_PARAM, "need to send %i bytes response back to target\n", len_out); login_cmd->length = len_out; memcpy(login_cmd->text, text_out, len_out); @@ -2011,10 +2011,10 @@ login_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea /* Callback */ callback: - TRACE(TRACE_ISCSI_DEBUG, "iscsi_login_cmd_args_t done (cmd status %i, iscsi status %i)\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "iscsi_login_cmd_args_t done (cmd status %i, iscsi status %i)\n", cmd->status, login_rsp.status_class); if ((*cmd->callback)(cmd) != 0) { - TRACE_ERROR("callback() failed\n"); + iscsi_trace_error("callback() failed\n"); LIR_CLEANUP; return -1; } @@ -2036,21 +2036,21 @@ logout_command_i(initiator_cmd_t * cmd) /* retreive the cmd ptr using the tag from the response PDU. */ if (hash_insert(&g_tag_hash, cmd, logout_cmd->tag) != 0) { - TRACE_ERROR("hash_insert() failed\n"); + iscsi_trace_error("hash_insert() failed\n"); return -1; } /* Send logout command PDU */ - TRACE(TRACE_ISCSI_DEBUG, "sending logout command\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "sending logout command\n"); if (iscsi_logout_cmd_encap(header, logout_cmd) != 0) { - TRACE_ERROR("(iscsi_logout_cmd_encap() failed\n"); + iscsi_trace_error("(iscsi_logout_cmd_encap() failed\n"); return -1; } if (iscsi_sock_msg(sess->sock, 1, ISCSI_HEADER_LEN, header, 0) != ISCSI_HEADER_LEN) { - TRACE_ERROR("iscsi_sock_msg() failed.\n"); + iscsi_trace_error("iscsi_sock_msg() failed.\n"); return -1; } - TRACE(TRACE_ISCSI_DEBUG, "logout command sent ok\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "logout command sent ok\n"); return 0; } @@ -2067,15 +2067,15 @@ logout_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *he if (cmd->ptr) { logout_cmd = (iscsi_logout_cmd_args_t *) cmd->ptr; } else { - TRACE_ERROR("no iscsi_logout_cmd_args_t specified for initiator_cmd_t??\n"); + iscsi_trace_error("no iscsi_logout_cmd_args_t specified for initiator_cmd_t??\n"); LOR_ERROR; } } else { - TRACE_ERROR("no initiator_cmd_t specified for iscsi_logout_cmd_args_t??\n"); + iscsi_trace_error("no initiator_cmd_t specified for iscsi_logout_cmd_args_t??\n"); return -1; } if (iscsi_logout_rsp_decap(header, &logout_rsp) != 0) { - TRACE_ERROR("iscsi_logout_rsp_decap() failed\n"); + iscsi_trace_error("iscsi_logout_rsp_decap() failed\n"); LOR_ERROR; } RETURN_NOT_EQUAL("Response", logout_rsp.response, ISCSI_LOGOUT_STATUS_SUCCESS, LOR_ERROR, -1); @@ -2092,22 +2092,22 @@ logout_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *he /* Callback */ cmd->status = 0; - TRACE(TRACE_ISCSI_DEBUG, "LOGOUT_CMD_T done (cmd status %i, iscsi status %i)\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "LOGOUT_CMD_T done (cmd status %i, iscsi status %i)\n", cmd->status, logout_rsp.response); callback: if ((*cmd->callback)(cmd) != 0) { - TRACE_ERROR("callback() failed\n"); + iscsi_trace_error("callback() failed\n"); return -1; } #if ISCSI_DEBUG - PRINT("*********************************************\n"); - PRINT("* LOGOUT SUCCESSFUL *\n"); - PRINT("* *\n"); - PRINT("* %20s:%20u *\n", "CID", sess->cid); - PRINT("* %20s:%20llu *\n", "ISID", sess->isid); - PRINT("* %20s:%20u *\n", "TSIH", sess->tsih); - PRINT("*********************************************\n"); + printf("*********************************************\n"); + printf("* LOGOUT SUCCESSFUL *\n"); + printf("* *\n"); + printf("* %20s:%20u *\n", "CID", sess->cid); + printf("* %20s:%20llu *\n", "ISID", sess->isid); + printf("* %20s:%20u *\n", "TSIH", sess->tsih); + printf("*********************************************\n"); #endif return 0; @@ -2134,7 +2134,7 @@ nop_out_i(initiator_cmd_t * cmd) /* NOP_IN_T PDU. */ if (hash_insert(&g_tag_hash, cmd, nop_out->tag) != 0) { - TRACE_ERROR("hash_insert() failed\n"); + iscsi_trace_error("hash_insert() failed\n"); return -1; } } @@ -2144,7 +2144,7 @@ nop_out_i(initiator_cmd_t * cmd) /* nop_out->CmdSN = sess->CmdSN++; */ nop_out->transfer_tag = 0xffffffff; if (iscsi_nop_out_encap(header, nop_out) != 0) { - TRACE_ERROR("iscsi_nop_out_encap() failed\n"); + iscsi_trace_error("iscsi_nop_out_encap() failed\n"); return -1; } /* @@ -2163,7 +2163,7 @@ nop_out_i(initiator_cmd_t * cmd) if ((rc = iscsi_sock_send_header_and_data(sess->sock, header, ISCSI_HEADER_LEN, nop_out->data, length, 0)) != ISCSI_HEADER_LEN + length) { - TRACE_ERROR("iscsi_sock_msg() failed: got %i expected %i\n", rc, ISCSI_HEADER_LEN + length); + iscsi_trace_error("iscsi_sock_msg() failed: got %i expected %i\n", rc, ISCSI_HEADER_LEN + length); return -1; } cmd->status = 0; @@ -2187,19 +2187,19 @@ scsi_command_i(initiator_cmd_t * cmd) sg_len = sg_len_copy = sg_len_which = 0; scsi_cmd->status = 0; - TRACE(TRACE_ISCSI_DEBUG, "tx_worker[%llu]: scsi op 0x%x lun %llu trans_len %i length %i send_sg_len %i recv_sg_len %i\n", target, scsi_cmd->cdb[0], scsi_cmd->lun, scsi_cmd->trans_len, scsi_cmd->length, scsi_cmd->send_sg_len, scsi_cmd->recv_sg_len); + iscsi_trace(TRACE_ISCSI_DEBUG, "tx_worker[%llu]: scsi op 0x%x lun %llu trans_len %i length %i send_sg_len %i recv_sg_len %i\n", target, scsi_cmd->cdb[0], scsi_cmd->lun, scsi_cmd->trans_len, scsi_cmd->length, scsi_cmd->send_sg_len, scsi_cmd->recv_sg_len); RETURN_GREATER("target id", (uint32_t) target, CONFIG_INITIATOR_NUM_TARGETS - 1, NO_CLEANUP, -1); /* Set and check scsi_cmd */ if (scsi_cmd->trans_len > sess->sess_params.max_burst_length) { - TRACE_ERROR("scsi_cmd->trans_len (%u) > MaxBurstLength (%u)\n", + iscsi_trace_error("scsi_cmd->trans_len (%u) > MaxBurstLength (%u)\n", scsi_cmd->trans_len, sess->sess_params.max_burst_length); return -1; } if (scsi_cmd->length > scsi_cmd->trans_len) { - TRACE_ERROR("scsi_cmd->length (%u) > scsi_cmd->trans_len (%u)\n", + iscsi_trace_error("scsi_cmd->length (%u) > scsi_cmd->trans_len (%u)\n", scsi_cmd->length, scsi_cmd->trans_len); return -1; } @@ -2227,7 +2227,7 @@ scsi_command_i(initiator_cmd_t * cmd) /* retreive the cmd ptr using the tag from the response PDU. */ if (hash_insert(&g_tag_hash, cmd, scsi_cmd->tag) != 0) { - TRACE_ERROR("hash_insert() failed\n"); + iscsi_trace_error("hash_insert() failed\n"); goto error; } /* Send command PDU */ @@ -2246,7 +2246,7 @@ scsi_command_i(initiator_cmd_t * cmd) scsi_cmd->final = 1; } if (iscsi_scsi_cmd_encap(header, scsi_cmd) != 0) { - TRACE_ERROR("iscsi_scsi_cmd_encap() failed\n"); + iscsi_trace_error("iscsi_scsi_cmd_encap() failed\n"); goto error; } /* @@ -2254,10 +2254,10 @@ scsi_command_i(initiator_cmd_t * cmd) * that */ /* contains only the immediata data (a subset of the original iovec). */ - TRACE(TRACE_ISCSI_DEBUG, "sending command PDU with %u bytes immediate data\n", scsi_cmd->length); + iscsi_trace(TRACE_ISCSI_DEBUG, "sending command PDU with %u bytes immediate data\n", scsi_cmd->length); if (scsi_cmd->length && sess->sess_params.immediate_data) { if ((sg_copy = iscsi_malloc_atomic(sg_len * sizeof(struct iovec))) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); goto error; } fragment_flag++; @@ -2265,43 +2265,43 @@ scsi_command_i(initiator_cmd_t * cmd) memcpy(sg_copy, sg, sizeof(struct iovec) * sg_len); sg_len_copy = sg_len; if (modify_iov(&sg_copy, &sg_len_copy, 0, scsi_cmd->length) != 0) { - TRACE_ERROR("modify_iov() failed\n"); + iscsi_trace_error("modify_iov() failed\n"); goto error; } if (scsi_cmd->ahs) { if (iscsi_sock_msg(sess->sock, 1, ISCSI_HEADER_LEN, header, 0) != ISCSI_HEADER_LEN) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); goto error; } if (iscsi_sock_msg(sess->sock, 1, scsi_cmd->ahs_len, scsi_cmd->ahs, 0) != scsi_cmd->ahs_len) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); goto error; } if (iscsi_sock_msg(sess->sock, 1, scsi_cmd->length, sg_copy, sg_len_copy) != scsi_cmd->length) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); goto error; } } else { if (iscsi_sock_send_header_and_data(sess->sock, header, ISCSI_HEADER_LEN, sg_copy, scsi_cmd->length, sg_len_copy) != ISCSI_HEADER_LEN + scsi_cmd->length) { - TRACE_ERROR("iscsi_sock_send_header_and_data() failed\n"); + iscsi_trace_error("iscsi_sock_send_header_and_data() failed\n"); goto error; } } scsi_cmd->bytes_sent += scsi_cmd->length; } else { if (iscsi_sock_msg(sess->sock, 1, ISCSI_HEADER_LEN, header, 0) != ISCSI_HEADER_LEN) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); goto error; } if (scsi_cmd->ahs_len) { if (iscsi_sock_msg(sess->sock, 1, scsi_cmd->ahs_len, scsi_cmd->ahs, 0) != scsi_cmd->ahs_len) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); goto error; } } } - TRACE(TRACE_ISCSI_DEBUG, "command PDU sent with %u bytes immediate data (%u bytes AHS)\n", scsi_cmd->length, scsi_cmd->ahs_len); + iscsi_trace(TRACE_ISCSI_DEBUG, "command PDU sent with %u bytes immediate data (%u bytes AHS)\n", scsi_cmd->length, scsi_cmd->ahs_len); /* * Send data PDUS if 1) we're not in R2T mode and 2) we haven't sent @@ -2319,7 +2319,7 @@ scsi_command_i(initiator_cmd_t * cmd) uint32_t DataSN = 0; - TRACE(TRACE_ISCSI_DEBUG, "preparing to send %i bytes write data\n", scsi_cmd->trans_len - scsi_cmd->bytes_sent); + iscsi_trace(TRACE_ISCSI_DEBUG, "preparing to send %i bytes write data\n", scsi_cmd->trans_len - scsi_cmd->bytes_sent); do { (void) memset(&data, 0x0, sizeof(data)); @@ -2360,7 +2360,7 @@ scsi_command_i(initiator_cmd_t * cmd) data.offset = scsi_cmd->bytes_sent; if (iscsi_write_data_encap(header, &data) != 0) { - TRACE_ERROR("iscsi_write_data_encap() failed\n"); + iscsi_trace_error("iscsi_write_data_encap() failed\n"); goto error; } if (data.length != scsi_cmd->trans_len) { @@ -2372,7 +2372,7 @@ scsi_command_i(initiator_cmd_t * cmd) if (!fragment_flag) { if ((sg_copy = iscsi_malloc_atomic(sg_len * sizeof(struct iovec))) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); goto error; } sg_copy_orig = sg_copy; @@ -2382,7 +2382,7 @@ scsi_command_i(initiator_cmd_t * cmd) memcpy(sg_copy, sg, sizeof(struct iovec) * sg_len); sg_len_copy = sg_len; if (modify_iov(&sg_copy, &sg_len_copy, scsi_cmd->bytes_sent, data.length) != 0) { - TRACE_ERROR("modify_iov() failed\n"); + iscsi_trace_error("modify_iov() failed\n"); goto error; } sg_which = sg_copy; @@ -2399,26 +2399,26 @@ scsi_command_i(initiator_cmd_t * cmd) sg_len_which = sg_len; } - TRACE(TRACE_ISCSI_DEBUG, "sending write data PDU (offset %u, len %u, sg_len %u)\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "sending write data PDU (offset %u, len %u, sg_len %u)\n", data.offset, data.length, sg_len_which); if (iscsi_sock_send_header_and_data(sess->sock, header, ISCSI_HEADER_LEN, sg_which, data.length, sg_len_which) != ISCSI_HEADER_LEN + data.length) { - TRACE_ERROR("iscsi_sock_send_header_and_data() failed\n"); + iscsi_trace_error("iscsi_sock_send_header_and_data() failed\n"); goto error; } - TRACE(TRACE_ISCSI_DEBUG, "sent write data PDU (offset %u, len %u)\n", data.offset, data.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "sent write data PDU (offset %u, len %u)\n", data.offset, data.length); scsi_cmd->bytes_sent += data.length; } while ((scsi_cmd->bytes_sent < scsi_cmd->trans_len) && ((scsi_cmd->bytes_sent < sess->sess_params.first_burst_length) || (!sess->sess_params.first_burst_length))); if (scsi_cmd->trans_len - scsi_cmd->bytes_sent) { - TRACE(TRACE_ISCSI_DEBUG, "REACHED FIRST BURST\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "REACHED FIRST BURST\n"); } - TRACE(TRACE_ISCSI_DEBUG, "successfully sent %u of %u bytes write data\n", scsi_cmd->bytes_sent, scsi_cmd->trans_len); + iscsi_trace(TRACE_ISCSI_DEBUG, "successfully sent %u of %u bytes write data\n", scsi_cmd->bytes_sent, scsi_cmd->trans_len); } if (scsi_cmd->output && (scsi_cmd->trans_len - scsi_cmd->bytes_sent)) { - TRACE(TRACE_ISCSI_DEBUG, "expecting R2T for remaining %u bytes write data\n", scsi_cmd->trans_len - scsi_cmd->bytes_sent); + iscsi_trace(TRACE_ISCSI_DEBUG, "expecting R2T for remaining %u bytes write data\n", scsi_cmd->trans_len - scsi_cmd->bytes_sent); } if (fragment_flag) iscsi_free_atomic(sg_copy_orig); @@ -2443,7 +2443,7 @@ reject_i(initiator_session_t * sess, uint8_t *header) /* Get & check args */ if (iscsi_reject_decap(header, &reject) != 0) { - TRACE_ERROR("iscsi_reject_decap() failed\n"); + iscsi_trace_error("iscsi_reject_decap() failed\n"); return -1; } RETURN_NOT_EQUAL("reject.length", reject.length, ISCSI_HEADER_LEN, NO_CLEANUP, -1); @@ -2451,23 +2451,23 @@ reject_i(initiator_session_t * sess, uint8_t *header) /* Read bad header, extract tag, and get cmd from hash table */ if (iscsi_sock_msg(sess->sock, 0, ISCSI_HEADER_LEN, bad_header, 0) != ISCSI_HEADER_LEN) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); return -1; } tag = ISCSI_NTOHL(*((uint32_t *) (bad_header + 16))); - TRACE_ERROR("REJECT PDU: tag 0x%x (reason 0x%x)\n", tag, reject.reason); + iscsi_trace_error("REJECT PDU: tag 0x%x (reason 0x%x)\n", tag, reject.reason); if (tag != 0xffffffff) { if ((cmd = hash_remove(&g_tag_hash, tag)) == NULL) { - TRACE(TRACE_ISCSI_DEBUG, "no cmd ptr associated with tag 0x%x\n", tag); + iscsi_trace(TRACE_ISCSI_DEBUG, "no cmd ptr associated with tag 0x%x\n", tag); } else { - TRACE(TRACE_ISCSI_DEBUG, "cmd %p associated with tag 0x%x\n", cmd, tag); + iscsi_trace(TRACE_ISCSI_DEBUG, "cmd %p associated with tag 0x%x\n", cmd, tag); ISCSI_LOCK(&sess->rx_worker.work_mutex, return -1); if (!cmd->tx_done) ISCSI_WAIT(&sess->rx_worker.work_cond, &sess->rx_worker.work_mutex, return -1); ISCSI_UNLOCK(&sess->rx_worker.work_mutex, return -1); } } else { - TRACE_ERROR("no command associated with tag 0x%x\n", tag); + iscsi_trace_error("no command associated with tag 0x%x\n", tag); } /* Execute callback to complete initiator_cmd_t */ @@ -2475,13 +2475,13 @@ reject_i(initiator_session_t * sess, uint8_t *header) if (cmd) { cmd->status = -1; if (cmd->callback) { - TRACE(TRACE_ISCSI_DEBUG, "issuing callback for cmd associated with tag 0x%x\n", tag); + iscsi_trace(TRACE_ISCSI_DEBUG, "issuing callback for cmd associated with tag 0x%x\n", tag); if ((*cmd->callback)(cmd) != 0) { - TRACE_ERROR("callback() failed\n"); + iscsi_trace_error("callback() failed\n"); return -1; } } else { - TRACE_ERROR("no callback associated with tag 0x%x\n", tag); + iscsi_trace_error("no callback associated with tag 0x%x\n", tag); } } return 0; @@ -2494,7 +2494,7 @@ async_msg_i(initiator_session_t * sess, uint8_t *header) /* Get & check args */ if (iscsi_amsg_decap(header, &msg) != 0) { - TRACE_ERROR("iscsi_amsg_decap() failed\n"); + iscsi_trace_error("iscsi_amsg_decap() failed\n"); return -1; } sess->CmdSN = msg.ExpCmdSN; @@ -2505,21 +2505,21 @@ async_msg_i(initiator_session_t * sess, uint8_t *header) if (msg.length) { uint8_t *sense_data = NULL; if ((sense_data = iscsi_malloc(msg.length)) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); return -1; } - TRACE(TRACE_ISCSI_DEBUG, "reading %i bytes sense data \n", msg.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "reading %i bytes sense data \n", msg.length); if (iscsi_sock_msg(sess->sock, 0, msg.length, sense_data, 0) != msg.length) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); if (sense_data != NULL) iscsi_free(sense_data); return -1; } - TRACE(TRACE_ISCSI_DEBUG, "read %i bytes sense data ok (currently discarding)\n", msg.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "read %i bytes sense data ok (currently discarding)\n", msg.length); if (sense_data != NULL) iscsi_free(sense_data); } else { - TRACE(TRACE_ISCSI_DEBUG, "no sense data available\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "no sense data available\n"); } switch (msg.AsyncEvent) { @@ -2534,7 +2534,7 @@ async_msg_i(initiator_session_t * sess, uint8_t *header) case 2: case 3: if (iscsi_sock_shutdown(sess->sock, 1) != 0) { - TRACE_ERROR("iscsi_sock_shutdown() failed\n"); + iscsi_trace_error("iscsi_sock_shutdown() failed\n"); } return -1; case 255: @@ -2557,31 +2557,31 @@ nop_in_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *header) if (cmd) { nop_out = (iscsi_nop_out_args_t *) cmd->ptr; } else { - TRACE_ERROR("no initiator_cmd_t associated with this NOP_IN\n"); + iscsi_trace_error("no initiator_cmd_t associated with this NOP_IN\n"); } if (iscsi_nop_in_decap(header, &nop_in) != 0) { - TRACE_ERROR("iscsi_nop_in() failed\n"); + iscsi_trace_error("iscsi_nop_in() failed\n"); return -1; } if (cmd) RETURN_NOT_EQUAL("nop_in.length", nop_in.length, nop_out->length, NO_CLEANUP, -1); if (nop_in.length) { - TRACE(TRACE_ISCSI_DEBUG, "reading %i bytes ping data\n", nop_in.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "reading %i bytes ping data\n", nop_in.length); if ((ping_data = iscsi_malloc_atomic(nop_in.length)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } #define NOI_CLEANUP {if (ping_data) iscsi_free_atomic(ping_data);} #define NOI_ERROR {NOI_CLEANUP; return -1;} if (iscsi_sock_msg(sess->sock, 0, nop_in.length, ping_data, 0) != nop_in.length) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); NOI_ERROR; } - TRACE(TRACE_ISCSI_DEBUG, "successfully read %i bytes ping data\n", nop_in.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "successfully read %i bytes ping data\n", nop_in.length); if (cmd) { for (i = 0; i < nop_in.length; i++) { if (nop_out->data[i] != ping_data[i]) { - TRACE_ERROR("Bad ping data[%i]. Got 0x%x, expected 0x%x\n", i, ping_data[i], nop_out->data[i]); + iscsi_trace_error("Bad ping data[%i]. Got 0x%x, expected 0x%x\n", i, ping_data[i], nop_out->data[i]); NOI_ERROR; } } @@ -2594,7 +2594,7 @@ nop_in_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *header) uint8_t nop_header[ISCSI_HEADER_LEN]; iscsi_nop_out_args_t nop_out_args; - TRACE(TRACE_ISCSI_DEBUG, "sending %i byte ping response\n", nop_in.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "sending %i byte ping response\n", nop_in.length); (void) memset(&nop_out_args, 0x0, sizeof(nop_out_args)); nop_out_args.tag = 0xffffffff; nop_out_args.immediate = 0x40; @@ -2604,14 +2604,14 @@ nop_in_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *header) nop_out_args.ExpStatSN = sess->ExpStatSN; nop_out_args.CmdSN = sess->CmdSN; if (iscsi_nop_out_encap(nop_header, &nop_out_args) != 0) { - TRACE_ERROR("iscsi_nop_out_encap() failed\n"); + iscsi_trace_error("iscsi_nop_out_encap() failed\n"); NOI_ERROR; } if (iscsi_sock_send_header_and_data(sess->sock, nop_header, nop_out_args.length, ping_data, nop_in.length, 0) != nop_in.length) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); NOI_ERROR; } - TRACE(TRACE_ISCSI_DEBUG, "successfully sent %i byte ping response\n", nop_in.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "successfully sent %i byte ping response\n", nop_in.length); } NOI_CLEANUP; /* Check and update numbering */ @@ -2632,13 +2632,13 @@ nop_in_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *header) if (cmd) { cmd->status = 0; if (cmd->callback) { - TRACE(TRACE_ISCSI_DEBUG, "NOP_OUT_T done (cmd status %i)\n", cmd->status); + iscsi_trace(TRACE_ISCSI_DEBUG, "NOP_OUT_T done (cmd status %i)\n", cmd->status); if ((*cmd->callback)(cmd) != 0) { - TRACE_ERROR("callback() failed\n"); + iscsi_trace_error("callback() failed\n"); return -1; } } else { - TRACE(TRACE_ISCSI_DEBUG, "no callback associated with NOP_IN_T??\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "no callback associated with NOP_IN_T??\n"); return -1; } } @@ -2667,21 +2667,21 @@ scsi_r2t_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *header) if (cmd) { if ((scsi_cmd = (iscsi_scsi_cmd_args_t *) cmd->ptr) == NULL) { - TRACE_ERROR("no iscsi_scsi_cmd_args_t associated with this initiator_cmd_t??\n"); + iscsi_trace_error("no iscsi_scsi_cmd_args_t associated with this initiator_cmd_t??\n"); return -1; } else if (cmd->callback == NULL) { - TRACE_ERROR("no callback associated with this initiator_cmd_t??\n"); + iscsi_trace_error("no callback associated with this initiator_cmd_t??\n"); return -1; } } else { - TRACE_ERROR("no initiator_cmd_t associated with this iscsi_r2t_t??\n"); + iscsi_trace_error("no initiator_cmd_t associated with this iscsi_r2t_t??\n"); return -1; } sg = sg_copy = sg_copy_orig = sg_which = NULL; sg_len = sg_len_copy = sg_len_which = 0; if (iscsi_r2t_decap(header, &r2t) != 0) { - TRACE_ERROR("iscsi_r2t_decap() failed\n"); + iscsi_trace_error("iscsi_r2t_decap() failed\n"); return -1; } /* Check args */ @@ -2696,7 +2696,7 @@ scsi_r2t_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *header) /* Send back requested data */ - TRACE(TRACE_ISCSI_DEBUG, "sending %i bytes R2T write data (offset %u)\n", r2t.length, r2t.offset); + iscsi_trace(TRACE_ISCSI_DEBUG, "sending %i bytes R2T write data (offset %u)\n", r2t.length, r2t.offset); if (scsi_cmd->send_sg_len) { sg = (struct iovec *) scsi_cmd->send_data; sg_len = scsi_cmd->send_sg_len; @@ -2728,16 +2728,16 @@ scsi_r2t_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *header) data.offset = r2t.offset + bytes_sent; data.lun = scsi_cmd->lun; if (iscsi_write_data_encap(header, &data) != 0) { - TRACE_ERROR("iscsi_write_data_encap() failed\n"); + iscsi_trace_error("iscsi_write_data_encap() failed\n"); FF_CLEANUP; return -1; } if ((data.length < r2t.length) || (r2t.offset)) { if (data.length < r2t.length) { - TRACE(TRACE_ISCSI_DEBUG, "R2T data is being fragmented: sending %u bytes of %u requested\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "R2T data is being fragmented: sending %u bytes of %u requested\n", data.length, r2t.length); } else { - TRACE(TRACE_ISCSI_DEBUG, "R2T data starts at offset %u, desired length %u\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "R2T data starts at offset %u, desired length %u\n", r2t.offset, r2t.length); } @@ -2745,7 +2745,7 @@ scsi_r2t_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *header) if (!fragment_flag) { if ((sg_copy_orig = iscsi_malloc_atomic(sg_len * sizeof(struct iovec))) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } fragment_flag++; @@ -2755,39 +2755,39 @@ scsi_r2t_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *header) * length */ - TRACE(TRACE_ISCSI_DEBUG, "modifying original iovec with offset %u length %u\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "modifying original iovec with offset %u length %u\n", r2t.offset + bytes_sent, data.length); sg_copy = sg_copy_orig; sg_len_copy = sg_len; memcpy(sg_copy, sg, sizeof(struct iovec) * sg_len); if (modify_iov(&sg_copy, &sg_len_copy, r2t.offset + bytes_sent, data.length) != 0) { - TRACE_ERROR("modify_iov() failed\n"); + iscsi_trace_error("modify_iov() failed\n"); FF_CLEANUP; return -1; } sg_which = sg_copy; sg_len_which = sg_len_copy; } else { - TRACE(TRACE_ISCSI_DEBUG, "using original iovec for R2T transfer (offset %u, length %u)\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "using original iovec for R2T transfer (offset %u, length %u)\n", r2t.offset, r2t.length); sg_which = sg; sg_len_which = sg_len; } - TRACE(TRACE_ISCSI_DEBUG, "sending R2T write data PDU (offset %u, len %u, sg_len %u)\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "sending R2T write data PDU (offset %u, len %u, sg_len %u)\n", data.offset, data.length, sg_len_which); if (iscsi_sock_send_header_and_data(sess->sock, header, ISCSI_HEADER_LEN, sg_which, data.length, sg_len_which) != ISCSI_HEADER_LEN + data.length) { - TRACE_ERROR("iscsi_sock_send_header_and_data() failed\n"); + iscsi_trace_error("iscsi_sock_send_header_and_data() failed\n"); FF_CLEANUP; return -1; } - TRACE(TRACE_ISCSI_DEBUG, "sent write data PDU OK (offset %u, len %u)\n", data.offset, data.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "sent write data PDU OK (offset %u, len %u)\n", data.offset, data.length); bytes_sent += data.length; scsi_cmd->bytes_sent += data.length; } while (bytes_sent < r2t.length); FF_CLEANUP; if (hash_insert(&g_tag_hash, cmd, scsi_cmd->tag) != 0) { - TRACE_ERROR("hash_insert() failed\n"); + iscsi_trace_error("hash_insert() failed\n"); return -1; } return 0; @@ -2808,14 +2808,14 @@ scsi_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *head if (cmd) { if ((scsi_cmd = (iscsi_scsi_cmd_args_t *) cmd->ptr) == NULL) { - TRACE_ERROR("no iscsi_scsi_cmd_args_t associated with this initiator_cmd_t??\n"); + iscsi_trace_error("no iscsi_scsi_cmd_args_t associated with this initiator_cmd_t??\n"); return -1; } else if (cmd->callback == NULL) { - TRACE_ERROR("no callback associated with this initiator_cmd_t??\n"); + iscsi_trace_error("no callback associated with this initiator_cmd_t??\n"); return -1; } } else { - TRACE_ERROR("no initiator_cmd_t associated with this iscsi_scsi_rsp_t??\n"); + iscsi_trace_error("no initiator_cmd_t associated with this iscsi_scsi_rsp_t??\n"); return -1; } @@ -2826,7 +2826,7 @@ scsi_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *head /* yet implemented. */ if (iscsi_scsi_rsp_decap(header, &scsi_rsp) != 0) { - TRACE_ERROR("iscsi_scsi_rsp_decap() failed\n"); + iscsi_trace_error("iscsi_scsi_rsp_decap() failed\n"); return -1; } RETURN_NOT_EQUAL("o bit (FIX ME)", scsi_rsp.bidi_overflow, 0, NO_CLEANUP, -1); @@ -2843,7 +2843,7 @@ scsi_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *head sess->sess_params.max_data_seg_length, NO_CLEANUP, -1); } if ((scsi_rsp.status == 0) && (scsi_rsp.length != 0)) { - TRACE_ERROR("Unexpected DataSegmentLength %u with GOOD SCSI status\n", scsi_rsp.length); + iscsi_trace_error("Unexpected DataSegmentLength %u with GOOD SCSI status\n", scsi_rsp.length); return -1; } /* @@ -2867,22 +2867,22 @@ scsi_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *head uint8_t *sense_data = NULL; if ((sense_data = iscsi_malloc(scsi_rsp.length)) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); return -1; } - TRACE_ERROR("reading %i bytes sense data (recv_sg_len %u)\n", + iscsi_trace_error("reading %i bytes sense data (recv_sg_len %u)\n", scsi_rsp.length, scsi_cmd->recv_sg_len); if (iscsi_sock_msg(sess->sock, 0, scsi_rsp.length, sense_data, 0) != scsi_rsp.length) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); if (sense_data != NULL) iscsi_free(sense_data); return -1; } - TRACE_ERROR("read %i bytes sense data ok (currently discarding)\n", scsi_rsp.length); + iscsi_trace_error("read %i bytes sense data ok (currently discarding)\n", scsi_rsp.length); if (sense_data != NULL) iscsi_free(sense_data); } else { - TRACE(TRACE_ISCSI_DEBUG, "no sense data available\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "no sense data available\n"); } /* Check and update numbering */ @@ -2898,10 +2898,10 @@ scsi_response_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *head cmd->status = 0; scsi_cmd->status = scsi_rsp.status; - TRACE(TRACE_ISCSI_DEBUG, "iscsi_scsi_cmd_args_t done (cmd status %i, iscsi status %i, scsi status %i)\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "iscsi_scsi_cmd_args_t done (cmd status %i, iscsi status %i, scsi status %i)\n", cmd->status, scsi_rsp.response, scsi_rsp.status); if ((*cmd->callback)(cmd) != 0) { - TRACE_ERROR("callback() failed\n"); + iscsi_trace_error("callback() failed\n"); return -1; } @@ -2915,7 +2915,7 @@ scsi_read_data_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea iscsi_scsi_cmd_args_t *scsi_cmd; int rc; - TRACE(TRACE_ISCSI_DEBUG, "processing read data\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "processing read data\n"); /* Make sure an initiator_cmd_t was specified, that it has a callback */ /* @@ -2926,7 +2926,7 @@ scsi_read_data_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea if (cmd) { if (cmd->type != ISCSI_SCSI_CMD) { - TRACE_ERROR("Invalid response from target for cmd type (0x%x)\n", cmd->type); + iscsi_trace_error("Invalid response from target for cmd type (0x%x)\n", cmd->type); cmd->status = -1; if (cmd->callback) { (*cmd->callback)(cmd); @@ -2934,18 +2934,18 @@ scsi_read_data_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea return -1; } if ((scsi_cmd = (iscsi_scsi_cmd_args_t *) cmd->ptr) == NULL) { - TRACE_ERROR("no iscsi_scsi_cmd_args_t associated with this initiator_cmd_t??\n"); + iscsi_trace_error("no iscsi_scsi_cmd_args_t associated with this initiator_cmd_t??\n"); return -1; } else if (cmd->callback == NULL) { - TRACE_ERROR("no callback associated with this initiator_cmd_t??\n"); + iscsi_trace_error("no callback associated with this initiator_cmd_t??\n"); return -1; } } else { - TRACE_ERROR("no initiator_cmd_t associated with this iscsi_read_data_t??\n"); + iscsi_trace_error("no initiator_cmd_t associated with this iscsi_read_data_t??\n"); return -1; } if (iscsi_read_data_decap(header, &data) != 0) { - TRACE_ERROR("iscsi_scsi_rsp_decap() failed\n"); + iscsi_trace_error("iscsi_scsi_rsp_decap() failed\n"); return -1; } /* Check args */ @@ -2978,7 +2978,7 @@ scsi_read_data_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea /* Make a copy of the iovec */ if ((sg_orig = sg = iscsi_malloc_atomic(sizeof(struct iovec) * sg_len)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } @@ -3016,9 +3016,9 @@ scsi_read_data_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea } else { sg = (struct iovec *) scsi_cmd->recv_data; } - TRACE(TRACE_ISCSI_DEBUG, "reading %i bytes into sg buffer (total offset %u)\n", data.length, data.offset); + iscsi_trace(TRACE_ISCSI_DEBUG, "reading %i bytes into sg buffer (total offset %u)\n", data.length, data.offset); if ((rc = iscsi_sock_msg(sess->sock, 0, data.length, (uint8_t *) sg, sg_len)) != data.length) { - TRACE_ERROR("iscsi_sock_msg() failed: got %u, expected %u\n", rc, data.length); + iscsi_trace_error("iscsi_sock_msg() failed: got %u, expected %u\n", rc, data.length); if (sg_orig) iscsi_free_atomic(sg_orig); return -1; @@ -3028,9 +3028,9 @@ scsi_read_data_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea iscsi_free_atomic(sg_orig); } else { if (data.length) { - TRACE(TRACE_ISCSI_DEBUG, "reading %i bytes into dest buffer (offset %u)\n", data.length, data.offset); + iscsi_trace(TRACE_ISCSI_DEBUG, "reading %i bytes into dest buffer (offset %u)\n", data.length, data.offset); if (iscsi_sock_msg(sess->sock, 0, data.length, scsi_cmd->recv_data + data.offset, 0) != data.length) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); return -1; } scsi_cmd->bytes_recv += data.length; @@ -3041,23 +3041,23 @@ scsi_read_data_i(initiator_session_t * sess, initiator_cmd_t * cmd, uint8_t *hea /* Check for status */ if (data.S_bit) { - TRACE(TRACE_ISCSI_DEBUG, "received status with final PDU\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "received status with final PDU\n"); RETURN_NOT_EQUAL("Final Bit", data.final, 1, NO_CLEANUP, -1); RETURN_NOT_EQUAL("StatSN", data.StatSN, sess->ExpStatSN++, NO_CLEANUP, -1); scsi_cmd->status = data.status = 0; cmd->status = 0; - TRACE(TRACE_ISCSI_DEBUG, "scsi op 0x%x done (tag %u, status %i)\n", scsi_cmd->cdb[0], scsi_cmd->tag, scsi_cmd->status); + iscsi_trace(TRACE_ISCSI_DEBUG, "scsi op 0x%x done (tag %u, status %i)\n", scsi_cmd->cdb[0], scsi_cmd->tag, scsi_cmd->status); if ((*cmd->callback)(cmd) != 0) { - TRACE_ERROR("callback() failed\n"); + iscsi_trace_error("callback() failed\n"); return -1; } } else { if (hash_insert(&g_tag_hash, cmd, scsi_cmd->tag) != 0) { - TRACE_ERROR("hash_insert() failed\n"); + iscsi_trace_error("hash_insert() failed\n"); return -1; } } - TRACE(TRACE_ISCSI_DEBUG, "read data processed\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "read data processed\n"); return 0; } @@ -3122,7 +3122,7 @@ initiator_discover(char *host, uint64_t target, int lun) discover_cmd.lun = lun; discover_cmd.tag = 0xffffffff; if (initiator_command(&cmd) != 0) { - TRACE_ERROR("initiator_command() failed\n"); + iscsi_trace_error("initiator_command() failed\n"); return -1; } return 0; diff --git a/dist/iscsi/src/iscsi-harness.c b/dist/iscsi/src/iscsi-harness.c index 9b36f332b410..dfa7a4944953 100644 --- a/dist/iscsi/src/iscsi-harness.c +++ b/dist/iscsi/src/iscsi-harness.c @@ -137,7 +137,7 @@ main(int argc, char **argv) if (user == NULL) { if ((pwp = getpwuid(geteuid())) == NULL) { - TRACE_ERROR("can't find user information\n"); + iscsi_trace_error("can't find user information\n"); exit(EXIT_FAILURE); } user = pwp->pw_name; @@ -145,7 +145,7 @@ main(int argc, char **argv) if (target != -1) { if (target >= CONFIG_INITIATOR_NUM_TARGETS) { - TRACE_ERROR("initiator only configured with %i targets\n", CONFIG_INITIATOR_NUM_TARGETS); + iscsi_trace_error("initiator only configured with %i targets\n", CONFIG_INITIATOR_NUM_TARGETS); exit(EXIT_FAILURE); } tgtlo = target; @@ -157,7 +157,7 @@ main(int argc, char **argv) } for (j = 0; j < iterations; j++) { - PRINT("\n", j); + printf("\n", j); /* Ignore sigpipe */ @@ -166,14 +166,14 @@ main(int argc, char **argv) /* Initialize Initiator */ if (initiator_init(host, user, auth_type, mutual_auth, digest_type) == -1) { - TRACE_ERROR("initiator_init() failed\n"); + iscsi_trace_error("initiator_init() failed\n"); return -1; } /* Run tests for each target */ for (i = tgtlo; i < tgthi; i++) { if (test_all(i, lun) != 0) { - TRACE_ERROR("test_all() failed\n"); + iscsi_trace_error("test_all() failed\n"); return -1; } } @@ -181,7 +181,7 @@ main(int argc, char **argv) /* Shutdown Initiator */ if (initiator_shutdown() == -1) { - TRACE_ERROR("initiator_shutdown() failed\n"); + iscsi_trace_error("initiator_shutdown() failed\n"); return -1; } } diff --git a/dist/iscsi/src/iscsi-target.c b/dist/iscsi/src/iscsi-target.c index 025bf43b2c3c..227af54dc860 100644 --- a/dist/iscsi/src/iscsi-target.c +++ b/dist/iscsi/src/iscsi-target.c @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi-target.c,v 1.7 2006/03/11 11:58:22 wiz Exp $ */ +/* $NetBSD: iscsi-target.c,v 1.8 2006/03/12 18:47:28 agc Exp $ */ /* * Copyright © 2006 Alistair Crooks. All rights reserved. @@ -141,14 +141,14 @@ main(int argc, char **argv) } /* Initialize target */ if (target_init(&g, &tv, TargetName) != 0) { - TRACE_ERROR("target_init() failed\n"); + iscsi_trace_error("target_init() failed\n"); exit(EXIT_FAILURE); } #ifdef HAVE_DAEMON /* if we are supposed to be a daemon, detach from controlling tty */ if (detach_me_harder && daemon(0, 0) < 0) { - TRACE_ERROR("daemon() failed\n"); + iscsi_trace_error("daemon() failed\n"); exit(EXIT_FAILURE); } #endif @@ -158,7 +158,7 @@ main(int argc, char **argv) /* Wait for connections */ if (target_listen(&g) != 0) { - TRACE_ERROR("target_listen() failed\n"); + iscsi_trace_error("target_listen() failed\n"); } return EXIT_SUCCESS; diff --git a/dist/iscsi/src/iscsi.c b/dist/iscsi/src/iscsi.c index 1bfdab40b15c..beff0f243c90 100644 --- a/dist/iscsi/src/iscsi.c +++ b/dist/iscsi/src/iscsi.c @@ -62,15 +62,15 @@ int iscsi_task_cmd_encap(uint8_t *header, iscsi_task_cmd_t * cmd) { - TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); - TRACE(TRACE_ISCSI_ARGS, "Function: %u\n", cmd->function); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "Ref Tag: 0x%x\n", cmd->ref_tag); - TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); - TRACE(TRACE_ISCSI_ARGS, "RefCmdSN: %u\n", cmd->RefCmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpDataSN: %u\n", cmd->ExpDataSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); + iscsi_trace(TRACE_ISCSI_ARGS, "Function: %u\n", cmd->function); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Ref Tag: 0x%x\n", cmd->ref_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "RefCmdSN: %u\n", cmd->RefCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpDataSN: %u\n", cmd->ExpDataSN); (void) memset(header, 0x0, ISCSI_HEADER_LEN); @@ -113,15 +113,15 @@ iscsi_task_cmd_decap(uint8_t *header, iscsi_task_cmd_t * cmd) RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *) (void *) (header + 40)), 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *) (void *) (header + 44)), 0, NO_CLEANUP, 1); - TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); - TRACE(TRACE_ISCSI_ARGS, "Function: %u\n", cmd->function); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "Ref Tag: 0x%x\n", cmd->ref_tag); - TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); - TRACE(TRACE_ISCSI_ARGS, "RefCmdSN: %u\n", cmd->RefCmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpDataSN: %u\n", cmd->ExpDataSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); + iscsi_trace(TRACE_ISCSI_ARGS, "Function: %u\n", cmd->function); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Ref Tag: 0x%x\n", cmd->ref_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "RefCmdSN: %u\n", cmd->RefCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpDataSN: %u\n", cmd->ExpDataSN); return 0; } @@ -136,12 +136,12 @@ iscsi_task_rsp_encap(uint8_t *header, iscsi_task_rsp_t * rsp) uint32_t length; - TRACE(TRACE_ISCSI_ARGS, "Response: %u\n", rsp->response); - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length); - TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", rsp->tag); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Response: %u\n", rsp->response); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length); + iscsi_trace(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", rsp->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); (void) memset(header, 0x0, ISCSI_HEADER_LEN); @@ -181,11 +181,11 @@ iscsi_task_rsp_decap(uint8_t *header, iscsi_task_rsp_t * rsp) RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *) (void *) (header + 40)), 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *) (void *) (header + 44)), 0, NO_CLEANUP, 1); - TRACE(TRACE_ISCSI_ARGS, "Response: %u\n", rsp->response); - TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", rsp->tag); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Response: %u\n", rsp->response); + iscsi_trace(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", rsp->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); return 0; } @@ -200,13 +200,13 @@ iscsi_nop_out_encap(uint8_t *header, iscsi_nop_out_args_t * cmd) uint32_t length; - TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); - TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); (void) memset(header, 0x0, ISCSI_HEADER_LEN); @@ -249,13 +249,13 @@ iscsi_nop_out_decap(uint8_t *header, iscsi_nop_out_args_t * cmd) RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *) (void *) (header + 40)), 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *) (void *) (header + 44)), 0, NO_CLEANUP, 1); - TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); - TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); return 0; } @@ -269,13 +269,13 @@ iscsi_nop_in_encap(uint8_t *header, iscsi_nop_in_args_t * cmd) { uint32_t length; - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); (void) memset(header, 0x0, ISCSI_HEADER_LEN); @@ -318,13 +318,13 @@ iscsi_nop_in_decap(uint8_t *header, iscsi_nop_in_args_t * cmd) RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *) (void *) (header + 40)), 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *) (void *) (header + 44)), 0, NO_CLEANUP, 1); - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); return 0; } @@ -337,15 +337,15 @@ iscsi_text_cmd_encap(uint8_t *header, iscsi_text_cmd_args_t * cmd) { uint32_t length; - TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); - TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final); - TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", cmd->cont); - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); - TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); + iscsi_trace(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final); + iscsi_trace(TRACE_ISCSI_ARGS, "Continue: %i\n", cmd->cont); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); (void) memset(header, 0x0, ISCSI_HEADER_LEN); @@ -397,15 +397,15 @@ iscsi_text_cmd_decap(uint8_t *header, iscsi_text_cmd_args_t * cmd) RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *) (void *) (header + 40)), 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *) (void *) (header + 44)), 0, NO_CLEANUP, 1); - TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); - TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final); - TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", cmd->cont); - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); - TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); + iscsi_trace(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final); + iscsi_trace(TRACE_ISCSI_ARGS, "Continue: %i\n", cmd->cont); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); return 0; } @@ -419,15 +419,15 @@ iscsi_text_rsp_encap(uint8_t *header, iscsi_text_rsp_args_t * rsp) { uint32_t length; - TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", rsp->final); - TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", rsp->cont); - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", rsp->lun); - TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", rsp->tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", rsp->transfer_tag); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Final: %i\n", rsp->final); + iscsi_trace(TRACE_ISCSI_ARGS, "Continue: %i\n", rsp->cont); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", rsp->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", rsp->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", rsp->transfer_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); (void) memset(header, 0x0, ISCSI_HEADER_LEN); header[0] |= 0x00 | ISCSI_TEXT_RSP; /* Opcode */ @@ -475,15 +475,15 @@ iscsi_text_rsp_decap(uint8_t *header, iscsi_text_rsp_args_t * rsp) RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *) (void *) (header + 40)), 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *) (void *) (header + 44)), 0, NO_CLEANUP, 1); - TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", rsp->final); - TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", rsp->cont); - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", rsp->lun); - TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", rsp->tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", rsp->transfer_tag); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Final: %i\n", rsp->final); + iscsi_trace(TRACE_ISCSI_ARGS, "Continue: %i\n", rsp->cont); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", rsp->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", rsp->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", rsp->transfer_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); return 0; } @@ -497,20 +497,20 @@ iscsi_login_cmd_encap(uint8_t *header, iscsi_login_cmd_args_t * cmd) { uint32_t length; - TRACE(TRACE_ISCSI_ARGS, "Transit: %i\n", cmd->transit); - TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", cmd->cont); - TRACE(TRACE_ISCSI_ARGS, "CSG: %u\n", cmd->csg); - TRACE(TRACE_ISCSI_ARGS, "NSG: %u\n", cmd->nsg); - TRACE(TRACE_ISCSI_ARGS, "Version_min: %u\n", cmd->version_min); - TRACE(TRACE_ISCSI_ARGS, "Version_max: %u\n", cmd->version_max); - TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->AHSlength); - TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "ISID: %" PRIu64 "\n", cmd->isid); - TRACE(TRACE_ISCSI_ARGS, "TSIH: %hu\n", cmd->tsih); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "CID: %hu\n", cmd->cid); - TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Transit: %i\n", cmd->transit); + iscsi_trace(TRACE_ISCSI_ARGS, "Continue: %i\n", cmd->cont); + iscsi_trace(TRACE_ISCSI_ARGS, "CSG: %u\n", cmd->csg); + iscsi_trace(TRACE_ISCSI_ARGS, "NSG: %u\n", cmd->nsg); + iscsi_trace(TRACE_ISCSI_ARGS, "Version_min: %u\n", cmd->version_min); + iscsi_trace(TRACE_ISCSI_ARGS, "Version_max: %u\n", cmd->version_max); + iscsi_trace(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->AHSlength); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "ISID: %" PRIu64 "\n", cmd->isid); + iscsi_trace(TRACE_ISCSI_ARGS, "TSIH: %hu\n", cmd->tsih); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "CID: %hu\n", cmd->cid); + iscsi_trace(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); (void) memset(header, 0x0, ISCSI_HEADER_LEN); @@ -559,20 +559,20 @@ iscsi_login_cmd_decap(uint8_t *header, iscsi_login_cmd_args_t * cmd) cmd->CmdSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 24))); /* CmdSN */ cmd->ExpStatSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 28))); /* ExpStatSN */ - TRACE(TRACE_ISCSI_ARGS, "Transit: %i\n", cmd->transit); - TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", cmd->cont); - TRACE(TRACE_ISCSI_ARGS, "CSG: %u\n", cmd->csg); - TRACE(TRACE_ISCSI_ARGS, "NSG: %u\n", cmd->nsg); - TRACE(TRACE_ISCSI_ARGS, "Version_min: %u\n", cmd->version_min); - TRACE(TRACE_ISCSI_ARGS, "Version_max: %u\n", cmd->version_max); - TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->AHSlength); - TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "ISID: %" PRIu64 "\n", cmd->isid); - TRACE(TRACE_ISCSI_ARGS, "TSIH: %hu\n", cmd->tsih); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "CID: %hu\n", cmd->cid); - TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Transit: %i\n", cmd->transit); + iscsi_trace(TRACE_ISCSI_ARGS, "Continue: %i\n", cmd->cont); + iscsi_trace(TRACE_ISCSI_ARGS, "CSG: %u\n", cmd->csg); + iscsi_trace(TRACE_ISCSI_ARGS, "NSG: %u\n", cmd->nsg); + iscsi_trace(TRACE_ISCSI_ARGS, "Version_min: %u\n", cmd->version_min); + iscsi_trace(TRACE_ISCSI_ARGS, "Version_max: %u\n", cmd->version_max); + iscsi_trace(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->AHSlength); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "ISID: %" PRIu64 "\n", cmd->isid); + iscsi_trace(TRACE_ISCSI_ARGS, "TSIH: %hu\n", cmd->tsih); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "CID: %hu\n", cmd->cid); + iscsi_trace(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); RETURN_NOT_EQUAL("Byte 1, bits 2-3", (header[1] & 0x30) >> 4, 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Bytes 22-23", *((uint16_t *) (void *) (header + 22)), 0, NO_CLEANUP, 1); @@ -600,22 +600,22 @@ int iscsi_login_rsp_encap(uint8_t *header, iscsi_login_rsp_args_t * rsp) { - TRACE(TRACE_ISCSI_ARGS, "Transit: %i\n", rsp->transit); - TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", rsp->cont); - TRACE(TRACE_ISCSI_ARGS, "CSG: %u\n", rsp->csg); - TRACE(TRACE_ISCSI_ARGS, "NSG: %u\n", rsp->nsg); - TRACE(TRACE_ISCSI_ARGS, "Version_max: %u\n", rsp->version_max); - TRACE(TRACE_ISCSI_ARGS, "Version_active: %u\n", rsp->version_active); - TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", rsp->AHSlength); - TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", rsp->length); - TRACE(TRACE_ISCSI_ARGS, "ISID: %" PRIu64 "\n", rsp->isid); - TRACE(TRACE_ISCSI_ARGS, "TSIH: %u\n", rsp->tsih); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", rsp->tag); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); - TRACE(TRACE_ISCSI_ARGS, "Status-Class: %u\n", rsp->status_class); - TRACE(TRACE_ISCSI_ARGS, "Status-Detail: %u\n", rsp->status_detail); + iscsi_trace(TRACE_ISCSI_ARGS, "Transit: %i\n", rsp->transit); + iscsi_trace(TRACE_ISCSI_ARGS, "Continue: %i\n", rsp->cont); + iscsi_trace(TRACE_ISCSI_ARGS, "CSG: %u\n", rsp->csg); + iscsi_trace(TRACE_ISCSI_ARGS, "NSG: %u\n", rsp->nsg); + iscsi_trace(TRACE_ISCSI_ARGS, "Version_max: %u\n", rsp->version_max); + iscsi_trace(TRACE_ISCSI_ARGS, "Version_active: %u\n", rsp->version_active); + iscsi_trace(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", rsp->AHSlength); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", rsp->length); + iscsi_trace(TRACE_ISCSI_ARGS, "ISID: %" PRIu64 "\n", rsp->isid); + iscsi_trace(TRACE_ISCSI_ARGS, "TSIH: %u\n", rsp->tsih); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", rsp->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Status-Class: %u\n", rsp->status_class); + iscsi_trace(TRACE_ISCSI_ARGS, "Status-Detail: %u\n", rsp->status_detail); (void) memset(header, 0x0, ISCSI_HEADER_LEN); @@ -670,23 +670,23 @@ iscsi_login_rsp_decap(uint8_t *header, iscsi_login_rsp_args_t * rsp) rsp->status_class = header[36]; /* Status-Class */ rsp->status_detail = header[37]; /* Status-Detail */ - TRACE(TRACE_ISCSI_ARGS, "Transit: %i\n", rsp->transit); - TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", rsp->cont); - TRACE(TRACE_ISCSI_ARGS, "CSG: %u\n", rsp->csg); - TRACE(TRACE_ISCSI_ARGS, "NSG: %u\n", rsp->nsg); + iscsi_trace(TRACE_ISCSI_ARGS, "Transit: %i\n", rsp->transit); + iscsi_trace(TRACE_ISCSI_ARGS, "Continue: %i\n", rsp->cont); + iscsi_trace(TRACE_ISCSI_ARGS, "CSG: %u\n", rsp->csg); + iscsi_trace(TRACE_ISCSI_ARGS, "NSG: %u\n", rsp->nsg); - TRACE(TRACE_ISCSI_ARGS, "Version_max: %u\n", rsp->version_max); - TRACE(TRACE_ISCSI_ARGS, "Version_active: %u\n", rsp->version_active); - TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", rsp->AHSlength); - TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", rsp->length); - TRACE(TRACE_ISCSI_ARGS, "ISID: %" PRIu64 "\n", rsp->isid); - TRACE(TRACE_ISCSI_ARGS, "TSIH: %u\n", rsp->tsih); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", rsp->tag); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); - TRACE(TRACE_ISCSI_ARGS, "Status-Class: %u\n", rsp->status_class); - TRACE(TRACE_ISCSI_ARGS, "Status-Detail: %u\n", rsp->status_detail); + iscsi_trace(TRACE_ISCSI_ARGS, "Version_max: %u\n", rsp->version_max); + iscsi_trace(TRACE_ISCSI_ARGS, "Version_active: %u\n", rsp->version_active); + iscsi_trace(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", rsp->AHSlength); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", rsp->length); + iscsi_trace(TRACE_ISCSI_ARGS, "ISID: %" PRIu64 "\n", rsp->isid); + iscsi_trace(TRACE_ISCSI_ARGS, "TSIH: %u\n", rsp->tsih); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", rsp->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Status-Class: %u\n", rsp->status_class); + iscsi_trace(TRACE_ISCSI_ARGS, "Status-Detail: %u\n", rsp->status_detail); RETURN_NOT_EQUAL("Byte 1, bits 2-3", (header[1] & 0x30) >> 4, 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Bytes 20-23", *((uint32_t *) (void *) (header + 20)), 0, NO_CLEANUP, 1); @@ -706,12 +706,12 @@ int iscsi_logout_cmd_encap(uint8_t *header, iscsi_logout_cmd_args_t * cmd) { - TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); - TRACE(TRACE_ISCSI_ARGS, "Reason: %u\n", cmd->reason); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "CID: %hu\n", cmd->cid); - TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); + iscsi_trace(TRACE_ISCSI_ARGS, "Reason: %u\n", cmd->reason); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "CID: %hu\n", cmd->cid); + iscsi_trace(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); (void) memset(header, 0x0, ISCSI_HEADER_LEN); @@ -741,13 +741,13 @@ iscsi_logout_cmd_decap(uint8_t *header, iscsi_logout_cmd_args_t * cmd) cmd->CmdSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 24))); /* CmdSN */ cmd->ExpStatSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 28))); /* ExpStatSN */ - TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); - TRACE(TRACE_ISCSI_ARGS, "Reason: %u\n", cmd->reason); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); + iscsi_trace(TRACE_ISCSI_ARGS, "Reason: %u\n", cmd->reason); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "CID: %hu\n", cmd->cid); - TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "CID: %hu\n", cmd->cid); + iscsi_trace(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); RETURN_NOT_EQUAL("Byte 0 bit 0", header[0] >> 7, 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Byte 1 bit 0", header[1] >> 7, 1, NO_CLEANUP, 1); @@ -773,15 +773,15 @@ int iscsi_logout_rsp_encap(uint8_t *header, iscsi_logout_rsp_args_t * rsp) { - TRACE(TRACE_ISCSI_ARGS, "Response: %u\n", rsp->response); - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", rsp->tag); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Response: %u\n", rsp->response); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", rsp->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); - TRACE(TRACE_ISCSI_ARGS, "Time2Wait: %hu\n", rsp->Time2Wait); - TRACE(TRACE_ISCSI_ARGS, "Time2Retain: %hu\n", rsp->Time2Retain); + iscsi_trace(TRACE_ISCSI_ARGS, "Time2Wait: %hu\n", rsp->Time2Wait); + iscsi_trace(TRACE_ISCSI_ARGS, "Time2Retain: %hu\n", rsp->Time2Retain); (void) memset(header, 0x0, ISCSI_HEADER_LEN); @@ -824,14 +824,14 @@ iscsi_logout_rsp_decap(uint8_t *header, iscsi_logout_rsp_args_t * rsp) RETURN_NOT_EQUAL("Bytes 36-39", *((uint32_t *) (void *) (header + 36)), 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *) (void *) (header + 44)), 0, NO_CLEANUP, 1); - TRACE(TRACE_ISCSI_ARGS, "Response: %u\n", rsp->response); - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", rsp->tag); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); - TRACE(TRACE_ISCSI_ARGS, "Time2Wait: %hu\n", rsp->Time2Wait); - TRACE(TRACE_ISCSI_ARGS, "Time2Retain: %hu\n", rsp->Time2Retain); + iscsi_trace(TRACE_ISCSI_ARGS, "Response: %u\n", rsp->response); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", rsp->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Time2Wait: %hu\n", rsp->Time2Wait); + iscsi_trace(TRACE_ISCSI_ARGS, "Time2Retain: %hu\n", rsp->Time2Retain); return 0; } @@ -844,19 +844,19 @@ int iscsi_scsi_cmd_encap(uint8_t *header, iscsi_scsi_cmd_args_t * cmd) { - TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); - TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final); - TRACE(TRACE_ISCSI_ARGS, "Input: %i\n", cmd->input); - TRACE(TRACE_ISCSI_ARGS, "Output: %i\n", cmd->output); - TRACE(TRACE_ISCSI_ARGS, "ATTR: %i\n", cmd->attr); - TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->ahs_len); - TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Length: %u\n", cmd->trans_len); - TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); - TRACE(TRACE_ISCSI_ARGS, "CDB: 0x%x\n", cmd->cdb[0]); + iscsi_trace(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); + iscsi_trace(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final); + iscsi_trace(TRACE_ISCSI_ARGS, "Input: %i\n", cmd->input); + iscsi_trace(TRACE_ISCSI_ARGS, "Output: %i\n", cmd->output); + iscsi_trace(TRACE_ISCSI_ARGS, "ATTR: %i\n", cmd->attr); + iscsi_trace(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->ahs_len); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Length: %u\n", cmd->trans_len); + iscsi_trace(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "CDB: 0x%x\n", cmd->cdb[0]); (void) memset(header, 0x0, ISCSI_HEADER_LEN); @@ -913,19 +913,19 @@ iscsi_scsi_cmd_decap(uint8_t *header, iscsi_scsi_cmd_args_t * cmd) RETURN_NOT_EQUAL("Byte 2", header[2], 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Byte 3", header[3], 0, NO_CLEANUP, 1); - TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); - TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final); - TRACE(TRACE_ISCSI_ARGS, "Input: %i\n", cmd->input); - TRACE(TRACE_ISCSI_ARGS, "Output: %i\n", cmd->output); - TRACE(TRACE_ISCSI_ARGS, "ATTR: %i\n", cmd->attr); - TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->ahs_len); - TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Length: %u\n", cmd->trans_len); - TRACE(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); - TRACE(TRACE_ISCSI_ARGS, "CDB: 0x%x\n", cmd->cdb[0]); + iscsi_trace(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate); + iscsi_trace(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final); + iscsi_trace(TRACE_ISCSI_ARGS, "Input: %i\n", cmd->input); + iscsi_trace(TRACE_ISCSI_ARGS, "Output: %i\n", cmd->output); + iscsi_trace(TRACE_ISCSI_ARGS, "ATTR: %i\n", cmd->attr); + iscsi_trace(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->ahs_len); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Length: %u\n", cmd->trans_len); + iscsi_trace(TRACE_ISCSI_ARGS, "CmdSN: %u\n", cmd->CmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "CDB: 0x%x\n", cmd->cdb[0]); return 0; } @@ -938,20 +938,20 @@ int iscsi_scsi_rsp_encap(uint8_t *header, iscsi_scsi_rsp_t * rsp) { - TRACE(TRACE_ISCSI_ARGS, "Bidi Overflow: %i\n", rsp->bidi_overflow); - TRACE(TRACE_ISCSI_ARGS, "Bidi Underflow: %i\n", rsp->bidi_underflow); - TRACE(TRACE_ISCSI_ARGS, "Overflow: %i\n", rsp->overflow); - TRACE(TRACE_ISCSI_ARGS, "Underflow: %i\n", rsp->underflow); - TRACE(TRACE_ISCSI_ARGS, "iSCSI Response: %u\n", rsp->response); - TRACE(TRACE_ISCSI_ARGS, "SCSI Status: %u\n", rsp->status); - TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", rsp->length); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", rsp->tag); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpDataSN: %u\n", rsp->ExpDataSN); - TRACE(TRACE_ISCSI_ARGS, "Bidi Residual Count: %u\n", rsp->bidi_res_cnt); - TRACE(TRACE_ISCSI_ARGS, "Residual Count: %u\n", rsp->basic_res_cnt); + iscsi_trace(TRACE_ISCSI_ARGS, "Bidi Overflow: %i\n", rsp->bidi_overflow); + iscsi_trace(TRACE_ISCSI_ARGS, "Bidi Underflow: %i\n", rsp->bidi_underflow); + iscsi_trace(TRACE_ISCSI_ARGS, "Overflow: %i\n", rsp->overflow); + iscsi_trace(TRACE_ISCSI_ARGS, "Underflow: %i\n", rsp->underflow); + iscsi_trace(TRACE_ISCSI_ARGS, "iSCSI Response: %u\n", rsp->response); + iscsi_trace(TRACE_ISCSI_ARGS, "SCSI Status: %u\n", rsp->status); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", rsp->length); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", rsp->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpDataSN: %u\n", rsp->ExpDataSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Bidi Residual Count: %u\n", rsp->bidi_res_cnt); + iscsi_trace(TRACE_ISCSI_ARGS, "Residual Count: %u\n", rsp->basic_res_cnt); (void) memset(header, 0x0, ISCSI_HEADER_LEN); @@ -1014,20 +1014,20 @@ iscsi_scsi_rsp_decap(uint8_t *header, iscsi_scsi_rsp_t * rsp) RETURN_NOT_EQUAL("bidi_underflow", rsp->bidi_underflow, 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("overflow", rsp->overflow, 0, NO_CLEANUP, 1); - TRACE(TRACE_ISCSI_ARGS, "Bidi Overflow: %i\n", rsp->bidi_overflow); - TRACE(TRACE_ISCSI_ARGS, "Bidi Underflow: %i\n", rsp->bidi_underflow); - TRACE(TRACE_ISCSI_ARGS, "Overflow: %i\n", rsp->overflow); - TRACE(TRACE_ISCSI_ARGS, "Underflow: %i\n", rsp->underflow); - TRACE(TRACE_ISCSI_ARGS, "iSCSI Response: %u\n", rsp->response); - TRACE(TRACE_ISCSI_ARGS, "SCSI Status: %u\n", rsp->status); - TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", rsp->length); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", rsp->tag); - TRACE(TRACE_ISCSI_ARGS, "Residual Count: %u\n", rsp->basic_res_cnt); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); - TRACE(TRACE_ISCSI_ARGS, "ExpDataSN: %u\n", rsp->ExpDataSN); - TRACE(TRACE_ISCSI_ARGS, "Bidi Residual Count: %u\n", rsp->bidi_res_cnt); + iscsi_trace(TRACE_ISCSI_ARGS, "Bidi Overflow: %i\n", rsp->bidi_overflow); + iscsi_trace(TRACE_ISCSI_ARGS, "Bidi Underflow: %i\n", rsp->bidi_underflow); + iscsi_trace(TRACE_ISCSI_ARGS, "Overflow: %i\n", rsp->overflow); + iscsi_trace(TRACE_ISCSI_ARGS, "Underflow: %i\n", rsp->underflow); + iscsi_trace(TRACE_ISCSI_ARGS, "iSCSI Response: %u\n", rsp->response); + iscsi_trace(TRACE_ISCSI_ARGS, "SCSI Status: %u\n", rsp->status); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", rsp->length); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", rsp->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Residual Count: %u\n", rsp->basic_res_cnt); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", rsp->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", rsp->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpDataSN: %u\n", rsp->ExpDataSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Bidi Residual Count: %u\n", rsp->bidi_res_cnt); return 0; } @@ -1042,16 +1042,16 @@ iscsi_r2t_encap(uint8_t *header, iscsi_r2t_t * cmd) { uint32_t length; - TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->AHSlength); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); - TRACE(TRACE_ISCSI_ARGS, "R2TSN: %u\n", cmd->R2TSN); - TRACE(TRACE_ISCSI_ARGS, "Offset: %u\n", cmd->offset); - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->AHSlength); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "R2TSN: %u\n", cmd->R2TSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Offset: %u\n", cmd->offset); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); (void) memset(header, 0x0, ISCSI_HEADER_LEN); @@ -1096,16 +1096,16 @@ iscsi_r2t_decap(uint8_t *header, iscsi_r2t_t * cmd) RETURN_NOT_EQUAL("Bytes 8-11", *((uint32_t *) (void *) (header + 8)), 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Bytes 12-15", *((uint32_t *) (void *) (header + 12)), 0, NO_CLEANUP, 1); - TRACE(TRACE_ISCSI_ARGS, "AHSLength: %u\n", cmd->AHSlength); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); - TRACE(TRACE_ISCSI_ARGS, "R2TSN: %u\n", cmd->R2TSN); - TRACE(TRACE_ISCSI_ARGS, "Offset: %u\n", cmd->offset); - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "AHSLength: %u\n", cmd->AHSlength); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "R2TSN: %u\n", cmd->R2TSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Offset: %u\n", cmd->offset); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); return 0; } @@ -1117,14 +1117,14 @@ int iscsi_write_data_encap(uint8_t *header, iscsi_write_data_t * cmd) { - TRACE(TRACE_ISCSI_ARGS, "Final: %u\n", cmd->final); - TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); - TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); - TRACE(TRACE_ISCSI_ARGS, "DataSN: %u\n", cmd->DataSN); - TRACE(TRACE_ISCSI_ARGS, "Buffer Offset: %u\n", cmd->offset); + iscsi_trace(TRACE_ISCSI_ARGS, "Final: %u\n", cmd->final); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSN: %u\n", cmd->DataSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Buffer Offset: %u\n", cmd->offset); (void) memset(header, 0x0, ISCSI_HEADER_LEN); header[0] = 0x00 | ISCSI_WRITE_DATA; /* Opcode */ @@ -1165,14 +1165,14 @@ iscsi_write_data_decap(uint8_t *header, iscsi_write_data_t * cmd) RETURN_NOT_EQUAL("Byte 32-35", *((uint32_t *) (void *) (header + 32)), 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Byte 44-47", *((uint32_t *) (void *) (header + 44)), 0, NO_CLEANUP, 1); - TRACE(TRACE_ISCSI_ARGS, "Final: %u\n", cmd->final); - TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); - TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); - TRACE(TRACE_ISCSI_ARGS, "DataSN: %u\n", cmd->DataSN); - TRACE(TRACE_ISCSI_ARGS, "Buffer Offset: %u\n", cmd->offset); + iscsi_trace(TRACE_ISCSI_ARGS, "Final: %u\n", cmd->final); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSN: %u\n", cmd->DataSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Buffer Offset: %u\n", cmd->offset); return 0; } @@ -1185,22 +1185,22 @@ int iscsi_read_data_encap(uint8_t *header, iscsi_read_data_t * cmd) { - TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final); - TRACE(TRACE_ISCSI_ARGS, "Acknowledge: %i\n", cmd->ack); - TRACE(TRACE_ISCSI_ARGS, "Overflow: %i\n", cmd->overflow); - TRACE(TRACE_ISCSI_ARGS, "Underflow: %i\n", cmd->underflow); - TRACE(TRACE_ISCSI_ARGS, "S_bit: %i\n", cmd->S_bit); - TRACE(TRACE_ISCSI_ARGS, "Status: %u\n", cmd->status); - TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->task_tag); - TRACE(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); - TRACE(TRACE_ISCSI_ARGS, "DataSN: %u\n", cmd->DataSN); - TRACE(TRACE_ISCSI_ARGS, "Buffer Offset %u\n", cmd->offset); - TRACE(TRACE_ISCSI_ARGS, "Residual Count: %u\n", cmd->res_count); + iscsi_trace(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final); + iscsi_trace(TRACE_ISCSI_ARGS, "Acknowledge: %i\n", cmd->ack); + iscsi_trace(TRACE_ISCSI_ARGS, "Overflow: %i\n", cmd->overflow); + iscsi_trace(TRACE_ISCSI_ARGS, "Underflow: %i\n", cmd->underflow); + iscsi_trace(TRACE_ISCSI_ARGS, "S_bit: %i\n", cmd->S_bit); + iscsi_trace(TRACE_ISCSI_ARGS, "Status: %u\n", cmd->status); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", cmd->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->task_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Transfer Tag: 0x%x\n", cmd->transfer_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSN: %u\n", cmd->DataSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Buffer Offset %u\n", cmd->offset); + iscsi_trace(TRACE_ISCSI_ARGS, "Residual Count: %u\n", cmd->res_count); (void) memset(header, 0x0, ISCSI_HEADER_LEN); @@ -1272,20 +1272,20 @@ iscsi_read_data_decap(uint8_t *header, iscsi_read_data_t * cmd) RETURN_NOT_EQUAL("Bytes 12-15", *((uint32_t *) (void *) (header + 12)), 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *) (void *) (header + 44)), 0, NO_CLEANUP, 1); - TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final); - TRACE(TRACE_ISCSI_ARGS, "Acknowledge: %i\n", cmd->ack); - TRACE(TRACE_ISCSI_ARGS, "Overflow: %i\n", cmd->overflow); - TRACE(TRACE_ISCSI_ARGS, "Underflow: %i\n", cmd->underflow); - TRACE(TRACE_ISCSI_ARGS, "S_bit: %i\n", cmd->S_bit); - TRACE(TRACE_ISCSI_ARGS, "Status: %u\n", cmd->status); - TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->task_tag); - TRACE(TRACE_ISCSI_ARGS, "Residual Count: %u\n", cmd->res_count); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); - TRACE(TRACE_ISCSI_ARGS, "DataSN: %u\n", cmd->DataSN); - TRACE(TRACE_ISCSI_ARGS, "Buffer Offset %u\n", cmd->offset); + iscsi_trace(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final); + iscsi_trace(TRACE_ISCSI_ARGS, "Acknowledge: %i\n", cmd->ack); + iscsi_trace(TRACE_ISCSI_ARGS, "Overflow: %i\n", cmd->overflow); + iscsi_trace(TRACE_ISCSI_ARGS, "Underflow: %i\n", cmd->underflow); + iscsi_trace(TRACE_ISCSI_ARGS, "S_bit: %i\n", cmd->S_bit); + iscsi_trace(TRACE_ISCSI_ARGS, "Status: %u\n", cmd->status); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "Task Tag: 0x%x\n", cmd->task_tag); + iscsi_trace(TRACE_ISCSI_ARGS, "Residual Count: %u\n", cmd->res_count); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSN: %u\n", cmd->DataSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Buffer Offset %u\n", cmd->offset); return 0; } @@ -1297,12 +1297,12 @@ int iscsi_reject_encap(uint8_t *header, iscsi_reject_t * cmd) { - TRACE(TRACE_ISCSI_ARGS, "Reason: %u\n", cmd->reason); - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); - TRACE(TRACE_ISCSI_ARGS, "DataSN: %u\n", cmd->DataSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Reason: %u\n", cmd->reason); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSN: %u\n", cmd->DataSN); (void) memset(header, 0x0, ISCSI_HEADER_LEN); @@ -1341,12 +1341,12 @@ iscsi_reject_decap(uint8_t *header, iscsi_reject_t * cmd) RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *) (void *) (header + 40)), 0, NO_CLEANUP, 1); RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *) (void *) (header + 44)), 0, NO_CLEANUP, 1); - TRACE(TRACE_ISCSI_ARGS, "Reason: %u\n", cmd->reason); - TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); - TRACE(TRACE_ISCSI_ARGS, "DataSN: %u\n", cmd->DataSN); + iscsi_trace(TRACE_ISCSI_ARGS, "Reason: %u\n", cmd->reason); + iscsi_trace(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", cmd->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", cmd->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", cmd->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSN: %u\n", cmd->DataSN); return 0; } @@ -1365,14 +1365,14 @@ iscsi_amsg_decap(uint8_t *header, iscsi_async_msg_t * msg) msg->AsyncEvent = header[36]; /* Async Event */ msg->AsyncVCode = header[37]; /* Async Vendor Code */ - TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", msg->AHSlength); - TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", msg->length); - TRACE(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", msg->lun); - TRACE(TRACE_ISCSI_ARGS, "StatSN: %u\n", msg->StatSN); - TRACE(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", msg->ExpCmdSN); - TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", msg->MaxCmdSN); - TRACE(TRACE_ISCSI_ARGS, "AsyncEvent: %u\n", msg->AsyncEvent); - TRACE(TRACE_ISCSI_ARGS, "AsyncVCode: %u\n", msg->AsyncVCode); + iscsi_trace(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", msg->AHSlength); + iscsi_trace(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", msg->length); + iscsi_trace(TRACE_ISCSI_ARGS, "LUN: %" PRIu64 "\n", msg->lun); + iscsi_trace(TRACE_ISCSI_ARGS, "StatSN: %u\n", msg->StatSN); + iscsi_trace(TRACE_ISCSI_ARGS, "ExpCmdSN: %u\n", msg->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", msg->MaxCmdSN); + iscsi_trace(TRACE_ISCSI_ARGS, "AsyncEvent: %u\n", msg->AsyncEvent); + iscsi_trace(TRACE_ISCSI_ARGS, "AsyncVCode: %u\n", msg->AsyncVCode); return 0; } diff --git a/dist/iscsi/src/iscsiconfig.c b/dist/iscsi/src/iscsiconfig.c index add1a36e5a16..b0fa68595b88 100644 --- a/dist/iscsi/src/iscsiconfig.c +++ b/dist/iscsi/src/iscsiconfig.c @@ -133,7 +133,7 @@ main(int argc, char **argv) if (user == NULL) { if ((pwp = getpwuid(geteuid())) == NULL) { - TRACE_ERROR("can't find user information\n"); + iscsi_trace_error("can't find user information\n"); exit(EXIT_FAILURE); } user = pwp->pw_name; @@ -141,7 +141,7 @@ main(int argc, char **argv) if (target != -1) { if (target >= CONFIG_INITIATOR_NUM_TARGETS) { - TRACE_ERROR("initiator only configured with %i targets\n", CONFIG_INITIATOR_NUM_TARGETS); + iscsi_trace_error("initiator only configured with %i targets\n", CONFIG_INITIATOR_NUM_TARGETS); exit(EXIT_FAILURE); } tgtlo = target; @@ -160,7 +160,7 @@ main(int argc, char **argv) for (i = optind ; i < argc ; i++) { /* Initialize Initiator */ if (initiator_init(host, user, auth_type, mutual_auth, digest_type) == -1) { - TRACE_ERROR("initiator_init() failed\n"); + iscsi_trace_error("initiator_init() failed\n"); exit(EXIT_FAILURE); } @@ -169,7 +169,7 @@ main(int argc, char **argv) /* Shutdown Initiator */ if (initiator_shutdown() == -1) { - TRACE_ERROR("initiator_shutdown() failed\n"); + iscsi_trace_error("initiator_shutdown() failed\n"); exit(EXIT_FAILURE); } } diff --git a/dist/iscsi/src/ktarget.c b/dist/iscsi/src/ktarget.c index 8180b22a7cad..5325c814b92b 100644 --- a/dist/iscsi/src/ktarget.c +++ b/dist/iscsi/src/ktarget.c @@ -52,7 +52,7 @@ static int port = ISCSI_PORT; MODULE_PARM(port, "i"); static int accept_connections(void *arg) { if (target_listen(port)!=0) { - TRACE_ERROR("target_listen() failed\n"); + iscsi_trace_error("target_listen() failed\n"); } return 0; } @@ -62,7 +62,7 @@ int init_module(void) { printk("Usage: port=\n"); printk("\n"); if (target_init(DEFAULT_TARGET_NAME)!=0) { - TRACE_ERROR("target_init() failed\n"); + iscsi_trace_error("target_init() failed\n"); return -1; } kernel_thread(accept_connections, NULL, 0); @@ -71,6 +71,6 @@ int init_module(void) { void cleanup_module(void) { if (target_shutdown()!=0) { - TRACE_ERROR("target_shutdown() failed\n"); + iscsi_trace_error("target_shutdown() failed\n"); } } diff --git a/dist/iscsi/src/mount_iscsi.c b/dist/iscsi/src/mount_iscsi.c index d559e69e3c8b..c254687b42bc 100644 --- a/dist/iscsi/src/mount_iscsi.c +++ b/dist/iscsi/src/mount_iscsi.c @@ -1,4 +1,4 @@ -/* $NetBSD: mount_iscsi.c,v 1.1.1.1 2006/02/08 18:56:18 agc Exp $ */ +/* $NetBSD: mount_iscsi.c,v 1.2 2006/03/12 18:47:28 agc Exp $ */ /* * Copyright © 2005 Alistair Crooks. All rights reserved. @@ -32,7 +32,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright © 2005 \ The NetBSD Foundation, Inc. All rights reserved."); -__RCSID("$NetBSD: mount_iscsi.c,v 1.1.1.1 2006/02/08 18:56:18 agc Exp $"); +__RCSID("$NetBSD: mount_iscsi.c,v 1.2 2006/03/12 18:47:28 agc Exp $"); #endif #include @@ -255,7 +255,7 @@ main(int argc, char **argv) } for (j = 0; j < 1; j++) { - PRINT("\n", j); + printf("\n", j); /* Ignore sigpipe */ @@ -265,14 +265,14 @@ main(int argc, char **argv) /* Initialize Initiator */ if (initiator_init(iqn.domain) == -1) { - TRACE_ERROR("initiator_init() failed\n"); + iscsi_trace_error("initiator_init() failed\n"); return -1; } /* Run tests for each target */ for (i = begin_tid; i < end_tid; i++) { if (test_all(i, lun) != 0) { - TRACE_ERROR("test_all() failed\n"); + iscsi_trace_error("test_all() failed\n"); return -1; } } @@ -280,7 +280,7 @@ main(int argc, char **argv) /* Shutdown Initiator */ if (initiator_shutdown() == -1) { - TRACE_ERROR("initiator_shutdown() failed\n"); + iscsi_trace_error("initiator_shutdown() failed\n"); return -1; } } diff --git a/dist/iscsi/src/osd-target.c b/dist/iscsi/src/osd-target.c index 85c4dce25bf8..e0190aefa262 100644 --- a/dist/iscsi/src/osd-target.c +++ b/dist/iscsi/src/osd-target.c @@ -1,4 +1,4 @@ -/* $NetBSD: osd-target.c,v 1.3 2006/02/12 14:48:49 agc Exp $ */ +/* $NetBSD: osd-target.c,v 1.4 2006/03/12 18:47:28 agc Exp $ */ /* * Copyright © 2006 Alistair Crooks. All rights reserved. @@ -36,7 +36,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright © 2006 \ The NetBSD Foundation, Inc. All rights reserved."); -__RCSID("$NetBSD: osd-target.c,v 1.3 2006/02/12 14:48:49 agc Exp $"); +__RCSID("$NetBSD: osd-target.c,v 1.4 2006/03/12 18:47:28 agc Exp $"); #endif #include "config.h" @@ -81,7 +81,7 @@ handler(int s) if (ISCSI_GETPID != g_main_pid) return; if (target_shutdown(&g) != 0) { - TRACE_ERROR("target_shutdown() failed\n"); + iscsi_trace_error("target_shutdown() failed\n"); return; } return; @@ -160,7 +160,7 @@ main(int argc, char **argv) /* Initialize target */ for (i = optind ; i < argc ; i++) { if (target_init(&g, &tv, TargetName, i) != 0) { - TRACE_ERROR("target_init() failed\n"); + iscsi_trace_error("target_init() failed\n"); exit(EXIT_FAILURE); } } @@ -168,7 +168,7 @@ main(int argc, char **argv) #ifdef HAVE_DAEMON /* if we are supposed to be a daemon, detach from controlling tty */ if (detach_me_harder && daemon(0, 0) < 0) { - TRACE_ERROR("daemon() failed\n"); + iscsi_trace_error("daemon() failed\n"); exit(EXIT_FAILURE); } #endif @@ -178,7 +178,7 @@ main(int argc, char **argv) /* Wait for connections */ if (target_listen(&g) != 0) { - TRACE_ERROR("target_listen() failed\n"); + iscsi_trace_error("target_listen() failed\n"); } return EXIT_SUCCESS; diff --git a/dist/iscsi/src/osd.c b/dist/iscsi/src/osd.c index bacfa8480d59..80fdb3d27923 100644 --- a/dist/iscsi/src/osd.c +++ b/dist/iscsi/src/osd.c @@ -124,7 +124,7 @@ device_init(globals_t *gp, char *dev) if (mkdir(base_dir, 0755) != 0) { if (errno != EEXIST) { - TRACE_ERROR("error creating directory \"%s\" for OSD: errno %i\n", base_dir, errno); + iscsi_trace_error("error creating directory \"%s\" for OSD: errno %i\n", base_dir, errno); return -1; } } @@ -134,7 +134,7 @@ device_init(globals_t *gp, char *dev) sprintf(FileName, "%s/lun_%i", base_dir, i); if (mkdir(FileName, 0755) != 0) { if (errno != EEXIST) { - TRACE_ERROR("error creating \"%s\" for LU %i: errno %i\n", FileName, i, errno); + iscsi_trace_error("error creating \"%s\" for LU %i: errno %i\n", FileName, i, errno); return -1; } } @@ -180,10 +180,10 @@ device_command(target_session_t * sess, target_cmd_t * cmd) uint32_t index = 0; int attr_len = 0; - TRACE(TRACE_SCSI_CMD, "SCSI op 0x%x (lun %llu)\n", args->cdb[0], args->lun); + iscsi_trace(TRACE_SCSI_CMD, "SCSI op 0x%x (lun %llu)\n", args->cdb[0], args->lun); if (args->lun >= osd_luns) { - TRACE(TRACE_SCSI_DEBUG, "invalid lun: %llu\n", args->lun); + iscsi_trace(TRACE_SCSI_DEBUG, "invalid lun: %llu\n", args->lun); args->status = 0x01; return 0; } @@ -193,14 +193,14 @@ device_command(target_session_t * sess, target_cmd_t * cmd) case TEST_UNIT_READY: - TRACE(TRACE_SCSI_CMD, "TEST_UNIT_READY(lun %llu)\n", args->lun); + iscsi_trace(TRACE_SCSI_CMD, "TEST_UNIT_READY(lun %llu)\n", args->lun); args->status = 0; args->length = 0; break; case INQUIRY: - TRACE(TRACE_SCSI_CMD, "INQUIRY(lun %llu)\n", args->lun); + iscsi_trace(TRACE_SCSI_CMD, "INQUIRY(lun %llu)\n", args->lun); data = args->send_data; memset(data, 0, args->cdb[4]); /* Clear allocated buffer */ data[0] = 0x0e; /* Peripheral Device Type */ @@ -247,7 +247,7 @@ device_command(target_session_t * sess, target_cmd_t * cmd) if (osd_args.set_attributes_list_length) { if ((set_list = iscsi_malloc_atomic(osd_args.set_attributes_list_length)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); goto done; } sg[sg_len].iov_base = set_list; @@ -256,7 +256,7 @@ device_command(target_session_t * sess, target_cmd_t * cmd) } if (osd_args.get_attributes_list_length) { if ((get_list = iscsi_malloc_atomic(osd_args.get_attributes_list_length)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); goto done; } sg[sg_len].iov_base = get_list; @@ -265,7 +265,7 @@ device_command(target_session_t * sess, target_cmd_t * cmd) } if (osd_args.service_action == OSD_WRITE) { if ((write_data = iscsi_malloc_atomic(osd_args.length)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); goto done; } sg[sg_len].iov_base = write_data; @@ -274,7 +274,7 @@ device_command(target_session_t * sess, target_cmd_t * cmd) } if (sg_len) { if (target_transfer_data(sess, args, sg, sg_len) != 0) { - TRACE_ERROR("target_transfer_data() failed\n"); + iscsi_trace_error("target_transfer_data() failed\n"); goto done; } } @@ -287,7 +287,7 @@ device_command(target_session_t * sess, target_cmd_t * cmd) uint16_t len; int i; - TRACE(TRACE_OSD, "OSD_SET_ATTR(lun %llu, GroupID 0x%x, UserID 0x%llx)\n", args->lun, osd_args.GroupID, osd_args.UserID); + iscsi_trace(TRACE_OSD, "OSD_SET_ATTR(lun %llu, GroupID 0x%x, UserID 0x%llx)\n", args->lun, osd_args.GroupID, osd_args.UserID); for (i = 0; i < osd_args.set_attributes_list_length;) { page = ISCSI_NTOHL(*((uint32_t *) (&(set_list[i])))); i += 4; @@ -298,15 +298,15 @@ device_command(target_session_t * sess, target_cmd_t * cmd) sprintf(FileName, "%s/lun_%llu/0x%x/0x%llx.0x%x.%u", base_dir, args->lun, osd_args.GroupID, osd_args.UserID, page, attr); if ((rc = open(FileName, O_WRONLY | O_CREAT, 0644)) == -1) { - TRACE_ERROR("error opening \"%s\": errno %i\n", FileName, errno); + iscsi_trace_error("error opening \"%s\": errno %i\n", FileName, errno); goto done; } if (write(rc, set_list + i, len) != len) { - TRACE_ERROR("write() failed\n"); + iscsi_trace_error("write() failed\n"); } close(rc); i += len; - TRACE(TRACE_OSD, "SET(0x%x,%u,%u>\n", page, attr, len); + iscsi_trace(TRACE_OSD, "SET(0x%x,%u,%u>\n", page, attr, len); } } args->send_sg_len = 0; @@ -321,16 +321,16 @@ device_command(target_session_t * sess, target_cmd_t * cmd) sprintf(FileName, "%s/lun_%llu/0x%x", base_dir, args->lun, GroupID); rc = mkdir(FileName, 0755); } while (rc == -1 && errno == EEXIST); - TRACE(TRACE_OSD, "OSD_CREATE_GROUP(lun %llu) --> 0x%x\n", args->lun, GroupID); + iscsi_trace(TRACE_OSD, "OSD_CREATE_GROUP(lun %llu) --> 0x%x\n", args->lun, GroupID); args->status = 0; break; case OSD_REMOVE_GROUP: - TRACE(TRACE_OSD, "OSD_REMOVE_GROUP(lun %llu, 0x%x)\n", args->lun, osd_args.GroupID); + iscsi_trace(TRACE_OSD, "OSD_REMOVE_GROUP(lun %llu, 0x%x)\n", args->lun, osd_args.GroupID); sprintf(FileName, "%s/lun_%llu/0x%x", base_dir, args->lun, osd_args.GroupID); if ((rc = rmdir(FileName)) == -1) { - TRACE_ERROR("rmdir(\"%s\") failed: errno %i\n", FileName, errno); + iscsi_trace_error("rmdir(\"%s\") failed: errno %i\n", FileName, errno); goto done; } args->status = 0; @@ -348,43 +348,43 @@ create_user_again: goto create_user_again; } close(rc); - TRACE(TRACE_OSD, "OSD_CREATE(lun %llu, GroupID 0x%x) --> 0x%llx\n", args->lun, osd_args.GroupID, UserID); + iscsi_trace(TRACE_OSD, "OSD_CREATE(lun %llu, GroupID 0x%x) --> 0x%llx\n", args->lun, osd_args.GroupID, UserID); args->status = 0; break; case OSD_REMOVE: - TRACE(TRACE_OSD, "OSD_REMOVE(lun %llu, 0x%llx)\n", args->lun, osd_args.UserID); + iscsi_trace(TRACE_OSD, "OSD_REMOVE(lun %llu, 0x%llx)\n", args->lun, osd_args.UserID); sprintf(FileName, "%s/lun_%llu/0x%x/0x%llx", base_dir, args->lun, osd_args.GroupID, osd_args.UserID); if ((rc = unlink(FileName)) == -1) { - TRACE_ERROR("unlink(\"%s\") failed: errno %i\n", FileName, errno); + iscsi_trace_error("unlink(\"%s\") failed: errno %i\n", FileName, errno); goto done; } sprintf(string, "rm -f %s/lun_%llu/0x%x/0x%llx.*", base_dir, args->lun, osd_args.GroupID, osd_args.UserID); if (system(string) != 0) { - TRACE_ERROR("\"%s\" failed\n", string); + iscsi_trace_error("\"%s\" failed\n", string); return -1; } args->status = 0; break; case OSD_WRITE: - TRACE(TRACE_OSD, "OSD_WRITE(lun %llu, GroupID 0x%x, UserID 0x%llx, length %llu, offset %llu)\n", + iscsi_trace(TRACE_OSD, "OSD_WRITE(lun %llu, GroupID 0x%x, UserID 0x%llx, length %llu, offset %llu)\n", args->lun, osd_args.GroupID, osd_args.UserID, osd_args.length, osd_args.offset); sprintf(FileName, "%s/lun_%llu/0x%x/0x%llx", base_dir, args->lun, osd_args.GroupID, osd_args.UserID); if ((rc = open(FileName, O_WRONLY, 0644)) == -1) { - TRACE_ERROR("error opening \"%s\": errno %i\n", FileName, errno); + iscsi_trace_error("error opening \"%s\": errno %i\n", FileName, errno); goto write_done; } if (lseek(rc, osd_args.offset, SEEK_SET) == -1) { - TRACE_ERROR("error seeking \"%s\": errno %i\n", FileName, errno); + iscsi_trace_error("error seeking \"%s\": errno %i\n", FileName, errno); goto write_done; } if (write(rc, write_data, osd_args.length) != osd_args.length) { - TRACE_ERROR("write() failed\n"); + iscsi_trace_error("write() failed\n"); goto write_done; } close(rc); @@ -393,24 +393,24 @@ write_done: break; case OSD_READ: - TRACE(TRACE_OSD, "OSD_READ(lun %llu, GroupID 0x%x, UserID 0x%llx, length %llu, offset %llu)\n", + iscsi_trace(TRACE_OSD, "OSD_READ(lun %llu, GroupID 0x%x, UserID 0x%llx, length %llu, offset %llu)\n", args->lun, osd_args.GroupID, osd_args.UserID, osd_args.length, osd_args.offset); sprintf(FileName, "%s/lun_%llu/0x%x/0x%llx", base_dir, args->lun, osd_args.GroupID, osd_args.UserID); if ((rc = open(FileName, O_RDONLY, 0644)) == -1) { - TRACE_ERROR("error opening \"%s\": errno %i\n", FileName, errno); + iscsi_trace_error("error opening \"%s\": errno %i\n", FileName, errno); goto read_done; } if ((read_data = iscsi_malloc_atomic(osd_args.length)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); goto read_done; } if (lseek(rc, osd_args.offset, SEEK_SET) == -1) { - TRACE_ERROR("error seeking \"%s\": errno %i\n", FileName, errno); + iscsi_trace_error("error seeking \"%s\": errno %i\n", FileName, errno); goto read_done; } if (read(rc, read_data, osd_args.length) != osd_args.length) { - TRACE_ERROR("read() failed\n"); + iscsi_trace_error("read() failed\n"); goto read_done; } close(rc); @@ -436,7 +436,7 @@ read_done: break; case OSD_GET_ATTR: - TRACE(TRACE_OSD, "OSD_GET_ATTR(lun %llu, GroupID 0x%x, UserID 0x%llx)\n", + iscsi_trace(TRACE_OSD, "OSD_GET_ATTR(lun %llu, GroupID 0x%x, UserID 0x%llx)\n", args->lun, osd_args.GroupID, osd_args.UserID); args->status = 0; break; @@ -455,7 +455,7 @@ read_done: if (osd_args.get_attributes_list_length || osd_args.get_attributes_page) { if ((get_data = iscsi_malloc_atomic(osd_args.get_attributes_allocation_length)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); goto done; } } @@ -467,7 +467,7 @@ read_done: i += 4; index = ISCSI_NTOHL(*((uint32_t *) (&(get_list[i])))); i += 4; - TRACE(TRACE_OSD, "GET(0x%x,%u)\n", page, index); + iscsi_trace(TRACE_OSD, "GET(0x%x,%u)\n", page, index); switch (page) { case 0x40000001: @@ -483,7 +483,7 @@ read_done: attr_len += 4; break; default: - TRACE_ERROR("unknown attr index %u\n", index); + iscsi_trace_error("unknown attr index %u\n", index); goto done; } break; @@ -510,7 +510,7 @@ read_done: attr_len += 8; break; default: - TRACE_ERROR("unknown attr index %u\n", index); + iscsi_trace_error("unknown attr index %u\n", index); goto done; } break; @@ -529,23 +529,23 @@ read_done: sprintf(FileName, "%s/lun_%llu/0x%x/0x%llx.0x%x.%u", base_dir, args->lun, osd_args.GroupID, osd_args.UserID, page, index); if ((rc = open(FileName, O_RDONLY, 0644)) == -1) { - TRACE_ERROR("error opening \"%s\": errno %i\n", FileName, errno); + iscsi_trace_error("error opening \"%s\": errno %i\n", FileName, errno); } if (read(rc, get_data + attr_len, 480) != 480) { - TRACE_ERROR("read() failed\n"); + iscsi_trace_error("read() failed\n"); goto done; } close(rc); attr_len += 480; break; default: - TRACE_ERROR("unknown vendor attr index %u\n", index); + iscsi_trace_error("unknown vendor attr index %u\n", index); goto done; } break; default: - TRACE_ERROR("unknown page 0x%x\n", page); + iscsi_trace_error("unknown page 0x%x\n", page); goto done; } } @@ -595,23 +595,23 @@ read_done: sprintf(FileName, "%s/lun_%llu/0x%x/0x%llx.0x%x.%u", base_dir, args->lun, osd_args.GroupID, osd_args.UserID, page, index); if ((rc = open(FileName, O_RDONLY, 0644)) == -1) { - TRACE_ERROR("error opening \"%s\": errno %i\n", FileName, errno); + iscsi_trace_error("error opening \"%s\": errno %i\n", FileName, errno); } if (read(rc, get_data + attr_len, 480) != 480) { - TRACE_ERROR("read() failed\n"); + iscsi_trace_error("read() failed\n"); goto done; } close(rc); attr_len += 480; break; default: - TRACE_ERROR("page not yet supported\n"); + iscsi_trace_error("page not yet supported\n"); goto done; } } if (attr_len) { if (attr_len != osd_args.get_attributes_allocation_length) { - TRACE_ERROR("allocation lengths differ: got %u, expected %u\n", + iscsi_trace_error("allocation lengths differ: got %u, expected %u\n", osd_args.get_attributes_allocation_length, attr_len); goto done; } @@ -634,14 +634,14 @@ read_done: break; default: - TRACE_ERROR("UNKNOWN OPCODE 0x%x\n", args->cdb[0]); + iscsi_trace_error("UNKNOWN OPCODE 0x%x\n", args->cdb[0]); args->status = 0x01; break; } done: - TRACE(TRACE_SCSI_DEBUG, "SCSI op 0x%x: done (status 0x%x)\n", args->cdb[0], args->status); + iscsi_trace(TRACE_SCSI_DEBUG, "SCSI op 0x%x: done (status 0x%x)\n", args->cdb[0], args->status); if (set_list) { iscsi_free_atomic(set_list); } diff --git a/dist/iscsi/src/osd_ops.c b/dist/iscsi/src/osd_ops.c index 4a658232b8b7..9761c8c68e22 100644 --- a/dist/iscsi/src/osd_ops.c +++ b/dist/iscsi/src/osd_ops.c @@ -47,25 +47,25 @@ extract_attribute(uint32_t page, uint32_t n, uint16_t len, for (i = 0; i < length;) { if (ISCSI_NTOHL(*(uint32_t *) (data + i)) != page) { - TRACE_ERROR("page mismatch: got 0x%x, expected 0x%x\n", ISCSI_NTOHL(*(uint32_t *) (data + i)), page); + iscsi_trace_error("page mismatch: got 0x%x, expected 0x%x\n", ISCSI_NTOHL(*(uint32_t *) (data + i)), page); return -1; } i += 4; if (ISCSI_NTOHL(*(uint32_t *) (data + i)) != n) { - TRACE_ERROR("index mismatch\n"); + iscsi_trace_error("index mismatch\n"); return -1; } i += 4; if (ISCSI_NTOHS(*(uint16_t *) (data + i)) != len) { - TRACE_ERROR("len mismatch\n"); + iscsi_trace_error("len mismatch\n"); return -1; } i += 2; - TRACE(TRACE_DEBUG, "page 0x%x, index %u, len %u\n", page, n, len); + iscsi_trace(TRACE_DEBUG, "page 0x%x, index %u, len %u\n", page, n, len); memcpy(val, data + i, len); i += len; } - TRACE(TRACE_DEBUG, "parsed %i bytes\n", i); + iscsi_trace(TRACE_DEBUG, "parsed %i bytes\n", i); return i; } @@ -107,15 +107,15 @@ osd_create_group(void *dev, args.get_attributes_allocation_length = 14; if (osd_exec(dev, &args, &mem) != 0) { - TRACE_ERROR("osd_exec() failed\n"); + iscsi_trace_error("osd_exec() failed\n"); return -1; } if (extract_attribute(0x40000001, 0x1, 4, get_data, 14, GroupID) == -1) { - TRACE_ERROR("extract_attributes() failed\n"); + iscsi_trace_error("extract_attributes() failed\n"); return -1; } *GroupID = ISCSI_NTOHL(*GroupID); - TRACE(TRACE_OSD, "osd_create_group() OK --> GroupID 0x%x\n", *GroupID); + iscsi_trace(TRACE_OSD, "osd_create_group() OK --> GroupID 0x%x\n", *GroupID); return 0; } @@ -158,15 +158,15 @@ osd_create(void *dev, uint32_t GroupID, args.get_attributes_allocation_length = 18; if (osd_exec(dev, &args, &mem) != 0) { - TRACE_ERROR("osd_exec() failed\n"); + iscsi_trace_error("osd_exec() failed\n"); return -1; } if (extract_attribute(0x00000001, 0x2, 8, get_data, 18, UserID) == -1) { - TRACE_ERROR("extract_attributes() failed\n"); + iscsi_trace_error("extract_attributes() failed\n"); return -1; } *UserID = ISCSI_NTOHLL(*UserID); - TRACE(TRACE_OSD, "osd_create(GroupID 0x%x) OK --> UserID 0x%llx\n", GroupID, *UserID); + iscsi_trace(TRACE_OSD, "osd_create(GroupID 0x%x) OK --> UserID 0x%llx\n", GroupID, *UserID); return 0; } @@ -190,10 +190,10 @@ osd_remove_group(void *dev, uint32_t GroupID, args.service_action = OSD_REMOVE_GROUP; args.GroupID = GroupID; if (osd_exec(dev, &args, &mem) != 0) { - TRACE_ERROR("osd_exec() failed\n"); + iscsi_trace_error("osd_exec() failed\n"); return -1; } - TRACE(TRACE_OSD, "osd_remove_group(Group ID 0x%x) OK\n", GroupID); + iscsi_trace(TRACE_OSD, "osd_remove_group(Group ID 0x%x) OK\n", GroupID); return 0; } @@ -218,10 +218,10 @@ osd_remove(void *dev, uint32_t GroupID, uint64_t UserID, args.UserID = UserID; args.GroupID = GroupID; if (osd_exec(dev, &args, &mem) != 0) { - TRACE_ERROR("osd_exec() failed\n"); + iscsi_trace_error("osd_exec() failed\n"); return -1; } - TRACE(TRACE_OSD, "osd_remove(GroupID 0x%x, UserID 0x%llx) OK\n", GroupID, UserID); + iscsi_trace(TRACE_OSD, "osd_remove(GroupID 0x%x, UserID 0x%llx) OK\n", GroupID, UserID); return 0; } @@ -234,7 +234,7 @@ osd_write(void *dev, osd_args_t args; OSD_OPS_MEM mem; - TRACE(TRACE_OSD, "osd_write(GroupID 0x%x, UserID 0x%llx, Offset %llu, Len %llu)\n", GroupID, UserID, offset, len); + iscsi_trace(TRACE_OSD, "osd_write(GroupID 0x%x, UserID 0x%llx, Offset %llu, Len %llu)\n", GroupID, UserID, offset, len); mem.send_data = send_data; mem.send_len = len; mem.send_sg = sg_len; @@ -249,7 +249,7 @@ osd_write(void *dev, args.offset = offset; args.length = len; if (osd_exec(dev, &args, &mem) != 0) { - TRACE_ERROR("osd_exec() failed\n"); + iscsi_trace_error("osd_exec() failed\n"); return -1; } return 0; @@ -263,7 +263,7 @@ osd_read(void *dev, osd_args_t args; OSD_OPS_MEM mem; - TRACE(TRACE_OSD, "osd_read(GroupID 0x%x, UserID 0x%llx, Offset %llu, Len %llu)\n", GroupID, UserID, offset, len); + iscsi_trace(TRACE_OSD, "osd_read(GroupID 0x%x, UserID 0x%llx, Offset %llu, Len %llu)\n", GroupID, UserID, offset, len); mem.send_data = NULL; mem.send_len = 0; mem.send_sg = 0; @@ -278,7 +278,7 @@ osd_read(void *dev, args.offset = offset; args.length = len; if (osd_exec(dev, &args, &mem) != 0) { - TRACE_ERROR("osd_exec() failed\n"); + iscsi_trace_error("osd_exec() failed\n"); return -1; } return 0; @@ -298,7 +298,7 @@ osd_set_one_attr(void *dev, uint8_t *buffer = NULL; #endif - TRACE(TRACE_OSD, "osd_set_one_attr(GroupID 0x%x, UserID 0x%llx, Page 0x%x, Index %u, Len %u)\n", + iscsi_trace(TRACE_OSD, "osd_set_one_attr(GroupID 0x%x, UserID 0x%llx, Page 0x%x, Index %u, Len %u)\n", GroupID, UserID, page, n, len); memset(&args, 0, sizeof(osd_args_t)); args.opcode = 0x7F; @@ -320,7 +320,7 @@ osd_set_one_attr(void *dev, mem.send_sg = 2; #else if ((buffer = iscsi_malloc_atomic(10 + len)) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); return -1; } memcpy(buffer, list, 10); @@ -334,7 +334,7 @@ osd_set_one_attr(void *dev, mem.recv_sg = 0; if (osd_exec(dev, &args, &mem) != 0) { - TRACE_ERROR("osd_exec() failed\n"); + iscsi_trace_error("osd_exec() failed\n"); return -1; } if (buffer) @@ -359,7 +359,7 @@ osd_get_one_attr(void *dev, uint8_t *buffer; #endif - TRACE(TRACE_OSD, "osd_get_one_attr(GroupID 0x%x, UserID 0x%llx, Page 0x%x, Index %u, Alloc Len %u)\n", + iscsi_trace(TRACE_OSD, "osd_get_one_attr(GroupID 0x%x, UserID 0x%llx, Page 0x%x, Index %u, Alloc Len %u)\n", GroupID, UserID, page, n, alloc_len); memset(&args, 0, sizeof(osd_args_t)); args.opcode = 0x7F; @@ -375,7 +375,7 @@ osd_get_one_attr(void *dev, mem.send_len = 8; mem.send_sg = 0; } else { - TRACE(TRACE_OSD, "requesting entire page or reference page\n"); + iscsi_trace(TRACE_OSD, "requesting entire page or reference page\n"); mem.send_data = NULL; mem.send_len = 0; mem.send_sg = 0; @@ -391,7 +391,7 @@ osd_get_one_attr(void *dev, mem.recv_sg = 2; #else if ((buffer = iscsi_malloc_atomic(10 + alloc_len)) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); return -1; } mem.recv_data = buffer; @@ -400,7 +400,7 @@ osd_get_one_attr(void *dev, #endif args.get_attributes_allocation_length = 10 + alloc_len; if (osd_exec(dev, &args, &mem) != 0) { - TRACE_ERROR("osd_exec() failed\n"); + iscsi_trace_error("osd_exec() failed\n"); return -1; } memcpy(value, buffer + 10, alloc_len); diff --git a/dist/iscsi/src/osdfs.c b/dist/iscsi/src/osdfs.c index d72d7b222bdd..c9cfbe0bb9fa 100644 --- a/dist/iscsi/src/osdfs.c +++ b/dist/iscsi/src/osdfs.c @@ -117,7 +117,7 @@ int osd_exec_via_scsi(void *dev, osd_args_t *args, OSD_OPS_MEM *m) { int len = 0; if (m->send_sg||m->recv_sg) { - TRACE_ERROR("scatter/gather not yet implemented!\n"); + iscsi_trace_error("scatter/gather not yet implemented!\n"); return -1; } @@ -146,7 +146,7 @@ int osd_exec_via_scsi(void *dev, osd_args_t *args, OSD_OPS_MEM *m) { SRpnt->sr_data_direction = 0; break; default: - TRACE_ERROR("unsupported OSD service action 0x%x\n", args->service_action); + iscsi_trace_error("unsupported OSD service action 0x%x\n", args->service_action); return -1; } OSD_ENCAP_CDB(args, cdb); @@ -155,7 +155,7 @@ int osd_exec_via_scsi(void *dev, osd_args_t *args, OSD_OPS_MEM *m) { scsi_wait_req(SRpnt, cdb, ptr, len, 5*HZ, 5); if (SRpnt->sr_result!=0) { - TRACE_ERROR("SCSI command failed (result %u)\n", SRpnt->sr_result); + iscsi_trace_error("SCSI command failed (result %u)\n", SRpnt->sr_result); scsi_release_request(SRpnt); SRpnt = NULL; return -1; @@ -178,7 +178,7 @@ static int entries_get(kdev_t dev, uint64_t uid, char **entries, uint32_t *num, uint16_t len; if (osd_get_one_attr((void *)&dev, root_gid, uid, 0x30000000, 0x0, sizeof(struct inode), &osd_exec_via_scsi, &len, (void *) &inode)!=0) { - TRACE_ERROR("osd_get_one_attr() failed\n"); + iscsi_trace_error("osd_get_one_attr() failed\n"); return -1; } *num = 0; @@ -187,11 +187,11 @@ static int entries_get(kdev_t dev, uint64_t uid, char **entries, uint32_t *num, int n = 0; if ((*entries=vmalloc(*size+1))==NULL) { - TRACE_ERROR("vmalloc() failed\n"); + iscsi_trace_error("vmalloc() failed\n"); return -1; } if (osd_read((void *)&dev, root_gid, uid, 0, *size, *entries, 0, &osd_exec_via_scsi)!=0) { - TRACE_ERROR("osd_read() failed\n"); + iscsi_trace_error("osd_read() failed\n"); vfree(*entries); return -1; } @@ -202,12 +202,12 @@ static int entries_get(kdev_t dev, uint64_t uid, char **entries, uint32_t *num, if ((ptr2=strchr(ptr, '\n'))!=NULL) { n++; if ((ptr2 = strchr(ptr2+1, '\n'))==NULL) { - TRACE_ERROR("directory 0x%llx corrupted (line %i)\n", uid, n); + iscsi_trace_error("directory 0x%llx corrupted (line %i)\n", uid, n); return -1; } (*num)++; } else { - TRACE_ERROR("directory 0x%llx corrupted (line %i)\n", uid, n); + iscsi_trace_error("directory 0x%llx corrupted (line %i)\n", uid, n); return -1; } ptr = ptr2+1; @@ -227,7 +227,7 @@ static int entry_add(kdev_t dev, ino_t dir_ino, ino_t entry_ino, /* Get size of directory */ if (osd_get_one_attr((void *)&dev, root_gid, uid, 0x30000000, 0x0, sizeof(struct inode), &osd_exec_via_scsi, &len, (void *) &inode)!=0) { - TRACE_ERROR("osd_get_one_attr() failed\n"); + iscsi_trace_error("osd_get_one_attr() failed\n"); return -1; } @@ -236,7 +236,7 @@ static int entry_add(kdev_t dev, ino_t dir_ino, ino_t entry_ino, sprintf(entry, "%s\n", name); sprintf(entry+strlen(entry), "%li\n", entry_ino); if (osd_write((void *)&dev, root_gid, uid, inode.i_size, strlen(entry), entry, 0, &osd_exec_via_scsi)!=0) { - TRACE_ERROR("osd_write() failed\n"); + iscsi_trace_error("osd_write() failed\n"); return -1; } *new_size += strlen(entry); @@ -253,12 +253,12 @@ static int entry_del(kdev_t dev, ino_t dir_ino, ino_t ino, const char *name, uin /* Read */ if (entries_get(dev, dir_ino, &entries, &num_entries, &size)!=0) { - TRACE_ERROR("entries_get() failed\n"); + iscsi_trace_error("entries_get() failed\n"); return -1; } entries[size] = 0x0; - TRACE(TRACE_OSDFS, "dir_ino 0x%llx has %u entries\n", dir_uid, num_entries); + iscsi_trace(TRACE_OSDFS, "dir_ino 0x%llx has %u entries\n", dir_uid, num_entries); if (num_entries) { char *ptr = entries; char *tmp = NULL; @@ -268,7 +268,7 @@ static int entry_del(kdev_t dev, ino_t dir_ino, ino_t ino, const char *name, uin do { n++; if ((nl=strchr(ptr, '\n'))==NULL) { - TRACE_ERROR("directory 0x%llx corrupted (line %i)\n", dir_uid, n); + iscsi_trace_error("directory 0x%llx corrupted (line %i)\n", dir_uid, n); return -1; } *nl = 0x0; @@ -278,28 +278,28 @@ static int entry_del(kdev_t dev, ino_t dir_ino, ino_t ino, const char *name, uin *nl = '\n'; n++; if ((ptr=strchr(nl+1, '\n'))==NULL) { - TRACE_ERROR("directory 0x%llx corrupted (line %i)\n", dir_uid, n); + iscsi_trace_error("directory 0x%llx corrupted (line %i)\n", dir_uid, n); return -1; } ptr++; } while (!tmp && *ptr); if (!tmp) { - TRACE_ERROR("entry \"%s\" not found in dir 0x%llx\n", name, dir_uid); + iscsi_trace_error("entry \"%s\" not found in dir 0x%llx\n", name, dir_uid); return -1; } if (entries+size-ptr) { - TRACE(TRACE_OSDFS, "writing remaining %u directory bytes at offset %u\n", + iscsi_trace(TRACE_OSDFS, "writing remaining %u directory bytes at offset %u\n", entries+size-ptr, tmp-entries); if (osd_write((void *)&dev, root_gid, dir_uid, tmp-entries, entries+size-ptr, ptr, 0, &osd_exec_via_scsi)!=0) { - TRACE_ERROR("osd_write() failed\n"); + iscsi_trace_error("osd_write() failed\n"); return -1; } } *new_size = size-(ptr-tmp); vfree(entries); } else { - TRACE_ERROR("dir 0x%llx has no entries\n", dir_uid); + iscsi_trace_error("dir 0x%llx has no entries\n", dir_uid); return -1; } @@ -312,10 +312,10 @@ static int entry_num(kdev_t dev, ino_t ino) { uint64_t size; if (entries_get(dev, ino, &entries, &num_entries, &size)!=0) { - TRACE_ERROR("entries_get() failed\n"); + iscsi_trace_error("entries_get() failed\n"); return -1; } - TRACE(TRACE_OSDFS, "ino %li has %i entries\n", ino, num_entries); + iscsi_trace(TRACE_OSDFS, "ino %li has %i entries\n", ino, num_entries); if (num_entries) vfree(entries); return num_entries; } @@ -335,7 +335,7 @@ static void osdfs_set_ops(struct inode *inode) { inode->i_op = &page_symlink_inode_operations; break; default: - TRACE_ERROR("UNKNOWN MODE\n"); + iscsi_trace_error("UNKNOWN MODE\n"); } inode->i_mapping->a_ops = &osdfs_aops; } @@ -345,14 +345,14 @@ static struct inode *osdfs_get_inode(struct super_block *sb, int mode, int dev, struct inode *inode; ino_t ino = ObjectID; - TRACE(TRACE_OSDFS, "osdfs_get_inode(\"%s\", mode %i (%s))\n", name, mode, + iscsi_trace(TRACE_OSDFS, "osdfs_get_inode(\"%s\", mode %i (%s))\n", name, mode, S_ISDIR(mode)?"DIR":(S_ISREG(mode)?"REG":"LNK")); /* iget() gets a free VFS inode and subsequently call */ /* osdfds_read_inode() to fill the inode structure. */ if ((inode=iget(sb, ino))==NULL) { - TRACE_ERROR("iget() failed\n"); + iscsi_trace_error("iget() failed\n"); return NULL; } @@ -372,16 +372,16 @@ static void osdfs_read_inode(struct inode *inode) { unsigned char *attr; uint16_t len; - TRACE(TRACE_OSDFS, "osdfs_read_inode(ino 0x%x, major %i, minor %i)\n", + iscsi_trace(TRACE_OSDFS, "osdfs_read_inode(ino 0x%x, major %i, minor %i)\n", (unsigned) ino, MAJOR(dev), MINOR(dev)); /* Get object attributes for rest of inode */ if ((attr=iscsi_malloc_atomic(sizeof(struct inode)))==NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); } if (osd_get_one_attr((void *)&dev, root_gid, uid, 0x30000000, 0x0, sizeof(struct inode), &osd_exec_via_scsi, &len, attr)!=0) { - TRACE_ERROR("osd_get_one_attr() failed\n"); + iscsi_trace_error("osd_get_one_attr() failed\n"); return; } @@ -400,7 +400,7 @@ static void osdfs_read_inode(struct inode *inode) { } void osdfs_dirty_inode(struct inode *inode) { - TRACE(TRACE_OSDFS, "osdfs_dirty_inode(ino 0x%x)\n", (unsigned) inode->i_ino); + iscsi_trace(TRACE_OSDFS, "osdfs_dirty_inode(ino 0x%x)\n", (unsigned) inode->i_ino); } void osdfs_write_inode(struct inode *inode, int sync) { @@ -408,41 +408,41 @@ void osdfs_write_inode(struct inode *inode, int sync) { kdev_t dev = inode->i_sb->s_dev; uint64_t uid = ino; - TRACE(TRACE_OSDFS, "osdfs_write_inode(0x%llx)\n", uid); + iscsi_trace(TRACE_OSDFS, "osdfs_write_inode(0x%llx)\n", uid); if (osd_set_one_attr((void *)&dev, root_gid, uid, 0x30000000, 0x1, sizeof(struct inode), (void *) inode, &osd_exec_via_scsi)!=0) { - TRACE_ERROR("osd_set_one_attr() failed\n"); + iscsi_trace_error("osd_set_one_attr() failed\n"); } inode->i_state &= ~I_DIRTY; } void osdfs_put_inode(struct inode *inode) { - TRACE(TRACE_OSDFS, "osdfs_put_inode(0x%x)\n", (unsigned) inode->i_ino); + iscsi_trace(TRACE_OSDFS, "osdfs_put_inode(0x%x)\n", (unsigned) inode->i_ino); } void osdfs_delete_inode(struct inode *inode) { - TRACE(TRACE_OSDFS, "osdfs_delete_inode(%lu)\n", inode->i_ino); + iscsi_trace(TRACE_OSDFS, "osdfs_delete_inode(%lu)\n", inode->i_ino); clear_inode(inode); } void osdfs_put_super(struct super_block *sb) { - TRACE_ERROR("osdfs_put_super() not implemented\n"); + iscsi_trace_error("osdfs_put_super() not implemented\n"); } void osdfs_write_super(struct super_block *sb) { - TRACE_ERROR("osdfs_write_super() not implemented\n"); + iscsi_trace_error("osdfs_write_super() not implemented\n"); } void osdfs_write_super_lockfs(struct super_block *sb) { - TRACE_ERROR("osdfs_write_super_lockfs() not implemented\n"); + iscsi_trace_error("osdfs_write_super_lockfs() not implemented\n"); } void osdfs_unlockfs(struct super_block *sb) { - TRACE_ERROR("osdfs_unlockfs() not implemented\n"); + iscsi_trace_error("osdfs_unlockfs() not implemented\n"); } int osdfs_statfs(struct super_block *sb, struct statfs *buff) { - TRACE(TRACE_OSDFS, "statfs()\n"); + iscsi_trace(TRACE_OSDFS, "statfs()\n"); buff->f_type = OSDFS_MAGIC; buff->f_bsize = PAGE_CACHE_SIZE; buff->f_blocks = 256; @@ -456,17 +456,17 @@ int osdfs_statfs(struct super_block *sb, struct statfs *buff) { } int osdfs_remount_fs(struct super_block *sb, int *i, char *c) { - TRACE_ERROR("osdfs_remount_fs() not implemented\n"); + iscsi_trace_error("osdfs_remount_fs() not implemented\n"); return -1; } void osdfs_clear_inode(struct inode *inode) { - TRACE(TRACE_OSDFS, "osdfs_clear_inode(ino %lu)\n", inode->i_ino); + iscsi_trace(TRACE_OSDFS, "osdfs_clear_inode(ino %lu)\n", inode->i_ino); } void osdfs_umount_begin(struct super_block *sb) { - TRACE_ERROR("osdfs_unmount_begin() not implemented\n"); + iscsi_trace_error("osdfs_unmount_begin() not implemented\n"); } static struct super_operations osdfs_ops = { @@ -493,12 +493,12 @@ static struct super_operations osdfs_ops = { static int osdfs_create(struct inode *dir, struct dentry *dentry, int mode) { - TRACE(TRACE_OSDFS, "osdfs_create(\"%s\")\n", dentry->d_name.name); + iscsi_trace(TRACE_OSDFS, "osdfs_create(\"%s\")\n", dentry->d_name.name); if (osdfs_mknod(dir, dentry, mode | S_IFREG, 0)!=0) { - TRACE_ERROR("osdfs_mknod() failed\n"); + iscsi_trace_error("osdfs_mknod() failed\n"); return -1; } - TRACE(TRACE_OSDFS, "file \"%s\" is inode 0x%x\n", dentry->d_name.name, (unsigned) dentry->d_inode->i_ino); + iscsi_trace(TRACE_OSDFS, "file \"%s\" is inode 0x%x\n", dentry->d_name.name, (unsigned) dentry->d_inode->i_ino); return 0; } @@ -513,18 +513,18 @@ static struct dentry * osdfs_lookup(struct inode *dir, struct dentry *dentry) { uint32_t num_entries; uint64_t size; - TRACE(TRACE_OSDFS, "osdfs_lookup(\"%s\" in dir ino %lu)\n", name, dir->i_ino); + iscsi_trace(TRACE_OSDFS, "osdfs_lookup(\"%s\" in dir ino %lu)\n", name, dir->i_ino); /* Get directory entries */ ISCSI_LOCK(&g_mutex, return NULL); if (entries_get(dev, uid, &entries, &num_entries, &size)!=0) { - TRACE_ERROR("entries_get() failed\n"); + iscsi_trace_error("entries_get() failed\n"); ISCSI_UNLOCK(&g_mutex, return NULL); return NULL; } ISCSI_UNLOCK(&g_mutex, return NULL); - TRACE(TRACE_OSDFS, "ino %li has %i entries\n", dir->i_ino, num_entries); + iscsi_trace(TRACE_OSDFS, "ino %li has %i entries\n", dir->i_ino, num_entries); /* Search for this entry */ @@ -538,9 +538,9 @@ static struct dentry * osdfs_lookup(struct inode *dir, struct dentry *dentry) { ptr2 = strchr(ptr2+1, '\n'); if (!strcmp(ptr, name)) { sscanf(ptr+strlen(ptr)+1, "%li", &ino); - TRACE(TRACE_OSDFS, "found \"%s\" at ino %li\n", name, ino); + iscsi_trace(TRACE_OSDFS, "found \"%s\" at ino %li\n", name, ino); if ((inode=iget(dir->i_sb, ino))==NULL) { - TRACE_ERROR("iget() failed\n"); + iscsi_trace_error("iget() failed\n"); return NULL; } } @@ -549,7 +549,7 @@ static struct dentry * osdfs_lookup(struct inode *dir, struct dentry *dentry) { vfree(entries); } if (!inode) { - TRACE(TRACE_OSDFS, "\"%s\" not found\n", name); + iscsi_trace(TRACE_OSDFS, "\"%s\" not found\n", name); } d_add(dentry, inode); @@ -564,10 +564,10 @@ static int osdfs_link(struct dentry *old_dentry, struct inode * dir, struct dent const char *name = dentry->d_name.name; if (S_ISDIR(inode->i_mode)) return -EPERM; - TRACE(TRACE_OSDFS, "osdfs_link(%lu, \"%s\")\n", ino, name); + iscsi_trace(TRACE_OSDFS, "osdfs_link(%lu, \"%s\")\n", ino, name); ISCSI_LOCK(&g_mutex, return -1); if (entry_add(dev, dir_ino, ino, name, &dir->i_size)!=0) { - TRACE_ERROR("entry_add() failed\n"); + iscsi_trace_error("entry_add() failed\n"); return -1; } inode->i_nlink++; @@ -587,7 +587,7 @@ static int osdfs_unlink(struct inode * dir, struct dentry *dentry) { ino_t ino = dentry->d_inode->i_ino; const char *name = dentry->d_name.name; - TRACE(TRACE_OSDFS, "osdfs_unlink(\"%s\", ino 0x%x)\n", name, (unsigned) ino); + iscsi_trace(TRACE_OSDFS, "osdfs_unlink(\"%s\", ino 0x%x)\n", name, (unsigned) ino); ISCSI_LOCK(&g_mutex, return -1); switch (inode->i_mode & S_IFMT) { case S_IFREG: @@ -595,25 +595,25 @@ static int osdfs_unlink(struct inode * dir, struct dentry *dentry) { break; case S_IFDIR: if (entry_num(dev, ino)) { - TRACE_ERROR("directory 0x%x still has %i entries\n", + iscsi_trace_error("directory 0x%x still has %i entries\n", (unsigned) ino, entry_num(dev, ino)); ISCSI_UNLOCK(&g_mutex, return -1); return -ENOTEMPTY; } } if (entry_del(dev, dir_ino, ino, name, &(dir->i_size))!=0) { - TRACE_ERROR("entry_del() failed\n"); + iscsi_trace_error("entry_del() failed\n"); ISCSI_UNLOCK(&g_mutex, return -1); return -1; } osdfs_write_inode(dir, 0); if (--inode->i_nlink) { - TRACE(TRACE_OSDFS, "ino 0x%x still has %i links\n", (unsigned) ino, inode->i_nlink); + iscsi_trace(TRACE_OSDFS, "ino 0x%x still has %i links\n", (unsigned) ino, inode->i_nlink); osdfs_write_inode(inode, 0); } else { - TRACE(TRACE_OSDFS, "ino 0x%x link count reached 0, removing object\n", (unsigned) ino); + iscsi_trace(TRACE_OSDFS, "ino 0x%x link count reached 0, removing object\n", (unsigned) ino); if (osd_remove((void *)&dev, root_gid, ino, &osd_exec_via_scsi)!=0) { - TRACE_ERROR("osd_remove() failed\n"); + iscsi_trace_error("osd_remove() failed\n"); return -1; } } @@ -625,26 +625,26 @@ static int osdfs_unlink(struct inode * dir, struct dentry *dentry) { static int osdfs_symlink(struct inode * dir, struct dentry *dentry, const char * symname) { struct inode *inode; - TRACE(TRACE_OSDFS, "osdfs_symlink(\"%s\"->\"%s\")\n", dentry->d_name.name, symname); + iscsi_trace(TRACE_OSDFS, "osdfs_symlink(\"%s\"->\"%s\")\n", dentry->d_name.name, symname); if (osdfs_mknod(dir, dentry, S_IRWXUGO | S_IFLNK, 0)!=0) { - TRACE_ERROR("osdfs_mknod() failed\n"); + iscsi_trace_error("osdfs_mknod() failed\n"); return -1; } inode = dentry->d_inode; if (block_symlink(inode, symname, strlen(symname)+1)!=0) { - TRACE_ERROR("block_symlink() failed\n"); + iscsi_trace_error("block_symlink() failed\n"); return -1; } - TRACE(TRACE_OSDFS, "symbolic link \"%s\" is inode %lu\n", dentry->d_name.name, inode->i_ino); + iscsi_trace(TRACE_OSDFS, "symbolic link \"%s\" is inode %lu\n", dentry->d_name.name, inode->i_ino); return 0; } static int osdfs_mkdir(struct inode * dir, struct dentry * dentry, int mode) { - TRACE(TRACE_OSDFS, "osdfs_mkdir(\"%s\")\n", dentry->d_name.name); + iscsi_trace(TRACE_OSDFS, "osdfs_mkdir(\"%s\")\n", dentry->d_name.name); if (osdfs_mknod(dir, dentry, mode | S_IFDIR, 0)!=0) { - TRACE_ERROR("osdfs_mkdir() failed\n"); + iscsi_trace_error("osdfs_mkdir() failed\n"); } return 0; @@ -657,12 +657,12 @@ static int osdfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int d kdev_t dev = dir->i_sb->s_dev; const char *name = dentry->d_name.name; - TRACE(TRACE_OSDFS, "osdfs_mknod(\"%s\")\n", dentry->d_name.name); + iscsi_trace(TRACE_OSDFS, "osdfs_mknod(\"%s\")\n", dentry->d_name.name); /* Create object */ if (osd_create((void *)&dev, root_gid, &osd_exec_via_scsi, &uid)!=0) { - TRACE_ERROR("osd_create() failed\n"); + iscsi_trace_error("osd_create() failed\n"); return -1; } @@ -678,14 +678,14 @@ static int osdfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int d attr.i_nlink = 1; if (osd_set_one_attr((void *)&dir->i_sb->s_dev, root_gid, uid, 0x30000000, 0x1, sizeof(struct inode), &attr, &osd_exec_via_scsi)!=0) { - TRACE_ERROR("osd_set_one_attr() failed\n"); + iscsi_trace_error("osd_set_one_attr() failed\n"); return -1; } /* Assign to an inode */ if ((inode = osdfs_get_inode(dir->i_sb, mode, dev, name, uid))==NULL) { - TRACE_ERROR("osdfs_get_inode() failed\n"); + iscsi_trace_error("osdfs_get_inode() failed\n"); return -ENOSPC; } d_instantiate(dentry, inode); @@ -695,7 +695,7 @@ static int osdfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int d if (inode->i_ino != 1) { ISCSI_LOCK(&g_mutex, return -1); if (entry_add(dev, dir->i_ino, inode->i_ino, name, &dir->i_size)!=0) { - TRACE_ERROR("entry_add() failed\n"); + iscsi_trace_error("entry_add() failed\n"); return -1; } osdfs_write_inode(dir, 0); @@ -714,10 +714,10 @@ static int osdfs_rename(struct inode *old_dir, struct dentry *old_dentry, struct const char *old_name = old_dentry->d_name.name; const char *new_name = new_dentry->d_name.name; - TRACE(TRACE_OSDFS, "old_dir = 0x%p (ino 0x%x)\n", old_dir, (unsigned) old_dir_ino); - TRACE(TRACE_OSDFS, "new_dir = 0x%p (ino 0x%x)\n", new_dir, (unsigned) new_dir_ino); - TRACE(TRACE_OSDFS, "old_dentry = 0x%p (ino 0x%x)\n", old_dentry, (unsigned) old_ino); - TRACE(TRACE_OSDFS, "new_dentry = 0x%p (ino 0x%x)\n", new_dentry, (unsigned) new_ino); + iscsi_trace(TRACE_OSDFS, "old_dir = 0x%p (ino 0x%x)\n", old_dir, (unsigned) old_dir_ino); + iscsi_trace(TRACE_OSDFS, "new_dir = 0x%p (ino 0x%x)\n", new_dir, (unsigned) new_dir_ino); + iscsi_trace(TRACE_OSDFS, "old_dentry = 0x%p (ino 0x%x)\n", old_dentry, (unsigned) old_ino); + iscsi_trace(TRACE_OSDFS, "new_dentry = 0x%p (ino 0x%x)\n", new_dentry, (unsigned) new_ino); /* * If we return -1, the VFS will implement a rename with a combination @@ -728,7 +728,7 @@ static int osdfs_rename(struct inode *old_dir, struct dentry *old_dentry, struct ISCSI_LOCK(&g_mutex, return -1); if (entry_del(dev, old_dir_ino, old_ino, old_name, &old_dir->i_size)!=0) { - TRACE_ERROR("error deleting old entry \"%s\"\n", old_name); + iscsi_trace_error("error deleting old entry \"%s\"\n", old_name); ISCSI_UNLOCK(&g_mutex, return -1); return -1; } @@ -738,9 +738,9 @@ static int osdfs_rename(struct inode *old_dir, struct dentry *old_dentry, struct /* Unlink entry from new directory */ if (new_dentry->d_inode) { - TRACE(TRACE_OSDFS, "unlinking existing file\n"); + iscsi_trace(TRACE_OSDFS, "unlinking existing file\n"); if (osdfs_unlink(new_dir, new_dentry)!=0) { - TRACE_ERROR("osdfs_unlink() failed\n"); + iscsi_trace_error("osdfs_unlink() failed\n"); return -1; } } @@ -749,7 +749,7 @@ static int osdfs_rename(struct inode *old_dir, struct dentry *old_dentry, struct ISCSI_LOCK(&g_mutex, return -1); if (entry_add(dev, new_dir_ino, new_ino, new_name, &new_dir->i_size)!=0) { - TRACE_ERROR("error adding new entry \"%s\"\n", new_name); + iscsi_trace_error("error adding new entry \"%s\"\n", new_name); ISCSI_UNLOCK(&g_mutex, return -1); return -1; } @@ -778,7 +778,7 @@ static struct inode_operations osdfs_dir_inode_operations = { static int osdfs_sync_file(struct file * file, struct dentry *dentry, int datasync) { - TRACE_ERROR("osdfs_syncfile() not implemented\n"); + iscsi_trace_error("osdfs_syncfile() not implemented\n"); return -1; } @@ -807,11 +807,11 @@ static int osdfs_readdir(struct file * filp, void * dirent, filldir_t filldir) { uint64_t uid = ino; name = dentry->d_name.name; - TRACE(TRACE_OSDFS, "osdfs_readdir(\"%s\", ino 0x%x, offset %i)\n", + iscsi_trace(TRACE_OSDFS, "osdfs_readdir(\"%s\", ino 0x%x, offset %i)\n", name, (unsigned) ino, offset); ISCSI_LOCK(&g_mutex, return -1); if (entries_get(dev, uid, &entries, &num_entries, &size)!=0) { - TRACE_ERROR("entries_get() failed\n"); + iscsi_trace_error("entries_get() failed\n"); ISCSI_UNLOCK(&g_mutex, return -1); return -1; } @@ -834,18 +834,18 @@ static int osdfs_readdir(struct file * filp, void * dirent, filldir_t filldir) { case 0: - TRACE(TRACE_OSDFS, "adding \".\" (ino 0x%x)\n", (unsigned) ino); + iscsi_trace(TRACE_OSDFS, "adding \".\" (ino 0x%x)\n", (unsigned) ino); if (filldir(dirent, ".", 1, filp->f_pos++, ino, DT_DIR) < 0) { - TRACE_ERROR("filldir() failed for \".\"??\n"); + iscsi_trace_error("filldir() failed for \".\"??\n"); vfree(entries); return -1; } case 1: - TRACE(TRACE_OSDFS, "adding \"..\" (ino 0x%x)\n", (unsigned) dentry->d_parent->d_inode->i_ino); + iscsi_trace(TRACE_OSDFS, "adding \"..\" (ino 0x%x)\n", (unsigned) dentry->d_parent->d_inode->i_ino); if (filldir(dirent, "..", 2, filp->f_pos++, dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) { - TRACE_ERROR("filldir() failed for \"..\"??\n"); + iscsi_trace_error("filldir() failed for \"..\"??\n"); vfree(entries); return -1; } @@ -863,7 +863,7 @@ static int osdfs_readdir(struct file * filp, void * dirent, filldir_t filldir) { offset--; } else { sscanf(ptr+strlen(ptr)+1, "%li", &ino); - TRACE(TRACE_OSDFS, "adding \"%s\" (ino 0x%x)\n", ptr, (unsigned) ino); + iscsi_trace(TRACE_OSDFS, "adding \"%s\" (ino 0x%x)\n", ptr, (unsigned) ino); if (filldir(dirent, ptr, strlen(ptr), filp->f_pos++, ino, DT_UNKNOWN) < 0) { vfree(entries); return 0; @@ -898,7 +898,7 @@ static int osdfs_readpage(struct file *file, struct page * page) { uint64_t len; uint64_t uid = ino; - TRACE(TRACE_OSDFS, "osdfs_readpage(ino %lu, Offset %llu, Length %llu)\n", ino, Offset, Length); + iscsi_trace(TRACE_OSDFS, "osdfs_readpage(ino %lu, Offset %llu, Length %llu)\n", ino, Offset, Length); if (Offset+Length>inode->i_size) { len = inode->i_size-Offset; } else { @@ -907,7 +907,7 @@ static int osdfs_readpage(struct file *file, struct page * page) { if (!Page_Uptodate(page)) { memset(kmap(page), 0, PAGE_CACHE_SIZE); if (osd_read((void *)&dev, root_gid, uid, Offset, len, page->virtual, 0, &osd_exec_via_scsi)!=0) { - TRACE_ERROR("osd_read() failed\n"); + iscsi_trace_error("osd_read() failed\n"); UnlockPage(page); return -1;; } @@ -915,7 +915,7 @@ static int osdfs_readpage(struct file *file, struct page * page) { flush_dcache_page(page); SetPageUptodate(page); } else { - TRACE_ERROR("The page IS up to date???\n"); + iscsi_trace_error("The page IS up to date???\n"); } UnlockPage(page); @@ -923,7 +923,7 @@ static int osdfs_readpage(struct file *file, struct page * page) { } static int osdfs_prepare_write(struct file *file, struct page *page, unsigned offset, unsigned to) { - TRACE(TRACE_OSDFS, "osdfs_prepare_write(ino %lu, offset %u, to %u)\n", page->mapping->host->i_ino, offset, to); + iscsi_trace(TRACE_OSDFS, "osdfs_prepare_write(ino %lu, offset %u, to %u)\n", page->mapping->host->i_ino, offset, to); return 0; } @@ -935,10 +935,10 @@ static int osdfs_commit_write(struct file *file, struct page *page, unsigned off ino_t ino = inode->i_ino; uint64_t uid = ino; - TRACE(TRACE_OSDFS, "osdfs_commit_write(ino %lu, offset %u, to %u, Offset %llu, Length %llu)\n", + iscsi_trace(TRACE_OSDFS, "osdfs_commit_write(ino %lu, offset %u, to %u, Offset %llu, Length %llu)\n", ino, offset, to, Offset, Length); if (osd_write((void *)&dev, root_gid, uid, Offset, Length, page->virtual+offset, 0, &osd_exec_via_scsi)!=0) { - TRACE_ERROR("osd_write() failed\n"); + iscsi_trace_error("osd_write() failed\n"); return -1; } if (Offset+Length>inode->i_size) { @@ -968,7 +968,7 @@ static struct super_block *osdfs_read_super(struct super_block *sb, void *data, struct inode attr; struct inode *inode; - TRACE(TRACE_OSDFS, "osdfs_read_super(major %i minor %i)\n", MAJOR(sb->s_dev), MINOR(sb->s_dev)); + iscsi_trace(TRACE_OSDFS, "osdfs_read_super(major %i minor %i)\n", MAJOR(sb->s_dev), MINOR(sb->s_dev)); root_gid = root_uid = 0; @@ -986,16 +986,16 @@ static struct super_block *osdfs_read_super(struct super_block *sb, void *data, } if (!strncmp(opt, "uid=", 3)) { if (sscanf(opt, "uid=0x%Lx", &root_uid)!=1) { - TRACE_ERROR("malformed option \"%s\"\n", opt); + iscsi_trace_error("malformed option \"%s\"\n", opt); return NULL; } } else if (!strncmp(opt, "gid=", 3)) { if (sscanf(opt, "gid=0x%x", &root_gid)!=1) { - TRACE_ERROR("malformed option \"%s\"\n", opt); + iscsi_trace_error("malformed option \"%s\"\n", opt); return NULL; } } else { - TRACE_ERROR("unknown option \"%s\"\n", opt); + iscsi_trace_error("unknown option \"%s\"\n", opt); return NULL; } } @@ -1012,39 +1012,39 @@ static struct super_block *osdfs_read_super(struct super_block *sb, void *data, /* Create group object for root directory */ if (osd_create_group((void *)&sb->s_dev, &osd_exec_via_scsi, &root_gid)!=0) { - TRACE_ERROR("osd_create_group() failed\n"); + iscsi_trace_error("osd_create_group() failed\n"); return NULL; } - PRINT("** ROOT DIRECTORY GROUP OBJECT IS 0x%x **\n", root_gid); + printf("** ROOT DIRECTORY GROUP OBJECT IS 0x%x **\n", root_gid); /* Create user object for root directory */ if (osd_create((void *)&sb->s_dev, root_gid, &osd_exec_via_scsi, &root_uid)!=0) { - TRACE_ERROR("osd_create() failed\n"); + iscsi_trace_error("osd_create() failed\n"); return NULL; } - PRINT("** ROOT DIRECTORY USER OBJECT IS 0x%llx **\n", root_uid); + printf("** ROOT DIRECTORY USER OBJECT IS 0x%llx **\n", root_uid); /* Initialize Attributes */ memset(&attr, 0, sizeof(struct inode)); attr.i_mode = S_IFDIR | 0755; if (osd_set_one_attr((void *)&sb->s_dev, root_gid, root_uid, 0x30000000, 0x1, sizeof(struct inode), (void *) &attr, &osd_exec_via_scsi)!=0) { - TRACE_ERROR("osd_set_one_attr() failed\n"); + iscsi_trace_error("osd_set_one_attr() failed\n"); return NULL; } } else { - TRACE(TRACE_OSDFS, "using root directory in 0x%x:0x%llx\n", root_gid, root_uid); + iscsi_trace(TRACE_OSDFS, "using root directory in 0x%x:0x%llx\n", root_gid, root_uid); } /* Create inode for root directory */ if ((inode=osdfs_get_inode(sb, S_IFDIR | 0755, 0, "/", root_uid))==NULL) { - TRACE_ERROR("osdfs_get_inode() failed\n"); + iscsi_trace_error("osdfs_get_inode() failed\n"); return NULL; } if ((sb->s_root=d_alloc_root(inode))==NULL) { - TRACE_ERROR("d_alloc_root() failed\n"); + iscsi_trace_error("d_alloc_root() failed\n"); iput(inode); return NULL; } @@ -1061,13 +1061,13 @@ static DECLARE_FSTYPE_DEV(osdfs_fs_type, "osdfs", osdfs_read_super); static int __init init_osdfs_fs(void) { - TRACE(TRACE_OSDFS, "init_osdfs_fs()\n"); + iscsi_trace(TRACE_OSDFS, "init_osdfs_fs()\n"); ISCSI_MUTEX_INIT(&g_mutex, return -1); return register_filesystem(&osdfs_fs_type); } static void __exit exit_osdfs_fs(void) { - TRACE(TRACE_OSDFS, "exit_osdfs_fs()\n"); + iscsi_trace(TRACE_OSDFS, "exit_osdfs_fs()\n"); ISCSI_MUTEX_DESTROY(&g_mutex, printk("mutex_destroy() failed\n")); unregister_filesystem(&osdfs_fs_type); } diff --git a/dist/iscsi/src/parameters.c b/dist/iscsi/src/parameters.c index d15f596f6fe9..d3fe48fda1c0 100644 --- a/dist/iscsi/src/parameters.c +++ b/dist/iscsi/src/parameters.c @@ -61,7 +61,7 @@ param_list_add(iscsi_parameter_t ** head, int type, const char *key, const char if (*head == NULL) { if ((*head = iscsi_malloc_atomic(sizeof(iscsi_parameter_t))) == NULL) { - TRACE_ERROR("out of memory\n"); + iscsi_trace_error("out of memory\n"); return -1; } param = *head; @@ -69,7 +69,7 @@ param_list_add(iscsi_parameter_t ** head, int type, const char *key, const char for (param = *head; param->next != NULL; param = param->next) { } if ((param->next = iscsi_malloc_atomic(sizeof(iscsi_parameter_t))) == NULL) { - TRACE_ERROR("out of memory\n"); + iscsi_trace_error("out of memory\n"); return -1; } param = param->next; @@ -92,7 +92,7 @@ param_list_add(iscsi_parameter_t ** head, int type, const char *key, const char /* set offer and answer lists to NULL */ if ((param->value_l = iscsi_malloc_atomic(sizeof(iscsi_parameter_value_t))) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } param->value_l->next = NULL; @@ -114,7 +114,7 @@ param_list_add(iscsi_parameter_t ** head, int type, const char *key, const char strcmp(valid, "no,yes") != 0 && strcmp(valid, "no") != 0 && strcmp(valid, "yes") != 0) { - TRACE_ERROR("bad field \"%s\" for ISCSI_PARAM_TYPE_BINARY\n", valid); + iscsi_trace_error("bad field \"%s\" for ISCSI_PARAM_TYPE_BINARY\n", valid); return -1; } break; @@ -127,7 +127,7 @@ param_list_add(iscsi_parameter_t ** head, int type, const char *key, const char strcmp(valid, "no,yes") != 0 && strcmp(valid, "no") != 0 && strcmp(valid, "yes") != 0) { - TRACE_ERROR("bad field \"%s\" for ISCSI_PARAM_TYPE_BINARY\n", valid); + iscsi_trace_error("bad field \"%s\" for ISCSI_PARAM_TYPE_BINARY\n", valid); return -1; } break; @@ -138,11 +138,11 @@ param_list_add(iscsi_parameter_t ** head, int type, const char *key, const char case ISCSI_PARAM_TYPE_LIST: break; default: - TRACE_ERROR("unknown parameter type %i\n", type); + iscsi_trace_error("unknown parameter type %i\n", type); return -1; } - TRACE(TRACE_ISCSI_PARAM, "\"%s\": valid \"%s\", default \"%s\", current \"%s\"\n", + iscsi_trace(TRACE_ISCSI_PARAM, "\"%s\": valid \"%s\", default \"%s\", current \"%s\"\n", param->key, param->valid, param->dflt, param->value_l->value); return 0; } @@ -160,13 +160,13 @@ param_list_destroy(iscsi_parameter_t * head) for (item_ptr = tmp->value_l; item_ptr != NULL; item_ptr = next) { next = item_ptr->next; /* - * TRACE(TRACE_ISCSI_PARAM, "freeing \"%s\" + * iscsi_trace(TRACE_ISCSI_PARAM, "freeing \"%s\" * (%p)\n", item_ptr->value, item_ptr); */ iscsi_free_atomic(item_ptr); } } - /* TRACE(TRACE_ISCSI_PARAM, "freeing %p\n", tmp); */ + /* iscsi_trace(TRACE_ISCSI_PARAM, "freeing %p\n", tmp); */ iscsi_free_atomic(tmp); } return 0; @@ -183,7 +183,7 @@ param_get(iscsi_parameter_t * head, const char *key) return ptr; } } - TRACE_ERROR("key \"%s\" not found in param list\n", key); + iscsi_trace_error("key \"%s\" not found in param list\n", key); return NULL; } @@ -205,19 +205,19 @@ param_val_which(iscsi_parameter_t * head, const char *key, int which) item_ptr = ptr->value_l; for (i = 0; i != which; i++) { if (item_ptr == NULL) { - TRACE_ERROR("item %i in value list is NULL\n", i); + iscsi_trace_error("item %i in value list is NULL\n", i); return NULL; } item_ptr = item_ptr->next; } if (item_ptr == NULL) { - TRACE_ERROR("item %i in value list is NULL\n", which); + iscsi_trace_error("item %i in value list is NULL\n", which); return NULL; } return item_ptr->value; } } - TRACE_ERROR("key \"%s\" not found in param list\n", key); + iscsi_trace_error("key \"%s\" not found in param list\n", key); return NULL; } @@ -237,7 +237,7 @@ param_val_delete_all(iscsi_parameter_t * head, char *key) return 0; } } - TRACE_ERROR("key \"%s\" not found in param list\n", key); + iscsi_trace_error("key \"%s\" not found in param list\n", key); return -1; } @@ -252,7 +252,7 @@ param_val_reset(iscsi_parameter_t * head, const char *key) return 0; } } - TRACE_ERROR("key \"%s\" not found in param list\n", key); + iscsi_trace_error("key \"%s\" not found in param list\n", key); return -1; } @@ -268,16 +268,16 @@ param_atoi(iscsi_parameter_t * head, const char *key) if ((value = param_val(head, key)) != NULL) { return iscsi_atoi(value); } else { - TRACE_ERROR("value is NULL\n"); + iscsi_trace_error("value is NULL\n"); return 0; } } else { - TRACE_ERROR("param \"%s\" has NULL value list\n", key); + iscsi_trace_error("param \"%s\" has NULL value list\n", key); return 0; } } } - TRACE_ERROR("key \"%s\" not found in param list\n", key); + iscsi_trace_error("key \"%s\" not found in param list\n", key); return 0; } @@ -290,17 +290,17 @@ param_equiv(iscsi_parameter_t * head, const char *key, const char *val) for (ptr = head; ptr != NULL; ptr = ptr->next) { if (strcmp(ptr->key, key) == 0) { if (ptr->value_l == NULL) { - TRACE_ERROR("param \"%s\" has NULL value list\n", key); + iscsi_trace_error("param \"%s\" has NULL value list\n", key); return 0; } if ((value = param_val(head, key)) == NULL) { - TRACE_ERROR("key \"%s\" value is NULL\n", key); + iscsi_trace_error("key \"%s\" value is NULL\n", key); return 0; } return (strcmp(value, val) == 0); } } - TRACE_ERROR("key \"%s\" not found in param list\n", key); + iscsi_trace_error("key \"%s\" not found in param list\n", key); return -1; } @@ -319,7 +319,7 @@ param_num_vals(iscsi_parameter_t * head, char *key) return num; } } - TRACE_ERROR("key \"%s\" not found in param list\n", key); + iscsi_trace_error("key \"%s\" not found in param list\n", key); return -1; } @@ -331,7 +331,7 @@ param_list_print(iscsi_parameter_t * head) for (ptr = head; ptr != NULL; ptr = ptr->next) { for (item_ptr = ptr->value_l; item_ptr != NULL; item_ptr = item_ptr->next) { - PRINT("\"%s\"=\"%s\"\n", ptr->key, item_ptr->value); + printf("\"%s\"=\"%s\"\n", ptr->key, item_ptr->value); } } return 0; @@ -353,13 +353,13 @@ param_text_print(char *text, uint32_t text_len) break; if ((eq = strchr(ptr, '=')) == NULL) { - TRACE_ERROR("delimiter \'=\' not found in token \"%s\"\n", ptr); + iscsi_trace_error("delimiter \'=\' not found in token \"%s\"\n", ptr); return -1; } strncpy(key, ptr, (unsigned)(eq - ptr)); key[(int)(eq - ptr)] = 0x0; value = eq + 1; - PRINT("\"%s\"=\"%s\"\n", key, value); + printf("\"%s\"=\"%s\"\n", key, value); } return 0; } @@ -400,7 +400,7 @@ find_credentials(cred_t *cred, char *user, const char *auth) (void) memset(&e, 0x0, sizeof(e)); if (!conffile_open(&conf, _PATH_ISCSI_PASSWD, "r", ":", "#")) { - TRACE_ERROR("can't open `%s'\n", _PATH_ISCSI_PASSWD); + iscsi_trace_error("can't open `%s'\n", _PATH_ISCSI_PASSWD); exit(EXIT_FAILURE); } while (conffile_getent(&conf, &e)) { @@ -462,11 +462,11 @@ param_parse_security(iscsi_parameter_t * head, int ret = 1; if ((chapstring = iscsi_malloc(ISCSI_CHAP_STRING_LENGTH)) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); return -1; } if ((context = iscsi_malloc(sizeof(MD5Context_t))) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); if (chapstring != NULL) iscsi_free(chapstring); return -1; @@ -541,14 +541,14 @@ param_parse_security(iscsi_parameter_t * head, param->rx_offer = 0; /* reset */ if (cred->shared_secret == NULL && !find_credentials(cred, cred->user, "chap")) { - TRACE_ERROR("Unknown user `%s'\n", param_in->offer_rx); + iscsi_trace_error("Unknown user `%s'\n", param_in->offer_rx); PPS_ERROR; } if (cred->user) { (void) strlcpy(param->offer_tx, cred->user, sizeof(param->offer_tx)); } else { - TRACE_ERROR("no valid user credentials\n"); + iscsi_trace_error("no valid user credentials\n"); PPS_ERROR; } @@ -564,7 +564,7 @@ param_parse_security(iscsi_parameter_t * head, MD5Update(context, &idData, 1); if (cred->shared_secret == NULL) { - TRACE_ERROR("null shared secret\n"); + iscsi_trace_error("null shared secret\n"); PPS_ERROR; } else { MD5Update(context, cred->shared_secret, strlen(cred->shared_secret)); @@ -612,7 +612,7 @@ param_parse_security(iscsi_parameter_t * head, user = (param_in->rx_offer) ? param_in->offer_rx : param_in->answer_rx; if (!find_credentials(cred, user, "chap")) { - TRACE_ERROR("Unknown user `%s'\n", user); + iscsi_trace_error("Unknown user `%s'\n", user); PPS_ERROR; } ret++; @@ -628,7 +628,7 @@ param_parse_security(iscsi_parameter_t * head, chapstring, ISCSI_CHAP_STRING_LENGTH); if (cred->shared_secret == NULL) { - TRACE_ERROR("Null shared secret in initiator\n"); + iscsi_trace_error("Null shared secret in initiator\n"); PPS_ERROR; } else { MD5Update(context, cred->shared_secret, strlen(cred->shared_secret)); @@ -644,7 +644,7 @@ param_parse_security(iscsi_parameter_t * head, param_in->offer_rx, ISCSI_CHAP_STRING_LENGTH); if (memcmp(respdata, chapdata, ISCSI_CHAP_DATA_LENGTH) != 0) { - TRACE_ERROR("Initiator authentication failed %x %x\n", *chapdata, *respdata); + iscsi_trace_error("Initiator authentication failed %x %x\n", *chapdata, *respdata); PPS_ERROR; } else { PPS_CLEANUP; @@ -688,21 +688,21 @@ param_text_parse(iscsi_parameter_t * head, */ /* text has offers that need an answer. */ - TRACE(TRACE_ISCSI_PARAM, "parsing %i %s bytes of text parameters\n", text_len_in, outgoing ? "outgoing" : "incoming"); + iscsi_trace(TRACE_ISCSI_PARAM, "parsing %i %s bytes of text parameters\n", text_len_in, outgoing ? "outgoing" : "incoming"); if ((key = iscsi_malloc(ISCSI_PARAM_KEY_LEN)) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); return -1; } if ((offer = iscsi_malloc(ISCSI_PARAM_MAX_LEN)) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); if (key != NULL) { iscsi_free(key); } return -1; } if ((valid = iscsi_malloc(ISCSI_PARAM_MAX_LEN)) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); if (key != NULL) { iscsi_free(key); } @@ -712,7 +712,7 @@ param_text_parse(iscsi_parameter_t * head, return -1; } if ((val1 = iscsi_malloc(ISCSI_PARAM_MAX_LEN)) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); if (key != NULL) { iscsi_free(key); } @@ -725,7 +725,7 @@ param_text_parse(iscsi_parameter_t * head, return -1; } if ((val2 = iscsi_malloc(ISCSI_PARAM_MAX_LEN)) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); if (key != NULL) { iscsi_free(key); } @@ -753,9 +753,9 @@ param_text_parse(iscsi_parameter_t * head, } #if ISCSI_DEBUG - PRINT("**************************************************\n"); - PRINT("* PARAMETERS NEGOTIATED *\n"); - PRINT("* *\n"); + printf("**************************************************\n"); + printf("* PARAMETERS NEGOTIATED *\n"); + printf("* *\n"); #endif for (ptr = text_in; ptr - text_in < text_len_in; ptr += (strlen(ptr) + 1)) { @@ -772,7 +772,7 @@ param_text_parse(iscsi_parameter_t * head, /* Extract = token from text_in */ if ((eq = strchr(ptr, '=')) == NULL) { - TRACE_ERROR("delimiter \'=\' not found in token \"%s\"\n", ptr); + iscsi_trace_error("delimiter \'=\' not found in token \"%s\"\n", ptr); } else { if ((int)(eq - ptr) >= (ISCSI_PARAM_KEY_LEN - 1)) { if (!outgoing) { @@ -784,7 +784,7 @@ param_text_parse(iscsi_parameter_t * head, PARAM_TEXT_ADD(head, tmp_key, "NotUnderstood", text_out, text_len_out, textsize, 0, PTP_ERROR); } } else { - PRINT("ignoring \"%s\"\n", key); + printf("ignoring \"%s\"\n", key); } goto next; } @@ -805,7 +805,7 @@ param_text_parse(iscsi_parameter_t * head, /* Key not understood. */ PARAM_TEXT_ADD(head, key, "NotUnderstood", text_out, text_len_out, textsize, 0, PTP_ERROR); } else { - PRINT("ignoring \"%s\"\n", key); + printf("ignoring \"%s\"\n", key); } goto next; } @@ -817,14 +817,14 @@ param_text_parse(iscsi_parameter_t * head, if (param->rx_offer) { param->tx_answer = 1; /* sending an answer */ (void) strlcpy(param->answer_tx, value, sizeof(param->answer_tx)); - TRACE(TRACE_ISCSI_PARAM, "sending answer \"%s\"=\"%s\" for offer \"%s\"\n", + iscsi_trace(TRACE_ISCSI_PARAM, "sending answer \"%s\"=\"%s\" for offer \"%s\"\n", param->key, param->answer_tx, param->offer_rx); goto negotiate; } else { param->tx_offer = 1; /* sending an offer */ param->rx_offer = 0; /* reset */ (void) strlcpy(param->offer_tx, value, sizeof(param->offer_tx)); - TRACE(TRACE_ISCSI_PARAM, "sending offer \"%s\"=\"%s\"\n", param->key, param->offer_tx); + iscsi_trace(TRACE_ISCSI_PARAM, "sending offer \"%s\"=\"%s\"\n", param->key, param->offer_tx); if ((param->type == ISCSI_PARAM_TYPE_DECLARATIVE) || (param->type == ISCSI_PARAM_TYPE_DECLARE_MULTI)) { goto negotiate; @@ -836,7 +836,7 @@ param_text_parse(iscsi_parameter_t * head, param->rx_answer = 1; /* received an answer */ param->tx_offer = 0; /* reset */ (void) strlcpy(param->answer_rx, value, sizeof(param->answer_rx)); - TRACE(TRACE_ISCSI_PARAM, "received answer \"%s\"=\"%s\" for offer \"%s\"\n", + iscsi_trace(TRACE_ISCSI_PARAM, "received answer \"%s\"=\"%s\" for offer \"%s\"\n", param->key, param->answer_rx, param->offer_tx); if ((ret = param_parse_security(head, param, cred, @@ -859,7 +859,7 @@ param_text_parse(iscsi_parameter_t * head, } else { param->rx_offer = 1; /* received an offer */ (void) strlcpy(param->offer_rx, value, sizeof(param->offer_rx)); - TRACE(TRACE_ISCSI_PARAM, "received offer \"%s\"=\"%s\"\n", param->key, param->offer_rx); + iscsi_trace(TRACE_ISCSI_PARAM, "received offer \"%s\"=\"%s\"\n", param->key, param->offer_rx); if ((ret = param_parse_security(head, param, cred, text_out, text_len_out, textsize)) > 1) { @@ -895,16 +895,16 @@ answer: /* Answer with current value if this is an inquiry (=?) */ if (strcmp(value, "?") == 0) { - TRACE(TRACE_ISCSI_PARAM, "got inquiry for param \"%s\"\n", param->key); + iscsi_trace(TRACE_ISCSI_PARAM, "got inquiry for param \"%s\"\n", param->key); if (param->value_l) { if (param->value_l->value) { (void) strlcpy(param->answer_tx, param->value_l->value, sizeof(param->answer_tx)); } else { - TRACE_ERROR("param \"%s\" has NULL value_l->value\n", param->key); + iscsi_trace_error("param \"%s\" has NULL value_l->value\n", param->key); param->answer_tx[0] = 0x0; } } else { - TRACE_ERROR("param \"%s\" has NULL value_l\n", param->key); + iscsi_trace_error("param \"%s\" has NULL value_l\n", param->key); param->answer_tx[0] = 0x0; } goto add_answer; @@ -922,7 +922,7 @@ binary_or: strcmp(value, "no") != 0 && strcmp(value, "Yes") != 0 && strcmp(value, "No") != 0) { - TRACE_ERROR("\"%s\" is not a valid binary value\n", value); + iscsi_trace_error("\"%s\" is not a valid binary value\n", value); (void) strlcpy(param->answer_tx, "Reject", sizeof(param->answer_tx)); goto add_answer; } @@ -991,13 +991,13 @@ binary_or: } } } else { - TRACE(TRACE_ISCSI_PARAM, "Valid list empty. Answering with first in offer list\n"); + iscsi_trace(TRACE_ISCSI_PARAM, "Valid list empty. Answering with first in offer list\n"); (void) strlcpy(param->answer_tx, offer, sizeof(param->answer_tx)); goto add_answer; } - TRACE(TRACE_ISCSI_PARAM, "\"%s\" is not a valid offer for key \"%s\" (must choose from \"%s\")\n", offer, param->key, param->valid); + iscsi_trace(TRACE_ISCSI_PARAM, "\"%s\" is not a valid offer for key \"%s\" (must choose from \"%s\")\n", offer, param->key, param->valid); } - TRACE(TRACE_ISCSI_PARAM, "No Valid offers: \"%s\" is added as value for key \"%s\")\n", "Reject", param->key); + iscsi_trace(TRACE_ISCSI_PARAM, "No Valid offers: \"%s\" is added as value for key \"%s\")\n", "Reject", param->key); (void) strlcpy(param->answer_tx, "Reject", sizeof(param->answer_tx)); break; @@ -1039,7 +1039,7 @@ numerical: goto next; } add_answer: PARAM_TEXT_ADD(head, key, param->answer_tx, text_out, text_len_out, textsize, 0, PTP_ERROR); - TRACE(TRACE_ISCSI_PARAM, "answering \"%s\"=\"%s\"\n", param->key, param->answer_tx); + iscsi_trace(TRACE_ISCSI_PARAM, "answering \"%s\"=\"%s\"\n", param->key, param->answer_tx); goto next; @@ -1070,7 +1070,7 @@ binary_or_negotiate: strcmp(val1, "no") != 0 && strcmp(val1, "Irrelevant") != 0) { /* Invalid value returned as answer. */ - TRACE_ERROR("Invalid answer (%s) for key (%s)\n", + iscsi_trace_error("Invalid answer (%s) for key (%s)\n", val1, key); PTP_ERROR; } @@ -1124,25 +1124,25 @@ numerical_negotiate: case ISCSI_PARAM_TYPE_LIST: if (outgoing) { if (param->tx_offer) { - TRACE_ERROR("we should not be here\n"); /* error - we're sending + iscsi_trace_error("we should not be here\n"); /* error - we're sending * an offer */ PTP_ERROR; } else if (param->tx_answer) { (void) strlcpy(val1, param->answer_tx, ISCSI_PARAM_MAX_LEN); /* we're sending an * answer */ } else { - TRACE_ERROR("unexpected error\n"); + iscsi_trace_error("unexpected error\n"); PTP_ERROR; } } else { if (param->rx_offer) { - TRACE_ERROR("we should not be here\n"); /* error - we received + iscsi_trace_error("we should not be here\n"); /* error - we received * an offer */ PTP_ERROR; } else if (param->rx_answer) { (void) strlcpy(val1, param->answer_rx, ISCSI_PARAM_MAX_LEN); /* we received an answer */ } else { - TRACE_ERROR("unexpected error\n"); + iscsi_trace_error("unexpected error\n"); PTP_ERROR; } } @@ -1169,50 +1169,50 @@ numerical_negotiate: } } } else { - TRACE(TRACE_ISCSI_PARAM, "Valid list empty??\n"); + iscsi_trace(TRACE_ISCSI_PARAM, "Valid list empty??\n"); PTP_ERROR; } - TRACE_ERROR("\"%s\" is not a valid value (must choose from \"%s\")\n", val1, param->valid); + iscsi_trace_error("\"%s\" is not a valid value (must choose from \"%s\")\n", val1, param->valid); PTP_ERROR; value_ok: (void) strlcpy(param->negotiated, val1, sizeof(param->negotiated)); break; } - TRACE(TRACE_ISCSI_PARAM, "negotiated \"%s\"=\"%s\"\n", param->key, param->negotiated); + iscsi_trace(TRACE_ISCSI_PARAM, "negotiated \"%s\"=\"%s\"\n", param->key, param->negotiated); /* For inquiries, we don't commit the value. */ if (param->tx_offer && strcmp(param->offer_tx, "?") == 0) { /* we're offering an inquiry */ - TRACE(TRACE_ISCSI_PARAM, "sending an inquiry for \"%s\"\n", param->key); + iscsi_trace(TRACE_ISCSI_PARAM, "sending an inquiry for \"%s\"\n", param->key); goto next; } else if (param->rx_offer && strcmp(param->offer_rx, "?") == 0) { /* we're receiving an inquiry */ - TRACE(TRACE_ISCSI_PARAM, "received an inquiry for \"%s\"\n", param->key); + iscsi_trace(TRACE_ISCSI_PARAM, "received an inquiry for \"%s\"\n", param->key); goto next; } else if (param->tx_answer && strcmp(param->offer_rx, "?") == 0) { /* we're answering an inquiry */ - TRACE(TRACE_ISCSI_PARAM, "answering an inquiry for \"%s\"\n", param->key); + iscsi_trace(TRACE_ISCSI_PARAM, "answering an inquiry for \"%s\"\n", param->key); goto next; } else if (param->rx_answer && strcmp(param->offer_tx, "?") == 0) { /* we're receiving an answer for our inquiry */ - TRACE(TRACE_ISCSI_PARAM, "received an answer for inquiry on \"%s\"\n", param->key); + iscsi_trace(TRACE_ISCSI_PARAM, "received an answer for inquiry on \"%s\"\n", param->key); goto next; } - TRACE(TRACE_ISCSI_PARAM, "automatically committing \"%s\"=\"%s\"\n", param->key, param->negotiated); + iscsi_trace(TRACE_ISCSI_PARAM, "automatically committing \"%s\"=\"%s\"\n", param->key, param->negotiated); c = param->negotiated[19]; param->negotiated[19] = 0x0; #if ISCSI_DEBUG - PRINT("* %25s:%20s *\n", param->key, param->negotiated); + printf("* %25s:%20s *\n", param->key, param->negotiated); #endif param->negotiated[19] = c; if (param->reset) { - TRACE(TRACE_ISCSI_PARAM, "deleting value list for \"%s\"\n", param->key); + iscsi_trace(TRACE_ISCSI_PARAM, "deleting value list for \"%s\"\n", param->key); if (param_val_delete_all(head, param->key) != 0) { - TRACE_ERROR("param_val_delete_all() failed\n"); + iscsi_trace_error("param_val_delete_all() failed\n"); PTP_ERROR; } param->reset = 0; @@ -1222,7 +1222,7 @@ value_ok: for (item_ptr = param->value_l; item_ptr->next != NULL; item_ptr = item_ptr->next) { } if ((item_ptr->next = iscsi_malloc_atomic(sizeof(iscsi_parameter_value_t))) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); PTP_ERROR; } item_ptr = item_ptr->next; @@ -1231,9 +1231,9 @@ value_ok: item_ptr = param->value_l; } } else { - TRACE(TRACE_ISCSI_PARAM, "allocating value ptr\n"); + iscsi_trace(TRACE_ISCSI_PARAM, "allocating value ptr\n"); if ((param->value_l = iscsi_malloc_atomic(sizeof(iscsi_parameter_value_t))) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); PTP_ERROR; } item_ptr = param->value_l; @@ -1244,10 +1244,10 @@ next: continue; } if (!outgoing) { - TRACE(TRACE_ISCSI_PARAM, "generated %d bytes response\n", *text_len_out); + iscsi_trace(TRACE_ISCSI_PARAM, "generated %d bytes response\n", *text_len_out); } #if ISCSI_DEBUG - PRINT("**************************************************\n"); + printf("**************************************************\n"); #endif PTP_CLEANUP; diff --git a/dist/iscsi/src/so.c b/dist/iscsi/src/so.c index babbd06efe06..af02c7cbc0d7 100644 --- a/dist/iscsi/src/so.c +++ b/dist/iscsi/src/so.c @@ -133,7 +133,7 @@ static int so_ioctl(struct inode * inode, struct file * file, unsigned int cmd, Scsi_Device * SDev; int osdinfo[4]; - TRACE(TRACE_OSDSO, "so_ioctl()\n"); + iscsi_trace(TRACE_OSDSO, "so_ioctl()\n"); SDev = rscsi_osds[DEVICE_NR(dev)].device; /* @@ -240,7 +240,7 @@ static int so_ioctl(struct inode * inode, struct file * file, unsigned int cmd, } static void so_devname(unsigned int index, char *buffer) { - TRACE(TRACE_OSDSO, "so_devname(%i)\n", index); + iscsi_trace(TRACE_OSDSO, "so_devname(%i)\n", index); sprintf(buffer, "so%i", index); } @@ -249,13 +249,13 @@ static request_queue_t *so_find_queue(kdev_t dev) Scsi_Osd *dpnt; int target; - TRACE(TRACE_OSDSO, "so_find_queue()\n"); + iscsi_trace(TRACE_OSDSO, "so_find_queue()\n"); target = DEVICE_NR(dev); dpnt = &rscsi_osds[target]; if (!dpnt) { - TRACE_ERROR("no such device\n"); + iscsi_trace_error("no such device\n"); return NULL; } return &dpnt->device->request_queue; @@ -269,7 +269,7 @@ static int so_init_command(Scsi_Cmnd * SCpnt) osd_args_t args; int index; - TRACE(TRACE_OSDSO, "so_init_command(MAJOR %i, MINOR %i)\n", + iscsi_trace(TRACE_OSDSO, "so_init_command(MAJOR %i, MINOR %i)\n", MAJOR(SCpnt->request.rq_dev), MINOR(SCpnt->request.rq_dev)); index = MINOR(SCpnt->request.rq_dev); so_devname(index, nbuff); @@ -279,26 +279,26 @@ static int so_init_command(Scsi_Cmnd * SCpnt) if (index >= so_template.dev_max || !dpnt || !dpnt->device->online || block + SCpnt->request.nr_sectors > so[index].nr_sects) { - TRACE_ERROR("index %i: request out of range: %i offset + %li count > %li total sectors\n", + iscsi_trace_error("index %i: request out of range: %i offset + %li count > %li total sectors\n", index, block, SCpnt->request.nr_sectors, so[index].nr_sects); return 0; } block += so[index].start_sect; if (dpnt->device->changed) { - TRACE_ERROR("SCSI osd has been changed. Prohibiting further I/O\n"); + iscsi_trace_error("SCSI osd has been changed. Prohibiting further I/O\n"); return 0; } switch (SCpnt->request.cmd) { case WRITE: - TRACE(TRACE_OSDSO, "Translating BLOCK WRITE to OBJECT WRITE\n"); + iscsi_trace(TRACE_OSDSO, "Translating BLOCK WRITE to OBJECT WRITE\n"); if (!dpnt->device->writeable) { - TRACE_ERROR("device is not writable\n"); + iscsi_trace_error("device is not writable\n"); return 0; } - TRACE(TRACE_OSDSO, "Translating BLOCK WRITE (sector %i, len %i) to OBJECT WRITE\n", block, this_count); + iscsi_trace(TRACE_OSDSO, "Translating BLOCK WRITE (sector %i, len %i) to OBJECT WRITE\n", block, this_count); memset(&args, 0, sizeof(osd_args_t)); args.opcode = 0x7f; args.add_cdb_len = CONFIG_OSD_CDB_LEN-7; @@ -314,7 +314,7 @@ static int so_init_command(Scsi_Cmnd * SCpnt) case READ: - TRACE(TRACE_OSDSO, "Translating BLOCK READ (sector %i, len %i) to OBJECT READ\n", block, this_count); + iscsi_trace(TRACE_OSDSO, "Translating BLOCK READ (sector %i, len %i) to OBJECT READ\n", block, this_count); memset(&args, 0, sizeof(osd_args_t)); args.opcode = 0x7f; args.add_cdb_len = CONFIG_OSD_CDB_LEN-7; @@ -365,7 +365,7 @@ static int so_open(struct inode *inode, struct file *filp) Scsi_Device * SDev; target = DEVICE_NR(inode->i_rdev); - TRACE(TRACE_OSDSO, "so_open()\n"); + iscsi_trace(TRACE_OSDSO, "so_open()\n"); SCSI_LOG_HLQUEUE(1, printk("target=%d, max=%d\n", target, so_template.dev_max)); @@ -439,7 +439,7 @@ static int so_release(struct inode *inode, struct file *file) int target; Scsi_Device * SDev; - TRACE(TRACE_OSDSO, "so_release()\n"); + iscsi_trace(TRACE_OSDSO, "so_release()\n"); target = DEVICE_NR(inode->i_rdev); SDev = rscsi_osds[target].device; @@ -501,7 +501,7 @@ static void rw_intr(Scsi_Cmnd * SCpnt) int block_sectors = 1; so_devname(DEVICE_NR(SCpnt->request.rq_dev), nbuff); - TRACE(TRACE_OSDSO, "rw_intr(/dev/%s, host %d, result 0x%x)\n", nbuff, SCpnt->host->host_no, result); + iscsi_trace(TRACE_OSDSO, "rw_intr(/dev/%s, host %d, result 0x%x)\n", nbuff, SCpnt->host->host_no, result); /* Handle MEDIUM ERRORs that indicate partial success. Since this is a @@ -576,7 +576,7 @@ static int check_scsiosd_media_change(kdev_t full_dev) int flag = 0; Scsi_Device * SDev; - TRACE(TRACE_OSDSO, "check_scsiosd_media_change()\n"); + iscsi_trace(TRACE_OSDSO, "check_scsiosd_media_change()\n"); target = DEVICE_NR(full_dev); SDev = rscsi_osds[target].device; @@ -641,11 +641,11 @@ static int so_init_oneosd(int i) { char nbuff[6]; Scsi_Request *SRpnt; - TRACE(TRACE_OSDSO, "so_init_oneosd(%i)\n", i); + iscsi_trace(TRACE_OSDSO, "so_init_oneosd(%i)\n", i); so_devname(i, nbuff); if (rscsi_osds[i].device->online == FALSE) { - TRACE_ERROR("device is offline??\n"); + iscsi_trace_error("device is offline??\n"); return i; } @@ -663,7 +663,7 @@ static int so_init_oneosd(int i) { SRpnt->sr_data_direction = SCSI_DATA_READ; scsi_wait_req (SRpnt, (void *) cmd, NULL, 0, SO_TIMEOUT, MAX_RETRIES); if (SRpnt->sr_result!=0) { - TRACE_ERROR("OSD not ready\n"); + iscsi_trace_error("OSD not ready\n"); return i; } @@ -700,18 +700,18 @@ static int so_registered; static int so_init() { int i; - TRACE(TRACE_OSDSO, "so_init()\n"); + iscsi_trace(TRACE_OSDSO, "so_init()\n"); if (so_template.dev_noticed == 0) { - TRACE_ERROR("no OSDs noticed\n"); + iscsi_trace_error("no OSDs noticed\n"); return 0; } if (!rscsi_osds) { - PRINT("%i osds detected \n", so_template.dev_noticed); + printf("%i osds detected \n", so_template.dev_noticed); so_template.dev_max = so_template.dev_noticed; } if (so_template.dev_max > SCSI_OSDS_PER_MAJOR) { - TRACE_ERROR("so_template.dev_max (%i) > SCSI_OSDS_PER_MAJOR\n", so_template.dev_max); + iscsi_trace_error("so_template.dev_max (%i) > SCSI_OSDS_PER_MAJOR\n", so_template.dev_max); so_template.dev_max = SCSI_OSDS_PER_MAJOR; } if (!so_registered) { @@ -729,7 +729,7 @@ static int so_init() { /* Real devices */ if ((rscsi_osds = kmalloc(so_template.dev_max * sizeof(Scsi_Osd), GFP_ATOMIC))==NULL) { - TRACE_ERROR("kmalloc() failed\n"); + iscsi_trace_error("kmalloc() failed\n"); goto cleanup_devfs; } memset(rscsi_osds, 0, so_template.dev_max * sizeof(Scsi_Osd)); @@ -738,7 +738,7 @@ static int so_init() { /* Partition sizes */ if ((so_sizes=kmalloc(so_template.dev_max*sizeof(int), GFP_ATOMIC))==NULL) { - TRACE_ERROR("kmalloc() failed\n"); + iscsi_trace_error("kmalloc() failed\n"); goto cleanup_rscsi_osds; } memset(so_sizes, 0, so_template.dev_max*sizeof(int)); @@ -747,7 +747,7 @@ static int so_init() { /* Block sizes */ if ((so_blocksizes=kmalloc(so_template.dev_max*sizeof(int), GFP_ATOMIC))==NULL) { - TRACE_ERROR("kmalloc() failed\n"); + iscsi_trace_error("kmalloc() failed\n"); goto cleanup_so_sizes; } blksize_size[SCSI_OSD_MAJOR] = so_blocksizes; @@ -755,7 +755,7 @@ static int so_init() { /* Sector sizes */ if ((so_hardsizes=kmalloc(so_template.dev_max*sizeof(int), GFP_ATOMIC))==NULL) { - TRACE_ERROR("kmalloc() failed\n"); + iscsi_trace_error("kmalloc() failed\n"); goto cleanup_so_blocksizes; } hardsect_size[SCSI_OSD_MAJOR] = so_hardsizes; @@ -763,7 +763,7 @@ static int so_init() { /* Partitions */ if ((so=kmalloc(so_template.dev_max*sizeof(struct hd_struct), GFP_ATOMIC))==NULL) { - TRACE_ERROR("kmalloc() failed\n"); + iscsi_trace_error("kmalloc() failed\n"); goto cleanup_so_hardsizes; } memset(so, 0, so_template.dev_max*sizeof(struct hd_struct)); @@ -781,7 +781,7 @@ static int so_init() { /* ??? */ if ((so_gendisk.de_arr=kmalloc(SCSI_OSDS_PER_MAJOR*sizeof(*so_gendisk.de_arr), GFP_ATOMIC))==NULL) { - TRACE_ERROR("kmalloc() failed\n"); + iscsi_trace_error("kmalloc() failed\n"); goto cleanup_so; } memset(so_gendisk.de_arr, 0, SCSI_OSDS_PER_MAJOR * sizeof *so_gendisk.de_arr); @@ -789,13 +789,13 @@ static int so_init() { /* Flags */ if ((so_gendisk.flags=kmalloc(SCSI_OSDS_PER_MAJOR*sizeof(*so_gendisk.flags),GFP_ATOMIC))==NULL) { - TRACE_ERROR("kmalloc() failed\n"); + iscsi_trace_error("kmalloc() failed\n"); goto cleanup_so_gendisk_de_arr; } memset(so_gendisk.flags, 0, SCSI_OSDS_PER_MAJOR * sizeof *so_gendisk.flags); if (so_gendisk.next) { - TRACE_ERROR("Why is this not NULL?\n"); + iscsi_trace_error("Why is this not NULL?\n"); so_gendisk.next = NULL; } @@ -825,7 +825,7 @@ static void so_finish() struct gendisk *gendisk; int i; - TRACE(TRACE_OSDSO, "so_finish()\n"); + iscsi_trace(TRACE_OSDSO, "so_finish()\n"); blk_dev[SCSI_OSD_MAJOR].queue = so_find_queue; for (gendisk = gendisk_head; gendisk != NULL; gendisk = gendisk->next) @@ -856,7 +856,7 @@ static void so_finish() static int so_detect(Scsi_Device * SDp) { char nbuff[6]; - TRACE(TRACE_OSDSO, "so_detect()\n"); + iscsi_trace(TRACE_OSDSO, "so_detect()\n"); if (SDp->type != TYPE_OSD && SDp->type != TYPE_MOD) return 0; @@ -876,7 +876,7 @@ static int so_attach(Scsi_Device * SDp) Scsi_Osd *dpnt; int i; - TRACE(TRACE_OSDSO, "so_attach(SDpnt 0x%p)\n", SDp); + iscsi_trace(TRACE_OSDSO, "so_attach(SDpnt 0x%p)\n", SDp); if (SDp->type != TYPE_OSD && SDp->type != TYPE_MOD) return 0; @@ -922,7 +922,7 @@ int revalidate_scsiosd(kdev_t dev, int maxusage) int start; int i; - TRACE(TRACE_OSDSO, "revalidate_scsiosd()\n"); + iscsi_trace(TRACE_OSDSO, "revalidate_scsiosd()\n"); target = DEVICE_NR(dev); @@ -965,7 +965,7 @@ int revalidate_scsiosd(kdev_t dev, int maxusage) static int fop_revalidate_scsiosd(kdev_t dev) { - TRACE(TRACE_OSDSO, "fop_revalidate_scsiosd()\n"); + iscsi_trace(TRACE_OSDSO, "fop_revalidate_scsiosd()\n"); return revalidate_scsiosd(dev, 0); } static void so_detach(Scsi_Device * SDp) @@ -975,7 +975,7 @@ static void so_detach(Scsi_Device * SDp) int max_p; int start; - TRACE(TRACE_OSDSO, "so_detach()\n"); + iscsi_trace(TRACE_OSDSO, "so_detach()\n"); for (dpnt = rscsi_osds, i = 0; i < so_template.dev_max; i++, dpnt++) if (dpnt->device == SDp) { @@ -1008,7 +1008,7 @@ static void so_detach(Scsi_Device * SDp) static int __init init_so(void) { - TRACE(TRACE_OSDSO, "init_so()\n"); + iscsi_trace(TRACE_OSDSO, "init_so()\n"); so_template.module = THIS_MODULE; return scsi_register_module(MODULE_SCSI_DEV, &so_template); } @@ -1019,7 +1019,7 @@ static void __exit exit_so(void) struct gendisk *sogd; int removed = 0; - TRACE(TRACE_OSDSO, "exit_so()\n"); + iscsi_trace(TRACE_OSDSO, "exit_so()\n"); scsi_unregister_module(MODULE_SCSI_DEV, &so_template); diff --git a/dist/iscsi/src/storage.c b/dist/iscsi/src/storage.c index 9b88adaeddec..049a98843df0 100644 --- a/dist/iscsi/src/storage.c +++ b/dist/iscsi/src/storage.c @@ -1,4 +1,4 @@ -/* $NetBSD: storage.c,v 1.2 2006/02/16 19:19:38 agc Exp $ */ +/* $NetBSD: storage.c,v 1.3 2006/03/12 18:47:28 agc Exp $ */ /* * Copyright © 2006 Alistair Crooks. All rights reserved. @@ -370,7 +370,7 @@ read_conf_file(const char *cf, targv_t *tvp, devv_t *dvp, extv_t *evp) (void) fprintf(stderr, "Error: can't open `%s'\n", cf); return 0; } - PRINT("Reading configuration from `%s'\n", cf); + printf("Reading configuration from `%s'\n", cf); (void) memset(&e, 0x0, sizeof(e)); while (conffile_getent(&conf, &e)) { if (strncmp(e.sv.v[0], "extent", 6) == 0) { diff --git a/dist/iscsi/src/target.c b/dist/iscsi/src/target.c index 0532d94a3395..94766bb6800c 100644 --- a/dist/iscsi/src/target.c +++ b/dist/iscsi/src/target.c @@ -106,7 +106,7 @@ reject_t(target_session_t * sess, uint8_t *header, uint8_t reason) iscsi_reject_t reject; uint8_t rsp_header[ISCSI_HEADER_LEN]; - TRACE_ERROR("reject %x\n", reason); + iscsi_trace_error("reject %x\n", reason); reject.reason = reason; reject.length = ISCSI_HEADER_LEN; reject.StatSN = ++(sess->StatSN); @@ -115,12 +115,12 @@ reject_t(target_session_t * sess, uint8_t *header, uint8_t reason) reject.DataSN = 0; /* SNACK not yet implemented */ if (iscsi_reject_encap(rsp_header, &reject) != 0) { - TRACE_ERROR("iscsi_reject_encap() failed\n"); + iscsi_trace_error("iscsi_reject_encap() failed\n"); return -1; } if (iscsi_sock_send_header_and_data(sess->sock, rsp_header, ISCSI_HEADER_LEN, header, ISCSI_HEADER_LEN, 0) != 2 * ISCSI_HEADER_LEN) { - TRACE_ERROR("iscsi_sock_send_header_and_data() failed\n"); + iscsi_trace_error("iscsi_sock_send_header_and_data() failed\n"); return -1; } return 0; @@ -138,16 +138,16 @@ scsi_command_t(target_session_t * sess, uint8_t *header) (void) memset(&scsi_cmd, 0x0, sizeof(scsi_cmd)); if (iscsi_scsi_cmd_decap(header, &scsi_cmd) != 0) { - TRACE_ERROR("iscsi_scsi_cmd_decap() failed\n"); + iscsi_trace_error("iscsi_scsi_cmd_decap() failed\n"); return -1; } - TRACE(TRACE_ISCSI_DEBUG, "session %i: SCSI Command (CmdSN %u, op 0x%x)\n", sess->id, scsi_cmd.CmdSN, scsi_cmd.cdb[0]); + iscsi_trace(TRACE_ISCSI_DEBUG, "session %i: SCSI Command (CmdSN %u, op 0x%x)\n", sess->id, scsi_cmd.CmdSN, scsi_cmd.cdb[0]); /* For Non-immediate commands, the CmdSN should be between ExpCmdSN */ /* and MaxCmdSN, inclusive of both. Otherwise, ignore the command */ if ((!scsi_cmd.immediate) && ((scsi_cmd.CmdSN < sess->ExpCmdSN) || (scsi_cmd.CmdSN > sess->MaxCmdSN))) { - TRACE_ERROR("CmdSN(%d) of SCSI Command not valid, ExpCmdSN(%d) MaxCmdSN(%d). Ignoring the command\n", scsi_cmd.CmdSN, sess->ExpCmdSN, sess->MaxCmdSN); + iscsi_trace_error("CmdSN(%d) of SCSI Command not valid, ExpCmdSN(%d) MaxCmdSN(%d). Ignoring the command\n", scsi_cmd.CmdSN, sess->ExpCmdSN, sess->MaxCmdSN); return 0; } /* Arg check. */ @@ -160,14 +160,14 @@ scsi_command_t(target_session_t * sess, uint8_t *header) /* Check Numbering */ if (scsi_cmd.CmdSN != sess->ExpCmdSN) { - TRACE_WARNING("Expected CmdSN %i, got %i. (ignoring and resetting expectations)\n", + iscsi_trace_warning("Expected CmdSN %i, got %i. (ignoring and resetting expectations)\n", sess->ExpCmdSN, scsi_cmd.CmdSN); sess->ExpCmdSN = scsi_cmd.CmdSN; } /* Check Transfer Lengths */ if (sess->sess_params.first_burst_length && (scsi_cmd.length > sess->sess_params.first_burst_length)) { - TRACE_ERROR("scsi_cmd.length (%u) > FirstBurstLength (%u)\n", + iscsi_trace_error("scsi_cmd.length (%u) > FirstBurstLength (%u)\n", scsi_cmd.length, sess->sess_params.first_burst_length); scsi_cmd.status = 0x02; scsi_cmd.length = 0; @@ -175,7 +175,7 @@ scsi_command_t(target_session_t * sess, uint8_t *header) } if (sess->sess_params.max_data_seg_length && (scsi_cmd.length > sess->sess_params.max_data_seg_length)) { - TRACE_ERROR("scsi_cmd.length (%u) > MaxRecvDataSegmentLength (%u)\n", + iscsi_trace_error("scsi_cmd.length (%u) > MaxRecvDataSegmentLength (%u)\n", scsi_cmd.length, sess->sess_params.max_data_seg_length); return -1; } @@ -196,40 +196,40 @@ scsi_command_t(target_session_t * sess, uint8_t *header) uint8_t ahs_type; scsi_cmd.ahs = NULL; - TRACE(TRACE_ISCSI_DEBUG, "reading %i bytes AHS\n", scsi_cmd.ahs_len); + iscsi_trace(TRACE_ISCSI_DEBUG, "reading %i bytes AHS\n", scsi_cmd.ahs_len); if ((scsi_cmd.ahs = iscsi_malloc_atomic((unsigned)scsi_cmd.ahs_len)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } #define AHS_CLEANUP { if(scsi_cmd.ahs != NULL) iscsi_free_atomic(scsi_cmd.ahs);} if (iscsi_sock_msg(sess->sock, 0, (unsigned)scsi_cmd.ahs_len, scsi_cmd.ahs, 0) != scsi_cmd.ahs_len) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); AHS_CLEANUP; return -1; } - TRACE(TRACE_ISCSI_DEBUG, "read %i bytes AHS\n", scsi_cmd.ahs_len); + iscsi_trace(TRACE_ISCSI_DEBUG, "read %i bytes AHS\n", scsi_cmd.ahs_len); for (ahs_ptr = scsi_cmd.ahs; ahs_ptr < (scsi_cmd.ahs + scsi_cmd.ahs_len - 1) ; ahs_ptr += ahs_len) { ahs_len = ISCSI_NTOHS(*((uint16_t *) (void *)ahs_ptr)); RETURN_EQUAL("AHS Length", ahs_len, 0, AHS_CLEANUP, -1); switch (ahs_type = *(ahs_ptr + 2)) { case 0x01: - TRACE(TRACE_ISCSI_DEBUG, "Got ExtendedCDB AHS (%u bytes extra CDB)\n", ahs_len - 1); + iscsi_trace(TRACE_ISCSI_DEBUG, "Got ExtendedCDB AHS (%u bytes extra CDB)\n", ahs_len - 1); scsi_cmd.ext_cdb = ahs_ptr + 4; break; case 0x02: scsi_cmd.bidi_trans_len = ISCSI_NTOHL(*((uint32_t *) (void *) (ahs_ptr + 4))); *((uint32_t *) (void *) (ahs_ptr + 4)) = scsi_cmd.bidi_trans_len; - TRACE(TRACE_ISCSI_DEBUG, "Got Bidirectional Read AHS (expected read length %u)\n", scsi_cmd.bidi_trans_len); + iscsi_trace(TRACE_ISCSI_DEBUG, "Got Bidirectional Read AHS (expected read length %u)\n", scsi_cmd.bidi_trans_len); break; default: - TRACE_ERROR("unknown AHS type %x\n", ahs_type); + iscsi_trace_error("unknown AHS type %x\n", ahs_type); AHS_CLEANUP return -1; } } - TRACE(TRACE_ISCSI_DEBUG, "done parsing %i bytes AHS\n", scsi_cmd.ahs_len); + iscsi_trace(TRACE_ISCSI_DEBUG, "done parsing %i bytes AHS\n", scsi_cmd.ahs_len); } else { - TRACE(TRACE_ISCSI_DEBUG, "no AHS to read\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "no AHS to read\n"); scsi_cmd.ahs = NULL; } @@ -248,7 +248,7 @@ scsi_command_t(target_session_t * sess, uint8_t *header) cmd.scsi_cmd = &scsi_cmd; cmd.callback = NULL; if (device_command(sess, &cmd) != 0) { - TRACE_ERROR("device_command() failed\n"); + iscsi_trace_error("device_command() failed\n"); AHS_CLEANUP; return -1; } @@ -264,12 +264,12 @@ scsi_command_t(target_session_t * sess, uint8_t *header) int offset_inc; #define SG_CLEANUP {if (fragment_flag) iscsi_free_atomic(sg_new);} if (scsi_cmd.output) { - TRACE(TRACE_ISCSI_DEBUG, "sending %u bytes bi-directional input data\n", scsi_cmd.bidi_trans_len); + iscsi_trace(TRACE_ISCSI_DEBUG, "sending %u bytes bi-directional input data\n", scsi_cmd.bidi_trans_len); trans_len = scsi_cmd.bidi_trans_len; } else { trans_len = scsi_cmd.trans_len; } - TRACE(TRACE_ISCSI_DEBUG, "sending %i bytes input data as separate PDUs\n", trans_len); + iscsi_trace(TRACE_ISCSI_DEBUG, "sending %i bytes input data as separate PDUs\n", trans_len); if (scsi_cmd.send_sg_len) { sg_orig = (struct iovec *) (void *) scsi_cmd.send_data; @@ -292,7 +292,7 @@ scsi_command_t(target_session_t * sess, uint8_t *header) if (data.length != trans_len) { if (!fragment_flag) { if ((sg_new = iscsi_malloc_atomic(sizeof(struct iovec) * sg_len_orig)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); AHS_CLEANUP; return -1; } @@ -302,13 +302,13 @@ scsi_command_t(target_session_t * sess, uint8_t *header) sg_len = sg_len_orig; (void) memcpy(sg, sg_orig, sizeof(struct iovec) * sg_len_orig); if (modify_iov(&sg, &sg_len, offset, data.length) != 0) { - TRACE_ERROR("modify_iov() failed\n"); + iscsi_trace_error("modify_iov() failed\n"); SG_CLEANUP; AHS_CLEANUP; return -1; } } - TRACE(TRACE_ISCSI_DEBUG, "sending read data PDU (offset %u, len %u)\n", offset, data.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "sending read data PDU (offset %u, len %u)\n", offset, data.length); if (offset + data.length == trans_len) { data.final = 1; @@ -316,12 +316,12 @@ scsi_command_t(target_session_t * sess, uint8_t *header) data.status = 1; data.status = scsi_cmd.status; data.StatSN = ++(sess->StatSN); - TRACE(TRACE_ISCSI_DEBUG, "status 0x%x collapsed into last data PDU\n", data.status); + iscsi_trace(TRACE_ISCSI_DEBUG, "status 0x%x collapsed into last data PDU\n", data.status); } else { - TRACE(TRACE_ISCSI_DEBUG, "NOT collapsing status with last data PDU\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "NOT collapsing status with last data PDU\n"); } } else if (offset + data.length > trans_len) { - TRACE_ERROR("offset+data.length > trans_len??\n"); + iscsi_trace_error("offset+data.length > trans_len??\n"); SG_CLEANUP; AHS_CLEANUP; return -1; @@ -332,23 +332,23 @@ scsi_command_t(target_session_t * sess, uint8_t *header) data.DataSN = DataSN++; data.offset = offset; if (iscsi_read_data_encap(rsp_header, &data) != 0) { - TRACE_ERROR("iscsi_read_data_encap() failed\n"); + iscsi_trace_error("iscsi_read_data_encap() failed\n"); SG_CLEANUP; AHS_CLEANUP; return -1; } if (iscsi_sock_send_header_and_data(sess->sock, rsp_header, ISCSI_HEADER_LEN, sg, data.length, sg_len) != ISCSI_HEADER_LEN + data.length) { - TRACE_ERROR("iscsi_sock_send_header_and_data() failed\n"); + iscsi_trace_error("iscsi_sock_send_header_and_data() failed\n"); SG_CLEANUP; AHS_CLEANUP; return -1; } scsi_cmd.bytes_sent += data.length; - TRACE(TRACE_ISCSI_DEBUG, "sent read data PDU ok (offset %u, len %u)\n", data.offset, data.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "sent read data PDU ok (offset %u, len %u)\n", data.offset, data.length); } SG_CLEANUP; - TRACE(TRACE_ISCSI_DEBUG, "successfully sent %i bytes read data\n", trans_len); + iscsi_trace(TRACE_ISCSI_DEBUG, "successfully sent %i bytes read data\n", trans_len); } /* * Send a response PDU if @@ -359,7 +359,7 @@ scsi_command_t(target_session_t * sess, uint8_t *header) */ response: if (!sess->UsePhaseCollapsedRead || !scsi_cmd.length || scsi_cmd.status) { - TRACE(TRACE_ISCSI_DEBUG, "sending SCSI response PDU\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "sending SCSI response PDU\n"); (void) memset(&scsi_rsp, 0x0, sizeof(scsi_rsp)); scsi_rsp.length = scsi_cmd.status ? scsi_cmd.length : 0; scsi_rsp.tag = scsi_cmd.tag; @@ -374,14 +374,14 @@ response: scsi_rsp.response = 0x00; /* iSCSI response */ scsi_rsp.status = scsi_cmd.status; /* SCSI status */ if (iscsi_scsi_rsp_encap(rsp_header, &scsi_rsp) != 0) { - TRACE_ERROR("iscsi_scsi_rsp_encap() failed\n"); + iscsi_trace_error("iscsi_scsi_rsp_encap() failed\n"); AHS_CLEANUP; return -1; } if (iscsi_sock_send_header_and_data(sess->sock, rsp_header, ISCSI_HEADER_LEN, scsi_cmd.send_data, scsi_rsp.length, scsi_cmd.send_sg_len) != ISCSI_HEADER_LEN + scsi_rsp.length) { - TRACE_ERROR("iscsi_sock_send_header_and_data() failed\n"); + iscsi_trace_error("iscsi_sock_send_header_and_data() failed\n"); AHS_CLEANUP; return -1; } @@ -401,9 +401,9 @@ response: /* Device callback after command has completed */ if (cmd.callback) { - TRACE(TRACE_ISCSI_DEBUG, "issuing device callback\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "issuing device callback\n"); if ((*cmd.callback)(cmd.callback_arg) != 0) { - TRACE_ERROR("device callback failed\n"); + iscsi_trace_error("device callback failed\n"); AHS_CLEANUP; return -1; } @@ -422,11 +422,11 @@ task_command_t(target_session_t * sess, uint8_t *header) /* Get & check args */ if (iscsi_task_cmd_decap(header, &cmd) != 0) { - TRACE_ERROR("iscsi_task_cmd_decap() failed\n"); + iscsi_trace_error("iscsi_task_cmd_decap() failed\n"); return -1; } if (cmd.CmdSN != sess->ExpCmdSN) { - TRACE_WARNING("Expected CmdSN %i, got %i. (ignoring and resetting expectations)\n", + iscsi_trace_warning("Expected CmdSN %i, got %i. (ignoring and resetting expectations)\n", cmd.CmdSN, sess->ExpCmdSN); sess->ExpCmdSN = cmd.CmdSN; } @@ -437,31 +437,31 @@ task_command_t(target_session_t * sess, uint8_t *header) switch (cmd.function) { case ISCSI_TASK_CMD_ABORT_TASK: - PRINT("ISCSI_TASK_CMD_ABORT_TASK\n"); + printf("ISCSI_TASK_CMD_ABORT_TASK\n"); break; case ISCSI_TASK_CMD_ABORT_TASK_SET: - PRINT("ISCSI_TASK_CMD_ABORT_TASK_SET\n"); + printf("ISCSI_TASK_CMD_ABORT_TASK_SET\n"); break; case ISCSI_TASK_CMD_CLEAR_ACA: - PRINT("ISCSI_TASK_CMD_CLEAR_ACA\n"); + printf("ISCSI_TASK_CMD_CLEAR_ACA\n"); break; case ISCSI_TASK_CMD_CLEAR_TASK_SET: - PRINT("ISCSI_TASK_CMD_CLEAR_TASK_SET\n"); + printf("ISCSI_TASK_CMD_CLEAR_TASK_SET\n"); break; case ISCSI_TASK_CMD_LOGICAL_UNIT_RESET: - PRINT("ISCSI_TASK_CMD_LOGICAL_UNIT_RESET\n"); + printf("ISCSI_TASK_CMD_LOGICAL_UNIT_RESET\n"); break; case ISCSI_TASK_CMD_TARGET_WARM_RESET: - PRINT("ISCSI_TASK_CMD_TARGET_WARM_RESET\n"); + printf("ISCSI_TASK_CMD_TARGET_WARM_RESET\n"); break; case ISCSI_TASK_CMD_TARGET_COLD_RESET: - PRINT("ISCSI_TASK_CMD_TARGET_COLD_RESET\n"); + printf("ISCSI_TASK_CMD_TARGET_COLD_RESET\n"); break; case ISCSI_TASK_CMD_TARGET_REASSIGN: - PRINT("ISCSI_TASK_CMD_TARGET_REASSIGN\n"); + printf("ISCSI_TASK_CMD_TARGET_REASSIGN\n"); break; default: - TRACE_ERROR("Unknown task function %i\n", cmd.function); + iscsi_trace_error("Unknown task function %i\n", cmd.function); rsp.response = ISCSI_TASK_RSP_REJECTED; } @@ -471,11 +471,11 @@ task_command_t(target_session_t * sess, uint8_t *header) rsp.MaxCmdSN = sess->MaxCmdSN; if (iscsi_task_rsp_encap(rsp_header, &rsp) != 0) { - TRACE_ERROR("iscsi_task_cmd_decap() failed\n"); + iscsi_trace_error("iscsi_task_cmd_decap() failed\n"); return -1; } if (iscsi_sock_msg(sess->sock, 1, ISCSI_HEADER_LEN, rsp_header, 0) != ISCSI_HEADER_LEN) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); return -1; } @@ -489,11 +489,11 @@ nop_out_t(target_session_t * sess, uint8_t *header) char *ping_data = NULL; if (iscsi_nop_out_decap(header, &nop_out) != 0) { - TRACE_ERROR("iscsi_nop_out_decap() failed\n"); + iscsi_trace_error("iscsi_nop_out_decap() failed\n"); return -1; } if (nop_out.CmdSN != sess->ExpCmdSN) { - TRACE_WARNING("Expected CmdSN %i, got %i. (ignoring and resetting expectations)\n", + iscsi_trace_warning("Expected CmdSN %i, got %i. (ignoring and resetting expectations)\n", nop_out.CmdSN, sess->ExpCmdSN); sess->ExpCmdSN = nop_out.CmdSN; } @@ -502,26 +502,26 @@ nop_out_t(target_session_t * sess, uint8_t *header) /* sess->MaxCmdSN++; */ if (nop_out.length) { - TRACE(TRACE_ISCSI_DEBUG, "reading %i bytes ping data\n", nop_out.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "reading %i bytes ping data\n", nop_out.length); if ((ping_data = iscsi_malloc(nop_out.length)) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); return -1; } if (iscsi_sock_msg(sess->sock, 0, nop_out.length, ping_data, 0) != nop_out.length) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); if (ping_data) { iscsi_free(ping_data); } return -1; } - TRACE(TRACE_ISCSI_DEBUG, "successfully read %i bytes ping data:\n", nop_out.length); - PRINT_BUFF(ping_data, nop_out.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "successfully read %i bytes ping data:\n", nop_out.length); + iscsi_print_buffer(ping_data, nop_out.length); } if (nop_out.tag != 0xffffffff) { iscsi_nop_in_args_t nop_in; uint8_t rsp_header[ISCSI_HEADER_LEN]; - TRACE(TRACE_ISCSI_DEBUG, "sending %i bytes ping response\n", nop_out.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "sending %i bytes ping response\n", nop_out.length); (void) memset(&nop_in, 0x0, sizeof(&nop_in)); nop_in.length = nop_out.length; nop_in.lun = nop_out.lun; @@ -532,7 +532,7 @@ nop_out_t(target_session_t * sess, uint8_t *header) nop_in.MaxCmdSN = sess->MaxCmdSN; if (iscsi_nop_in_encap(rsp_header, &nop_in) != 0) { - TRACE_ERROR("iscsi_nop_in_encap() failed\n"); + iscsi_trace_error("iscsi_nop_in_encap() failed\n"); if (ping_data) { iscsi_free(ping_data); } @@ -540,13 +540,13 @@ nop_out_t(target_session_t * sess, uint8_t *header) } if (iscsi_sock_send_header_and_data(sess->sock, rsp_header, ISCSI_HEADER_LEN, ping_data, nop_in.length, 0) != ISCSI_HEADER_LEN + nop_in.length) { - TRACE_ERROR("iscsi_sock_send_header_and_data() failed\n"); + iscsi_trace_error("iscsi_sock_send_header_and_data() failed\n"); if (ping_data) { iscsi_free(ping_data); } return -1; } - TRACE(TRACE_ISCSI_DEBUG, "successfully sent %i bytes ping response\n", nop_out.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "successfully sent %i bytes ping response\n", nop_out.length); } if (ping_data) { iscsi_free(ping_data); @@ -576,7 +576,7 @@ text_command_t(target_session_t * sess, uint8_t *header) /* Get text args */ if (iscsi_text_cmd_decap(header, &text_cmd) != 0) { - TRACE_ERROR("iscsi_text_cmd_decap() failed\n"); + iscsi_trace_error("iscsi_text_cmd_decap() failed\n"); return -1; } /* Check args & update numbering */ @@ -587,7 +587,7 @@ text_command_t(target_session_t * sess, uint8_t *header) sess->MaxCmdSN++; if ((text_out = iscsi_malloc_atomic(2048)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } /* Read text parameters */ @@ -596,13 +596,13 @@ text_command_t(target_session_t * sess, uint8_t *header) iscsi_parameter_t *ptr; if ((text_in = iscsi_malloc_atomic(len_in + 1)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); TC_CLEANUP; return -1; } - TRACE(TRACE_ISCSI_DEBUG, "reading %i bytes text parameters\n", len_in); + iscsi_trace(TRACE_ISCSI_DEBUG, "reading %i bytes text parameters\n", len_in); if (iscsi_sock_msg(sess->sock, 0, len_in, text_in, 0) != len_in) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); TC_CLEANUP; return -1; } @@ -615,13 +615,13 @@ text_command_t(target_session_t * sess, uint8_t *header) */ if ((ptr = param_get(sess->params, "SendTargets")) == NULL) { - TRACE_ERROR("param_get() failed\n"); + iscsi_trace_error("param_get() failed\n"); TC_CLEANUP; return -1; } if (ptr->rx_offer) { if (ptr->offer_rx && strcmp(ptr->offer_rx, "All") == 0 && !param_equiv(sess->params, "SessionType", "Discovery")) { - TRACE(TRACE_ISCSI_DEBUG, "Rejecting SendTargets=All in a non Discovery session\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "Rejecting SendTargets=All in a non Discovery session\n"); PARAM_TEXT_ADD(sess->params, "SendTargets", "Reject", text_out, &len_out, 2048, 0, TC_ERROR); } else { for (i = 0 ; i < sess->globals->tv->c ; i++) { @@ -660,18 +660,18 @@ text_command_t(target_session_t * sess, uint8_t *header) text_rsp.ExpCmdSN = sess->ExpCmdSN; text_rsp.MaxCmdSN = sess->MaxCmdSN; if (iscsi_text_rsp_encap(rsp_header, &text_rsp) != 0) { - TRACE_ERROR("iscsi_text_rsp_encap() failed\n"); + iscsi_trace_error("iscsi_text_rsp_encap() failed\n"); TC_CLEANUP; return -1; } if (iscsi_sock_msg(sess->sock, 1, ISCSI_HEADER_LEN, rsp_header, 0) != ISCSI_HEADER_LEN) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); TC_CLEANUP; return -1; } if (len_out) { if (iscsi_sock_msg(sess->sock, 1, (unsigned) len_out, text_out, 0) != len_out) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); TC_CLEANUP; return -1; } @@ -710,47 +710,47 @@ login_command_t(target_session_t * sess, uint8_t *header) /* Get login args & check preconditions */ if (iscsi_login_cmd_decap(header, &cmd) != 0) { - TRACE_ERROR("iscsi_login_cmd_decap() failed\n"); + iscsi_trace_error("iscsi_login_cmd_decap() failed\n"); goto response; } if (sess->IsLoggedIn) { - TRACE_ERROR("duplicate login attempt on sess %i\n", sess->id); + iscsi_trace_error("duplicate login attempt on sess %i\n", sess->id); goto response; } if ((cmd.cont != 0) && (cmd.transit != 0)) { - TRACE_ERROR("Bad cmd.continue. Expected 0.\n"); + iscsi_trace_error("Bad cmd.continue. Expected 0.\n"); goto response; } else if ((cmd.version_max < ISCSI_VERSION) || (cmd.version_min > ISCSI_VERSION)) { - TRACE_ERROR("Target iscsi version (%u) not supported by initiator [Max Ver (%u) and Min Ver (%u)]\n", ISCSI_VERSION, cmd.version_max, cmd.version_min); + iscsi_trace_error("Target iscsi version (%u) not supported by initiator [Max Ver (%u) and Min Ver (%u)]\n", ISCSI_VERSION, cmd.version_max, cmd.version_min); rsp.status_class = ISCSI_LOGIN_STATUS_INITIATOR_ERROR; rsp.status_detail = 0x05; /* Version not supported */ rsp.version_max = ISCSI_VERSION; rsp.version_active = ISCSI_VERSION; goto response; } else if (cmd.tsih != 0) { - TRACE_ERROR("Bad cmd.tsih (%u). Expected 0.\n", cmd.tsih); + iscsi_trace_error("Bad cmd.tsih (%u). Expected 0.\n", cmd.tsih); goto response; } /* Parse text parameters and build response */ if ((text_out = iscsi_malloc_atomic(2048)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } if ((len_in = cmd.length) != 0) { - TRACE(TRACE_ISCSI_DEBUG, "reading %i bytes text data\n", len_in); + iscsi_trace(TRACE_ISCSI_DEBUG, "reading %i bytes text data\n", len_in); if ((text_in = iscsi_malloc_atomic((unsigned)(len_in + 1))) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); LC_CLEANUP; return -1; } if (iscsi_sock_msg(sess->sock, 0, (unsigned) len_in, text_in, 0) != len_in) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); LC_CLEANUP; return -1; } text_in[len_in] = 0x0; - TRACE(TRACE_ISCSI_DEBUG, "successfully read %i bytes text data\n", len_in); + iscsi_trace(TRACE_ISCSI_DEBUG, "successfully read %i bytes text data\n", len_in); /* * Parse incoming parameters (text_out will contain the @@ -812,17 +812,17 @@ login_command_t(target_session_t * sess, uint8_t *header) } if (cmd.transit && cmd.nsg == ISCSI_LOGIN_STAGE_FULL_FEATURE) { - TRACE(TRACE_ISCSI_DEBUG, "transitioning to ISCSI_LOGIN_STAGE_FULL_FEATURE\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "transitioning to ISCSI_LOGIN_STAGE_FULL_FEATURE\n"); /* Check post conditions */ if (param_equiv(sess->params, "InitiatorName", "")) { - TRACE_ERROR("InitiatorName not specified\n"); + iscsi_trace_error("InitiatorName not specified\n"); goto response; } if (param_equiv(sess->params, "SessionType", "Normal")) { if (param_equiv(sess->params, "TargetName", "")) { - TRACE_ERROR("TargetName not specified\n"); + iscsi_trace_error("TargetName not specified\n"); goto response; } for (found = 0, i = 0 ; !found && i < sess->globals->tv->c ; i++) { @@ -833,12 +833,12 @@ login_command_t(target_session_t * sess, uint8_t *header) } } if (!found) { - TRACE_ERROR("Bad TargetName \"%s\"\n", param_val(sess->params, "TargetName")); + iscsi_trace_error("Bad TargetName \"%s\"\n", param_val(sess->params, "TargetName")); goto response; } } if (param_equiv(sess->params, "SessionType", "")) { - TRACE_ERROR("SessionType not specified\n"); + iscsi_trace_error("SessionType not specified\n"); goto response; } sess->ExpCmdSN = sess->MaxCmdSN = cmd.CmdSN; @@ -881,43 +881,43 @@ response: } } if (iscsi_login_rsp_encap(rsp_header, &rsp) != 0) { - TRACE_ERROR("iscsi_login_rsp_encap() failed\n"); + iscsi_trace_error("iscsi_login_rsp_encap() failed\n"); LC_CLEANUP; return -1; } - TRACE(TRACE_ISCSI_DEBUG, "sending login response\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "sending login response\n"); if (iscsi_sock_send_header_and_data(sess->sock, rsp_header, ISCSI_HEADER_LEN, text_out, rsp.length, 0) != ISCSI_HEADER_LEN + rsp.length) { - TRACE_ERROR("iscsi_sock_send_header_and_data() failed\n"); + iscsi_trace_error("iscsi_sock_send_header_and_data() failed\n"); LC_CLEANUP; return -1; } - TRACE(TRACE_ISCSI_DEBUG, "sent login response ok\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "sent login response ok\n"); if (rsp.status_class != 0) { LC_CLEANUP; return -1; } if (cmd.transit && (cmd.nsg == ISCSI_LOGIN_STAGE_FULL_FEATURE)) { - PRINT("**************************************************\n"); - PRINT("* LOGIN SUCCESSFUL *\n"); - TRACE(TRACE_ISCSI_DEBUG, "* %20s:%20u *\n", "CID", sess->cid); - TRACE(TRACE_ISCSI_DEBUG, "* %20s:%20" PRIu64 " *\n", "ISID", sess->isid); - TRACE(TRACE_ISCSI_DEBUG, "* %20s:%20u *\n", "TSIH", sess->tsih); - TRACE(TRACE_ISCSI_DEBUG, "* %20s:%20u *\n", "StatSN", sess->StatSN); - TRACE(TRACE_ISCSI_DEBUG, "* %20s:%20u *\n", "ExpCmdSN", sess->ExpCmdSN); - TRACE(TRACE_ISCSI_DEBUG, "* %20s:%20u *\n", "MaxCmdSN", sess->MaxCmdSN); - PRINT("**************************************************\n"); + printf("**************************************************\n"); + printf("* LOGIN SUCCESSFUL *\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "* %20s:%20u *\n", "CID", sess->cid); + iscsi_trace(TRACE_ISCSI_DEBUG, "* %20s:%20" PRIu64 " *\n", "ISID", sess->isid); + iscsi_trace(TRACE_ISCSI_DEBUG, "* %20s:%20u *\n", "TSIH", sess->tsih); + iscsi_trace(TRACE_ISCSI_DEBUG, "* %20s:%20u *\n", "StatSN", sess->StatSN); + iscsi_trace(TRACE_ISCSI_DEBUG, "* %20s:%20u *\n", "ExpCmdSN", sess->ExpCmdSN); + iscsi_trace(TRACE_ISCSI_DEBUG, "* %20s:%20u *\n", "MaxCmdSN", sess->MaxCmdSN); + printf("**************************************************\n"); /* Buffer for data xfers to/from the scsi device */ if (!param_equiv(sess->params, "MaxRecvDataSegmentLength", "0")) { if ((sess->buff = iscsi_malloc((unsigned)(param_atoi(sess->params, "MaxRecvDataSegmentLength")))) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); LC_CLEANUP; return -1; } } else { - TRACE_ERROR("MaxRecvDataSegmentLength of 0 not supported\n"); + iscsi_trace_error("MaxRecvDataSegmentLength of 0 not supported\n"); LC_CLEANUP; return -1; } @@ -935,7 +935,7 @@ logout_command_t(target_session_t * sess, uint8_t *header) (void) memset(&rsp, 0x0, sizeof(rsp)); if (iscsi_logout_cmd_decap(header, &cmd) != 0) { - TRACE_ERROR("iscsi_logout_cmd_decap() failed\n"); + iscsi_trace_error("iscsi_logout_cmd_decap() failed\n"); return -1; } sess->StatSN = cmd.ExpStatSN; @@ -950,22 +950,22 @@ logout_command_t(target_session_t * sess, uint8_t *header) rsp.ExpCmdSN = ++sess->ExpCmdSN; rsp.MaxCmdSN = sess->MaxCmdSN; if (iscsi_logout_rsp_encap(rsp_header, &rsp) != 0) { - TRACE_ERROR("iscsi_logout_rsp_encap() failed\n"); + iscsi_trace_error("iscsi_logout_rsp_encap() failed\n"); return -1; } if (iscsi_sock_msg(sess->sock, 1, ISCSI_HEADER_LEN, rsp_header, 0) != ISCSI_HEADER_LEN) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); return -1; } - TRACE(TRACE_ISCSI_DEBUG, "sent logout response OK\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "sent logout response OK\n"); - PRINT("**************************************************\n"); - PRINT("* LOGOUT SUCCESSFUL *\n"); - PRINT("* *\n"); - PRINT("* %20s:%20u *\n", "CID", sess->cid); - PRINT("* %20s:%20" PRIu64 " *\n", "ISID", sess->isid); - PRINT("* %20s:%20u *\n", "TSIH", sess->tsih); - PRINT("**************************************************\n"); + printf("**************************************************\n"); + printf("* LOGOUT SUCCESSFUL *\n"); + printf("* *\n"); + printf("* %20s:%20u *\n", "CID", sess->cid); + printf("* %20s:%20" PRIu64 " *\n", "ISID", sess->isid); + printf("* %20s:%20u *\n", "TSIH", sess->tsih); + printf("**************************************************\n"); #ifdef HAVE_SYSLOG_H syslog(LOG_INFO, "< %s logout from %s on %s", param_val(sess->params, "SessionType"), param_val(sess->params, "InitiatorName"), sess->initiator); @@ -986,14 +986,14 @@ verify_cmd_t(target_session_t * sess, uint8_t *header) if ((!sess->LoginStarted) && (op != ISCSI_LOGIN_CMD)) { /* Terminate the connection */ - TRACE_ERROR("session %i: iSCSI op 0x%x attempted before LOGIN PHASE\n", + iscsi_trace_error("session %i: iSCSI op 0x%x attempted before LOGIN PHASE\n", sess->id, op); return -1; } if (!sess->IsFullFeature && ((op != ISCSI_LOGIN_CMD) && (op != ISCSI_LOGOUT_CMD))) { iscsi_login_rsp_args_t rsp; uint8_t rsp_header[ISCSI_HEADER_LEN]; - TRACE_ERROR("session %i: iSCSI op 0x%x attempted before FULL FEATURE\n", + iscsi_trace_error("session %i: iSCSI op 0x%x attempted before FULL FEATURE\n", sess->id, op); /* Create Login Reject response */ (void) memset(&rsp, 0x0, sizeof(rsp)); @@ -1003,17 +1003,17 @@ verify_cmd_t(target_session_t * sess, uint8_t *header) rsp.version_active = ISCSI_VERSION; if (iscsi_login_rsp_encap(rsp_header, &rsp) != 0) { - TRACE_ERROR("iscsi_login_rsp_encap() failed\n"); + iscsi_trace_error("iscsi_login_rsp_encap() failed\n"); return -1; } - TRACE(TRACE_ISCSI_DEBUG, "sending login response\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "sending login response\n"); if (iscsi_sock_send_header_and_data(sess->sock, rsp_header, ISCSI_HEADER_LEN, NULL, 0, 0) != ISCSI_HEADER_LEN + rsp.length) { - TRACE_ERROR("iscsi_sock_send_header_and_data() failed\n"); + iscsi_trace_error("iscsi_sock_send_header_and_data() failed\n"); return -1; } - TRACE(TRACE_ISCSI_DEBUG, "sent login response ok\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "sent login response ok\n"); return -1; } return 0; @@ -1029,57 +1029,57 @@ execute_t(target_session_t * sess, uint8_t *header) } switch (op) { case ISCSI_TASK_CMD: - TRACE(TRACE_ISCSI_CMD, "session %i: Task Command\n", sess->id); + iscsi_trace(TRACE_ISCSI_CMD, "session %i: Task Command\n", sess->id); if (task_command_t(sess, header) != 0) { - TRACE_ERROR("task_command_t() failed\n"); + iscsi_trace_error("task_command_t() failed\n"); return -1; } break; case ISCSI_NOP_OUT: - TRACE(TRACE_ISCSI_CMD, "session %i: NOP-Out\n", sess->id); + iscsi_trace(TRACE_ISCSI_CMD, "session %i: NOP-Out\n", sess->id); if (nop_out_t(sess, header) != 0) { - TRACE_ERROR("nop_out_t() failed\n"); + iscsi_trace_error("nop_out_t() failed\n"); return -1; } break; case ISCSI_LOGIN_CMD: - TRACE(TRACE_ISCSI_CMD, "session %i: Login Command\n", sess->id); + iscsi_trace(TRACE_ISCSI_CMD, "session %i: Login Command\n", sess->id); if (login_command_t(sess, header) != 0) { - TRACE_ERROR("login_command_t() failed\n"); + iscsi_trace_error("login_command_t() failed\n"); return -1; } break; case ISCSI_TEXT_CMD: - TRACE(TRACE_ISCSI_CMD, "session %i: Text Command\n", sess->id); + iscsi_trace(TRACE_ISCSI_CMD, "session %i: Text Command\n", sess->id); if (text_command_t(sess, header) != 0) { - TRACE_ERROR("text_command_t() failed\n"); + iscsi_trace_error("text_command_t() failed\n"); return -1; } break; case ISCSI_LOGOUT_CMD: - TRACE(TRACE_ISCSI_CMD, "session %i: Logout Command\n", sess->id); + iscsi_trace(TRACE_ISCSI_CMD, "session %i: Logout Command\n", sess->id); if (logout_command_t(sess, header) != 0) { - TRACE_ERROR("logout_command_t() failed\n"); + iscsi_trace_error("logout_command_t() failed\n"); return -1; } break; case ISCSI_SCSI_CMD: - TRACE(TRACE_ISCSI_CMD, "session %i: SCSI Command\n", sess->id); + iscsi_trace(TRACE_ISCSI_CMD, "session %i: SCSI Command\n", sess->id); if (scsi_command_t(sess, header) != 0) { - TRACE_ERROR("scsi_command_t() failed\n"); + iscsi_trace_error("scsi_command_t() failed\n"); return -1; } break; default: - TRACE_ERROR("Unknown Opcode 0x%x\n", ISCSI_OPCODE(header)); + iscsi_trace_error("Unknown Opcode 0x%x\n", ISCSI_OPCODE(header)); if (reject_t(sess, header, 0x04) != 0) { - TRACE_ERROR("reject_t() failed\n"); + iscsi_trace_error("reject_t() failed\n"); return -1; } break; @@ -1101,7 +1101,7 @@ worker_proc_t(void *arg) ISCSI_THREAD_START("worker_thread"); sess->worker.pid = ISCSI_GETPID; sess->worker.state |= ISCSI_WORKER_STATE_STARTED; - TRACE(TRACE_ISCSI_DEBUG, "session %i: started\n", sess->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "session %i: started\n", sess->id); /* * ISCSI_PARAM_TYPE_LIST format: @@ -1160,19 +1160,19 @@ worker_proc_t(void *arg) /* Loop for commands */ while (sess->globals->state != TARGET_SHUT_DOWN) { - TRACE(TRACE_ISCSI_DEBUG, "session %i: reading header\n", sess->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "session %i: reading header\n", sess->id); if (iscsi_sock_msg(sess->sock, 0, ISCSI_HEADER_LEN, header, 0) != ISCSI_HEADER_LEN) { - TRACE(TRACE_ISCSI_DEBUG, "session %i: iscsi_sock_msg() failed\n", sess->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "session %i: iscsi_sock_msg() failed\n", sess->id); break; } - TRACE(TRACE_ISCSI_DEBUG, "session %i: iscsi op 0x%x\n", sess->id, ISCSI_OPCODE(header)); + iscsi_trace(TRACE_ISCSI_DEBUG, "session %i: iscsi op 0x%x\n", sess->id, ISCSI_OPCODE(header)); if (execute_t(sess, header) != 0) { - TRACE_ERROR("execute_t() failed\n"); + iscsi_trace_error("execute_t() failed\n"); break; } - TRACE(TRACE_ISCSI_DEBUG, "session %i: iscsi op 0x%x complete\n", sess->id, ISCSI_OPCODE(header)); + iscsi_trace(TRACE_ISCSI_DEBUG, "session %i: iscsi op 0x%x complete\n", sess->id, ISCSI_OPCODE(header)); if (ISCSI_OPCODE(header) == ISCSI_LOGOUT_CMD) { - TRACE(TRACE_ISCSI_DEBUG, "session %i: logout received, ending session\n", sess->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "session %i: logout received, ending session\n", sess->id); break; } } @@ -1181,24 +1181,24 @@ worker_proc_t(void *arg) iscsi_free(sess->buff); if (param_list_destroy(sess->params) != 0) { - TRACE_ERROR("param_list_destroy() failed\n"); + iscsi_trace_error("param_list_destroy() failed\n"); return -1; } /* Terminate connection */ if (iscsi_sock_close(sess->sock) != 0) { - TRACE_ERROR("iscsi_sock_close() failed\n"); + iscsi_trace_error("iscsi_sock_close() failed\n"); } /* Make session available */ ISCSI_LOCK(&g_session_q_mutex, return -1); (void) memset(sess, 0x0, sizeof(*sess)); if (iscsi_queue_insert(&g_session_q, sess) != 0) { - TRACE_ERROR("iscsi_queue_insert() failed\n"); + iscsi_trace_error("iscsi_queue_insert() failed\n"); return -1; } ISCSI_UNLOCK(&g_session_q_mutex, return -1); - TRACE(TRACE_ISCSI_DEBUG, "session %i: ended\n", sess->id); + iscsi_trace(TRACE_ISCSI_DEBUG, "session %i: ended\n", sess->id); return 0; } @@ -1212,11 +1212,11 @@ read_data_pdu(target_session_t * sess, int ret_val = -1; if (iscsi_sock_msg(sess->sock, 0, ISCSI_HEADER_LEN, header, 0) != ISCSI_HEADER_LEN) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); return -1; } if ((ret_val = iscsi_write_data_decap(header, data)) != 0) { - TRACE_ERROR("iscsi_write_data_decap() failed\n"); + iscsi_trace_error("iscsi_write_data_decap() failed\n"); return ret_val; } /* Check args */ @@ -1231,15 +1231,15 @@ read_data_pdu(target_session_t * sess, return -1; } if (data->tag != args->tag) { - TRACE(TRACE_ISCSI_DEBUG, "Data ITT (%d) does not match with command ITT (%d)\n", data->tag, args->tag); + iscsi_trace(TRACE_ISCSI_DEBUG, "Data ITT (%d) does not match with command ITT (%d)\n", data->tag, args->tag); if (data->final) { args->status = 0x02; return -1; } else { /* Send a reject PDU */ - TRACE(TRACE_ISCSI_DEBUG, "Sending Reject PDU\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "Sending Reject PDU\n"); if (reject_t(sess, header, 0x09) != 0) { /* Invalid PDU Field */ - TRACE(TRACE_ISCSI_DEBUG, "Sending Reject PDU failed\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "Sending Reject PDU failed\n"); return 1; } } @@ -1257,14 +1257,14 @@ target_transfer_data(target_session_t * sess, iscsi_scsi_cmd_args_t * args, stru args->bytes_recv = 0; if ((!sess->sess_params.immediate_data) && args->length) { - TRACE(TRACE_ISCSI_DEBUG, "Cannot accept any Immediate data\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "Cannot accept any Immediate data\n"); args->status = 0x02; return -1; } /* Make a copy of the iovec */ if ((iov_ptr = iscsi_malloc_atomic(sizeof(struct iovec) * sg_len)) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } iov = iov_ptr; @@ -1282,17 +1282,17 @@ target_transfer_data(target_session_t * sess, iscsi_scsi_cmd_args_t * args, stru /* Modify iov to include just immediate data */ if (modify_iov(&iov, &iov_len, 0, args->length) != 0) { - TRACE_ERROR("modify_iov() failed\n"); + iscsi_trace_error("modify_iov() failed\n"); TTD_CLEANUP; return -1; } - TRACE(TRACE_SCSI_DATA, "reading %i bytes immediate write data\n", args->length); + iscsi_trace(TRACE_SCSI_DATA, "reading %i bytes immediate write data\n", args->length); if (iscsi_sock_msg(sess->sock, 0, args->length, iov, iov_len) != args->length) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); TTD_CLEANUP; return -1; } - TRACE(TRACE_SCSI_DATA, "successfully read %i bytes immediate write data\n", args->length); + iscsi_trace(TRACE_SCSI_DATA, "successfully read %i bytes immediate write data\n", args->length); args->bytes_recv += args->length; } /* @@ -1321,7 +1321,7 @@ target_transfer_data(target_session_t * sess, iscsi_scsi_cmd_args_t * args, stru desired_xfer_len = MIN((args->trans_len - args->bytes_recv), sess->sess_params.max_burst_length); - TRACE(TRACE_ISCSI_DEBUG, "sending R2T for %u bytes data\n", desired_xfer_len); + iscsi_trace(TRACE_ISCSI_DEBUG, "sending R2T for %u bytes data\n", desired_xfer_len); r2t.tag = args->tag; r2t.transfer_tag = 0x1234; @@ -1332,14 +1332,14 @@ target_transfer_data(target_session_t * sess, iscsi_scsi_cmd_args_t * args, stru r2t.length = desired_xfer_len; r2t.offset = args->bytes_recv; if (iscsi_r2t_encap(header, &r2t) != 0) { - TRACE_ERROR("r2t_encap() failed\n"); + iscsi_trace_error("r2t_encap() failed\n"); TTD_CLEANUP; return -1; } - TRACE(TRACE_ISCSI_DEBUG, "sending R2T tag %u transfer tag %u len %u offset %u\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "sending R2T tag %u transfer tag %u len %u offset %u\n", r2t.tag, r2t.transfer_tag, r2t.length, r2t.offset); if (iscsi_sock_msg(sess->sock, 1, ISCSI_HEADER_LEN, header, 0) != ISCSI_HEADER_LEN) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); TTD_CLEANUP; return -1; } @@ -1348,20 +1348,20 @@ target_transfer_data(target_session_t * sess, iscsi_scsi_cmd_args_t * args, stru } /* Read iSCSI data PDU */ - TRACE(TRACE_ISCSI_DEBUG, "reading data pdu\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "reading data pdu\n"); if ((read_status = read_data_pdu(sess, &data, args)) != 0) { if (read_status == 1) { - TRACE(TRACE_ISCSI_DEBUG, "Unknown PDU received and ignored. Expecting Data PDU\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "Unknown PDU received and ignored. Expecting Data PDU\n"); continue; } else { - TRACE_ERROR("read_data_pdu() failed\n"); + iscsi_trace_error("read_data_pdu() failed\n"); args->status = 0x02; TTD_CLEANUP; return -1; } } WARN_NOT_EQUAL("ExpStatSN", data.ExpStatSN, sess->StatSN); - TRACE(TRACE_ISCSI_DEBUG, "read data pdu OK (offset %u, length %u)\n", data.offset, data.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "read data pdu OK (offset %u, length %u)\n", data.offset, data.length); /* Modify iov with offset and length. */ @@ -1369,34 +1369,34 @@ target_transfer_data(target_session_t * sess, iscsi_scsi_cmd_args_t * args, stru (void) memcpy(iov, sg, sizeof(struct iovec) * sg_len); iov_len = sg_len; if (modify_iov(&iov, &iov_len, data.offset, data.length) != 0) { - TRACE_ERROR("modify_iov() failed\n"); + iscsi_trace_error("modify_iov() failed\n"); TTD_CLEANUP; return -1; } /* Scatter into destination buffers */ if (iscsi_sock_msg(sess->sock, 0, data.length, iov, iov_len) != data.length) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); TTD_CLEANUP; return -1; } - TRACE(TRACE_ISCSI_DEBUG, "successfully scattered %u bytes\n", data.length); + iscsi_trace(TRACE_ISCSI_DEBUG, "successfully scattered %u bytes\n", data.length); args->bytes_recv += data.length; desired_xfer_len -= data.length; if ((!r2t_flag) && (args->bytes_recv > sess->sess_params.first_burst_length)) { - TRACE_ERROR("Received unsolicited data (%d) more than first_burst_length (%d)\n", args->bytes_recv, sess->sess_params.first_burst_length); + iscsi_trace_error("Received unsolicited data (%d) more than first_burst_length (%d)\n", args->bytes_recv, sess->sess_params.first_burst_length); args->status = 0x02; TTD_CLEANUP; return -1; } if ((desired_xfer_len != 0) && data.final) { - TRACE_ERROR("Expecting more data (%d) from initiator for this sequence\n", desired_xfer_len); + iscsi_trace_error("Expecting more data (%d) from initiator for this sequence\n", desired_xfer_len); args->status = 0x02; TTD_CLEANUP; return -1; } if ((desired_xfer_len == 0) && !data.final) { - TRACE_ERROR("Final bit not set on the last data PDU of this sequence\n"); + iscsi_trace_error("Final bit not set on the last data PDU of this sequence\n"); args->status = 0x02; TTD_CLEANUP; return -1; @@ -1408,7 +1408,7 @@ target_transfer_data(target_session_t * sess, iscsi_scsi_cmd_args_t * args, stru } else { RETURN_NOT_EQUAL("Final bit", args->final, 1, TTD_CLEANUP, -1); } - TRACE(TRACE_ISCSI_DEBUG, "successfully transferred %u bytes write data\n", args->trans_len); + iscsi_trace(TRACE_ISCSI_DEBUG, "successfully transferred %u bytes write data\n", args->trans_len); TTD_CLEANUP; return 0; } @@ -1427,25 +1427,25 @@ target_init(globals_t *gp, targv_t *tv, char *TargetName) (void) strlcpy(gp->targetname, TargetName, sizeof(gp->targetname)); if (gp->state == TARGET_INITIALIZING || gp->state == TARGET_INITIALIZED) { - TRACE_ERROR("duplicate target initialization attempted\n"); + iscsi_trace_error("duplicate target initialization attempted\n"); return -1; } gp->state = TARGET_INITIALIZING; if (iscsi_queue_init(&g_session_q, DEFAULT_TARGET_MAX_SESSIONS) != 0) { - TRACE_ERROR("iscsi_queue_init() failed\n"); + iscsi_trace_error("iscsi_queue_init() failed\n"); return -1; } gp->tv = tv; for (i = 0; i < DEFAULT_TARGET_MAX_SESSIONS; i++) { g_session[i].id = i; if (iscsi_queue_insert(&g_session_q, &g_session[i]) != 0) { - TRACE_ERROR("iscsi_queue_insert() failed\n"); + iscsi_trace_error("iscsi_queue_insert() failed\n"); return -1; } } for (i = 0 ; i < tv->c ; i++) { if ((g_session[i].d = device_init(gp, tv, &tv->v[i])) < 0) { - TRACE_ERROR("device_init() failed\n"); + iscsi_trace_error("device_init() failed\n"); return -1; } } @@ -1454,7 +1454,7 @@ target_init(globals_t *gp, targv_t *tv, char *TargetName) gp->listener_pid = -1; gp->state = TARGET_INITIALIZED; - PRINT("TARGET: TargetName is %s, via Address Family %s on port %d\n", + printf("TARGET: TargetName is %s, via Address Family %s on port %d\n", gp->targetname, (gp->address_family == ISCSI_IPv4) ? "IPv4" : (gp->address_family == ISCSI_IPv6) ? "IPv6" : "unknown", @@ -1470,54 +1470,54 @@ target_shutdown(globals_t *gp) int i; if ((gp->state == TARGET_SHUTTING_DOWN) || (gp->state == TARGET_SHUT_DOWN)) { - TRACE_ERROR("duplicate target shutdown attempted\n"); + iscsi_trace_error("duplicate target shutdown attempted\n"); return -1; } gp->state = TARGET_SHUTTING_DOWN; - TRACE(TRACE_ISCSI_DEBUG, "shutting down target\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "shutting down target\n"); for (i = 0; i < DEFAULT_TARGET_MAX_SESSIONS; i++) { sess = &g_session[i]; /* Need to replace with a call to session_destroy() */ if (sess->IsLoggedIn) { - PRINT("shutting down socket on sess %i\n", i); - TRACE(TRACE_ISCSI_DEBUG, "shutting down socket on sess %i\n", i); + printf("shutting down socket on sess %i\n", i); + iscsi_trace(TRACE_ISCSI_DEBUG, "shutting down socket on sess %i\n", i); if (iscsi_sock_shutdown(sess->sock, 2) != 0) { - TRACE_ERROR("iscsi_sock_shutdown() failed\n"); + iscsi_trace_error("iscsi_sock_shutdown() failed\n"); return -1; } - PRINT("waiting for worker %i (pid %i, state %i)\n", i, sess->worker.pid, sess->worker.state); - TRACE(TRACE_ISCSI_DEBUG, "waiting for worker %i (pid %i, state %i)\n", + printf("waiting for worker %i (pid %i, state %i)\n", i, sess->worker.pid, sess->worker.state); + iscsi_trace(TRACE_ISCSI_DEBUG, "waiting for worker %i (pid %i, state %i)\n", i, sess->worker.pid, sess->worker.state); while (sess->worker.state & ISCSI_WORKER_STATE_STARTED) { ISCSI_SPIN; } - TRACE(TRACE_ISCSI_DEBUG, "worker %i has exited\n", i); + iscsi_trace(TRACE_ISCSI_DEBUG, "worker %i has exited\n", i); } if (device_shutdown(sess) != 0) { - TRACE_ERROR("device_shutdown() failed\n"); + iscsi_trace_error("device_shutdown() failed\n"); return -1; } } - TRACE(TRACE_ISCSI_DEBUG, "shutting down accept socket\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "shutting down accept socket\n"); if (iscsi_sock_shutdown(gp->sock, 2) != 0) { - TRACE_ERROR("iscsi_sock_shutdown() failed\n"); + iscsi_trace_error("iscsi_sock_shutdown() failed\n"); return -1; } if (gp->listener_pid != ISCSI_GETPID) { - TRACE(TRACE_ISCSI_DEBUG, "waiting for listener thread\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "waiting for listener thread\n"); while (gp->listener_listening) ISCSI_SPIN; - TRACE(TRACE_ISCSI_DEBUG, "listener thread has exited\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "listener thread has exited\n"); } - TRACE(TRACE_ISCSI_DEBUG, "closing accept socket\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "closing accept socket\n"); if (iscsi_sock_close(gp->sock) != 0) { - TRACE_ERROR("iscsi_sock_close() failed\n"); + iscsi_trace_error("iscsi_sock_close() failed\n"); return -1; } ISCSI_MUTEX_DESTROY(&g_session_q_mutex, return -1); - TRACE(TRACE_ISCSI_DEBUG, "target shutdown complete\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "target shutdown complete\n"); gp->state = TARGET_SHUT_DOWN; return 0; @@ -1538,38 +1538,38 @@ target_listen(globals_t *gp) ISCSI_THREAD_START("listen_thread"); gp->listener_pid = ISCSI_GETPID; gp->listener_listening++; - TRACE(TRACE_ISCSI_DEBUG, "listener thread started\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "listener thread started\n"); /* Create/Bind/Listen */ if (iscsi_sock_create(&gp->sock) < 0) { - TRACE_ERROR("iscsi_sock_create() failed\n"); + iscsi_trace_error("iscsi_sock_create() failed\n"); goto done; } if (iscsi_sock_setsockopt(&gp->sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) != 0) { - TRACE_ERROR("iscsi_sock_setsockopt() failed\n"); + iscsi_trace_error("iscsi_sock_setsockopt() failed\n"); goto done; } if (iscsi_sock_setsockopt(&gp->sock, SOL_TCP, TCP_NODELAY, &one, sizeof(one)) != 0) { - TRACE_ERROR("iscsi_sock_setsockopt() failed\n"); + iscsi_trace_error("iscsi_sock_setsockopt() failed\n"); return -1; } if (iscsi_sock_bind(gp->sock, gp->port) < 0) { - TRACE_ERROR("iscsi_sock_bind() failed\n"); + iscsi_trace_error("iscsi_sock_bind() failed\n"); goto done; } if (iscsi_sock_listen(gp->sock) < 0) { - TRACE_ERROR("iscsi_sock_listen() failed\n"); + iscsi_trace_error("iscsi_sock_listen() failed\n"); goto done; } - TRACE(TRACE_NET_DEBUG, "create, bind, listen OK\n"); + iscsi_trace(TRACE_NET_DEBUG, "create, bind, listen OK\n"); /* Loop for connections: FIX ME with queue */ while (gp->state != TARGET_SHUT_DOWN) { ISCSI_LOCK(&g_session_q_mutex, return -1); if ((sess = iscsi_queue_remove(&g_session_q)) == NULL) { - TRACE_ERROR("no free sessions: iscsi_queue_remove() failed\n"); + iscsi_trace_error("no free sessions: iscsi_queue_remove() failed\n"); goto done; } ISCSI_UNLOCK(&g_session_q_mutex, return -1); @@ -1582,23 +1582,23 @@ target_listen(globals_t *gp) /* Accept connection, spawn session thread, and */ /* clean up old threads */ - TRACE(TRACE_NET_DEBUG, "waiting for IPv4 connection on port %d\n", gp->port); + iscsi_trace(TRACE_NET_DEBUG, "waiting for IPv4 connection on port %d\n", gp->port); if (iscsi_sock_accept(gp->sock, &sess->sock) < 0) { - TRACE(TRACE_ISCSI_DEBUG, "iscsi_sock_accept() failed\n"); + iscsi_trace(TRACE_ISCSI_DEBUG, "iscsi_sock_accept() failed\n"); goto done; } localAddrLen = sizeof(localAddrStorage); (void) memset(&localAddrStorage, 0x0, sizeof(localAddrStorage)); if (iscsi_sock_getsockname(sess->sock, (struct sockaddr *) (void *) &localAddrStorage, &localAddrLen) < 0) { - TRACE_ERROR("iscsi_sock_getsockname() failed\n"); + iscsi_trace_error("iscsi_sock_getsockname() failed\n"); goto done; } remoteAddrLen = sizeof(remoteAddrStorage); (void) memset(&remoteAddrStorage, 0x0, sizeof(remoteAddrStorage)); if (iscsi_sock_getpeername(sess->sock, (struct sockaddr *) (void *) &remoteAddrStorage, &remoteAddrLen) < 0) { - TRACE_ERROR("iscsi_sock_getsockname() failed\n"); + iscsi_trace_error("iscsi_sock_getsockname() failed\n"); goto done; } @@ -1609,30 +1609,30 @@ target_listen(globals_t *gp) (void) strlcpy(sess->initiator, inet_ntoa(remoteAddrStorage.sin_addr), sizeof(sess->initiator)); (void) snprintf(gp->targetaddress, sizeof(gp->targetaddress), "%s:%u,1", local, gp->port); - TRACE(TRACE_ISCSI_DEBUG, "IPv4 connection accepted on port %d (local IP %s, remote IP %s)\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "IPv4 connection accepted on port %d (local IP %s, remote IP %s)\n", gp->port, local, sess->initiator); - TRACE(TRACE_ISCSI_DEBUG, "TargetAddress = \"%s\"\n", gp->targetaddress); + iscsi_trace(TRACE_ISCSI_DEBUG, "TargetAddress = \"%s\"\n", gp->targetaddress); if (iscsi_thread_create(&sess->worker.thread, (void *) worker_proc_t, sess) != 0) { - TRACE_ERROR("iscsi_thread_create() failed\n"); + iscsi_trace_error("iscsi_thread_create() failed\n"); goto done; } break; case ISCSI_IPv6: if (inet_ntop(localAddrStorage.sin_family, (void *)&localAddrStorage.sin_addr, local, sizeof(local)) == NULL) { - TRACE_ERROR("inet_ntop local failed\n"); + iscsi_trace_error("inet_ntop local failed\n"); } if (inet_ntop(remoteAddrStorage.sin_family, (void *)&remoteAddrStorage.sin_addr, remote, sizeof(remote)) == NULL) { - TRACE_ERROR("inet_ntop remotefailed\n"); + iscsi_trace_error("inet_ntop remotefailed\n"); } (void) strlcpy(sess->initiator, remote, sizeof(sess->initiator)); (void) snprintf(gp->targetaddress, sizeof(gp->targetaddress), "%s:%u,1", local, gp->port); - TRACE(TRACE_ISCSI_DEBUG, "IPv6 connection accepted on port %d (local IP %s, remote IP %s)\n", + iscsi_trace(TRACE_ISCSI_DEBUG, "IPv6 connection accepted on port %d (local IP %s, remote IP %s)\n", gp->port, local, sess->initiator); - TRACE(TRACE_ISCSI_DEBUG, "TargetAddress = \"%s\"\n", gp->targetaddress); + iscsi_trace(TRACE_ISCSI_DEBUG, "TargetAddress = \"%s\"\n", gp->targetaddress); break; } if (iscsi_thread_create(&sess->worker.thread, (void *) worker_proc_t, sess) != 0) { - TRACE_ERROR("iscsi_thread_create() failed\n"); + iscsi_trace_error("iscsi_thread_create() failed\n"); goto done; } } diff --git a/dist/iscsi/src/tests.c b/dist/iscsi/src/tests.c index ff9aae490438..a3e6e3fdf142 100644 --- a/dist/iscsi/src/tests.c +++ b/dist/iscsi/src/tests.c @@ -81,24 +81,24 @@ int osd_command(void *dev, osd_args_t * args, OSD_OPS_MEM * mem); */ #if 0 -TRACE(TRACE_SCSI_ARGS, " Peripheral device type: %u\n", data[0] & 0x1f); -TRACE(TRACE_SCSI_ARGS, " Removable bit: %u\n", data[1] >> 7); -TRACE(TRACE_SCSI_ARGS, " ANSI-approved version: %u\n", data[2] & 0x7); -TRACE(TRACE_SCSI_ARGS, " AENC: %u\n", data[3] >> 7); -TRACE(TRACE_SCSI_ARGS, " TrmIOP: %u\n", (data[3] & 0x40) >> 6); -TRACE(TRACE_SCSI_ARGS, " NormACA: %u\n", (data[3] & 0x20) >> 5); -TRACE(TRACE_SCSI_ARGS, " Additional length: %u\n", data[4]); -TRACE(TRACE_SCSI_ARGS, " RelAdr: %u\n", data[7] & 0x7); -TRACE(TRACE_SCSI_ARGS, " Bus32: %u\n", (data[7] & 0x40) >> 6); -TRACE(TRACE_SCSI_ARGS, " WBus16: %u\n", (data[7] & 0x20) >> 5); -TRACE(TRACE_SCSI_ARGS, " Sync: %u\n", (data[7] & 0x10) >> 4); -TRACE(TRACE_SCSI_ARGS, " Linked: %u\n", (data[7] & 0x08) >> 3); -TRACE(TRACE_SCSI_ARGS, " TransDis: %u\n", (data[7] & 0x04) >> 2); -TRACE(TRACE_SCSI_ARGS, " CmdQue: %u\n", (data[7] & 0x02) >> 1); -TRACE(TRACE_SCSI_ARGS, " SftRe: %u\n", (data[7] & 0x01)); -TRACE(TRACE_SCSI_ARGS, " Vendor ID: %s\n", (data + 8)); -TRACE(TRACE_SCSI_ARGS, " Product ID: %s\n", (data + 16)); -TRACE(TRACE_SCSI_ARGS, " Revision Level: %s\n", (data + 32)); +iscsi_trace(TRACE_SCSI_ARGS, " Peripheral device type: %u\n", data[0] & 0x1f); +iscsi_trace(TRACE_SCSI_ARGS, " Removable bit: %u\n", data[1] >> 7); +iscsi_trace(TRACE_SCSI_ARGS, " ANSI-approved version: %u\n", data[2] & 0x7); +iscsi_trace(TRACE_SCSI_ARGS, " AENC: %u\n", data[3] >> 7); +iscsi_trace(TRACE_SCSI_ARGS, " TrmIOP: %u\n", (data[3] & 0x40) >> 6); +iscsi_trace(TRACE_SCSI_ARGS, " NormACA: %u\n", (data[3] & 0x20) >> 5); +iscsi_trace(TRACE_SCSI_ARGS, " Additional length: %u\n", data[4]); +iscsi_trace(TRACE_SCSI_ARGS, " RelAdr: %u\n", data[7] & 0x7); +iscsi_trace(TRACE_SCSI_ARGS, " Bus32: %u\n", (data[7] & 0x40) >> 6); +iscsi_trace(TRACE_SCSI_ARGS, " WBus16: %u\n", (data[7] & 0x20) >> 5); +iscsi_trace(TRACE_SCSI_ARGS, " Sync: %u\n", (data[7] & 0x10) >> 4); +iscsi_trace(TRACE_SCSI_ARGS, " Linked: %u\n", (data[7] & 0x08) >> 3); +iscsi_trace(TRACE_SCSI_ARGS, " TransDis: %u\n", (data[7] & 0x04) >> 2); +iscsi_trace(TRACE_SCSI_ARGS, " CmdQue: %u\n", (data[7] & 0x02) >> 1); +iscsi_trace(TRACE_SCSI_ARGS, " SftRe: %u\n", (data[7] & 0x01)); +iscsi_trace(TRACE_SCSI_ARGS, " Vendor ID: %s\n", (data + 8)); +iscsi_trace(TRACE_SCSI_ARGS, " Product ID: %s\n", (data + 16)); +iscsi_trace(TRACE_SCSI_ARGS, " Revision Level: %s\n", (data + 32)); #endif int @@ -120,7 +120,7 @@ nop_out(uint64_t target, int lun, int length, int ping, const char *data) nop_cmd.tag = 0xffffffff; } if (initiator_command(&cmd) != 0) { - TRACE_ERROR("initiator_command() failed\n"); + iscsi_trace_error("initiator_command() failed\n"); return -1; } return 0; @@ -149,15 +149,15 @@ inquiry(uint64_t target, uint32_t lun, uint32_t *device_type) cmd.ptr = &args; if (initiator_command(&cmd) != 0) { - TRACE_ERROR("initiator_command() failed\n"); + iscsi_trace_error("initiator_command() failed\n"); return -1; } if (args.status) { - TRACE_ERROR("INQUIRY failed (status 0x%x)\n", args.status); + iscsi_trace_error("INQUIRY failed (status 0x%x)\n", args.status); return -1; } *device_type = data[0] & 0x1f; - TRACE(TRACE_SCSI_DEBUG, "Device Type 0x%x\n", *device_type); + iscsi_trace(TRACE_SCSI_DEBUG, "Device Type 0x%x\n", *device_type); return 0; } @@ -186,23 +186,23 @@ read_capacity(uint64_t target, uint32_t lun, uint32_t *max_lba, uint32_t *block_ cmd.ptr = &args; if (initiator_command(&cmd) != 0) { - TRACE_ERROR("initiator_command() failed\n"); + iscsi_trace_error("initiator_command() failed\n"); return -1; } if (args.status) { - TRACE_ERROR("READ_CAPACITY failed (status 0x%x)\n", args.status); + iscsi_trace_error("READ_CAPACITY failed (status 0x%x)\n", args.status); return -1; } - TRACE(TRACE_SCSI_DEBUG, "Max LBA (lun %u): %u\n", lun, *max_lba); - TRACE(TRACE_SCSI_DEBUG, "Block Len (lun %u): %u\n", lun, *block_len); + iscsi_trace(TRACE_SCSI_DEBUG, "Max LBA (lun %u): %u\n", lun, *max_lba); + iscsi_trace(TRACE_SCSI_DEBUG, "Block Len (lun %u): %u\n", lun, *block_len); *max_lba = ISCSI_NTOHL(*((uint32_t *) (data))); *block_len = ISCSI_NTOHL(*((uint32_t *) (data + 4))); if (*max_lba == 0) { - TRACE_ERROR("Device returned Maximum LBA of zero\n"); + iscsi_trace_error("Device returned Maximum LBA of zero\n"); return -1; } if (*block_len % 2) { - TRACE_ERROR("Device returned strange block len: %u\n", *block_len); + iscsi_trace_error("Device returned strange block len: %u\n", *block_len); return -1; } return 0; @@ -229,13 +229,13 @@ write_read_test(uint64_t target, uint32_t lun, int type) int i, j; if ((type != 6) && (type != 10)) { - TRACE_ERROR("bad type, select 6 or 10\n"); + iscsi_trace_error("bad type, select 6 or 10\n"); return -1; } /* determine last block on device */ if (read_capacity(target, lun, &max_lba, &block_len) != 0) { - TRACE_ERROR("read_capacity() failed\n"); + iscsi_trace_error("read_capacity() failed\n"); return -1; } /* write pattern into first and last block on device */ @@ -285,11 +285,11 @@ write_read_test(uint64_t target, uint32_t lun, int type) cmd.ptr = &args; cmd.type = ISCSI_SCSI_CMD; if (initiator_command(&cmd) != 0) { - TRACE_ERROR("initiator_command() failed\n"); + iscsi_trace_error("initiator_command() failed\n"); return -1; } if (args.status) { - TRACE_ERROR("initiator_command() failed\n"); + iscsi_trace_error("initiator_command() failed\n"); return -1; } } @@ -337,16 +337,16 @@ write_read_test(uint64_t target, uint32_t lun, int type) cmd.type = ISCSI_SCSI_CMD; cmd.ptr = &args; if (initiator_command(&cmd) != 0) { - TRACE_ERROR("initiator_command() failed\n"); + iscsi_trace_error("initiator_command() failed\n"); return -1; } if (args.status) { - TRACE_ERROR("initiator_command() failed\n"); + iscsi_trace_error("initiator_command() failed\n"); return -1; } for (j = 0; j < block_len; j++) { if (data[j] != (uint8_t) (i + j)) { - TRACE_ERROR("Bad byte. data[%i] = %u, expected %u.\n", + iscsi_trace_error("Bad byte. data[%i] = %u, expected %u.\n", j, data[j], (uint8_t) (i + j)); return -1; } @@ -397,11 +397,11 @@ read_or_write(uint64_t target, uint32_t lun, uint32_t lba, uint32_t len, /* Execute iSCSI command */ if (initiator_command(&cmd) != 0) { - TRACE_ERROR("initiator_command() failed\n"); + iscsi_trace_error("initiator_command() failed\n"); return -1; } if (args.status) { - TRACE_ERROR("scsi_command() failed (status 0x%x)\n", args.status); + iscsi_trace_error("scsi_command() failed (status 0x%x)\n", args.status); return -1; } return 0; @@ -423,40 +423,40 @@ throughput_test(uint32_t target, uint32_t lun, uint32_t length, uint32_t request /* Get device block len & capacity */ if (read_capacity(target, lun, &max_lba, &block_len) != 0) { - TRACE_ERROR("read_capacity() failed\n"); + iscsi_trace_error("read_capacity() failed\n"); return -1; } if (request % block_len) { - TRACE_ERROR("request must be a multiple of %u\n", block_len); + iscsi_trace_error("request must be a multiple of %u\n", block_len); return -1; } if (!sg_factor) { - TRACE_ERROR("sg_factor must be at least 1\n"); + iscsi_trace_error("sg_factor must be at least 1\n"); return -1; } if (request % sg_factor) { - TRACE_ERROR("request must be a multiple of sg_factor\n"); + iscsi_trace_error("request must be a multiple of sg_factor\n"); return -1; } if (length % request) { - TRACE_ERROR("length must be a multiple of request\n"); + iscsi_trace_error("length must be a multiple of request\n"); return -1; } if (length > ((max_lba + 1) * block_len)) { - TRACE_ERROR("attempt to read past device (max length %u)\n", max_lba * block_len); + iscsi_trace_error("attempt to read past device (max length %u)\n", max_lba * block_len); return -1; } if ((sg = iscsi_malloc(sg_factor * sizeof(struct iovec))) == NULL) { - TRACE_ERROR("out of memory\n"); + iscsi_trace_error("out of memory\n"); return -1; } if ((data = iscsi_malloc(sg_factor * sizeof(uint8_t *))) == NULL) { - TRACE_ERROR("out of memory\n"); + iscsi_trace_error("out of memory\n"); return -1; } for (i = 0; i < sg_factor; i++) { if ((data[i] = iscsi_malloc(request / sg_factor)) == NULL) { - TRACE_ERROR("out of memory\n"); + iscsi_trace_error("out of memory\n"); return -1; } } @@ -475,11 +475,11 @@ throughput_test(uint32_t target, uint32_t lun, uint32_t length, uint32_t request sg[j].iov_len = request / sg_factor; } if (read_or_write(target, lun, block_offset, num_blocks, block_len, (uint8_t *) sg, sg_factor, writing) != 0) { - TRACE_ERROR("read_10() failed\n"); + iscsi_trace_error("read_10() failed\n"); goto done; } if (verbose && !((i + 1) % verbose)) { - PRINT("%u total bytes %s: this request (lba %u, len %u)\n", + printf("%u total bytes %s: this request (lba %u, len %u)\n", (i + 1) * request, writing ? "written" : "read", block_offset, num_blocks); } } @@ -489,7 +489,7 @@ throughput_test(uint32_t target, uint32_t lun, uint32_t length, uint32_t request /* Output results */ - PRINT("%u MB %s in %.2f seconds --> %.2f MB/sec\n", length / 1048576, writing ? "written" : "read", (double) seconds, + printf("%u MB %s in %.2f seconds --> %.2f MB/sec\n", length / 1048576, writing ? "written" : "read", (double) seconds, (double) (length / seconds) / 1048576); done: for (i = 0; i < sg_factor; i++) { @@ -513,38 +513,38 @@ integrity_test(uint32_t target, uint32_t lun, uint32_t length, int sg_factor) /* Get device block len & capacity; and check args */ if (read_capacity(target, lun, &max_lba, &block_len) != 0) { - TRACE_ERROR("read_capacity() failed\n"); + iscsi_trace_error("read_capacity() failed\n"); return -1; } if (length % block_len) { - TRACE_ERROR("length must be a multiple of block len %u\n", block_len); + iscsi_trace_error("length must be a multiple of block len %u\n", block_len); return -1; } if (!sg_factor) { - TRACE_ERROR("sg_factor must be at least 1\n"); + iscsi_trace_error("sg_factor must be at least 1\n"); return -1; } if (length % sg_factor) { - TRACE_ERROR("length must be a multiple of sg_factor\n"); + iscsi_trace_error("length must be a multiple of sg_factor\n"); return -1; } if (length > ((max_lba + 1) * block_len)) { - TRACE_ERROR("attempt to read past device (max length %u)\n", max_lba * block_len); + iscsi_trace_error("attempt to read past device (max length %u)\n", max_lba * block_len); return -1; } /* Allocate sg and data buffers; fill data buffers with pattern */ if ((sg = iscsi_malloc(sg_factor * sizeof(struct iovec))) == NULL) { - TRACE_ERROR("out of memory\n"); + iscsi_trace_error("out of memory\n"); return -1; } if ((data = iscsi_malloc(sg_factor * sizeof(uint8_t *))) == NULL) { - TRACE_ERROR("out of memory\n"); + iscsi_trace_error("out of memory\n"); return -1; } for (i = 0; i < sg_factor; i++) { if ((data[i] = iscsi_malloc(length / sg_factor)) == NULL) { - TRACE_ERROR("out of memory\n"); + iscsi_trace_error("out of memory\n"); return -1; } for (j = 0; j < (length / sg_factor); j++) { @@ -560,14 +560,14 @@ integrity_test(uint32_t target, uint32_t lun, uint32_t length, int sg_factor) sg[j].iov_len = length / sg_factor; } if (read_or_write(target, lun, 0, length / block_len, block_len, (uint8_t *) sg, sg_factor, 1) != 0) { - TRACE_ERROR("read_or_write() failed\n"); + iscsi_trace_error("read_or_write() failed\n"); goto done; } for (i = 0; i < sg_factor; i++) { for (j = 0; j < (length / sg_factor); j++) { /* if (data[i][j] != (uint8_t)(i+j)) { */ if (data[i][j] != (uint8_t) (i + 1)) { - TRACE_ERROR("Bad byte data[%i][%i]: got %u, expected %u\n", i, j, data[i][j], (uint8_t) (i + j)); + iscsi_trace_error("Bad byte data[%i][%i]: got %u, expected %u\n", i, j, data[i][j], (uint8_t) (i + j)); goto done; } } @@ -581,14 +581,14 @@ integrity_test(uint32_t target, uint32_t lun, uint32_t length, int sg_factor) sg[j].iov_len = length / sg_factor; } if (read_or_write(target, lun, 0, length / block_len, block_len, (uint8_t *) sg, sg_factor, 0) != 0) { - TRACE_ERROR("read_or_write() failed\n"); + iscsi_trace_error("read_or_write() failed\n"); goto done; } for (i = 0; i < sg_factor; i++) { for (j = 0; j < (length / sg_factor); j++) { /* if (data[i][j] != (uint8_t)(i+j)) { */ if (data[i][j] != (uint8_t) (i + 1)) { - TRACE_ERROR("Bad byte data[%i][%i]: got %u, expected %u\n", i, j, data[i][j], (uint8_t) (i + j)); + iscsi_trace_error("Bad byte data[%i][%i]: got %u, expected %u\n", i, j, data[i][j], (uint8_t) (i + j)); goto done; } } @@ -613,7 +613,7 @@ nop_test(uint32_t target, uint32_t lun, uint32_t iters) int i, j, k; if ((data = iscsi_malloc(4096)) == NULL) { - TRACE_ERROR("iscsi_malloc() failed\n"); + iscsi_trace_error("iscsi_malloc() failed\n"); return -1; } /* Fill with some pattern */ @@ -627,7 +627,7 @@ nop_test(uint32_t target, uint32_t lun, uint32_t iters) gettimeofday(&t_start, 0); for (i = 0; i < iters; i++) { if (nop_out(target, lun, j, k, data) != 0) { - TRACE_ERROR("nop_out() failed\n"); + iscsi_trace_error("nop_out() failed\n"); return -1; } } @@ -635,7 +635,7 @@ nop_test(uint32_t target, uint32_t lun, uint32_t iters) /* Output results */ - PRINT("NOP_OUT (%4i bytes, ping = %i): %u iters in %.2f sec --> %.2f usec\n", j, k, + printf("NOP_OUT (%4i bytes, ping = %i): %u iters in %.2f sec --> %.2f usec\n", j, k, iters, toSeconds(t_stop) - toSeconds(t_start), ((toSeconds(t_stop) - toSeconds(t_start)) * 1e6) / iters); if (!j) @@ -669,16 +669,16 @@ latency_test(uint64_t target, uint32_t lun, uint8_t op, uint32_t iters) if ((op == WRITE_10) || (op == READ_10)) { if (read_capacity(target, lun, &max_lba, &block_len) != 0) { - TRACE_ERROR("read_capacity() failed\n"); + iscsi_trace_error("read_capacity() failed\n"); return -1; } if ((data = iscsi_malloc(block_len)) == NULL) { - TRACE_ERROR("out of memory\n"); + iscsi_trace_error("out of memory\n"); return -1; } } else { if ((data = iscsi_malloc(1024)) == NULL) { - TRACE_ERROR("out of memory\n"); + iscsi_trace_error("out of memory\n"); return -1; } } @@ -755,7 +755,7 @@ latency_test(uint64_t target, uint32_t lun, uint8_t op, uint32_t iters) #endif break; default: - TRACE_ERROR("op 0x%x not implemented\n", op); + iscsi_trace_error("op 0x%x not implemented\n", op); return -1; } @@ -779,11 +779,11 @@ latency_test(uint64_t target, uint32_t lun, uint8_t op, uint32_t iters) gettimeofday(&t_start, 0); for (i = 0; i < iters; i++) { if (initiator_command(&cmd) != 0) { - TRACE_ERROR("initiator_command() failed\n"); + iscsi_trace_error("initiator_command() failed\n"); goto done; } if (args.status) { - TRACE_ERROR("scsi_command() failed (status 0x%x)\n", args.status); + iscsi_trace_error("scsi_command() failed (status 0x%x)\n", args.status); goto done; } } @@ -791,7 +791,7 @@ latency_test(uint64_t target, uint32_t lun, uint8_t op, uint32_t iters) /* Output results */ - PRINT("SCSI op 0x%2x: %u iters in %.2f sec --> %.2f usec\n", + printf("SCSI op 0x%2x: %u iters in %.2f sec --> %.2f usec\n", op, iters, toSeconds(t_stop) - toSeconds(t_start), ((toSeconds(t_stop) - toSeconds(t_start)) * 1e6) / iters); @@ -833,7 +833,7 @@ scatter_gather_test(uint64_t target, uint32_t lun, uint8_t op) /* Number of iterations (xfer_chunk bytes read/written per iteration) */ if (xfer_size % xfer_chunk) { - TRACE_ERROR("xfer_size (%i) is not a multiple of xfer_chunk (%i)\n", xfer_size, xfer_chunk); + iscsi_trace_error("xfer_size (%i) is not a multiple of xfer_chunk (%i)\n", xfer_size, xfer_chunk); return -1; } n = xfer_size / xfer_chunk; @@ -841,11 +841,11 @@ scatter_gather_test(uint64_t target, uint32_t lun, uint8_t op) /* Number of blocks per iteration */ if (read_capacity(target, lun, &max_lba, &block_len) != 0) { - TRACE_ERROR("read_capacity() failed\n"); + iscsi_trace_error("read_capacity() failed\n"); return -1; } if (xfer_chunk % block_len) { - TRACE_ERROR("xfer_chunk (%i) is not a multiple of block_len (%i)\n", xfer_chunk, block_len); + iscsi_trace_error("xfer_chunk (%i) is not a multiple of block_len (%i)\n", xfer_chunk, block_len); return -1; } len = xfer_chunk / block_len; @@ -867,24 +867,24 @@ scatter_gather_test(uint64_t target, uint32_t lun, uint8_t op) input = 1; break; default: - TRACE_ERROR("scatter/gather test not implemented for SCSI op 0x%x\n", op); + iscsi_trace_error("scatter/gather test not implemented for SCSI op 0x%x\n", op); return -1; } /* Allocate buffers for scatter/gather */ if ((buff = iscsi_malloc(len * sizeof(uint8_t *))) == NULL) { - TRACE_ERROR("out of memory\n"); + iscsi_trace_error("out of memory\n"); return -1; } for (i = 0; i < len; i++) { buff[i] = iscsi_malloc(block_len); if (buff[i] == NULL) { - TRACE_ERROR("out of memory\n"); + iscsi_trace_error("out of memory\n"); } } if ((sg = iscsi_malloc(len * sizeof(struct iovec))) == NULL) { - TRACE_ERROR("out of memory\n"); + iscsi_trace_error("out of memory\n"); return -1; } for (i = 0; i < len; i++) { @@ -941,11 +941,11 @@ scatter_gather_test(uint64_t target, uint32_t lun, uint8_t op) cmd.ptr = &args; if (initiator_command(&cmd) != 0) { - TRACE_ERROR("initiator_command() failed\n"); + iscsi_trace_error("initiator_command() failed\n"); goto done; } if (args.status) { - TRACE_ERROR("scsi_command() failed (status 0x%x)\n", args.status); + iscsi_trace_error("scsi_command() failed (status 0x%x)\n", args.status); goto done; } } @@ -980,57 +980,57 @@ osd_tests(int target, int lun) uint16_t len; if (osd_create_group((void *) &dev, &osd_command, &GroupID) != 0) { - TRACE_ERROR("osd_create_group() failed\n"); + iscsi_trace_error("osd_create_group() failed\n"); return -1; } - PRINT("OSD_CREATE_GROUP: PASSED\n"); + printf("OSD_CREATE_GROUP: PASSED\n"); if (osd_create((void *) &dev, GroupID, &osd_command, &UserID) != 0) { - TRACE_ERROR("osd_create() failed\n"); + iscsi_trace_error("osd_create() failed\n"); return -1; } - PRINT("OSD_CREATE: PASSED\n"); + printf("OSD_CREATE: PASSED\n"); if (osd_write((void *) &dev, GroupID, UserID, 0, 13, "Hello, World!", 0, &osd_command) != 0) { - TRACE_ERROR("osd_write() failed\n"); + iscsi_trace_error("osd_write() failed\n"); return -1; } - PRINT("OSD_WRITE: PASSED\n"); + printf("OSD_WRITE: PASSED\n"); if (osd_read((void *) &dev, GroupID, UserID, 0, 13, buffer, 0, &osd_command) != 0) { - TRACE_ERROR("osd_write() failed\n"); + iscsi_trace_error("osd_write() failed\n"); } if (strncmp(buffer, "Hello, World!", 13)) { - TRACE_ERROR("osd_read() failed\n"); + iscsi_trace_error("osd_read() failed\n"); return -1; } - PRINT("OSD_READ: PASSED\n"); + printf("OSD_READ: PASSED\n"); if (osd_set_one_attr((void *) &dev, GroupID, UserID, 0x30000000, 0x1, 480, buffer, &osd_command) != 0) { - TRACE_ERROR("osd_write() failed\n"); + iscsi_trace_error("osd_write() failed\n"); } - PRINT("OSD_SET_ATTR: PASSED\n"); + printf("OSD_SET_ATTR: PASSED\n"); if (osd_get_one_attr((void *) &dev, GroupID, UserID, 0x30000000, 0, 480, &osd_command, &len, buffer) != 0) { - TRACE_ERROR("osd_get_one_attr() failed\n"); + iscsi_trace_error("osd_get_one_attr() failed\n"); } if (strncmp(buffer, "Hello, World!", 13)) { - TRACE_ERROR("osd_read() failed\n"); + iscsi_trace_error("osd_read() failed\n"); return -1; } - PRINT("OSD_GET_ATTR: PASSED\n"); + printf("OSD_GET_ATTR: PASSED\n"); if (osd_remove((void *) &dev, GroupID, UserID, &osd_command) != 0) { - TRACE_ERROR("osd_remove() failed\n"); + iscsi_trace_error("osd_remove() failed\n"); return -1; } - PRINT("OSD_REMOVE: PASSED\n"); + printf("OSD_REMOVE: PASSED\n"); if (osd_remove_group((void *) &dev, GroupID, &osd_command) != 0) { - TRACE_ERROR("osd_remove_group() failed\n"); + iscsi_trace_error("osd_remove_group() failed\n"); return -1; } - PRINT("OSD_REMOVE: PASSED\n"); + printf("OSD_REMOVE: PASSED\n"); return 0; } @@ -1047,48 +1047,48 @@ disk_tests(int target, int lun) /* Initial Tests */ if (read_capacity(target, lun, &max_lba, &block_len) != 0) { - TRACE_ERROR("read_capacity() failed\n"); + iscsi_trace_error("read_capacity() failed\n"); return -1; } - PRINT("read_capacity PASSED\n"); + printf("read_capacity PASSED\n"); if (write_read_test(target, lun, 10) != 0) { - TRACE_ERROR("write_read_test() failed\n"); + iscsi_trace_error("write_read_test() failed\n"); return -1; } - PRINT("write_read_test PASSED\n"); + printf("write_read_test PASSED\n"); if (integrity_test(target, lun, max_request_size, 1024) != 0) { - TRACE_ERROR("integrity_test() failed\n"); + iscsi_trace_error("integrity_test() failed\n"); return -1; } - PRINT("integrity_test PASSED\n"); + printf("integrity_test PASSED\n"); /* Latency Tests */ if (latency_test(target, lun, READ_10, 1000) != 0) { - TRACE_ERROR("latency_test(READ_10) failed\n"); + iscsi_trace_error("latency_test(READ_10) failed\n"); return -1; } if (latency_test(target, lun, WRITE_10, 1000) != 0) { - TRACE_ERROR("latency_test(WRITE_10) failed\n"); + iscsi_trace_error("latency_test(WRITE_10) failed\n"); return -1; } if (latency_test(target, lun, READ_CAPACITY, 1000) != 0) { - TRACE_ERROR("latency_test(READ_CAPACITY) failed\n"); + iscsi_trace_error("latency_test(READ_CAPACITY) failed\n"); return -1; } /* Throughput Tests */ for (request_size = min_request_size; request_size <= max_request_size; request_size *= 2) { - PRINT("%u bytes/request: ", request_size); + printf("%u bytes/request: ", request_size); if (throughput_test(target, lun, xfer_size, request_size, (xfer_size / request_size) + 1, 1, 1) != 0) { - TRACE_ERROR("througput_test() failed\n"); + iscsi_trace_error("througput_test() failed\n"); return -1; } } for (request_size = min_request_size; request_size <= max_request_size; request_size *= 2) { - PRINT("%u bytes/request: ", request_size); + printf("%u bytes/request: ", request_size); if (throughput_test(target, lun, xfer_size, request_size, (xfer_size / request_size) + 1, 0, 1) != 0) { - TRACE_ERROR("througput_test() failed\n"); + iscsi_trace_error("througput_test() failed\n"); return -1; } } @@ -1104,66 +1104,66 @@ test_all(int target, int lun) /* Initial Tests */ - PRINT("##BEGIN INITIAL TESTS[%i:%i]##\n", target, lun); + printf("##BEGIN INITIAL TESTS[%i:%i]##\n", target, lun); if (nop_out(target, lun, 13, 0, data) != 0) { - TRACE_ERROR("nop_out() failed\n"); + iscsi_trace_error("nop_out() failed\n"); return -1; } - PRINT("nop_out() PASSED\n"); + printf("nop_out() PASSED\n"); if (nop_out(target, lun, 13, 1, data) != 0) { - TRACE_ERROR("nop_out() w/ ping failed\n"); + iscsi_trace_error("nop_out() w/ ping failed\n"); return -1; } - PRINT("nop_out() w/ ping PASSED\n"); + printf("nop_out() w/ ping PASSED\n"); if (inquiry(target, lun, &device_type) != 0) { - TRACE_ERROR("inquiry() failed\n"); + iscsi_trace_error("inquiry() failed\n"); return -1; } - PRINT("inquiry() PASSED: device type 0x%x\n", device_type); - PRINT("##END INITIAL TESTS[%i:%i]##\n\n", target, lun); + printf("inquiry() PASSED: device type 0x%x\n", device_type); + printf("##END INITIAL TESTS[%i:%i]##\n\n", target, lun); /* iSCSI Latency Tests */ - PRINT("##BEGIN iSCSI LATENCY TESTS[%i:%i]##\n", target, lun); + printf("##BEGIN iSCSI LATENCY TESTS[%i:%i]##\n", target, lun); if (nop_test(target, lun, 1000) != 0) { - TRACE_ERROR("nop_test() failed\n"); + iscsi_trace_error("nop_test() failed\n"); return -1; } - PRINT("##END iSCSI LATENCY TESTS[%i:%i]##\n\n", target, lun); + printf("##END iSCSI LATENCY TESTS[%i:%i]##\n\n", target, lun); /* SCSI Latency Tests */ - PRINT("##BEGIN SCSI LATENCY TESTS[%i:%i]##\n", target, lun); + printf("##BEGIN SCSI LATENCY TESTS[%i:%i]##\n", target, lun); if (latency_test(target, lun, TEST_UNIT_READY, 1000) != 0) { - TRACE_ERROR("latency_test(TEST_UNIT_READY) failed\n"); + iscsi_trace_error("latency_test(TEST_UNIT_READY) failed\n"); return -1; } if (latency_test(target, lun, INQUIRY, 1000) != 0) { - TRACE_ERROR("latency_test(INQUIRY) failed\n"); + iscsi_trace_error("latency_test(INQUIRY) failed\n"); return -1; } - PRINT("##END SCSI LATENCY TESTS[%i:%i]##\n\n", target, lun); + printf("##END SCSI LATENCY TESTS[%i:%i]##\n\n", target, lun); /* Device-specific tests */ - PRINT("##BEGIN DEVICE-SPECIFIC TESTS[%i:%i]##\n", target, lun); + printf("##BEGIN DEVICE-SPECIFIC TESTS[%i:%i]##\n", target, lun); switch (device_type) { case 0x00: if (disk_tests(target, lun) != 0) { - TRACE_ERROR("disk_tests() failed\n"); + iscsi_trace_error("disk_tests() failed\n"); return -1; } break; case 0x0e: if (osd_tests(target, lun) != 0) { - TRACE_ERROR("osd_tests() failed\n"); + iscsi_trace_error("osd_tests() failed\n"); return -1; } break; default: break; } - PRINT("##END DEVICE-SPECIFIC TESTS[%i:%i]##\n\n", target, lun); + printf("##END DEVICE-SPECIFIC TESTS[%i:%i]##\n\n", target, lun); return 0; } @@ -1240,11 +1240,11 @@ osd_command(void *dev, osd_args_t * args, OSD_OPS_MEM * m) /* Execute initiator_cmd_t */ if (initiator_command(&initiator_cmd) != 0) { - TRACE_ERROR("initiator_command() failed\n"); + iscsi_trace_error("initiator_command() failed\n"); return -1; } if (scsi_cmd.status != 0) { - TRACE_ERROR("SCSI command failed\n"); + iscsi_trace_error("SCSI command failed\n"); return -1; } return 0; diff --git a/dist/iscsi/src/usocktest.c b/dist/iscsi/src/usocktest.c index da6a4234f97c..6836048142f7 100644 --- a/dist/iscsi/src/usocktest.c +++ b/dist/iscsi/src/usocktest.c @@ -128,12 +128,12 @@ int main(int argc, char *argv[]) { } else if (!strcmp(argv[i], "-v")) { i++; sscanf(argv[i], "%u", &VerboseFreq); } else { - PRINT("Unknown option \"%s\"\n", argv[i]); - PRINT("%s\n", usage); + printf("Unknown option \"%s\"\n", argv[i]); + printf("%s\n", usage); return -1; } } - if (argc == 1) PRINT("%s\n", usage); + if (argc == 1) printf("%s\n", usage); IsTarget = (strlen(TargetIP)>0)?0:1; /* @@ -157,16 +157,16 @@ int main(int argc, char *argv[]) { */ if (iscsi_sock_create(&iscsi_sock)!=0) { - TRACE_ERROR("iscsi_sock_create() failed\n"); + iscsi_trace_error("iscsi_sock_create() failed\n"); return -1; } if (IsTarget) { if (iscsi_sock_bind(iscsi_sock, Port)!=0) { - TRACE_ERROR("iscsi_sock_bind() failed\n"); + iscsi_trace_error("iscsi_sock_bind() failed\n"); return -1; } if (iscsi_sock_listen(iscsi_sock)!=0) { - TRACE_ERROR("iscsi_sock_listen() failed\n"); + iscsi_trace_error("iscsi_sock_listen() failed\n"); return -1; } } @@ -177,19 +177,19 @@ int main(int argc, char *argv[]) { accept: if (IsTarget) { - PRINT("Waiting for TCP connection on port %u\n", Port); + printf("Waiting for TCP connection on port %u\n", Port); if(iscsi_sock_accept(iscsi_sock, &iscsi_sock_new)!=0) { - TRACE_ERROR("iscsi_sock_accept() failed\n"); + iscsi_trace_error("iscsi_sock_accept() failed\n"); return -1; } - PRINT("Connection accepted\n"); + printf("Connection accepted\n"); } else { printf("Connecting to %s\n", TargetIP); if(iscsi_sock_connect(iscsi_sock, TargetIP, Port)!=0) { - TRACE_ERROR("iscsi_sock_connect() failed\n"); + iscsi_trace_error("iscsi_sock_connect() failed\n"); return -1; } - PRINT("Connected\n"); + printf("Connected\n"); iscsi_sock_new = iscsi_sock; } @@ -198,25 +198,25 @@ accept: */ if (!IsTarget) { - TRACE(TRACE_DEBUG, "Sending test parameters\n"); + iscsi_trace(TRACE_DEBUG, "Sending test parameters\n"); sprintf(ctrlBufferSend, "%s:%s:%s:%s:%i:%i:%i", HostSendPattern, HostRecvPattern, TargSendPattern, TargRecvPattern, NumIters, VerboseFreq, Port); if ((n=iscsi_sock_msg(iscsi_sock_new, 1, ctrlBuffSize, ctrlBufferSend, 0))!=ctrlBuffSize) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); return -1; } if ((n=iscsi_sock_msg(iscsi_sock_new, 0, ctrlBuffSize, ctrlBufferRecv, 0))!=ctrlBuffSize) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); return -1; } - TRACE(TRACE_DEBUG, "Test parameters sent\n"); + iscsi_trace(TRACE_DEBUG, "Test parameters sent\n"); } else { char *ptr, *delim; - TRACE(TRACE_DEBUG, "Receiving test parameters\n"); + iscsi_trace(TRACE_DEBUG, "Receiving test parameters\n"); if ((n=iscsi_sock_msg(iscsi_sock_new, 0, ctrlBuffSize, ctrlBufferRecv, 0))!=ctrlBuffSize) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); return -1; } ptr = ctrlBufferRecv; @@ -230,10 +230,10 @@ accept: strncpy(TargRecvPattern, ptr, delim-ptr+1); TargRecvPattern[delim-ptr] = 0x0; ptr = delim+1; sscanf(ptr, "%i:%i", &NumIters, &VerboseFreq); if ((n=iscsi_sock_msg(iscsi_sock_new, 1, ctrlBuffSize, ctrlBufferSend, 0))!=ctrlBuffSize) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); return -1; } - TRACE(TRACE_DEBUG, "Test parameters received\n"); + iscsi_trace(TRACE_DEBUG, "Test parameters received\n"); } /* @@ -243,25 +243,25 @@ accept: HostSendTotal = 0; for (i=0; i Target receiving size (%i)\n", + iscsi_trace_error("Host sending size (%i) > Target receiving size (%i)\n", HostSendTotal, TargRecvTotal); return -1; } HostRecvTotal = 0; for (i=0; i Target sending size (%i)\n", + iscsi_trace_error("Host receiving size (%i) > Target sending size (%i)\n", HostRecvTotal, TargSendTotal); return -1; } - TRACE(TRACE_DEBUG, "HostSendPattern: \"%s\"\n", HostSendPattern); - TRACE(TRACE_DEBUG, "HostRecvPattern: \"%s\"\n", HostRecvPattern); - TRACE(TRACE_DEBUG, "TargRecvPattern: \"%s\"\n", TargRecvPattern); - TRACE(TRACE_DEBUG, "TargSendPattern: \"%s\"\n", TargSendPattern); - TRACE(TRACE_DEBUG, "NumIters: %i\n", NumIters); - TRACE(TRACE_DEBUG, "VerboseFreq: %i\n", VerboseFreq); - TRACE(TRACE_DEBUG, "HostSendTotal: %i bytes\n", HostSendTotal); - TRACE(TRACE_DEBUG, "HostRecvTotal: %i bytes\n", HostRecvTotal); + iscsi_trace(TRACE_DEBUG, "HostSendPattern: \"%s\"\n", HostSendPattern); + iscsi_trace(TRACE_DEBUG, "HostRecvPattern: \"%s\"\n", HostRecvPattern); + iscsi_trace(TRACE_DEBUG, "TargRecvPattern: \"%s\"\n", TargRecvPattern); + iscsi_trace(TRACE_DEBUG, "TargSendPattern: \"%s\"\n", TargSendPattern); + iscsi_trace(TRACE_DEBUG, "NumIters: %i\n", NumIters); + iscsi_trace(TRACE_DEBUG, "VerboseFreq: %i\n", VerboseFreq); + iscsi_trace(TRACE_DEBUG, "HostSendTotal: %i bytes\n", HostSendTotal); + iscsi_trace(TRACE_DEBUG, "HostRecvTotal: %i bytes\n", HostRecvTotal); /* * Allocate buffers @@ -269,22 +269,22 @@ accept: for (i=0; i= CONFIG_INITIATOR_NUM_TARGETS) { - TRACE_ERROR("initiator only configured with %i targets\n", CONFIG_INITIATOR_NUM_TARGETS); + iscsi_trace_error("initiator only configured with %i targets\n", CONFIG_INITIATOR_NUM_TARGETS); exit(EXIT_FAILURE); } tgtlo = target; @@ -119,7 +119,7 @@ main(int argc, char *argv[]) } for (j = 0; j < iterations; j++) { - PRINT("\n", j); + printf("\n", j); /* Ignore sigpipe */ @@ -128,14 +128,14 @@ main(int argc, char *argv[]) /* Initialize Initiator */ if (initiator_init(host) == -1) { - TRACE_ERROR("initiator_init() failed\n"); + iscsi_trace_error("initiator_init() failed\n"); return -1; } /* Run tests for each target */ for (i = tgtlo; i < tgthi; i++) { if (test_all(i, lun) != 0) { - TRACE_ERROR("test_all() failed\n"); + iscsi_trace_error("test_all() failed\n"); return -1; } } @@ -143,7 +143,7 @@ main(int argc, char *argv[]) /* Shutdown Initiator */ if (initiator_shutdown() == -1) { - TRACE_ERROR("initiator_shutdown() failed\n"); + iscsi_trace_error("initiator_shutdown() failed\n"); return -1; } } diff --git a/dist/iscsi/src/util.c b/dist/iscsi/src/util.c index c574baeb7dcf..69f52ba7c3fa 100644 --- a/dist/iscsi/src/util.c +++ b/dist/iscsi/src/util.c @@ -98,7 +98,7 @@ iscsi_malloc_atomic(unsigned n) void *ptr; ptr = malloc(n); - TRACE(TRACE_MEM, "iscsi_malloc_atomic(%i) = 0x%p\n", n, ptr); + iscsi_trace(TRACE_MEM, "iscsi_malloc_atomic(%i) = 0x%p\n", n, ptr); return ptr; } @@ -108,7 +108,7 @@ iscsi_malloc(unsigned n) void *ptr; ptr = malloc(n); - TRACE(TRACE_MEM, "iscsi_malloc_atomic(%i) = 0x%p\n", n, ptr); + iscsi_trace(TRACE_MEM, "iscsi_malloc_atomic(%i) = 0x%p\n", n, ptr); return ptr; } @@ -116,14 +116,14 @@ void iscsi_free_atomic(void *ptr) { (void) free(ptr); - TRACE(TRACE_MEM, "iscsi_free_atomic(0x%p)\n", ptr); + iscsi_trace(TRACE_MEM, "iscsi_free_atomic(0x%p)\n", ptr); } void iscsi_free(void *ptr) { (void) free(ptr); - TRACE(TRACE_MEM, "iscsi_free(0x%p)\n", ptr); + iscsi_trace(TRACE_MEM, "iscsi_free(0x%p)\n", ptr); } /* debugging levels */ @@ -150,11 +150,11 @@ int iscsi_thread_create(iscsi_thread_t * thread, void *(*proc) (void *), void *arg) { if (pthread_create(&thread->pthread, NULL, proc, arg) != 0) { - TRACE_ERROR("pthread_create() failed\n"); + iscsi_trace_error("pthread_create() failed\n"); return -1; } if (pthread_detach(thread->pthread) != 0) { - TRACE_ERROR("pthread_detach() failed\n"); + iscsi_trace_error("pthread_detach() failed\n"); return -1; } return 0; @@ -169,7 +169,7 @@ iscsi_queue_init(iscsi_queue_t * q, int depth) q->head = q->tail = q->count = 0; q->depth = depth; if ((q->elem = iscsi_malloc_atomic(depth * sizeof(void *))) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } iscsi_spin_init(&q->lock); @@ -201,7 +201,7 @@ iscsi_queue_insert(iscsi_queue_t * q, void *ptr) iscsi_spin_lock_irqsave(&q->lock, &flags); if (iscsi_queue_full(q)) { - TRACE_ERROR("QUEUE FULL\n"); + iscsi_trace_error("QUEUE FULL\n"); iscsi_spin_unlock_irqrestore(&q->lock, &flags); return -1; } @@ -222,7 +222,7 @@ iscsi_queue_remove(iscsi_queue_t * q) uint32_t flags = 0; iscsi_spin_lock_irqsave(&q->lock, &flags); if (!iscsi_queue_depth(q)) { - TRACE(TRACE_QUEUE, "QUEUE EMPTY\n"); + iscsi_trace(TRACE_QUEUE, "QUEUE EMPTY\n"); iscsi_spin_unlock_irqrestore(&q->lock, &flags); return NULL; } @@ -236,6 +236,84 @@ iscsi_queue_remove(iscsi_queue_t * q) return ptr; } +void +iscsi_trace(const int trace, const char *fmt, ...) +{ +#ifdef CONFIG_ISCSI_DEBUG + va_list vp; + char buf[8192]; + + if (iscsi_debug_level & trace) { + va_start(vp, fmt); + (void) snprintf(buf, sizeof(buf), fmt, vp); + printf("pid %i:%s:%d: %s", + ISCSI_GETPID, __FILE__, __LINE__, + buf); + va_end(vp); + } +#endif +} + +void +iscsi_trace_warning(const char *fmt, ...) +{ +#ifdef CONFIG_ISCSI_DEBUG + va_list vp; + char buf[8192]; + + if (iscsi_debug_level & TRACE_WARN) { + va_start(vp, fmt); + (void) snprintf(buf, sizeof(buf), fmt, vp); + printf("pid %i:%s:%d: ***WARNING*** %s", + ISCSI_GETPID, __FILE__, __LINE__, + buf); + va_end(vp); + } +#endif +} + +void +iscsi_trace_error(const char *fmt, ...) +{ +#ifdef CONFIG_ISCSI_DEBUG + va_list vp; + char buf[8192]; + + va_start(vp, fmt); + (void) snprintf(buf, sizeof(buf), fmt, vp); + va_end(vp); + printf("pid %i:%s:%d: ***WARNING*** %s", + ISCSI_GETPID, __FILE__, __LINE__, + buf); + syslog(LOG_ERR, "pid %d:%s:%d: ***ERROR*** %s", + ISCSI_GETPID, __FILE__, __LINE__, + buf); +#endif +} + +void +iscsi_print_buffer(const char *buf, const size_t len) +{ +#ifdef CONFIG_ISCSI_DEBUG + int i; + + if (iscsi_debug_level & TRACE_NET_BUFF) { + for (i=0 ; i < len; i++) { + if (i % 4 == 0) { + if (i) { + printf("\n"); + } + printf("%4i:", i); + } + printf("%2x ", (uint8_t) (buf)[i]); + } + if ((len + 1) % 32) { + printf("\n"); + } + } +#endif +} + /* * Hashing Functions */ @@ -251,7 +329,7 @@ hash_init(hash_t * h, int n) h->insertions = 0; h->collisions = 0; if ((h->bucket = iscsi_malloc_atomic(n * sizeof(initiator_cmd_t *))) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } for (i = 0; i < n; i++) @@ -270,13 +348,13 @@ hash_insert(hash_t * h, initiator_cmd_t * cmd, unsigned key) i = key % (h->n); if (h->bucket[i] == NULL) { - TRACE(TRACE_HASH, "inserting key %u (val 0x%p) into bucket[%i]\n", key, cmd, i); + iscsi_trace(TRACE_HASH, "inserting key %u (val 0x%p) into bucket[%i]\n", key, cmd, i); h->bucket[i] = cmd; } else { cmd->hash_next = h->bucket[i]; h->bucket[i] = cmd; h->collisions++; - TRACE(TRACE_HASH, "inserting key %u (val 0x%p) into bucket[%i] (collision)\n", key, cmd, i); + iscsi_trace(TRACE_HASH, "inserting key %u (val 0x%p) into bucket[%i] (collision)\n", key, cmd, i); } h->insertions++; iscsi_spin_unlock(&h->lock); @@ -293,7 +371,7 @@ hash_remove(hash_t * h, unsigned key) iscsi_spin_lock(&h->lock); i = key % (h->n); if (h->bucket[i] == NULL) { - TRACE_ERROR("bucket emtpy\n"); + iscsi_trace_error("bucket emtpy\n"); curr = NULL; } else { prev = NULL; @@ -303,18 +381,18 @@ hash_remove(hash_t * h, unsigned key) curr = curr->hash_next; } if (curr->key != key) { - TRACE_ERROR("key %u (0x%x) not found in bucket[%i]\n", key, key, i); + iscsi_trace_error("key %u (0x%x) not found in bucket[%i]\n", key, key, i); curr = NULL; } else { if (prev == NULL) { h->bucket[i] = h->bucket[i]->hash_next; - TRACE(TRACE_HASH, "removed key %u (val 0x%p) from head of bucket\n", key, curr); + iscsi_trace(TRACE_HASH, "removed key %u (val 0x%p) from head of bucket\n", key, curr); } else { prev->hash_next = curr->hash_next; if (prev->hash_next == NULL) { - TRACE(TRACE_HASH, "removed key %u (val 0x%p) from end of bucket\n", key, curr); + iscsi_trace(TRACE_HASH, "removed key %u (val 0x%p) from end of bucket\n", key, curr); } else { - TRACE(TRACE_HASH, "removed key %u (val 0x%p) from middle of bucket\n", key, curr); + iscsi_trace(TRACE_HASH, "removed key %u (val 0x%p) from middle of bucket\n", key, curr); } } } @@ -348,13 +426,13 @@ modify_iov(struct iovec ** iov_ptr, int *iovc, uint32_t offset, uint32_t length) for (i = 0; i < *iovc; i++) { len += iov[i].iov_len; if (len > offset) { - TRACE(TRACE_NET_IOV, "found offset %u in iov[%i]\n", offset, i); + iscsi_trace(TRACE_NET_IOV, "found offset %u in iov[%i]\n", offset, i); break; } disp -= iov[i].iov_len; } if (i == *iovc) { - TRACE_ERROR("sum of iov lens (%u) < offset (%u)\n", len, offset); + iscsi_trace_error("sum of iov lens (%u) < offset (%u)\n", len, offset); return -1; } iov[i].iov_len -= disp; @@ -374,14 +452,14 @@ modify_iov(struct iovec ** iov_ptr, int *iovc, uint32_t offset, uint32_t length) for (i = 0; i < *iovc; i++) { len += iov[i].iov_len; if (len >= length) { - TRACE(TRACE_NET_IOV, "length %u ends in iovec[%i]\n", length, i); + iscsi_trace(TRACE_NET_IOV, "length %u ends in iovec[%i]\n", length, i); break; } } if (i == *iovc) { - TRACE_ERROR("sum of iovec lens (%u) < length (%u)\n", len, length); + iscsi_trace_error("sum of iovec lens (%u) < length (%u)\n", len, length); for (i = 0; i < *iovc; i++) { - TRACE_ERROR("iov[%i].iov_base = %p (len %u)\n", i, iov[i].iov_base, (unsigned)iov[i].iov_len); + iscsi_trace_error("iov[%i].iov_base = %p (len %u)\n", i, iov[i].iov_base, (unsigned)iov[i].iov_len); } return -1; } @@ -389,13 +467,13 @@ modify_iov(struct iovec ** iov_ptr, int *iovc, uint32_t offset, uint32_t length) *iovc = i + 1; #ifdef CONFIG_ISCSI_DEBUG - TRACE(TRACE_NET_IOV, "new iov:\n"); + iscsi_trace(TRACE_NET_IOV, "new iov:\n"); len = 0; for (i = 0; i < *iovc; i++) { - TRACE(TRACE_NET_IOV, "iov[%i].iov_base = %p (len %u)\n", i, iov[i].iov_base, (unsigned)iov[i].iov_len); + iscsi_trace(TRACE_NET_IOV, "iov[%i].iov_base = %p (len %u)\n", i, iov[i].iov_base, (unsigned)iov[i].iov_len); len += iov[i].iov_len; } - TRACE(TRACE_NET_IOV, "new iov length: %u bytes\n", len); + iscsi_trace(TRACE_NET_IOV, "new iov length: %u bytes\n", len); #endif return 0; @@ -407,7 +485,7 @@ iscsi_sock_setsockopt(iscsi_socket_t * sock, int level, int optname, void *optva int rc; if ((rc = setsockopt(*sock, level, optname, optval, optlen)) != 0) { - TRACE_ERROR("sock->ops->setsockopt() failed: rc %i errno %i\n", rc, errno); + iscsi_trace_error("sock->ops->setsockopt() failed: rc %i errno %i\n", rc, errno); return -1; } return 0; @@ -419,7 +497,7 @@ iscsi_sock_getsockopt(iscsi_socket_t * sock, int level, int optname, void *optva int rc; if ((rc = getsockopt(*sock, level, optname, optval, optlen)) != 0) { - TRACE_ERROR("sock->ops->getsockopt() failed: rc %i errno %i\n", rc, errno); + iscsi_trace_error("sock->ops->getsockopt() failed: rc %i errno %i\n", rc, errno); return -1; } return 0; @@ -431,11 +509,11 @@ iscsi_sock_create(iscsi_socket_t * sock) int rc; if ((rc = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - TRACE_ERROR("socket() failed: rc %i errno %i\n", rc, errno); + iscsi_trace_error("socket() failed: rc %i errno %i\n", rc, errno); } *sock = rc; if (rc < 0) { - TRACE_ERROR("error creating socket (rc %i)\n", rc); + iscsi_trace_error("error creating socket (rc %i)\n", rc); return -1; } return 0; @@ -452,7 +530,7 @@ iscsi_sock_bind(iscsi_socket_t sock, int port) laddr.sin_addr.s_addr = INADDR_ANY; laddr.sin_port = ISCSI_HTON16(port); if ((rc = bind(sock, (struct sockaddr *) (void *) &laddr, sizeof(laddr))) < 0) { - TRACE_ERROR("bind() failed: rc %i errno %i\n", rc, errno); + iscsi_trace_error("bind() failed: rc %i errno %i\n", rc, errno); return -1; } return 0; @@ -464,7 +542,7 @@ iscsi_sock_listen(iscsi_socket_t sock) int rc; if ((rc = listen(sock, 32)) < 0) { - TRACE_ERROR("listen() failed: rc %i errno %i\n", rc, errno); + iscsi_trace_error("listen() failed: rc %i errno %i\n", rc, errno); return -1; } return 0; @@ -479,7 +557,7 @@ iscsi_sock_accept(iscsi_socket_t sock, iscsi_socket_t * newsock) remoteAddrLen = sizeof(remoteAddr); (void) memset(&remoteAddr, 0, sizeof(remoteAddr)); if ((*newsock = accept(sock, (struct sockaddr *) (void *)& remoteAddr, &remoteAddrLen)) < 0) { - TRACE(TRACE_NET_DEBUG, "accept() failed: rc %i errno %i\n", *newsock, errno); + iscsi_trace(TRACE_NET_DEBUG, "accept() failed: rc %i errno %i\n", *newsock, errno); return -1; } @@ -490,7 +568,7 @@ int iscsi_sock_getsockname(iscsi_socket_t sock, struct sockaddr * name, unsigned *namelen) { if (getsockname(sock, name, namelen) != 0) { - TRACE_ERROR("getsockame() failed (errno %i)\n", errno); + iscsi_trace_error("getsockame() failed (errno %i)\n", errno); return -1; } return 0; @@ -500,7 +578,7 @@ int iscsi_sock_getpeername(iscsi_socket_t sock, struct sockaddr * name, unsigned *namelen) { if (getpeername(sock, name, namelen) != 0) { - TRACE_ERROR("getpeername() failed (errno %i)\n", errno); + iscsi_trace_error("getpeername() failed (errno %i)\n", errno); return -1; } return 0; @@ -512,7 +590,7 @@ iscsi_sock_shutdown(iscsi_socket_t sock, int how) int rc; if ((rc = shutdown(sock, how)) != 0) { - TRACE(TRACE_NET_DEBUG, "shutdown() failed: rc %i, errno %i\n", rc, errno); + iscsi_trace(TRACE_NET_DEBUG, "shutdown() failed: rc %i, errno %i\n", rc, errno); } return 0; } @@ -523,7 +601,7 @@ iscsi_sock_close(iscsi_socket_t sock) int rc; if ((rc = close(sock)) != 0) { - TRACE_ERROR("close() failed: rc %i errno %i\n", rc, errno); + iscsi_trace_error("close() failed: rc %i errno %i\n", rc, errno); return -1; } return 0; @@ -548,14 +626,14 @@ iscsi_sock_connect(iscsi_socket_t sock, char *hostname, int port) addr.sin_addr.s_addr = inet_addr(hostname); #if ISCSI_SOCK_CONNECT_NONBLOCK == 1 if (fcntl(sock, F_SETFL, O_NONBLOCK) != 0) { - TRACE_ERROR("fcntl() failed"); + iscsi_trace_error("fcntl() failed"); return -1; } #endif rc = connect(sock, (struct sockaddr *) (void *) &addr, sizeof(addr)); #if ISCSI_SOCK_CONNECT_NONBLOCK == 1 if (fcntl(sock, F_SETFL, O_SYNC) != 0) { - TRACE_ERROR("fcntl() failed\n"); + iscsi_trace_error("fcntl() failed\n"); return -1; } #endif @@ -568,7 +646,7 @@ iscsi_sock_connect(iscsi_socket_t sock, char *hostname, int port) } if (errno == EAGAIN || errno == EINPROGRESS || errno == EALREADY) { if (i != ISCSI_SOCK_CONNECT_TIMEOUT - 1) { - PRINT("***SLEEPING***\n"); + printf("***SLEEPING***\n"); ISCSI_SLEEP(1); } } else { @@ -576,7 +654,7 @@ iscsi_sock_connect(iscsi_socket_t sock, char *hostname, int port) } } if (rc < 0) { - TRACE_ERROR("connect() to %s:%i failed (errno %i)\n", hostname, port, errno); + iscsi_trace_error("connect() to %s:%i failed (errno %i)\n", hostname, port, errno); } return rc; } @@ -600,9 +678,9 @@ iscsi_sock_msg(iscsi_socket_t sock, int xmit, unsigned len, void *data, int iovc uint32_t padding_len = 0; int total_len = 0; - TRACE(TRACE_NET_DEBUG, "%s %i bytes on sock\n", xmit ? "sending" : "receiving", len); + iscsi_trace(TRACE_NET_DEBUG, "%s %i bytes on sock\n", xmit ? "sending" : "receiving", len); if (iovc == 0) { - TRACE(TRACE_NET_DEBUG, "building singleton iovec (data %p, len %u)\n", data, len); + iscsi_trace(TRACE_NET_DEBUG, "building singleton iovec (data %p, len %u)\n", data, len); singleton.iov_base = data; singleton.iov_len = len; iov = &singleton; @@ -615,7 +693,7 @@ iscsi_sock_msg(iscsi_socket_t sock, int xmit, unsigned len, void *data, int iovc if ((remainder = len % ISCSI_SOCK_MSG_BYTE_ALIGN) != 0) { if ((iov_padding = iscsi_malloc_atomic((iovc + 1) * sizeof(struct iovec))) == NULL) { - TRACE_ERROR("iscsi_malloc_atomic() failed\n"); + iscsi_trace_error("iscsi_malloc_atomic() failed\n"); return -1; } memcpy(iov_padding, iov, iovc * sizeof(struct iovec)); @@ -626,7 +704,7 @@ iscsi_sock_msg(iscsi_socket_t sock, int xmit, unsigned len, void *data, int iovc iovc++; memset(padding, 0, padding_len); len += padding_len; - TRACE(TRACE_NET_DEBUG, "Added iovec for padding (len %u)\n", padding_len); + iscsi_trace(TRACE_NET_DEBUG, "Added iovec for padding (len %u)\n", padding_len); } /* * We make copy of iovec if we're in debugging mode, as we'll print @@ -641,47 +719,47 @@ iscsi_sock_msg(iscsi_socket_t sock, int xmit, unsigned len, void *data, int iovc /* Check iovec */ total_len = 0; - TRACE(TRACE_NET_DEBUG, "%s %i buffers\n", xmit ? "gathering from" : "scattering into", iovc); + iscsi_trace(TRACE_NET_DEBUG, "%s %i buffers\n", xmit ? "gathering from" : "scattering into", iovc); for (i = 0; i < iovc; i++) { - TRACE(TRACE_NET_IOV, "iov[%i].iov_base = %p, len %u\n", i, iov[i].iov_base, (unsigned)iov[i].iov_len); + iscsi_trace(TRACE_NET_IOV, "iov[%i].iov_base = %p, len %u\n", i, iov[i].iov_base, (unsigned)iov[i].iov_len); total_len += iov[i].iov_len; } if (total_len != len - n) { - TRACE_ERROR("iovcs sum to %i != total len of %i\n", total_len, len - n); - TRACE_ERROR("iov = %p\n", iov); + iscsi_trace_error("iovcs sum to %i != total len of %i\n", total_len, len - n); + iscsi_trace_error("iov = %p\n", iov); for (i = 0; i < iovc; i++) { - TRACE_ERROR("iov[%i].iov_base = %p, len %u\n", + iscsi_trace_error("iov[%i].iov_base = %p, len %u\n", i, iov[i].iov_base, (unsigned)iov[i].iov_len); } return -1; } if ((rc = (xmit) ? writev(sock, iov, iovc) : readv(sock, iov, iovc)) == 0) { - TRACE(TRACE_NET_DEBUG, "%s() failed: rc %i errno %i\n", (xmit) ? "writev" : "readv", rc, errno); + iscsi_trace(TRACE_NET_DEBUG, "%s() failed: rc %i errno %i\n", (xmit) ? "writev" : "readv", rc, errno); break; } else if (rc < 0) { /* Temp FIXME */ - TRACE_ERROR("%s() failed: rc %i errno %i\n", (xmit)?"writev":"readv", rc, errno); + iscsi_trace_error("%s() failed: rc %i errno %i\n", (xmit)?"writev":"readv", rc, errno); break; } n += rc; if (n < len) { - TRACE(TRACE_NET_DEBUG, "Got partial %s: %i bytes of %i\n", (xmit) ? "send" : "recv", rc, len - n + rc); + iscsi_trace(TRACE_NET_DEBUG, "Got partial %s: %i bytes of %i\n", (xmit) ? "send" : "recv", rc, len - n + rc); total_len = 0; for (i = 0; i < iovc; i++) { total_len += iov[i].iov_len; } - TRACE(TRACE_NET_IOV, "before modify_iov: %s %i buffers, total_len = %u, n = %u, rc = %u\n", + iscsi_trace(TRACE_NET_IOV, "before modify_iov: %s %i buffers, total_len = %u, n = %u, rc = %u\n", xmit ? "gathering from" : "scattering into", iovc, total_len, n, rc); if (modify_iov(&iov, &iovc, (unsigned) rc, len - n) != 0) { - TRACE_ERROR("modify_iov() failed\n"); + iscsi_trace_error("modify_iov() failed\n"); break; } total_len = 0; for (i = 0; i < iovc; i++) { total_len += iov[i].iov_len; } - TRACE(TRACE_NET_IOV, "after modify_iov: %s %i buffers, total_len = %u, n = %u, rc = %u\n\n", + iscsi_trace(TRACE_NET_IOV, "after modify_iov: %s %i buffers, total_len = %u, n = %u, rc = %u\n\n", xmit ? "gathering from" : "scattering into", iovc, total_len, n, rc); } } while (n < len); @@ -689,7 +767,7 @@ iscsi_sock_msg(iscsi_socket_t sock, int xmit, unsigned len, void *data, int iovc if (remainder) { iscsi_free_atomic(iov_padding); } - TRACE(TRACE_NET_DEBUG, "successfully %s %i bytes on sock (%i bytes padding)\n", xmit ? "sent" : "received", n, padding_len); + iscsi_trace(TRACE_NET_DEBUG, "successfully %s %i bytes on sock (%i bytes padding)\n", xmit ? "sent" : "received", n, padding_len); return n - padding_len; } @@ -713,7 +791,7 @@ iscsi_sock_send_header_and_data(iscsi_socket_t sock, if (data_len && data_len <= ISCSI_SOCK_HACK_CROSSOVER) { /* combine header and data into one iovec */ if (iovc >= ISCSI_MAX_IOVECS) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); return -1; } if (iovc == 0) { @@ -729,16 +807,16 @@ iscsi_sock_send_header_and_data(iscsi_socket_t sock, iovc += 1; } if (iscsi_sock_msg(sock, Transmit, header_len + data_len, iov, iovc) != header_len + data_len) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); return -1; } } else { if (iscsi_sock_msg(sock, Transmit, header_len, header, 0) != header_len) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); return -1; } if (data_len != 0 && iscsi_sock_msg(sock, Transmit, data_len, __UNCONST((const char *) data), iovc) != data_len) { - TRACE_ERROR("iscsi_sock_msg() failed\n"); + iscsi_trace_error("iscsi_sock_msg() failed\n"); return -1; } } @@ -860,7 +938,7 @@ uint32_t iscsi_atoi(char *value) { if (value == NULL) { - TRACE_ERROR("iscsi_atoi() called with NULL value\n"); + iscsi_trace_error("iscsi_atoi() called with NULL value\n"); return 0; } return atoi(value);