From patchwork Mon Oct 16 23:54:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10010289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 835AA600CC for ; Mon, 16 Oct 2017 23:55:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7551728713 for ; Mon, 16 Oct 2017 23:55:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 635C928715; Mon, 16 Oct 2017 23:55:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D98BD28713 for ; Mon, 16 Oct 2017 23:55:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757445AbdJPXya (ORCPT ); Mon, 16 Oct 2017 19:54:30 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:53481 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757444AbdJPXy1 (ORCPT ); Mon, 16 Oct 2017 19:54:27 -0400 Received: by mail-pg0-f42.google.com with SMTP id s2so8090797pge.10 for ; Mon, 16 Oct 2017 16:54:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=jtGiVeuH8RLfOJ5sKdkpKn5hEq8noh4rL3DAInSN/xQ=; b=WZfOT2xDEPxxNKtJ/JV4rhuogf2LJ/AfyzSswOgaRe84R709+a2BVNMBOgR9isd67s exT9lyy8opK46ZXdSbL88IkZoNYzX2Irw+LX0wMU/dtiEbdRowBWQ60qDf0KIZCHvU7k vN6s8ortZUBuVe5oobcHw9L8RvlftzX6JWzIk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=jtGiVeuH8RLfOJ5sKdkpKn5hEq8noh4rL3DAInSN/xQ=; b=SIMb9roZc9a/Ac/EAgLmP/Tha83I3TrNwpgksaBVbKUslTNZzFZcB1k25eTi2mqIuY +n8z1Ik9SFeT7he9B1m0Msk6m8//qKq4xkNg49rmUR7d84Ksb7ldT19a5TgKDkSrf/2G BgzauEy7Lc4xar0UI5aLJ78DFCPDvoI8kEpLVF3qbKdr0i7MjTQ/Lr3E5ymq2002UjGo F3kIUeLdZ+WygtBnh2zf8S0V6x1lhW4DnRR2bsD+sJa6pHnPho6fpasO2aOhoSgJsIAE yBBmpvZclsUkvACwdJkQK8ZcpSa0OSWw6hgFrb3QKWRggtIDQmrotCg2e4Pf7+C3VgvN 8QEw== X-Gm-Message-State: AMCzsaXKH23rTOxftVkffsV0siDbwRAzJIjCPcof1HkCMikZJmOlFKvJ +f3Z7lChip4+TAjIKNMcLjLMdg== X-Google-Smtp-Source: AOwi7QD/DkcvNSjC1aUBBuJwGmERnKKsf5RANJ/1KJ/Ouc1u9Y1l6hEPxjwYV9E8KLY999scPsTLdw== X-Received: by 10.99.63.199 with SMTP id m190mr9459398pga.187.1508198066642; Mon, 16 Oct 2017 16:54:26 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id g3sm14386667pgc.63.2017.10.16.16.54.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 16:54:25 -0700 (PDT) Date: Mon, 16 Oct 2017 16:54:24 -0700 From: Kees Cook To: "Martin K. Petersen" Cc: Lee Duncan , Chris Leech , "James E.J. Bottomley" , "Martin K. Petersen" , open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: libiscsi: Convert timers to use timer_setup() Message-ID: <20171016235424.GA102550@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Cc: Lee Duncan Cc: Chris Leech Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: open-iscsi@googlegroups.com Cc: linux-scsi@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Martin K. Petersen Reviewed-by: Chris Leech --- drivers/scsi/libiscsi.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index f8dc1601efd5..9c50d2d9f27c 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1805,9 +1805,9 @@ int iscsi_target_alloc(struct scsi_target *starget) } EXPORT_SYMBOL_GPL(iscsi_target_alloc); -static void iscsi_tmf_timedout(unsigned long data) +static void iscsi_tmf_timedout(struct timer_list *t) { - struct iscsi_conn *conn = (struct iscsi_conn *)data; + struct iscsi_conn *conn = from_timer(conn, t, tmf_timer); struct iscsi_session *session = conn->session; spin_lock(&session->frwd_lock); @@ -1838,8 +1838,6 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, } conn->tmfcmd_pdus_cnt++; conn->tmf_timer.expires = timeout * HZ + jiffies; - conn->tmf_timer.function = iscsi_tmf_timedout; - conn->tmf_timer.data = (unsigned long)conn; add_timer(&conn->tmf_timer); ISCSI_DBG_EH(session, "tmf set timeout\n"); @@ -2089,9 +2087,9 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) } EXPORT_SYMBOL_GPL(iscsi_eh_cmd_timed_out); -static void iscsi_check_transport_timeouts(unsigned long data) +static void iscsi_check_transport_timeouts(struct timer_list *t) { - struct iscsi_conn *conn = (struct iscsi_conn *)data; + struct iscsi_conn *conn = from_timer(conn, t, transport_timer); struct iscsi_session *session = conn->session; unsigned long recv_timeout, next_timeout = 0, last_recv; @@ -2913,9 +2911,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size, conn->exp_statsn = 0; conn->tmf_state = TMF_INITIAL; - init_timer(&conn->transport_timer); - conn->transport_timer.data = (unsigned long)conn; - conn->transport_timer.function = iscsi_check_transport_timeouts; + timer_setup(&conn->transport_timer, iscsi_check_transport_timeouts, 0); INIT_LIST_HEAD(&conn->mgmtqueue); INIT_LIST_HEAD(&conn->cmdqueue); @@ -2939,7 +2935,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size, goto login_task_data_alloc_fail; conn->login_task->data = conn->data = data; - init_timer(&conn->tmf_timer); + timer_setup(&conn->tmf_timer, iscsi_tmf_timedout, 0); init_waitqueue_head(&conn->ehwait); return cls_conn;