Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3836692ybi; Sun, 14 Jul 2019 23:16:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqybYBuPj1iPFge/igITZd+DNl4WgG/GN/eYUuAIE+Lrc7oMlXSoCOfl1F4NCBWSZlPuUHq7 X-Received: by 2002:a17:902:b186:: with SMTP id s6mr26406760plr.343.1563171367100; Sun, 14 Jul 2019 23:16:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563171367; cv=none; d=google.com; s=arc-20160816; b=0OfKogeOdMDWW4FyMMl+UFwR7Hl0PAKTn+Ls7cLLGWeHUD30oW6LZyll+hzFuq/Ii0 jJ2zkAFvPAH2aFzl96zxdgqS3TcRCYl+SYnxp7y/7uw66aw3WjjzPSKvJTPy++6mee20 TagNPJQ/UZnc5wtqaWMQakdtzAcwlfgFiyhOKUZXl7IMItoQPIjoGogKXkOx3Ekj1HX+ dRu0/BvGHPHGtId6U3BK4s3t/B07VG9yOnrOAOabavsyS0nXTPWbVEJTPA1Xepjp1DXJ G1TLie4Mm2JfBBNHKmmIokpdRXaZWq/45uyY8mlFalD/4uVWRVK5FQNmnDVqLPjJ/G7c BpxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=RIiEji5I3KbVV+XghvkwsuWmiysFPsxaLCO3qTp4irk=; b=gYg0beMq5bcjEpQ9ehhT6BVQcSmz/qdVnfnQENi/anGs+WIsoCec1CkAoBiTdUR5U5 qrfMdILid+34orAoXwbtQC22pkzoGnVRA0wX3xRSKsmYIup8bH3eVpKtonJI8ATQyjHv RLaEDeW9An+VHX1Arl+oJqMHCO0ojxuwUKmuvklZKyOKdRKbPQq2iTU7fSXMxA7r5b9N dj65OBeIe604Olb2fTX0CeZdbaCR+C8Nja/qnZb6YkRiAW15mQqacly4swwNX9l/yJP4 SAmEj/S1SMHEprXE0iAVxLq1zCemF4Fq/8btozSXCsPniWIC0VJlrGUaeV/WKp4qRaoh NjWg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j195si8426940pgc.355.2019.07.14.23.15.46; Sun, 14 Jul 2019 23:16:07 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729073AbfGOGNk (ORCPT + 99 others); Mon, 15 Jul 2019 02:13:40 -0400 Received: from mx2.suse.de ([195.135.220.15]:52670 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726075AbfGOGNj (ORCPT ); Mon, 15 Jul 2019 02:13:39 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E7ECFAEA4; Mon, 15 Jul 2019 06:13:37 +0000 (UTC) Subject: Re: [PATCH V2] mpt3sas: support target smid for [abort|query] task To: minwoo.im@samsung.com, "sreekanth.reddy@broadcom.com" , "sathya.prakash@broadcom.com" , "suganath-prabu.subramani@broadcom.com" , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" Cc: "MPT-FusionLinux.pdl@broadcom.com" , "linux-kernel@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "linux-block@vger.kernel.org" , Euihyeok Kwon , Sarah Cho , Sanggwan Lee , Gyeongmin Nam , Sungjun Park , "minwoo.im.dev@gmail.com" References: <20190714034415epcms2p25f9787cb71993a30f58524d2f355b543@epcms2p2> From: Hannes Reinecke Openpgp: preference=signencrypt Autocrypt: addr=hare@suse.de; prefer-encrypt=mutual; keydata= mQINBE6KyREBEACwRN6XKClPtxPiABx5GW+Yr1snfhjzExxkTYaINHsWHlsLg13kiemsS6o7 qrc+XP8FmhcnCOts9e2jxZxtmpB652lxRB9jZE40mcSLvYLM7S6aH0WXKn8bOqpqOGJiY2bc 6qz6rJuqkOx3YNuUgiAxjuoYauEl8dg4bzex3KGkGRuxzRlC8APjHlwmsr+ETxOLBfUoRNuE b4nUtaseMPkNDwM4L9+n9cxpGbdwX0XwKFhlQMbG3rWA3YqQYWj1erKIPpgpfM64hwsdk9zZ QO1krgfULH4poPQFpl2+yVeEMXtsSou915jn/51rBelXeLq+cjuK5+B/JZUXPnNDoxOG3j3V VSZxkxLJ8RO1YamqZZbVP6jhDQ/bLcAI3EfjVbxhw9KWrh8MxTcmyJPn3QMMEp3wpVX9nSOQ tzG72Up/Py67VQe0x8fqmu7R4MmddSbyqgHrab/Nu+ak6g2RRn3QHXAQ7PQUq55BDtj85hd9 W2iBiROhkZ/R+Q14cJkWhzaThN1sZ1zsfBNW0Im8OVn/J8bQUaS0a/NhpXJWv6J1ttkX3S0c QUratRfX4D1viAwNgoS0Joq7xIQD+CfJTax7pPn9rT////hSqJYUoMXkEz5IcO+hptCH1HF3 qz77aA5njEBQrDRlslUBkCZ5P+QvZgJDy0C3xRGdg6ZVXEXJOQARAQABtCpIYW5uZXMgUmVp bmVja2UgKFN1U0UgTGFicykgPGhhcmVAc3VzZS5kZT6JAkEEEwECACsCGwMFCRLMAwAGCwkI BwMCBhUIAgkKCwQWAgMBAh4BAheABQJOisquAhkBAAoJEGz4yi9OyKjPOHoQAJLeLvr6JNHx GPcHXaJLHQiinz2QP0/wtsT8+hE26dLzxb7hgxLafj9XlAXOG3FhGd+ySlQ5wSbbjdxNj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/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190714034415epcms2p25f9787cb71993a30f58524d2f355b543@epcms2p2> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/14/19 5:44 AM, Minwoo Im wrote: > We can request task management IOCTL command(MPI2_FUNCTION_SCSI_TASK_MGMT) > to /dev/mpt3ctl. If the given task_type is either abort task or query > task, it may need a field named "Initiator Port Transfer Tag to Manage" > in the IU. > > Current code does not support to check target IPTT tag from the > tm_request. This patch introduces to check TaskMID given from the > userspace as a target tag. We have a rule of relationship between > (struct request *req->tag) and smid in mpt3sas_base.c: > > 3318 u16 > 3319 mpt3sas_base_get_smid_scsiio(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx, > 3320 struct scsi_cmnd *scmd) > 3321 { > 3322 struct scsiio_tracker *request = scsi_cmd_priv(scmd); > 3323 unsigned int tag = scmd->request->tag; > 3324 u16 smid; > 3325 > 3326 smid = tag + 1; > > So if we want to abort a request tagged #X, then we can pass (X + 1) to > this IOCTL handler. Otherwise, user space just can pass 0 TaskMID to > abort the first outstanding smid which is legacy behaviour. > > Cc: Sreekanth Reddy > Cc: Suganath Prabu Subramani > Cc: Sathya Prakash > Cc: James E.J. Bottomley > Cc: Martin K. Petersen > Cc: MPT-FusionLinux.pdl@broadcom.com > Signed-off-by: Minwoo Im > --- > drivers/scsi/mpt3sas/mpt3sas_ctl.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c > index b2bb47c14d35..f6b8fd90610a 100644 > --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c > +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c > @@ -596,8 +596,16 @@ _ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command *karg, > if (priv_data->sas_target->handle != handle) > continue; > st = scsi_cmd_priv(scmd); > - tm_request->TaskMID = cpu_to_le16(st->smid); > - found = 1; > + > + /* > + * If the given TaskMID from the user space is zero, then the > + * first outstanding smid will be picked up. Otherwise, > + * targeted smid will be the one. > + */ > + if (!tm_request->TaskMID || tm_request->TaskMID == st->smid) { > + tm_request->TaskMID = cpu_to_le16(st->smid); > + found = 1; > + } > } > > if (!found) { > I think this is fundamentally wrong. ABORT_TASK is used to abort a single task, which of course has to be known beforehand. If you don't know the task, what exactly do you hope to achieve here? Aborting random I/O? Or, even worse, aborting I/O the driver uses internally and corrupt the internal workflow of the driver? We should simply disallow any ABORT TASK from userspace if the TaskMID is zero. And I would even argue to disabllow ABORT TASK from userspace completely, as the smid is never relayed to userland, and as such the user cannot know which task should be aborted. Cheers, Hannes -- Dr. Hannes Reinecke Teamlead Storage & Networking hare@suse.de +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg)