Skip to content

Commit 55bdabd

Browse files
Andy GroverNicholas Bellinger
authored andcommitted
iscsi: Use struct scsi_lun in iscsi structs instead of u8[8]
struct scsi_lun is also just a struct with an array of 8 octets (64 bits) but using it instead in iscsi structs lets us call scsilun_to_int without a cast, and also lets us copy it using assignment, instead of memcpy(). Signed-off-by: Andy Grover <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent 1235218 commit 55bdabd

File tree

5 files changed

+23
-24
lines changed

5 files changed

+23
-24
lines changed

drivers/scsi/be2iscsi/be_main.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3963,11 +3963,10 @@ static int beiscsi_iotask(struct iscsi_task *task, struct scatterlist *sg,
39633963
}
39643964
memcpy(&io_task->cmd_bhs->iscsi_data_pdu.
39653965
dw[offsetof(struct amap_pdu_data_out, lun) / 32],
3966-
io_task->cmd_bhs->iscsi_hdr.lun, sizeof(struct scsi_lun));
3966+
&io_task->cmd_bhs->iscsi_hdr.lun, sizeof(struct scsi_lun));
39673967

39683968
AMAP_SET_BITS(struct amap_iscsi_wrb, lun, pwrb,
3969-
cpu_to_be16((unsigned short)io_task->cmd_bhs->iscsi_hdr.
3970-
lun[0]));
3969+
cpu_to_be16(*(unsigned short *)&io_task->cmd_bhs->iscsi_hdr.lun));
39713970
AMAP_SET_BITS(struct amap_iscsi_wrb, r2t_exp_dtl, pwrb, xferlen);
39723971
AMAP_SET_BITS(struct amap_iscsi_wrb, wrb_idx, pwrb,
39733972
io_task->pwrb_handle->wrb_index);

drivers/scsi/bnx2i/bnx2i_hwi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
430430
default:
431431
tmfabort_wqe->ref_itt = RESERVED_ITT;
432432
}
433-
memcpy(scsi_lun, tmfabort_hdr->lun, sizeof(struct scsi_lun));
433+
memcpy(scsi_lun, &tmfabort_hdr->lun, sizeof(struct scsi_lun));
434434
tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]);
435435
tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]);
436436

@@ -547,7 +547,7 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,
547547

548548
nopout_wqe->op_code = nopout_hdr->opcode;
549549
nopout_wqe->op_attr = ISCSI_FLAG_CMD_FINAL;
550-
memcpy(nopout_wqe->lun, nopout_hdr->lun, 8);
550+
memcpy(nopout_wqe->lun, &nopout_hdr->lun, 8);
551551

552552
if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) {
553553
u32 tmp = nopout_wqe->lun[0];
@@ -1711,7 +1711,7 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
17111711
hdr->flags = ISCSI_FLAG_CMD_FINAL;
17121712
hdr->itt = task->hdr->itt;
17131713
hdr->ttt = cpu_to_be32(nop_in->ttt);
1714-
memcpy(hdr->lun, nop_in->lun, 8);
1714+
memcpy(&hdr->lun, nop_in->lun, 8);
17151715
}
17161716
done:
17171717
__iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0);
@@ -1754,7 +1754,7 @@ static void bnx2i_process_async_mesg(struct iscsi_session *session,
17541754
resp_hdr->opcode = async_cqe->op_code;
17551755
resp_hdr->flags = 0x80;
17561756

1757-
memcpy(resp_hdr->lun, async_cqe->lun, 8);
1757+
memcpy(&resp_hdr->lun, async_cqe->lun, 8);
17581758
resp_hdr->exp_cmdsn = cpu_to_be32(async_cqe->exp_cmd_sn);
17591759
resp_hdr->max_cmdsn = cpu_to_be32(async_cqe->max_cmd_sn);
17601760

drivers/scsi/libiscsi.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void iscsi_prep_data_out_pdu(struct iscsi_task *task, struct iscsi_r2t_info *r2t
169169
hdr->datasn = cpu_to_be32(r2t->datasn);
170170
r2t->datasn++;
171171
hdr->opcode = ISCSI_OP_SCSI_DATA_OUT;
172-
memcpy(hdr->lun, task->lun, sizeof(hdr->lun));
172+
hdr->lun = task->lun;
173173
hdr->itt = task->hdr_itt;
174174
hdr->exp_statsn = r2t->exp_statsn;
175175
hdr->offset = cpu_to_be32(r2t->data_offset + r2t->sent);
@@ -296,7 +296,7 @@ static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode)
296296
/*
297297
* Allow PDUs for unrelated LUNs
298298
*/
299-
hdr_lun = scsilun_to_int((struct scsi_lun *)tmf->lun);
299+
hdr_lun = scsilun_to_int(&tmf->lun);
300300
if (hdr_lun != task->sc->device->lun)
301301
return 0;
302302
/* fall through */
@@ -389,8 +389,8 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
389389
return rc;
390390
hdr->opcode = ISCSI_OP_SCSI_CMD;
391391
hdr->flags = ISCSI_ATTR_SIMPLE;
392-
int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
393-
memcpy(task->lun, hdr->lun, sizeof(task->lun));
392+
int_to_scsilun(sc->device->lun, &hdr->lun);
393+
task->lun = hdr->lun;
394394
hdr->exp_statsn = cpu_to_be32(conn->exp_statsn);
395395
cmd_len = sc->cmd_len;
396396
if (cmd_len < ISCSI_CDB_SIZE)
@@ -968,7 +968,7 @@ static void iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
968968
hdr.flags = ISCSI_FLAG_CMD_FINAL;
969969

970970
if (rhdr) {
971-
memcpy(hdr.lun, rhdr->lun, 8);
971+
hdr.lun = rhdr->lun;
972972
hdr.ttt = rhdr->ttt;
973973
hdr.itt = RESERVED_ITT;
974974
} else
@@ -2092,7 +2092,7 @@ static void iscsi_prep_abort_task_pdu(struct iscsi_task *task,
20922092
hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
20932093
hdr->flags = ISCSI_TM_FUNC_ABORT_TASK & ISCSI_FLAG_TM_FUNC_MASK;
20942094
hdr->flags |= ISCSI_FLAG_CMD_FINAL;
2095-
memcpy(hdr->lun, task->lun, sizeof(hdr->lun));
2095+
hdr->lun = task->lun;
20962096
hdr->rtt = task->hdr_itt;
20972097
hdr->refcmdsn = task->cmdsn;
20982098
}
@@ -2233,7 +2233,7 @@ static void iscsi_prep_lun_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr)
22332233
hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
22342234
hdr->flags = ISCSI_TM_FUNC_LOGICAL_UNIT_RESET & ISCSI_FLAG_TM_FUNC_MASK;
22352235
hdr->flags |= ISCSI_FLAG_CMD_FINAL;
2236-
int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
2236+
int_to_scsilun(sc->device->lun, &hdr->lun);
22372237
hdr->rtt = RESERVED_ITT;
22382238
}
22392239

include/scsi/iscsi_proto.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct iscsi_hdr {
6060
uint8_t rsvd2[2];
6161
uint8_t hlength; /* AHSs total length */
6262
uint8_t dlength[3]; /* Data length */
63-
uint8_t lun[8];
63+
struct scsi_lun lun;
6464
itt_t itt; /* Initiator Task Tag, opaque for target */
6565
__be32 ttt; /* Target Task Tag */
6666
__be32 statsn;
@@ -122,7 +122,7 @@ struct iscsi_scsi_req {
122122
__be16 rsvd2;
123123
uint8_t hlength;
124124
uint8_t dlength[3];
125-
uint8_t lun[8];
125+
struct scsi_lun lun;
126126
itt_t itt; /* Initiator Task Tag */
127127
__be32 data_length;
128128
__be32 cmdsn;
@@ -198,7 +198,7 @@ struct iscsi_async {
198198
uint8_t rsvd2[2];
199199
uint8_t rsvd3;
200200
uint8_t dlength[3];
201-
uint8_t lun[8];
201+
struct scsi_lun lun;
202202
uint8_t rsvd4[8];
203203
__be32 statsn;
204204
__be32 exp_cmdsn;
@@ -226,7 +226,7 @@ struct iscsi_nopout {
226226
__be16 rsvd2;
227227
uint8_t rsvd3;
228228
uint8_t dlength[3];
229-
uint8_t lun[8];
229+
struct scsi_lun lun;
230230
itt_t itt; /* Initiator Task Tag */
231231
__be32 ttt; /* Target Transfer Tag */
232232
__be32 cmdsn;
@@ -241,7 +241,7 @@ struct iscsi_nopin {
241241
__be16 rsvd2;
242242
uint8_t rsvd3;
243243
uint8_t dlength[3];
244-
uint8_t lun[8];
244+
struct scsi_lun lun;
245245
itt_t itt; /* Initiator Task Tag */
246246
__be32 ttt; /* Target Transfer Tag */
247247
__be32 statsn;
@@ -257,7 +257,7 @@ struct iscsi_tm {
257257
uint8_t rsvd1[2];
258258
uint8_t hlength;
259259
uint8_t dlength[3];
260-
uint8_t lun[8];
260+
struct scsi_lun lun;
261261
itt_t itt; /* Initiator Task Tag */
262262
itt_t rtt; /* Reference Task Tag */
263263
__be32 cmdsn;
@@ -315,7 +315,7 @@ struct iscsi_r2t_rsp {
315315
uint8_t rsvd2[2];
316316
uint8_t hlength;
317317
uint8_t dlength[3];
318-
uint8_t lun[8];
318+
struct scsi_lun lun;
319319
itt_t itt; /* Initiator Task Tag */
320320
__be32 ttt; /* Target Transfer Tag */
321321
__be32 statsn;
@@ -333,7 +333,7 @@ struct iscsi_data {
333333
uint8_t rsvd2[2];
334334
uint8_t rsvd3;
335335
uint8_t dlength[3];
336-
uint8_t lun[8];
336+
struct scsi_lun lun;
337337
itt_t itt;
338338
__be32 ttt;
339339
__be32 rsvd4;
@@ -353,7 +353,7 @@ struct iscsi_data_rsp {
353353
uint8_t cmd_status;
354354
uint8_t hlength;
355355
uint8_t dlength[3];
356-
uint8_t lun[8];
356+
struct scsi_lun lun;
357357
itt_t itt;
358358
__be32 ttt;
359359
__be32 statsn;

include/scsi/libiscsi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ struct iscsi_task {
115115
/* copied values in case we need to send tmfs */
116116
itt_t hdr_itt;
117117
__be32 cmdsn;
118-
uint8_t lun[8];
118+
struct scsi_lun lun;
119119

120120
int itt; /* this ITT */
121121

0 commit comments

Comments
 (0)