Skip to content

Commit 05c7808

Browse files
committed
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull SCSI target updates from Nicholas Bellinger: "Here are the outstanding target-pending updates for v4.3-rc1. Mostly bug-fixes and minor changes this round. The fallout from the big v4.2-rc1 RCU conversion have (thus far) been minimal. The highlights this round include: - Move sense handling routines into scsi_common code (Sagi) - Return ABORTED_COMMAND sense key for PI errors (Sagi) - Add tpg_enabled_sendtargets attribute for disabled iscsi-target discovery (David) - Shrink target struct se_cmd by rearranging fields (Roland) - Drop iSCSI use of mutex around max_cmd_sn increment (Roland) - Replace iSCSI __kernel_sockaddr_storage with sockaddr_storage (Andy + Chris) - Honor fabric max_data_sg_nents I/O transfer limit (Arun + Himanshu + nab) - Fix EXTENDED_COPY >= v4.1 regression OOPsen (Alex + nab)" * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (37 commits) target: use stringify.h instead of own definition target/user: Fix UFLAG_UNKNOWN_OP handling target: Remove no-op conditional target/user: Remove unused variable target: Fix max_cmd_sn increment w/o cmdsn mutex regressions target: Attach EXTENDED_COPY local I/O descriptors to xcopy_pt_sess target/qla2xxx: Honor max_data_sg_nents I/O transfer limit target/iscsi: Replace __kernel_sockaddr_storage with sockaddr_storage target/iscsi: Replace conn->login_ip with login_sockaddr target/iscsi: Keep local_ip as the actual sockaddr target/iscsi: Fix np_ip bracket issue by removing np_ip target: Drop iSCSI use of mutex around max_cmd_sn increment qla2xxx: Update tcm_qla2xxx module description to 24xx+ iscsi-target: Add tpg_enabled_sendtargets for disabled discovery drivers: target: Drop unlikely before IS_ERR(_OR_NULL) target: check DPO/FUA usage for COMPARE AND WRITE target: Shrink struct se_cmd by rearranging fields target: Remove cmd->se_ordered_id (unused except debug log lines) target: add support for START_STOP_UNIT SCSI opcode target: improve unsupported opcode message ...
2 parents 8e78b7d + ac64a2c commit 05c7808

38 files changed

+675
-633
lines changed

drivers/infiniband/ulp/isert/ib_isert.c

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,7 +3095,7 @@ isert_setup_id(struct isert_np *isert_np)
30953095

30963096
static int
30973097
isert_setup_np(struct iscsi_np *np,
3098-
struct __kernel_sockaddr_storage *ksockaddr)
3098+
struct sockaddr_storage *ksockaddr)
30993099
{
31003100
struct isert_np *isert_np;
31013101
struct rdma_cm_id *isert_lid;
@@ -3117,7 +3117,7 @@ isert_setup_np(struct iscsi_np *np,
31173117
* in iscsi_target_configfs.c code..
31183118
*/
31193119
memcpy(&np->np_sockaddr, ksockaddr,
3120-
sizeof(struct __kernel_sockaddr_storage));
3120+
sizeof(struct sockaddr_storage));
31213121

31223122
isert_lid = isert_setup_id(isert_np);
31233123
if (IS_ERR(isert_lid)) {
@@ -3199,32 +3199,11 @@ isert_set_conn_info(struct iscsi_np *np, struct iscsi_conn *conn,
31993199
{
32003200
struct rdma_cm_id *cm_id = isert_conn->cm_id;
32013201
struct rdma_route *cm_route = &cm_id->route;
3202-
struct sockaddr_in *sock_in;
3203-
struct sockaddr_in6 *sock_in6;
32043202

32053203
conn->login_family = np->np_sockaddr.ss_family;
32063204

3207-
if (np->np_sockaddr.ss_family == AF_INET6) {
3208-
sock_in6 = (struct sockaddr_in6 *)&cm_route->addr.dst_addr;
3209-
snprintf(conn->login_ip, sizeof(conn->login_ip), "%pI6c",
3210-
&sock_in6->sin6_addr.in6_u);
3211-
conn->login_port = ntohs(sock_in6->sin6_port);
3212-
3213-
sock_in6 = (struct sockaddr_in6 *)&cm_route->addr.src_addr;
3214-
snprintf(conn->local_ip, sizeof(conn->local_ip), "%pI6c",
3215-
&sock_in6->sin6_addr.in6_u);
3216-
conn->local_port = ntohs(sock_in6->sin6_port);
3217-
} else {
3218-
sock_in = (struct sockaddr_in *)&cm_route->addr.dst_addr;
3219-
sprintf(conn->login_ip, "%pI4",
3220-
&sock_in->sin_addr.s_addr);
3221-
conn->login_port = ntohs(sock_in->sin_port);
3222-
3223-
sock_in = (struct sockaddr_in *)&cm_route->addr.src_addr;
3224-
sprintf(conn->local_ip, "%pI4",
3225-
&sock_in->sin_addr.s_addr);
3226-
conn->local_port = ntohs(sock_in->sin_port);
3227-
}
3205+
conn->login_sockaddr = cm_route->addr.dst_addr;
3206+
conn->local_sockaddr = cm_route->addr.src_addr;
32283207
}
32293208

32303209
static int

drivers/scsi/libiscsi.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -853,12 +853,9 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
853853
SAM_STAT_CHECK_CONDITION;
854854
scsi_build_sense_buffer(1, sc->sense_buffer,
855855
ILLEGAL_REQUEST, 0x10, ascq);
856-
sc->sense_buffer[7] = 0xc; /* Additional sense length */
857-
sc->sense_buffer[8] = 0; /* Information desc type */
858-
sc->sense_buffer[9] = 0xa; /* Additional desc length */
859-
sc->sense_buffer[10] = 0x80; /* Validity bit */
860-
861-
put_unaligned_be64(sector, &sc->sense_buffer[12]);
856+
scsi_set_sense_information(sc->sense_buffer,
857+
SCSI_SENSE_BUFFERSIZE,
858+
sector);
862859
goto out;
863860
}
864861
}

drivers/scsi/qla2xxx/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ config SCSI_QLA_FC
3232
They are also included in the linux-firmware tree as well.
3333

3434
config TCM_QLA2XXX
35-
tristate "TCM_QLA2XXX fabric module for Qlogic 2xxx series target mode HBAs"
35+
tristate "TCM_QLA2XXX fabric module for QLogic 24xx+ series target mode HBAs"
3636
depends on SCSI_QLA_FC && TARGET_CORE
3737
depends on LIBFC
3838
select BTREE
3939
default n
4040
---help---
41-
Say Y here to enable the TCM_QLA2XXX fabric module for Qlogic 2xxx series target mode HBAs
41+
Say Y here to enable the TCM_QLA2XXX fabric module for QLogic 24xx+ series target mode HBAs

drivers/scsi/qla2xxx/tcm_qla2xxx.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,9 +1359,7 @@ static void tcm_qla2xxx_free_session(struct qla_tgt_sess *sess)
13591359
struct qla_hw_data *ha = tgt->ha;
13601360
scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
13611361
struct se_session *se_sess;
1362-
struct se_node_acl *se_nacl;
13631362
struct tcm_qla2xxx_lport *lport;
1364-
struct tcm_qla2xxx_nacl *nacl;
13651363

13661364
BUG_ON(in_interrupt());
13671365

@@ -1371,8 +1369,6 @@ static void tcm_qla2xxx_free_session(struct qla_tgt_sess *sess)
13711369
dump_stack();
13721370
return;
13731371
}
1374-
se_nacl = se_sess->se_node_acl;
1375-
nacl = container_of(se_nacl, struct tcm_qla2xxx_nacl, se_node_acl);
13761372

13771373
lport = vha->vha_tgt.target_lport_ptr;
13781374
if (!lport) {
@@ -1680,7 +1676,6 @@ static int tcm_qla2xxx_lport_register_npiv_cb(struct scsi_qla_host *base_vha,
16801676
(struct tcm_qla2xxx_lport *)target_lport_ptr;
16811677
struct tcm_qla2xxx_lport *base_lport =
16821678
(struct tcm_qla2xxx_lport *)base_vha->vha_tgt.target_lport_ptr;
1683-
struct tcm_qla2xxx_tpg *base_tpg;
16841679
struct fc_vport_identifiers vport_id;
16851680

16861681
if (!qla_tgt_mode_enabled(base_vha)) {
@@ -1693,7 +1688,6 @@ static int tcm_qla2xxx_lport_register_npiv_cb(struct scsi_qla_host *base_vha,
16931688
pr_err("qla2xxx base_lport or tpg_1 not available\n");
16941689
return -EPERM;
16951690
}
1696-
base_tpg = base_lport->tpg_1;
16971691

16981692
memset(&vport_id, 0, sizeof(vport_id));
16991693
vport_id.port_name = npiv_wwpn;
@@ -1810,6 +1804,11 @@ static const struct target_core_fabric_ops tcm_qla2xxx_ops = {
18101804
.module = THIS_MODULE,
18111805
.name = "qla2xxx",
18121806
.node_acl_size = sizeof(struct tcm_qla2xxx_nacl),
1807+
/*
1808+
* XXX: Limit assumes single page per scatter-gather-list entry.
1809+
* Current maximum is ~4.9 MB per se_cmd->t_data_sg with PAGE_SIZE=4096
1810+
*/
1811+
.max_data_sg_nents = 1200,
18131812
.get_fabric_name = tcm_qla2xxx_get_fabric_name,
18141813
.tpg_get_wwn = tcm_qla2xxx_get_fabric_wwn,
18151814
.tpg_get_tag = tcm_qla2xxx_get_tag,
@@ -1958,7 +1957,7 @@ static void __exit tcm_qla2xxx_exit(void)
19581957
tcm_qla2xxx_deregister_configfs();
19591958
}
19601959

1961-
MODULE_DESCRIPTION("TCM QLA2XXX series NPIV enabled fabric driver");
1960+
MODULE_DESCRIPTION("TCM QLA24XX+ series NPIV enabled fabric driver");
19621961
MODULE_LICENSE("GPL");
19631962
module_init(tcm_qla2xxx_init);
19641963
module_exit(tcm_qla2xxx_exit);

drivers/scsi/scsi_common.c

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <linux/bug.h>
66
#include <linux/kernel.h>
77
#include <linux/string.h>
8+
#include <linux/errno.h>
9+
#include <asm/unaligned.h>
810
#include <scsi/scsi_common.h>
911

1012
/* NB: These are exposed through /proc/scsi/scsi and form part of the ABI.
@@ -176,3 +178,110 @@ bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
176178
return true;
177179
}
178180
EXPORT_SYMBOL(scsi_normalize_sense);
181+
182+
/**
183+
* scsi_sense_desc_find - search for a given descriptor type in descriptor sense data format.
184+
* @sense_buffer: byte array of descriptor format sense data
185+
* @sb_len: number of valid bytes in sense_buffer
186+
* @desc_type: value of descriptor type to find
187+
* (e.g. 0 -> information)
188+
*
189+
* Notes:
190+
* only valid when sense data is in descriptor format
191+
*
192+
* Return value:
193+
* pointer to start of (first) descriptor if found else NULL
194+
*/
195+
const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len,
196+
int desc_type)
197+
{
198+
int add_sen_len, add_len, desc_len, k;
199+
const u8 * descp;
200+
201+
if ((sb_len < 8) || (0 == (add_sen_len = sense_buffer[7])))
202+
return NULL;
203+
if ((sense_buffer[0] < 0x72) || (sense_buffer[0] > 0x73))
204+
return NULL;
205+
add_sen_len = (add_sen_len < (sb_len - 8)) ?
206+
add_sen_len : (sb_len - 8);
207+
descp = &sense_buffer[8];
208+
for (desc_len = 0, k = 0; k < add_sen_len; k += desc_len) {
209+
descp += desc_len;
210+
add_len = (k < (add_sen_len - 1)) ? descp[1]: -1;
211+
desc_len = add_len + 2;
212+
if (descp[0] == desc_type)
213+
return descp;
214+
if (add_len < 0) // short descriptor ??
215+
break;
216+
}
217+
return NULL;
218+
}
219+
EXPORT_SYMBOL(scsi_sense_desc_find);
220+
221+
/**
222+
* scsi_build_sense_buffer - build sense data in a buffer
223+
* @desc: Sense format (non zero == descriptor format,
224+
* 0 == fixed format)
225+
* @buf: Where to build sense data
226+
* @key: Sense key
227+
* @asc: Additional sense code
228+
* @ascq: Additional sense code qualifier
229+
*
230+
**/
231+
void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq)
232+
{
233+
if (desc) {
234+
buf[0] = 0x72; /* descriptor, current */
235+
buf[1] = key;
236+
buf[2] = asc;
237+
buf[3] = ascq;
238+
buf[7] = 0;
239+
} else {
240+
buf[0] = 0x70; /* fixed, current */
241+
buf[2] = key;
242+
buf[7] = 0xa;
243+
buf[12] = asc;
244+
buf[13] = ascq;
245+
}
246+
}
247+
EXPORT_SYMBOL(scsi_build_sense_buffer);
248+
249+
/**
250+
* scsi_set_sense_information - set the information field in a
251+
* formatted sense data buffer
252+
* @buf: Where to build sense data
253+
* @buf_len: buffer length
254+
* @info: 64-bit information value to be set
255+
*
256+
* Return value:
257+
* 0 on success or EINVAL for invalid sense buffer length
258+
**/
259+
int scsi_set_sense_information(u8 *buf, int buf_len, u64 info)
260+
{
261+
if ((buf[0] & 0x7f) == 0x72) {
262+
u8 *ucp, len;
263+
264+
len = buf[7];
265+
ucp = (char *)scsi_sense_desc_find(buf, len + 8, 0);
266+
if (!ucp) {
267+
buf[7] = len + 0xc;
268+
ucp = buf + 8 + len;
269+
}
270+
271+
if (buf_len < len + 0xc)
272+
/* Not enough room for info */
273+
return -EINVAL;
274+
275+
ucp[0] = 0;
276+
ucp[1] = 0xa;
277+
ucp[2] = 0x80; /* Valid bit */
278+
ucp[3] = 0;
279+
put_unaligned_be64(info, &ucp[4]);
280+
} else if ((buf[0] & 0x7f) == 0x70) {
281+
buf[0] |= 0x80;
282+
put_unaligned_be64(info, &buf[3]);
283+
}
284+
285+
return 0;
286+
}
287+
EXPORT_SYMBOL(scsi_set_sense_information);

drivers/scsi/scsi_error.c

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <scsi/scsi_device.h>
3434
#include <scsi/scsi_driver.h>
3535
#include <scsi/scsi_eh.h>
36+
#include <scsi/scsi_common.h>
3637
#include <scsi/scsi_transport.h>
3738
#include <scsi/scsi_host.h>
3839
#include <scsi/scsi_ioctl.h>
@@ -2424,45 +2425,6 @@ bool scsi_command_normalize_sense(const struct scsi_cmnd *cmd,
24242425
}
24252426
EXPORT_SYMBOL(scsi_command_normalize_sense);
24262427

2427-
/**
2428-
* scsi_sense_desc_find - search for a given descriptor type in descriptor sense data format.
2429-
* @sense_buffer: byte array of descriptor format sense data
2430-
* @sb_len: number of valid bytes in sense_buffer
2431-
* @desc_type: value of descriptor type to find
2432-
* (e.g. 0 -> information)
2433-
*
2434-
* Notes:
2435-
* only valid when sense data is in descriptor format
2436-
*
2437-
* Return value:
2438-
* pointer to start of (first) descriptor if found else NULL
2439-
*/
2440-
const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len,
2441-
int desc_type)
2442-
{
2443-
int add_sen_len, add_len, desc_len, k;
2444-
const u8 * descp;
2445-
2446-
if ((sb_len < 8) || (0 == (add_sen_len = sense_buffer[7])))
2447-
return NULL;
2448-
if ((sense_buffer[0] < 0x72) || (sense_buffer[0] > 0x73))
2449-
return NULL;
2450-
add_sen_len = (add_sen_len < (sb_len - 8)) ?
2451-
add_sen_len : (sb_len - 8);
2452-
descp = &sense_buffer[8];
2453-
for (desc_len = 0, k = 0; k < add_sen_len; k += desc_len) {
2454-
descp += desc_len;
2455-
add_len = (k < (add_sen_len - 1)) ? descp[1]: -1;
2456-
desc_len = add_len + 2;
2457-
if (descp[0] == desc_type)
2458-
return descp;
2459-
if (add_len < 0) // short descriptor ??
2460-
break;
2461-
}
2462-
return NULL;
2463-
}
2464-
EXPORT_SYMBOL(scsi_sense_desc_find);
2465-
24662428
/**
24672429
* scsi_get_sense_info_fld - get information field from sense data (either fixed or descriptor format)
24682430
* @sense_buffer: byte array of sense data
@@ -2512,31 +2474,3 @@ int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len,
25122474
}
25132475
}
25142476
EXPORT_SYMBOL(scsi_get_sense_info_fld);
2515-
2516-
/**
2517-
* scsi_build_sense_buffer - build sense data in a buffer
2518-
* @desc: Sense format (non zero == descriptor format,
2519-
* 0 == fixed format)
2520-
* @buf: Where to build sense data
2521-
* @key: Sense key
2522-
* @asc: Additional sense code
2523-
* @ascq: Additional sense code qualifier
2524-
*
2525-
**/
2526-
void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq)
2527-
{
2528-
if (desc) {
2529-
buf[0] = 0x72; /* descriptor, current */
2530-
buf[1] = key;
2531-
buf[2] = asc;
2532-
buf[3] = ascq;
2533-
buf[7] = 0;
2534-
} else {
2535-
buf[0] = 0x70; /* fixed, current */
2536-
buf[2] = key;
2537-
buf[7] = 0xa;
2538-
buf[12] = asc;
2539-
buf[13] = ascq;
2540-
}
2541-
}
2542-
EXPORT_SYMBOL(scsi_build_sense_buffer);

0 commit comments

Comments
 (0)