diff mbox series

[v3] target: split out helper for cxn timeout error stashing

Message ID 20181013231354.12838-1-ddiss@suse.de (mailing list archive)
State New, archived
Headers show
Series [v3] target: split out helper for cxn timeout error stashing | expand

Commit Message

David Disseldorp Oct. 13, 2018, 11:13 p.m. UTC
Replace existing nested code blocks with helper function calls.

Signed-off-by: David Disseldorp <ddiss@suse.de>
---
 drivers/target/iscsi/iscsi_target_erl0.c | 15 +------------
 drivers/target/iscsi/iscsi_target_util.c | 36 ++++++++++++++++++--------------
 drivers/target/iscsi/iscsi_target_util.h |  1 +
 3 files changed, 22 insertions(+), 30 deletions(-)

Comments

kernel test robot Oct. 14, 2018, 3:43 a.m. UTC | #1
Hi David,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on target/master]
[also build test ERROR on v4.19-rc7 next-20181012]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/David-Disseldorp/target-split-out-helper-for-cxn-timeout-error-stashing/20181014-111810
base:   https://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master
config: x86_64-randconfig-x007-201841 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/target/iscsi/iscsi_target_util.c: In function 'iscsit_handle_nopin_response_timeout':
>> drivers/target/iscsi/iscsi_target_util.c:902:36: error: 'sess' undeclared (first use in this function); did you mean 'sem'?
     iscsit_fill_cxn_timeout_err_stats(sess);
                                       ^~~~
                                       sem
   drivers/target/iscsi/iscsi_target_util.c:902:36: note: each undeclared identifier is reported only once for each function it appears in

vim +902 drivers/target/iscsi/iscsi_target_util.c

   882	
   883	static void iscsit_handle_nopin_response_timeout(unsigned long data)
   884	{
   885		struct iscsi_conn *conn = (struct iscsi_conn *) data;
   886	
   887		iscsit_inc_conn_usage_count(conn);
   888	
   889		spin_lock_bh(&conn->nopin_timer_lock);
   890		if (conn->nopin_response_timer_flags & ISCSI_TF_STOP) {
   891			spin_unlock_bh(&conn->nopin_timer_lock);
   892			iscsit_dec_conn_usage_count(conn);
   893			return;
   894		}
   895	
   896		pr_debug("Did not receive response to NOPIN on CID: %hu on"
   897			" SID: %u, failing connection.\n", conn->cid,
   898				conn->sess->sid);
   899		conn->nopin_response_timer_flags &= ~ISCSI_TF_RUNNING;
   900		spin_unlock_bh(&conn->nopin_timer_lock);
   901	
 > 902		iscsit_fill_cxn_timeout_err_stats(sess);
   903		iscsit_cause_connection_reinstatement(conn, 0);
   904		iscsit_dec_conn_usage_count(conn);
   905	}
   906	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Oct. 14, 2018, 9:42 a.m. UTC | #2
Hi David,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on target/master]
[also build test ERROR on v4.19-rc7 next-20181012]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/David-Disseldorp/target-split-out-helper-for-cxn-timeout-error-stashing/20181014-111810
base:   https://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master
config: i386-randconfig-s1-201841 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/target/iscsi/iscsi_target_util.c: In function 'iscsit_handle_nopin_response_timeout':
>> drivers/target/iscsi/iscsi_target_util.c:902:36: error: 'sess' undeclared (first use in this function)
     iscsit_fill_cxn_timeout_err_stats(sess);
                                       ^~~~
   drivers/target/iscsi/iscsi_target_util.c:902:36: note: each undeclared identifier is reported only once for each function it appears in

vim +/sess +902 drivers/target/iscsi/iscsi_target_util.c

   882	
   883	static void iscsit_handle_nopin_response_timeout(unsigned long data)
   884	{
   885		struct iscsi_conn *conn = (struct iscsi_conn *) data;
   886	
   887		iscsit_inc_conn_usage_count(conn);
   888	
   889		spin_lock_bh(&conn->nopin_timer_lock);
   890		if (conn->nopin_response_timer_flags & ISCSI_TF_STOP) {
   891			spin_unlock_bh(&conn->nopin_timer_lock);
   892			iscsit_dec_conn_usage_count(conn);
   893			return;
   894		}
   895	
   896		pr_debug("Did not receive response to NOPIN on CID: %hu on"
   897			" SID: %u, failing connection.\n", conn->cid,
   898				conn->sess->sid);
   899		conn->nopin_response_timer_flags &= ~ISCSI_TF_RUNNING;
   900		spin_unlock_bh(&conn->nopin_timer_lock);
   901	
 > 902		iscsit_fill_cxn_timeout_err_stats(sess);
   903		iscsit_cause_connection_reinstatement(conn, 0);
   904		iscsit_dec_conn_usage_count(conn);
   905	}
   906	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
David Disseldorp Oct. 14, 2018, 10:09 a.m. UTC | #3
On Sun, 14 Oct 2018 11:43:34 +0800, kbuild test robot wrote:

> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on target/master]
> [also build test ERROR on v4.19-rc7 next-20181012]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
...
>    drivers/target/iscsi/iscsi_target_util.c: In function 'iscsit_handle_nopin_response_timeout':
> >> drivers/target/iscsi/iscsi_target_util.c:902:36: error: 'sess' undeclared (first use in this function)

This patch is a v3 respin of an individual patch within the series:
[PATCH v2 0/5] target: improve Data-Out and NOP timeout error reporting
The sess declaration is provided in [PATCH v2 3/5].

I guess I'll resend entire series in future to avoid false kbuild
reports.

Cheers, David
Martin K. Petersen Oct. 16, 2018, 4:42 a.m. UTC | #4
David,

> This patch is a v3 respin of an individual patch within the series:
> [PATCH v2 0/5] target: improve Data-Out and NOP timeout error
> reporting The sess declaration is provided in [PATCH v2 3/5].
>
> I guess I'll resend entire series in future to avoid false kbuild
> reports.

Yes, please. Patchwork can't handle individual patches getting updated
either.

Applied to 4.20/scsi-queue.
David Disseldorp Oct. 16, 2018, 9:21 a.m. UTC | #5
On Tue, 16 Oct 2018 00:42:57 -0400, Martin K. Petersen wrote:

> > I guess I'll resend entire series in future to avoid false kbuild
> > reports.  
> 
> Yes, please. Patchwork can't handle individual patches getting updated
> either.

Okay, will do.

> Applied to 4.20/scsi-queue.

Thanks Martin.

Cheers, David
diff mbox series

Patch

diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c
index 718fe9a1b709..1193cf884a28 100644
--- a/drivers/target/iscsi/iscsi_target_erl0.c
+++ b/drivers/target/iscsi/iscsi_target_erl0.c
@@ -770,21 +770,8 @@  void iscsit_handle_time2retain_timeout(struct timer_list *t)
 
 	pr_err("Time2Retain timer expired for SID: %u, cleaning up"
 			" iSCSI session.\n", sess->sid);
-	{
-	struct iscsi_tiqn *tiqn = tpg->tpg_tiqn;
-
-	if (tiqn) {
-		spin_lock(&tiqn->sess_err_stats.lock);
-		strcpy(tiqn->sess_err_stats.last_sess_fail_rem_name,
-			(void *)sess->sess_ops->InitiatorName);
-		tiqn->sess_err_stats.last_sess_failure_type =
-				ISCSI_SESS_ERR_CXN_TIMEOUT;
-		tiqn->sess_err_stats.cxn_timeout_errors++;
-		atomic_long_inc(&sess->conn_timeout_errors);
-		spin_unlock(&tiqn->sess_err_stats.lock);
-	}
-	}
 
+	iscsit_fill_cxn_timeout_err_stats(sess);
 	spin_unlock_bh(&se_tpg->session_lock);
 	iscsit_close_session(sess);
 }
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c
index 931c51f56435..1227872227dc 100644
--- a/drivers/target/iscsi/iscsi_target_util.c
+++ b/drivers/target/iscsi/iscsi_target_util.c
@@ -933,22 +933,7 @@  void iscsit_handle_nopin_response_timeout(struct timer_list *t)
 	conn->nopin_response_timer_flags &= ~ISCSI_TF_RUNNING;
 	spin_unlock_bh(&conn->nopin_timer_lock);
 
-	{
-	struct iscsi_portal_group *tpg = conn->sess->tpg;
-	struct iscsi_tiqn *tiqn = tpg->tpg_tiqn;
-
-	if (tiqn) {
-		spin_lock_bh(&tiqn->sess_err_stats.lock);
-		strcpy(tiqn->sess_err_stats.last_sess_fail_rem_name,
-				conn->sess->sess_ops->InitiatorName);
-		tiqn->sess_err_stats.last_sess_failure_type =
-				ISCSI_SESS_ERR_CXN_TIMEOUT;
-		tiqn->sess_err_stats.cxn_timeout_errors++;
-		atomic_long_inc(&conn->sess->conn_timeout_errors);
-		spin_unlock_bh(&tiqn->sess_err_stats.lock);
-	}
-	}
-
+	iscsit_fill_cxn_timeout_err_stats(sess);
 	iscsit_cause_connection_reinstatement(conn, 0);
 	iscsit_dec_conn_usage_count(conn);
 }
@@ -1407,3 +1392,22 @@  struct iscsi_tiqn *iscsit_snmp_get_tiqn(struct iscsi_conn *conn)
 
 	return tpg->tpg_tiqn;
 }
+
+void iscsit_fill_cxn_timeout_err_stats(struct iscsi_session *sess)
+{
+	struct iscsi_portal_group *tpg = sess->tpg;
+	struct iscsi_tiqn *tiqn = tpg->tpg_tiqn;
+
+	if (!tiqn)
+		return;
+
+	spin_lock_bh(&tiqn->sess_err_stats.lock);
+	strlcpy(tiqn->sess_err_stats.last_sess_fail_rem_name,
+			sess->sess_ops->InitiatorName,
+			sizeof(tiqn->sess_err_stats.last_sess_fail_rem_name));
+	tiqn->sess_err_stats.last_sess_failure_type =
+			ISCSI_SESS_ERR_CXN_TIMEOUT;
+	tiqn->sess_err_stats.cxn_timeout_errors++;
+	atomic_long_inc(&sess->conn_timeout_errors);
+	spin_unlock_bh(&tiqn->sess_err_stats.lock);
+}
diff --git a/drivers/target/iscsi/iscsi_target_util.h b/drivers/target/iscsi/iscsi_target_util.h
index d66dfc212624..68e84803b0a1 100644
--- a/drivers/target/iscsi/iscsi_target_util.h
+++ b/drivers/target/iscsi/iscsi_target_util.h
@@ -67,5 +67,6 @@  extern int rx_data(struct iscsi_conn *, struct kvec *, int, int);
 extern int tx_data(struct iscsi_conn *, struct kvec *, int, int);
 extern void iscsit_collect_login_stats(struct iscsi_conn *, u8, u8);
 extern struct iscsi_tiqn *iscsit_snmp_get_tiqn(struct iscsi_conn *);
+extern void iscsit_fill_cxn_timeout_err_stats(struct iscsi_session *);
 
 #endif /*** ISCSI_TARGET_UTIL_H ***/