From patchwork Sat Jun 3 09:32:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Yi X-Patchwork-Id: 9764093 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 69313602B6 for ; Sat, 3 Jun 2017 09:32:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 588662521E for ; Sat, 3 Jun 2017 09:32:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D40C252D5; Sat, 3 Jun 2017 09:32:22 +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 E557F2521E for ; Sat, 3 Jun 2017 09:32:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750991AbdFCJcU (ORCPT ); Sat, 3 Jun 2017 05:32:20 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34471 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750765AbdFCJcT (ORCPT ); Sat, 3 Jun 2017 05:32:19 -0400 Received: by mail-pf0-f195.google.com with SMTP id w69so15214207pfk.1 for ; Sat, 03 Jun 2017 02:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=ffTb3bj1UEfzdQQzOSe1khUW/jMNAjDxIBH9m+kvwho=; b=HY0v7iWqW/HBs4BxhL15XxJaQ2EhBXziqfQcXoWpLzfiotCc1Sh9q1ow7FGhcQqejX ri4BGLJjsP38zV/g4GeNNWCU5J178j3QsM6+AmFT1bO3VTluQAxtCugnj6gQHcOYNoLU y7DkWUmysCdS7uSbBD0fYaMWvXnDn/S5XqW5Olt/p9mLWL8vx5p/5my78CeX9QiwZh74 Tmkm5slboxi6mwlf0Qrp5KReYrEs3BtICVhHc3Ink0AySXVhHzOI5YH+oCYK4M9e/wvC IpwlkpCOVLLn0IHJyZ5x7mD4w+Vdr4USaN0oEuoXUVYpI8hkemE+GVp4XkbgDMHe6Uyx j81g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=ffTb3bj1UEfzdQQzOSe1khUW/jMNAjDxIBH9m+kvwho=; b=sgV4uJ0miT1xg8Rz8zUsPiueSgA7xKHufs+P7kfPevIPikEi1tLWck1FxWZIlrOD/6 Z5qiOJCtd5pqcQTNxmM99iURQEm7oBxPtQhReEh1jyIHvxtBVH+JluAsOtiINaXa78/0 EwpUXGMgR8INv3wS+MjWd+aui43+GG5QOMG4eG+OdomTqyAx/e1VR8wdpB2Onm4d8qpf w3YQejAntI37IgnOuj+Hm2s63Dwl0gijNcIfXg0cDEUYYDmRWGa9ekyrLJMT8dPiirTd 9jk+kuOGH49CbucvqBvSdZKmgRqcsnqIcjcYJ4U+TN2Hrs3zP/D8tiBe7rCwplmlhus7 75mQ== X-Gm-Message-State: AODbwcC+8h4UkJ6ANfUIQI56pxUVJE9zQvov9JuSUUw61MX+sz262a/v z20BRPjbdtxCr8Mv2yM= X-Received: by 10.99.53.197 with SMTP id c188mr4948853pga.165.1496482338675; Sat, 03 Jun 2017 02:32:18 -0700 (PDT) Received: from [10.12.12.133] (125-227-147-112.HINET-IP.hinet.net. [125.227.147.112]) by smtp.gmail.com with ESMTPSA id f71sm45848362pfd.98.2017.06.03.02.32.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Jun 2017 02:32:18 -0700 (PDT) To: nab@linux-iscsi.org Cc: target-devel@vger.kernel.org From: Jiang Yi Subject: [PATCH] target: up caw_sem if COMPARE_AND_WRITE got aborted Message-ID: <6b4bfba1-8c59-eb14-0307-1dcf828e1ca3@gmail.com> Date: Sat, 3 Jun 2017 17:32:16 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 Content-Language: en-US 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 Hi Nic, If a se_cmd of COMPARE_AND_WRITE got aborted, "struct semaphore caw_sem" of the corresponding se_device will never being called up(). I propose a patch: Signed-off-by: Jiang Yi --- drivers/target/target_core_transport.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 6025935..02734ca 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -726,6 +726,9 @@ void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) */ if (cmd->transport_state & CMD_T_ABORTED || cmd->transport_state & CMD_T_STOP) { + if ((cmd->se_cmd_flags & SCF_COMPARE_AND_WRITE) && success) { + up(&dev->caw_sem); + } spin_unlock_irqrestore(&cmd->t_state_lock, flags); complete_all(&cmd->t_transport_stop_comp); return;