libiscsi.c (83970cd63b9f864525761137b500113ab0b49c94) | libiscsi.c (5bd856256f8c03e329f8ff36d8c8efcb111fe6df) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * iSCSI lib functions 4 * 5 * Copyright (C) 2006 Red Hat, Inc. All rights reserved. 6 * Copyright (C) 2004 - 2006 Mike Christie 7 * Copyright (C) 2004 - 2005 Dmitry Yusupov 8 * Copyright (C) 2004 - 2005 Alex Aizman --- 1378 unchanged lines hidden (view full) --- 1387 struct iscsi_session *session = conn->session; 1388 1389 if (session->state == ISCSI_STATE_FAILED) 1390 return false; 1391 1392 if (conn->stop_stage == 0) 1393 session->state = ISCSI_STATE_FAILED; 1394 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * iSCSI lib functions 4 * 5 * Copyright (C) 2006 Red Hat, Inc. All rights reserved. 6 * Copyright (C) 2004 - 2006 Mike Christie 7 * Copyright (C) 2004 - 2005 Dmitry Yusupov 8 * Copyright (C) 2004 - 2005 Alex Aizman --- 1378 unchanged lines hidden (view full) --- 1387 struct iscsi_session *session = conn->session; 1388 1389 if (session->state == ISCSI_STATE_FAILED) 1390 return false; 1391 1392 if (conn->stop_stage == 0) 1393 session->state = ISCSI_STATE_FAILED; 1394 |
1395 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx); 1396 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx); | 1395 set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags); 1396 set_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags); |
1397 return true; 1398} 1399 1400void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err) 1401{ 1402 struct iscsi_session *session = conn->session; 1403 bool needs_evt; 1404 --- 44 unchanged lines hidden (view full) --- 1449 */ 1450 if (was_requeue) 1451 __iscsi_put_task(task); 1452 1453 /* 1454 * Do this after dropping the extra ref because if this was a requeue 1455 * it's removed from that list and cleanup_queued_task would miss it. 1456 */ | 1397 return true; 1398} 1399 1400void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err) 1401{ 1402 struct iscsi_session *session = conn->session; 1403 bool needs_evt; 1404 --- 44 unchanged lines hidden (view full) --- 1449 */ 1450 if (was_requeue) 1451 __iscsi_put_task(task); 1452 1453 /* 1454 * Do this after dropping the extra ref because if this was a requeue 1455 * it's removed from that list and cleanup_queued_task would miss it. 1456 */ |
1457 if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { | 1457 if (test_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags)) { |
1458 /* 1459 * Save the task and ref in case we weren't cleaning up this 1460 * task and get woken up again. 1461 */ 1462 conn->task = task; 1463 spin_unlock_bh(&conn->session->back_lock); 1464 return -ENODATA; 1465 } --- 61 unchanged lines hidden (view full) --- 1527 * successful xmit. 1528 **/ 1529static int iscsi_data_xmit(struct iscsi_conn *conn) 1530{ 1531 struct iscsi_task *task; 1532 int rc = 0; 1533 1534 spin_lock_bh(&conn->session->frwd_lock); | 1458 /* 1459 * Save the task and ref in case we weren't cleaning up this 1460 * task and get woken up again. 1461 */ 1462 conn->task = task; 1463 spin_unlock_bh(&conn->session->back_lock); 1464 return -ENODATA; 1465 } --- 61 unchanged lines hidden (view full) --- 1527 * successful xmit. 1528 **/ 1529static int iscsi_data_xmit(struct iscsi_conn *conn) 1530{ 1531 struct iscsi_task *task; 1532 int rc = 0; 1533 1534 spin_lock_bh(&conn->session->frwd_lock); |
1535 if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { | 1535 if (test_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags)) { |
1536 ISCSI_DBG_SESSION(conn->session, "Tx suspended!\n"); 1537 spin_unlock_bh(&conn->session->frwd_lock); 1538 return -ENODATA; 1539 } 1540 1541 if (conn->task) { 1542 rc = iscsi_xmit_task(conn, conn->task, false); 1543 if (rc) --- 197 unchanged lines hidden (view full) --- 1741 1742 conn = session->leadconn; 1743 if (!conn) { 1744 reason = FAILURE_SESSION_FREED; 1745 sc->result = DID_NO_CONNECT << 16; 1746 goto fault; 1747 } 1748 | 1536 ISCSI_DBG_SESSION(conn->session, "Tx suspended!\n"); 1537 spin_unlock_bh(&conn->session->frwd_lock); 1538 return -ENODATA; 1539 } 1540 1541 if (conn->task) { 1542 rc = iscsi_xmit_task(conn, conn->task, false); 1543 if (rc) --- 197 unchanged lines hidden (view full) --- 1741 1742 conn = session->leadconn; 1743 if (!conn) { 1744 reason = FAILURE_SESSION_FREED; 1745 sc->result = DID_NO_CONNECT << 16; 1746 goto fault; 1747 } 1748 |
1749 if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { | 1749 if (test_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags)) { |
1750 reason = FAILURE_SESSION_IN_RECOVERY; 1751 sc->result = DID_REQUEUE << 16; 1752 goto fault; 1753 } 1754 1755 if (iscsi_check_cmdsn_window_closed(conn)) { 1756 reason = FAILURE_WINDOW_CLOSED; 1757 goto reject; --- 172 unchanged lines hidden (view full) --- 1930 * new commands from being queued. This only needs to be called 1931 * by offload drivers that need to sync a path like ep disconnect 1932 * with the iscsi_queuecommand/xmit_task. To start IO again libiscsi 1933 * will call iscsi_start_tx and iscsi_unblock_session when in FFP. 1934 */ 1935void iscsi_suspend_queue(struct iscsi_conn *conn) 1936{ 1937 spin_lock_bh(&conn->session->frwd_lock); | 1750 reason = FAILURE_SESSION_IN_RECOVERY; 1751 sc->result = DID_REQUEUE << 16; 1752 goto fault; 1753 } 1754 1755 if (iscsi_check_cmdsn_window_closed(conn)) { 1756 reason = FAILURE_WINDOW_CLOSED; 1757 goto reject; --- 172 unchanged lines hidden (view full) --- 1930 * new commands from being queued. This only needs to be called 1931 * by offload drivers that need to sync a path like ep disconnect 1932 * with the iscsi_queuecommand/xmit_task. To start IO again libiscsi 1933 * will call iscsi_start_tx and iscsi_unblock_session when in FFP. 1934 */ 1935void iscsi_suspend_queue(struct iscsi_conn *conn) 1936{ 1937 spin_lock_bh(&conn->session->frwd_lock); |
1938 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx); | 1938 set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags); |
1939 spin_unlock_bh(&conn->session->frwd_lock); 1940} 1941EXPORT_SYMBOL_GPL(iscsi_suspend_queue); 1942 1943/** 1944 * iscsi_suspend_tx - suspend iscsi_data_xmit 1945 * @conn: iscsi conn tp stop processing IO on. 1946 * 1947 * This function sets the suspend bit to prevent iscsi_data_xmit 1948 * from sending new IO, and if work is queued on the xmit thread 1949 * it will wait for it to be completed. 1950 */ 1951void iscsi_suspend_tx(struct iscsi_conn *conn) 1952{ 1953 struct Scsi_Host *shost = conn->session->host; 1954 struct iscsi_host *ihost = shost_priv(shost); 1955 | 1939 spin_unlock_bh(&conn->session->frwd_lock); 1940} 1941EXPORT_SYMBOL_GPL(iscsi_suspend_queue); 1942 1943/** 1944 * iscsi_suspend_tx - suspend iscsi_data_xmit 1945 * @conn: iscsi conn tp stop processing IO on. 1946 * 1947 * This function sets the suspend bit to prevent iscsi_data_xmit 1948 * from sending new IO, and if work is queued on the xmit thread 1949 * it will wait for it to be completed. 1950 */ 1951void iscsi_suspend_tx(struct iscsi_conn *conn) 1952{ 1953 struct Scsi_Host *shost = conn->session->host; 1954 struct iscsi_host *ihost = shost_priv(shost); 1955 |
1956 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx); | 1956 set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags); |
1957 if (ihost->workq) 1958 flush_workqueue(ihost->workq); 1959} 1960EXPORT_SYMBOL_GPL(iscsi_suspend_tx); 1961 1962static void iscsi_start_tx(struct iscsi_conn *conn) 1963{ | 1957 if (ihost->workq) 1958 flush_workqueue(ihost->workq); 1959} 1960EXPORT_SYMBOL_GPL(iscsi_suspend_tx); 1961 1962static void iscsi_start_tx(struct iscsi_conn *conn) 1963{ |
1964 clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx); | 1964 clear_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags); |
1965 iscsi_conn_queue_work(conn); 1966} 1967 1968/* 1969 * We want to make sure a ping is in flight. It has timed out. 1970 * And we are not busy processing a pdu that is making 1971 * progress but got started before the ping and is taking a while 1972 * to complete so the ping is just stuck behind it in a queue. --- 1067 unchanged lines hidden (view full) --- 3040 char *data; 3041 int err; 3042 3043 cls_conn = iscsi_alloc_conn(cls_session, sizeof(*conn) + dd_size, 3044 conn_idx); 3045 if (!cls_conn) 3046 return NULL; 3047 conn = cls_conn->dd_data; | 1965 iscsi_conn_queue_work(conn); 1966} 1967 1968/* 1969 * We want to make sure a ping is in flight. It has timed out. 1970 * And we are not busy processing a pdu that is making 1971 * progress but got started before the ping and is taking a while 1972 * to complete so the ping is just stuck behind it in a queue. --- 1067 unchanged lines hidden (view full) --- 3040 char *data; 3041 int err; 3042 3043 cls_conn = iscsi_alloc_conn(cls_session, sizeof(*conn) + dd_size, 3044 conn_idx); 3045 if (!cls_conn) 3046 return NULL; 3047 conn = cls_conn->dd_data; |
3048 memset(conn, 0, sizeof(*conn) + dd_size); | |
3049 3050 conn->dd_data = cls_conn->dd_data + sizeof(*conn); 3051 conn->session = session; 3052 conn->cls_conn = cls_conn; 3053 conn->c_stage = ISCSI_CONN_INITIAL_STAGE; 3054 conn->id = conn_idx; 3055 conn->exp_statsn = 0; 3056 --- 268 unchanged lines hidden (view full) --- 3325 * we have to reset max/exp cmdsn so we can see the new values. 3326 */ 3327 spin_lock_bh(&session->back_lock); 3328 session->max_cmdsn = session->exp_cmdsn = session->cmdsn + 1; 3329 spin_unlock_bh(&session->back_lock); 3330 /* 3331 * Unblock xmitworker(), Login Phase will pass through. 3332 */ | 3048 3049 conn->dd_data = cls_conn->dd_data + sizeof(*conn); 3050 conn->session = session; 3051 conn->cls_conn = cls_conn; 3052 conn->c_stage = ISCSI_CONN_INITIAL_STAGE; 3053 conn->id = conn_idx; 3054 conn->exp_statsn = 0; 3055 --- 268 unchanged lines hidden (view full) --- 3324 * we have to reset max/exp cmdsn so we can see the new values. 3325 */ 3326 spin_lock_bh(&session->back_lock); 3327 session->max_cmdsn = session->exp_cmdsn = session->cmdsn + 1; 3328 spin_unlock_bh(&session->back_lock); 3329 /* 3330 * Unblock xmitworker(), Login Phase will pass through. 3331 */ |
3333 clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx); 3334 clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx); | 3332 clear_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags); 3333 clear_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags); |
3335 return 0; 3336} 3337EXPORT_SYMBOL_GPL(iscsi_conn_bind); 3338 3339int iscsi_switch_str_param(char **param, char *new_val_buf) 3340{ 3341 char *new_val; 3342 --- 453 unchanged lines hidden --- | 3334 return 0; 3335} 3336EXPORT_SYMBOL_GPL(iscsi_conn_bind); 3337 3338int iscsi_switch_str_param(char **param, char *new_val_buf) 3339{ 3340 char *new_val; 3341 --- 453 unchanged lines hidden --- |