From patchwork Wed Oct 25 21:36:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uma Krishnan X-Patchwork-Id: 10027245 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 5377560381 for ; Wed, 25 Oct 2017 21:36:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45A9928C04 for ; Wed, 25 Oct 2017 21:36:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 391C828C60; Wed, 25 Oct 2017 21:36:42 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 CF04628C04 for ; Wed, 25 Oct 2017 21:36:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751887AbdJYVgl (ORCPT ); Wed, 25 Oct 2017 17:36:41 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57340 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751753AbdJYVgk (ORCPT ); Wed, 25 Oct 2017 17:36:40 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9PLZPXH064187 for ; Wed, 25 Oct 2017 17:36:40 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2du2jhr7qt-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 25 Oct 2017 17:36:39 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 25 Oct 2017 15:36:39 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 25 Oct 2017 15:36:36 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9PLaa7D61145312; Wed, 25 Oct 2017 14:36:36 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1E68E78037; Wed, 25 Oct 2017 15:36:36 -0600 (MDT) Received: from p8tul1-build.aus.stglabs.ibm.com (unknown [9.3.141.206]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 9CF567803F; Wed, 25 Oct 2017 15:36:35 -0600 (MDT) From: Uma Krishnan To: linux-scsi@vger.kernel.org, James Bottomley , "Martin K. Petersen" , "Matthew R. Ochs" , "Manoj N. Kumar" Cc: linuxppc-dev@lists.ozlabs.org, Andrew Donnellan , Frederic Barrat , Christophe Lombard Subject: [PATCH 3/3] cxlflash: Derive pid through accessors Date: Wed, 25 Oct 2017 16:36:29 -0500 X-Mailer: git-send-email 2.1.0 In-Reply-To: <1508967302-54403-1-git-send-email-ukrishn@linux.vnet.ibm.com> References: <1508967302-54403-1-git-send-email-ukrishn@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17102521-0012-0000-0000-0000153290D3 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007950; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00936424; UDB=6.00471879; IPR=6.00716689; BA=6.00005660; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017714; XFM=3.00000015; UTC=2017-10-25 21:36:38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17102521-0013-0000-0000-000050042B54 Message-Id: <1508967389-54524-1-git-send-email-ukrishn@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-25_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710250281 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 From: "Matthew R. Ochs" The cxlflash driver tracks process IDs alongside contexts to validate context ownership. Currently, the process IDs are derived by directly accessing values from the 'current' task pointer. While this method of access is fine for the current process, it is incorrect when the parent process ID is needed as the access requires serialization. To address the incorrect issue and provide a consistent means of deriving the process ID within the cxlflash driver, use the task accessors defined linux/sched.h. Signed-off-by: Matthew R. Ochs Signed-off-by: Uma Krishnan --- drivers/scsi/cxlflash/superpipe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c index ed46e8d..170fff5 100644 --- a/drivers/scsi/cxlflash/superpipe.c +++ b/drivers/scsi/cxlflash/superpipe.c @@ -165,7 +165,7 @@ struct ctx_info *get_context(struct cxlflash_cfg *cfg, u64 rctxid, struct llun_info *lli = arg; u64 ctxid = DECODE_CTXID(rctxid); int rc; - pid_t pid = current->tgid, ctxpid = 0; + pid_t pid = task_tgid_nr(current), ctxpid = 0; if (ctx_ctrl & CTX_CTRL_FILE) { lli = NULL; @@ -173,7 +173,7 @@ struct ctx_info *get_context(struct cxlflash_cfg *cfg, u64 rctxid, } if (ctx_ctrl & CTX_CTRL_CLONE) - pid = current->parent->tgid; + pid = task_ppid_nr(current); if (likely(ctxid < MAX_CONTEXT)) { while (true) { @@ -824,7 +824,7 @@ static void init_context(struct ctx_info *ctxi, struct cxlflash_cfg *cfg, ctxi->rht_perms = perms; ctxi->ctrl_map = &afu->afu_map->ctrls[ctxid].ctrl; ctxi->ctxid = ENCODE_CTXID(ctxi, ctxid); - ctxi->pid = current->tgid; /* tgid = pid */ + ctxi->pid = task_tgid_nr(current); /* tgid = pid */ ctxi->ctx = ctx; ctxi->cfg = cfg; ctxi->file = file;