From patchwork Wed Sep 13 06:07:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenjiro Nakayama X-Patchwork-Id: 9950449 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 55EFB6038F for ; Wed, 13 Sep 2017 06:08:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42F0A29070 for ; Wed, 13 Sep 2017 06:08:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 367C5290A4; Wed, 13 Sep 2017 06:08:20 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham 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 BB80C2901C for ; Wed, 13 Sep 2017 06:08:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751121AbdIMGHW (ORCPT ); Wed, 13 Sep 2017 02:07:22 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33050 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751056AbdIMGHW (ORCPT ); Wed, 13 Sep 2017 02:07:22 -0400 Received: by mail-pf0-f194.google.com with SMTP id h4so7142691pfk.0 for ; Tue, 12 Sep 2017 23:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=uCoAPqGiZXl4Fy3Bj9FwwyQ5tBIaqBRnWnJBslLim7w=; b=IGBIIj+QkgOG91PpAvWN34o99iCmv15LYLoBIHE9BIbqC8TbG72WnmiquAoVG1pHsI UEtigciOCA3HvX8v3yEVNKCBnadlJwFEwexnEIYP2wEa1RD0K5rwg9WrC70c/EvB/fIV BxrXIuyJjlMFTcwXAlKnAA57EHYrPG08oSgToSHakixBoqoYpJ6sZOBeY5hDG7t2/vWg /4jiorrR0c+CMvMPB2KerQ8nwSupOV85tMkdT3l5Or7/XLq8T2wMIbkSVKROcmZdIPWp qqq6RholQrYtl9wbXeCwQUlNv3kAUfgnAL0qordUHf+JEKwfAyLAsYRKerJox3gpUTfK iiVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uCoAPqGiZXl4Fy3Bj9FwwyQ5tBIaqBRnWnJBslLim7w=; b=XBjm27nbAJfySaAAWlLen7kh2S40aGuZXEDQg9OvQ2VltcIuW+WtdVAjsMe60HHHrE SOBYC5x5/6sKN4QXXpHimqG7nTXlhKOMX0bTwrY5LfcQQ+jKOSnjqidjcE3CC/lZTjP0 ZKbciLl++IU/n2C+ciQKk+9ExOe2ir+gUchOE6TQsxHlneCOMzvcBZ0KpB9Dze7eDmOj z6CviR60TQQS9ghRR2XK+wibZlmNkwJaWhjC0ncO0+CQA7RHzDQ4abRskJK2Yjf/dcnV CeXKjOPMZWKBCMChbYM8uLpapoMmdaZJr8GVawcZ14YeR8KOxNvBPiNwgNKNdV+H13Cw Zv2g== X-Gm-Message-State: AHPjjUhKqjq893R76Bpkv8+/io8PfUVeR+tDHOido3fghvcH/LSQitMm 16ASOX2ovf0+pwsH X-Google-Smtp-Source: AOwi7QDT1mVpQ80RYhJtAPgUu1ULd8gM0MvTp3+6M2Wf42CF6jel9ijl/VH5kPzjmW6gDPFlKhNPWQ== X-Received: by 10.101.64.72 with SMTP id h8mr2966058pgp.110.1505282841397; Tue, 12 Sep 2017 23:07:21 -0700 (PDT) Received: from localhost.localdomain ([2400:4030:ac55:d000:18f3:45f2:6d16:16e9]) by smtp.gmail.com with ESMTPSA id y128sm21190249pfy.125.2017.09.12.23.07.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Sep 2017 23:07:20 -0700 (PDT) From: Kenjiro Nakayama To: target-devel@vger.kernel.org Cc: nab@linux-iscsi.org, mchristi@redhat.com, Kenjiro Nakayama Subject: [PATCH] target/tcmu: Adds a timeout for the completion of netlink command reply Date: Wed, 13 Sep 2017 15:07:03 +0900 Message-Id: <20170913060703.17846-1-nakayamakenjiro@gmail.com> X-Mailer: git-send-email 2.13.5 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a timeout for the completion of netlink command reply. Current code waits for the netlink reply from userspace and the status change, but it hangs forever when userspace failed to reply. To fix this issue, this patch replace wait_for_completion with wait_for_completion_timeout. Signed-off-by: Kenjiro Nakayama --- drivers/target/target_core_user.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 942d094269fb..284294340167 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -1333,7 +1333,12 @@ static int tcmu_wait_genl_cmd_reply(struct tcmu_dev *udev) return 0; pr_debug("sleeping for nl reply\n"); - wait_for_completion(&nl_cmd->complete); + ret = wait_for_completion_timeout(&nl_cmd->complete, + msecs_to_jiffies(3000)); + if (!ret) { + printk(KERN_ERR "timeout waiting for nl reply from userspace\n"); + return -ETIME; + } spin_lock(&udev->nl_cmd_lock); nl_cmd->cmd = TCMU_CMD_UNSPEC;