Received: by 10.223.185.116 with SMTP id b49csp5947484wrg; Wed, 7 Mar 2018 22:24:33 -0800 (PST) X-Google-Smtp-Source: AG47ELsiegDfHtepiAlfjrX962SAUL2FxH8ibfYsNwVsqPNOfUMPMkK+aHn5HtUxzeN28AQB+0vX X-Received: by 2002:a17:902:7294:: with SMTP id d20-v6mr21460056pll.43.1520490273769; Wed, 07 Mar 2018 22:24:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520490273; cv=none; d=google.com; s=arc-20160816; b=vpePmqE0yXQJD5RsIcU8SoJD6xCXV2GSyHDA0WW6+daIrW4xt0dE6j4GkCo2qieQ9k yfLGguCW0ubmPuyjplRd4avJ7Uq4cUu+EDEgCHKlkofMC414zwWSYXzAIoySsyeAJ4ku D3nMG00SjAv1OmWlI3ePnEmIAfytn0SDhxN+8uU2zFn+gGXeZ1cqJVHg7sbGod+oCg1o F4Odb9xzdlbWjudAuMxPS3dt9vvIMyO6C7RmCgZhDgqbboMGvj3C5tNr/Uu1pbWNHBQW EUA8ulsbFgRBLv8SjqYCEbnIqSsQvU2xyCwETc5EeKED/JnrawZ+Hh+K54fW1wD64H6N sv3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=VcptOchmbsaEvCaD6M0LNi109LLIU7UaiI/Ob+s4XN8=; b=j4PTsAkguES+MmhrK8HFBzFHgPtnvvJZqAXfitUFKsR26c/wRJuyPNKf5nob1X1MHS wYLc29A6wejwyTYEEsA4AXrPrENE7t69ZSqB5SyuZ4aXjvObw2EmKXMj1NffVWP5pJNj 7be+XCb63KrR3m92Da7DOMORJlMKnQlu9sZep3WQAPMcnkY6Or31/rxWt3JjWVCLURc+ g2jIE0ZCoSBcchuUbogeB9e0804Hsifzapb/q/+gi4hEtG+hZU4oYMtbmTZfshkNgMXU MV7Gh5TdKqPCM+F+kkncXnhsaz4mqFZXNYZWHsTBg4lwxnJ8Z4pqfyQxgOAtO7NkAWqg ZkdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Hb1uOMbg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m11si12552980pgc.671.2018.03.07.22.24.19; Wed, 07 Mar 2018 22:24:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Hb1uOMbg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935540AbeCHGWj (ORCPT + 99 others); Thu, 8 Mar 2018 01:22:39 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:48102 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935509AbeCHGWb (ORCPT ); Thu, 8 Mar 2018 01:22:31 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w286H0Nq156870; Thu, 8 Mar 2018 06:20:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=VcptOchmbsaEvCaD6M0LNi109LLIU7UaiI/Ob+s4XN8=; b=Hb1uOMbgAjYKWy7Xlt4mGqa+gtPp7niE6sCMML+waz9TrInia82pOeV5GySk0OAdYQKM VbfTqNx1T56gPQK+BTUw+gjTGQ25RGm7/Giqa3fNH+v54qjm8GgEp6r3GAPWfSF8BuoO 3+hHgNkSkAlaaKvzYDf/O+xG1GJsR4qSdWjH0FGz4RG8xZXBFGwGv01nNaK67n6nsz+W /yv+ii1uwAusK9y2KgY23CDkcuJKhxaoT731OlTNt+ph/8oaDvHi7nncVEdjyifiMu2x BwuRJNSKTJOK79I4X9cPkjNpr10U56qREUJ/m+aQGa5LNLHrqEb7CD5GxZo6NkL9eIT8 8g== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2gjxjk0cf1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Mar 2018 06:20:04 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w286K3lC017355 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 8 Mar 2018 06:20:03 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w286K2IM008455; Thu, 8 Mar 2018 06:20:03 GMT Received: from will-ThinkCentre-M910s.cn.oracle.com (/10.182.70.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 07 Mar 2018 22:20:02 -0800 From: Jianchao Wang To: keith.busch@intel.com, axboe@fb.com, hch@lst.de, sagi@grimberg.me Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH V4 1/5] nvme: do atomically bit operations on nvme_request.flags Date: Thu, 8 Mar 2018 14:19:27 +0800 Message-Id: <1520489971-31174-2-git-send-email-jianchao.w.wang@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520489971-31174-1-git-send-email-jianchao.w.wang@oracle.com> References: <1520489971-31174-1-git-send-email-jianchao.w.wang@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8825 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=930 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803080079 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do atomically bit operations on nvme_request.flags instead of regular read/write, then we could add other flags and set/clear them safely. Signed-off-by: Jianchao Wang --- drivers/nvme/host/core.c | 4 ++-- drivers/nvme/host/lightnvm.c | 4 ++-- drivers/nvme/host/nvme.h | 4 ++-- drivers/nvme/host/pci.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 29ead91..7b8df47 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -674,7 +674,7 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, blk_execute_rq(req->q, NULL, req, at_head); if (result) *result = nvme_req(req)->result; - if (nvme_req(req)->flags & NVME_REQ_CANCELLED) + if (test_bit(NVME_REQ_CANCELLED, &nvme_req(req)->flags)) ret = -EINTR; else ret = nvme_req(req)->status; @@ -763,7 +763,7 @@ static int nvme_submit_user_cmd(struct request_queue *q, } blk_execute_rq(req->q, disk, req, 0); - if (nvme_req(req)->flags & NVME_REQ_CANCELLED) + if (test_bit(NVME_REQ_CANCELLED, &nvme_req(req)->flags)) ret = -EINTR; else ret = nvme_req(req)->status; diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index 50ef71ee..fd0c499 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -470,7 +470,7 @@ static int nvme_nvm_submit_io_sync(struct nvm_dev *dev, struct nvm_rq *rqd) * handle the error accordingly. */ blk_execute_rq(q, NULL, rq, 0); - if (nvme_req(rq)->flags & NVME_REQ_CANCELLED) + if (test_bit(NVME_REQ_CANCELLED, &nvme_req(rq)->flags)) ret = -EINTR; rqd->ppa_status = le64_to_cpu(nvme_req(rq)->result.u64); @@ -599,7 +599,7 @@ static int nvme_nvm_submit_user_cmd(struct request_queue *q, blk_execute_rq(q, NULL, rq, 0); - if (nvme_req(rq)->flags & NVME_REQ_CANCELLED) + if (test_bit(NVME_REQ_CANCELLED, &nvme_req(rq)->flags)) ret = -EINTR; else if (nvme_req(rq)->status & 0x7ff) ret = -EIO; diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index e80fd74..02097e8 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -93,8 +93,8 @@ struct nvme_request { struct nvme_command *cmd; union nvme_result result; u8 retries; - u8 flags; u16 status; + unsigned long flags; }; /* @@ -103,7 +103,7 @@ struct nvme_request { #define REQ_NVME_MPATH REQ_DRV enum { - NVME_REQ_CANCELLED = (1 << 0), + NVME_REQ_CANCELLED = 0, }; static inline struct nvme_request *nvme_req(struct request *req) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 73036d2..e186158 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1222,7 +1222,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) "I/O %d QID %d timeout, disable controller\n", req->tag, nvmeq->qid); nvme_dev_disable(dev, false); - nvme_req(req)->flags |= NVME_REQ_CANCELLED; + set_bit(NVME_REQ_CANCELLED, &nvme_req(req)->flags); return BLK_EH_HANDLED; default: break; @@ -1244,7 +1244,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) * Mark the request as handled, since the inline shutdown * forces all outstanding requests to complete. */ - nvme_req(req)->flags |= NVME_REQ_CANCELLED; + set_bit(NVME_REQ_CANCELLED, &nvme_req(req)->flags); return BLK_EH_HANDLED; } -- 2.7.4