Skip to content

Commit 5f27eda

Browse files
author
Nicholas Bellinger
committed
sbp-target: Convert to TARGET_SCF_ACK_KREF I/O krefs
This patch converts sbp-target to modern TARGET_SCF_ACK_KREF usage for sbp_send_status() callback path, and drops the now obsolete sbp_free_request() failure path calls. Acked-by: Chris Boot <bootc@bootc.net> Tested-by: Chris Boot <bootc@bootc.net> Cc: Christoph Hellwig <hch@lst.de> Cc: Hannes Reinecke <hare@suse.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent 5a3ee22 commit 5f27eda

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

drivers/target/sbp/sbp_target.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,6 @@ static void tgt_agent_process_work(struct work_struct *work)
893893
STATUS_BLOCK_SBP_STATUS(
894894
SBP_STATUS_REQ_TYPE_NOTSUPP));
895895
sbp_send_status(req);
896-
sbp_free_request(req);
897896
return;
898897
case 3: /* Dummy ORB */
899898
req->status.status |= cpu_to_be32(
@@ -904,7 +903,6 @@ static void tgt_agent_process_work(struct work_struct *work)
904903
STATUS_BLOCK_SBP_STATUS(
905904
SBP_STATUS_DUMMY_ORB_COMPLETE));
906905
sbp_send_status(req);
907-
sbp_free_request(req);
908906
return;
909907
default:
910908
BUG();
@@ -989,7 +987,6 @@ static void tgt_agent_fetch_work(struct work_struct *work)
989987
spin_unlock_bh(&agent->lock);
990988

991989
sbp_send_status(req);
992-
sbp_free_request(req);
993990
return;
994991
}
995992

@@ -1236,7 +1233,7 @@ static void sbp_handle_command(struct sbp_target_request *req)
12361233
req->se_cmd.tag = req->orb_pointer;
12371234
if (target_submit_cmd(&req->se_cmd, sess->se_sess, req->cmd_buf,
12381235
req->sense_buf, unpacked_lun, data_length,
1239-
TCM_SIMPLE_TAG, data_dir, 0))
1236+
TCM_SIMPLE_TAG, data_dir, TARGET_SCF_ACK_KREF))
12401237
goto err;
12411238

12421239
return;
@@ -1248,7 +1245,6 @@ static void sbp_handle_command(struct sbp_target_request *req)
12481245
STATUS_BLOCK_LEN(1) |
12491246
STATUS_BLOCK_SBP_STATUS(SBP_STATUS_UNSPECIFIED_ERROR));
12501247
sbp_send_status(req);
1251-
sbp_free_request(req);
12521248
}
12531249

12541250
/*
@@ -1347,22 +1343,29 @@ static int sbp_rw_data(struct sbp_target_request *req)
13471343

13481344
static int sbp_send_status(struct sbp_target_request *req)
13491345
{
1350-
int ret, length;
1346+
int rc, ret = 0, length;
13511347
struct sbp_login_descriptor *login = req->login;
13521348

13531349
length = (((be32_to_cpu(req->status.status) >> 24) & 0x07) + 1) * 4;
13541350

1355-
ret = sbp_run_request_transaction(req, TCODE_WRITE_BLOCK_REQUEST,
1351+
rc = sbp_run_request_transaction(req, TCODE_WRITE_BLOCK_REQUEST,
13561352
login->status_fifo_addr, &req->status, length);
1357-
if (ret != RCODE_COMPLETE) {
1358-
pr_debug("sbp_send_status: write failed: 0x%x\n", ret);
1359-
return -EIO;
1353+
if (rc != RCODE_COMPLETE) {
1354+
pr_debug("sbp_send_status: write failed: 0x%x\n", rc);
1355+
ret = -EIO;
1356+
goto put_ref;
13601357
}
13611358

13621359
pr_debug("sbp_send_status: status write complete for ORB: 0x%llx\n",
13631360
req->orb_pointer);
1364-
1365-
return 0;
1361+
/*
1362+
* Drop the extra ACK_KREF reference taken by target_submit_cmd()
1363+
* ahead of sbp_check_stop_free() -> transport_generic_free_cmd()
1364+
* final se_cmd->cmd_kref put.
1365+
*/
1366+
put_ref:
1367+
target_put_sess_cmd(&req->se_cmd);
1368+
return ret;
13661369
}
13671370

13681371
static void sbp_sense_mangle(struct sbp_target_request *req)
@@ -1822,8 +1825,7 @@ static int sbp_check_stop_free(struct se_cmd *se_cmd)
18221825
struct sbp_target_request *req = container_of(se_cmd,
18231826
struct sbp_target_request, se_cmd);
18241827

1825-
transport_generic_free_cmd(&req->se_cmd, 0);
1826-
return 1;
1828+
return transport_generic_free_cmd(&req->se_cmd, 0);
18271829
}
18281830

18291831
static int sbp_count_se_tpg_luns(struct se_portal_group *tpg)

0 commit comments

Comments
 (0)