From patchwork Thu Feb 23 00:19:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13149725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 569A7C678D5 for ; Thu, 23 Feb 2023 00:20:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232865AbjBWAUJ (ORCPT ); Wed, 22 Feb 2023 19:20:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232796AbjBWAUH (ORCPT ); Wed, 22 Feb 2023 19:20:07 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B12F62313C; Wed, 22 Feb 2023 16:20:06 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31MNp8q9007624; Thu, 23 Feb 2023 00:20:02 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 : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=2mClXI10T8EIPeLA+eZAmowoCQbblUSf3AtG69qFTQ0=; b=dwGmn8g73uo/fRTXd/c3zcjvp0YTQWrSnvw0FUBfdbhYhEeDBq+ZAEzZ857Yt3L+3h9E d7ByHXtJfeUPFbq7Oa7Tok6R5DHN1NMPkIsZpXukK0U8VAE8siz6QqyAIvxQind8XfN9 pkMZYxSMJa3JZtMpY5IaE5mKJIqGnnQTHV1LrO0q1TOzK9T9+i3BVnJMntW5z2/ghUMF L3OiassUKZ5yW+4avxo67Q9Vf8GCgKML6mZfCLotJgZGY8KJ5Hbmz+uVEB6zsQFPRE1j 46SURJ6Tgd+BtTRdaqzXZ5WFHFRxE8Q+Mnwj+83le4of/kCld/nG4HqaaAzFhvAnP1xz 7Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ntp9tsdqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Feb 2023 00:20:02 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31MMqpsV023257; Thu, 23 Feb 2023 00:20:02 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2048.outbound.protection.outlook.com [104.47.74.48]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ntn47cj97-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Feb 2023 00:20:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cOBgLZ+Q5iHZ7OMcCdm6wdJ42rQV12aKP96wEEo7Rrn/BxI97tF7BMsfm0vf/D2jTpRxCBIAKwL67Z1CDzKVwoN78tyn+MJMhjgyCbuvzDVm9aSDOGixozUS7559NlmW7CVXpdmWZdfkvYhmfdg1lI30cPLlFflKn3mN/5lgRzOyVNRvSbyUiYPBI9rCE8B/ecGIv0iuRDuI1mZ5GcKwiSjFJlZHrjfR+5XS8KWGXwNe9u7Rc2Jx25P9jSgQW87MNIsZh1VpoOnKjKau6LTA3zxCCBLeGyUmANxWq2ujF7dXbKcH50Zf9M1gptK4X5afqe3mhpSIp5EP1tDsaDSZWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2mClXI10T8EIPeLA+eZAmowoCQbblUSf3AtG69qFTQ0=; b=RFrl3CxYIpGqa/ss5D0LfAnrLTmI89cKDNdgJSOPl+Pk5lkn0k6bRP8L6OMWGjTkajMtqLEq+LKnxdK0F6AjXIJvwjWyZnkdBYWtxNI1uqm6ZzlIKrXd/g66qQtbrfpnESRSzAjfiTdVGfYLQKeso/QQUb6HN7N/QKac/7F36bV9iG64tPzJQ8IbC4GdT/lUV+tZOmjzz++bQrkResr5ntKau65U1tJB4SV21DPIGvyNSIS/CPNGDAdcKu2g8Zy1/jvoZ7ViuEzgjAUeII9SvHBJNIcL8FNsII5FJVIuI1VP9RwEADs4hWS93UIHEtpvSTdOba8CJLJu9MKKE/Pxjw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2mClXI10T8EIPeLA+eZAmowoCQbblUSf3AtG69qFTQ0=; b=MYKZaO1A8exPS2tDvMq4k3gJdSNONMUmao9rIjc7wcmY0ZOfr1oZNHAdAAeBRjkV7kuOwmAIFnvQ7Q7YZGsmBJB3nBkVEjsw06xHhLfGaMOg4XjKDVjACkpDNkBGBUOcNP7WLoiMQJIX9MmeC5v1Uz52zt/eqlXz0Xpb3Lw1omU= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BN0PR10MB5286.namprd10.prod.outlook.com (2603:10b6:408:127::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.6; Thu, 23 Feb 2023 00:20:00 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6134.019; Thu, 23 Feb 2023 00:20:00 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 1/5] vhost-scsi: Hold tv_tpg_mutex when decrementing tv_tpg_vhost_count Date: Wed, 22 Feb 2023 18:19:45 -0600 Message-Id: <20230223001949.2884-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230223001949.2884-1-michael.christie@oracle.com> References: <20230223001949.2884-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0093.namprd03.prod.outlook.com (2603:10b6:5:3b7::8) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|BN0PR10MB5286:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c5ab632-1a4e-479f-a78d-08db1533b39b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OvIiNLMdDcJ1VkiMsL0XEgOFuHab4o3l6HtbE5u9UBlR9LSEM2t1+ghrVpyqoKEq9u05gTRKdqTVem49I2gCZl3PSBAwdIDDzT1jO8myFOKIv1CVA4+cepRZYCUJITa2Gx5lE+QXqDlB3laDKnHVIK/6/zbe/1x6MfG2S85zod+rQj7S2saNpxkMyPa9KorxRc4pehv8pRCXln5we7YLk/jmhHgONlzmiuPv4sNDZaq1G6FRw+Dox24qpLfZ1Sbm4vv0iBNZ0zoFXXLvZ7Fpgb0HeVEekPhLTce+wtajV9CDKamgzNSifgDJDZU2PMt2/Tge9bh5uBtRqigmpqxc5D8eROAx5DOMvQjhoYmZEJw7oo9oQ4tEz0q1N14l4rLbIv6YcKPXFTomaMkKVpRd4MtXHpDY7qTXZrI6uQroAw7G+xplrR6bOFoB7xwPherOg+RUxMYVFFLlrpCxHZmcg7pqUV5FgM5usrsontwlf8ylKorR73WuUJQYMzJPLBhtW5nw3aI1Wb0RIJWEy25+OFKEEzHuCkV+qEWWUiODGbOfR2zr5cK4kxNqLKx3iTn1sfI4lCkbOxmGhysP5bBHK+Jda7Zu/FBfNI1DKhgFHal5NPG17E+Caf11VTGA+quDM0UTIzBsFlpB2UfCoECE6Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(346002)(39860400002)(376002)(136003)(366004)(451199018)(5660300002)(38100700002)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(8936002)(2616005)(26005)(186003)(1076003)(6506007)(6666004)(6512007)(2906002)(83380400001)(478600001)(36756003)(6486002)(107886003)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: x6b+ZYYbcjb53PcSkrvaGrHPSQqH+A96w96zXU7Czcr3b72vcqNdOhssREr8YrCDcqzcwDfy4hc3z7o/liXFRSjtTMQ5NUIEyFgYOOScS/czjTgfxnRbX20sSnxn9M6IM7AElLtk5qzV2n5bbN95BhRqyR2rZcFoQdlzxFCB4lfB9nIcrxZh7qhxHTMyv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9vHh5SIyV9KJXM5h/Fqx3augg90jLzfgGbj3q9JYj5Noqnu/HeM5HsLQXLMddcHA2fq2BH7qieQAu2CW19/fzcQ42l5phJA4i6lXQnBZ/ATBjRtyku+VfTd/7sJdfyffQphsppGnQle+mdeFZVtwgVvA0tgpGew8PkOSCj3TnptdQO1wj7yPPUD9qBlfAyVBcWvpth3kC62tWEHZrozLn1Ux2G3gA6cmRT9BytV4EXiOjyh97gwCY5UUT4IU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c5ab632-1a4e-479f-a78d-08db1533b39b X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2023 00:20:00.5457 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5qWRCbVdE6/T71Q71mL5cNt4/1sm169G2Dt03Han9iCWiiLYTkA35pY5G6lP/evnoFoVC/u7r6cjquYvEU8GpuWv0auyUy7yA3utsMUyMBE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5286 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-22_11,2023-02-22_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302230001 X-Proofpoint-GUID: UOUf1BxVu9PYWdso4R-lqOdEvzy8MhHV X-Proofpoint-ORIG-GUID: UOUf1BxVu9PYWdso4R-lqOdEvzy8MhHV Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has us hold the tv_tpg_mutex when decrementing the tv_tpg_vhost_count in vhost_scsi_set_endpoint's failure path. We currently don't need to because we are holding the vhost_scsi_mutex and the dev.mutex when incrementing/decrementing in the normal paths, and we can't hit the tv_tpg_port_count check in vhost_scsi_drop_nexus during this time because there is a nexus and we have a refcount to the tpg. In the next patch we will change when we hold the vhost_scsi_mutex, so it's not always held in set/clear endpoint and in the future we might change the dev.mutex use, so this future proofs us. Signed-off-by: Mike Christie --- drivers/vhost/scsi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index d5ecb8876fc9..c31659aa5466 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -1658,7 +1658,9 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs, for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) { tpg = vs_tpg[i]; if (tpg) { + mutex_lock(&tpg->tv_tpg_mutex); tpg->tv_tpg_vhost_count--; + mutex_unlock(&tpg->tv_tpg_mutex); target_undepend_item(&tpg->se_tpg.tpg_group.cg_item); } } From patchwork Thu Feb 23 00:19:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13149727 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39011C64ED6 for ; Thu, 23 Feb 2023 00:20:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232867AbjBWAUO (ORCPT ); Wed, 22 Feb 2023 19:20:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231820AbjBWAUK (ORCPT ); Wed, 22 Feb 2023 19:20:10 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E274241090; Wed, 22 Feb 2023 16:20:09 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31MNiMoN007598; Thu, 23 Feb 2023 00:20:06 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 : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=sTo17Bubdke+YOcOvG8UaJoxskwSobyL8YwVTD6ooNU=; b=IiJ+gVZuC1r9XQ6v+lNj2K9lwIvdN9PmTZkEib+q04Dx4ZV39iFtQ/0Ck4iU6ek+ZUfy qB6W6gxEQuPI/0Uc2RfwpKRNgUJne6ODih2NAxUL26VOkoSjuhtz8OXz4CQ1XkXGmZ2a AkFUggz8JbllI5SiQSggVgdS2eFXKEj3wYXep5mte9bhAW+/R8y7un74Xx/lYORqRd97 o49tjby0zGxZy+H7vksfyvye1cSMb6zySvG8b/2HGnUGqSh0KQnZ+opZkfa3O2+PrMe0 NolQI/MT/LQfTrjXFiMo16XDv7weXXYv70NYiCRyyVgCIHhdPTlubvhAzufoX5CUIvI/ Dw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ntp9tsdqm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Feb 2023 00:20:06 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31MMkhC3031500; Thu, 23 Feb 2023 00:20:05 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2045.outbound.protection.outlook.com [104.47.74.45]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ntn479u23-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Feb 2023 00:20:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fium69raqNq15kXAQeSA8VbJLkMLAwKr7EAkJkVAZyW3L6SOt7Pqan7wvpa3tMRWTsjUm3kbXk8QdyTIpnOoBS2ztDkm5uezb2/92YMLx4OiR2auDWhVvpnsc3V5mFErDvEZWqjLsu29xOa/oE5uXUeVPdOdmliAl+g331kK/Qn33YFR2YZZ6Yd95jXcXZl+hAAJxfrZcGWaccPLOjTbHVq8EL989Ba9/S40G9fbTMCYA3aJYaKlyJclnDpR69Vg6Fl1cdLjBS2E/avWfLyt8ZHelPIn+NFpSuwNF+MpY+ktl6iycJ8sYib0WgXR13S2recZVuUP4Ygamdfd26GInw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sTo17Bubdke+YOcOvG8UaJoxskwSobyL8YwVTD6ooNU=; b=j9wbgvYk5xLLQtIZcvmm9RIJ4Wop6azXl/I3lkhttJWtnKvzWpcZA6oTY7ZrfuQ842fHOz5UkkPAA+Mm5R2ij8l3aCMqnmRb07o+AWpUPjNK7Od5sQ5/on0fxzUQXRCiMq1Bhd2Okn96Nng1MJDBCISMHCYGijVy8JYaewIkfrvjlnjd3NgRensS3hWpSPNQXCxlUeSz5qOuK8NjcDVKwM2OtZlzUv/9ujRjJiQjPbv3BbLBkM6lSMjkfJKiGccLrE2i42S8KXp3YfJDrS4RXewMHKqKBBtTMtj4EXJd5JpMPMXfqmqzEZOy8s39fGAIim6Aox5DUiinzgggN0Agdw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sTo17Bubdke+YOcOvG8UaJoxskwSobyL8YwVTD6ooNU=; b=tDFYdjqEoaGQzBzjAWEfWCxixJHNkp+LHOpqCDgYxzLCHnl2HZUQgNY3vyRxNThoLz2ME2xKYgR03bsnKu1S7Jtfd/pVMREXCDkVzTLb0WJ22FZZeZ2TRPpbiFFN89V+dxp2HNb3pSNlo3vGaZJVv16Nmo8rnwP2ikDp2tKJVEE= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BN0PR10MB5286.namprd10.prod.outlook.com (2603:10b6:408:127::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.6; Thu, 23 Feb 2023 00:20:02 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6134.019; Thu, 23 Feb 2023 00:20:02 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 2/5] vhost-scsi: Drop vhost_scsi_flush during endpoint clearing Date: Wed, 22 Feb 2023 18:19:46 -0600 Message-Id: <20230223001949.2884-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230223001949.2884-1-michael.christie@oracle.com> References: <20230223001949.2884-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0003.namprd03.prod.outlook.com (2603:10b6:5:3b8::8) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|BN0PR10MB5286:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b12422f-d0f1-4802-3083-08db1533b4cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fwlXWItwcC+9sDDCFQBlD6UrAONaRC24u2s1t1qsTRGRKANiwfpscxaZ+QmkbYKjntmm7XPeUQY4sGszE0Qv+RxK/Qx/kcvFS+zGIdZeghe7jwNvD28I+6k5n9BseSM/Gy2yi67jo2UV/0YY7rb2KwhPIX93fQaeQxfrlYYIdfmqmJaKVI8YMA9M6vQ14HQSxIJ4j6MgAYIGKJSkAzirBeC+pslJRBhvo46dMGWWCTc6tpVeBKHBZ0kjdt72zbdoJNu+U/Ppdg8tZahlK7ghfUXqzz3vmA9CcCb/YvsJGJObqVDDAWXrLAJJZdYlQL9usv295ssvcCCWXYasdpEQ+Vrz9hopjCGDIPRIq5A73C73N3xpyTFo8yI3rj7ZDWR3KF/oDrWdGt/A0M5VZktvrGOvCwPjiddURpfZom+SfZZMs+6UyZrQocfgjNqN9q4xK/vOEODUrxhnR9D+dI/j11EUXAwl/9Ct5nG683UUvfGwx8UI56ADneeQVAfJYRYrAzXjHG2kD0zWpEgb18l7IT+hg63XhBAwVIW//fJb1LwKt4opbX0EcXGuWmODDRM+ha1ZHwnu4ebDLLZhpCxLXaQsLfdsEkOsp7L+qFE4kC3fX2Nd37aXBEklVdZzgpoFGPa2Yxb6Fex2NdePZy2tbw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(346002)(39860400002)(376002)(136003)(366004)(451199018)(5660300002)(38100700002)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(8936002)(2616005)(26005)(186003)(1076003)(6506007)(6666004)(6512007)(4744005)(2906002)(83380400001)(478600001)(36756003)(6486002)(107886003)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LJweNAkpKAfF3bWHzhaBrX7BZ+juoqoWrckaitb3Qe4a1fkfc7y4t4dwaBpxGWJagDox8LpshFjFTZo5ZZ/yo9yBzXC/p+OhQNfca1AP5K8s/pwgCTm3/OWlA+qvMCXDaQd/7xC1045JD4zDPwpug9abo5nw4Fo6IvMCpmMQl5BGFJ3kfVpStFQgG0GTIIalhLnhJ8crYW5nk/zpgEj5u6IFgzsC2SkU4rX8/XCN1BpV2KnSrPtb7TIo+93Wql4R/pQYRKgMnSZb6PiHiBMiuInq3xWjdPLyVKXE23HXdDjpX3vfZqxfy2HpupaBpibyeUA3qqin4tPLLK9f2A5l3fjruIRGzNhz1qL+8YiHOu1iKeYHYSMLBrFketIRSObc6jZGYbQszu28Xt5G9ZGrBDdmqY9Ah9GOhQGW2n6xvYpc9fTEnbLsSSK27bycWTHpTwGtJHsRfl68n/pI70YhPR6Tz5bjjfbxThqdwEpFytVQIKXT/c8eX2eLgP6mSGp0tHb8WQdatlb8FhkJQhxLwKOH5KLF6Ic5fys3gg9FrthU4G0Q+VHRc7eLZgB3O48nc+v4XoCxfriOClWr46b7tUbPCO5GdXrjLzXmyCYJJx4nFA7Ub0/M5RHjtD7MOUWH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2NkFC/nk+WAv2bjVn2rakr2lo4jwzkUFHueOotf87IjYECpaBfy4nusqO6Q3wPF5N+pv/d203Vb9yvO/QJnjlSnyEk4EOonpRR57rcc+xgPV2h3xLUxUh611c4Fner1TXngYM9WN4Vl07UxlxwG6oIOmdsPsoEr+7XtUgITjxINqcGSCqDW8pzXyZahWMKoxjYe9cFTImkJisBI18vbjfhqsbhERRlXxqO0D/7vvoCI0z/CoCqj7MmnrLMvkwBQcD52g/67UuStaO1c+6M6TMINbiF2CDuYa6YnOD4EjVyZTF/Tcex/ZR/IYi/J3V4KriZD5Ei1eMBRkfobaaaZGUjU0JVDfWuNgqcqH/K98uaIzNeWdOtUZZeRhHR3WqQcp+/8nr0LwqtzoMzQcG2bGMqY+MgnQkE1x1lRQeWbxM6WFDV/AAQxhqQ/r0BB7c3k0wKwNmIPXFiLFrlLmxmgAJA3wiujQkpoc3tFmPj338nrEGnp+Z4xLNVCAq9Hha9ySYKi8hu0RXbfFxc8iZCAwkcbH1qlc/wUz+WIxE8gHRXtxIi9bhuBlbnjb73SXxVcKps3a2KAmHM/XyT9/RdwRhaSF902+j18r5WMmNpqWkGZRSyzCLD+pk72C35VXTMkAE1WwPqkhA2JtjRWcjTB8vnfFtLZ+1PzsZ3Q9dcBHFSn8tAdFdROTa73rxvAfkGz5JEFE+4SxF8kIDhyOZSQSaW6BrJDbciZ0Trn86kYIdTN7nDO74Ghj0tvPqAVliyvGcgVRKNzbhoezPzlTpQl0021bEOOqCMiGzG52MPDYebyFxbZrpnUgzmWg1PPUcWIeh4dnXtIDx1jrflC3Lulk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b12422f-d0f1-4802-3083-08db1533b4cf X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2023 00:20:02.5455 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bhKOPrn34hUTQUf4VF/6DExueO8DBjCazXSOaZQ0AJk7r8aUjR/qQyJyTFimRlWIirlvem3XHmZqIu5tdh/WK/X3ts6f9EqoHAo2SWJ0Y+4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5286 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-22_11,2023-02-22_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302230001 X-Proofpoint-GUID: p-9oqMy-G7bTaGoz2O0zstj2hs9eiqSg X-Proofpoint-ORIG-GUID: p-9oqMy-G7bTaGoz2O0zstj2hs9eiqSg Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We don't need to run vhost_scsi_flush at the end of vhost_scsi_clear_endpoint, because a couple lines before this code if there are any tpgs in vs_tpg we take every vq mutex and clear the vq backend so know there will be no new IOs accessing the vs_tpg. And after we clear the backend we run vhost_scsi_flush already so we know there are no running cmds accessing the vs_tpg. Signed-off-by: Mike Christie --- drivers/vhost/scsi.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index c31659aa5466..502d64b53d9c 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -1746,11 +1746,7 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs, vhost_scsi_destroy_vq_cmds(vq); } } - /* - * Act as synchronize_rcu to make sure access to - * old vs->vs_tpg is finished. - */ - vhost_scsi_flush(vs); + kfree(vs->vs_tpg); vs->vs_tpg = NULL; WARN_ON(vs->vs_events_nr); From patchwork Thu Feb 23 00:19:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13149728 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 489EEC678D5 for ; Thu, 23 Feb 2023 00:20:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232869AbjBWAUP (ORCPT ); Wed, 22 Feb 2023 19:20:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231567AbjBWAUM (ORCPT ); Wed, 22 Feb 2023 19:20:12 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D4A7460AC; Wed, 22 Feb 2023 16:20:11 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31N0HFQl003422; Thu, 23 Feb 2023 00:20:07 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 : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=jW3HSCGNQzDFxSxggapaugLhqWKpwDvq5NdU9JGGR3c=; b=CTGYjfCbEzU78oiMlJg/VnjrzrekycOey0wjYUsUjdOlbkRbpbm8+s1pKMOyjZVY5qjp DDzKOZgDc2hLzUHkoltMEsngo2p/sg7kcBbrTplRgb00AG3JjGUYjVVakAp35k3QCn25 raw6fhadoa1LZdoto2bTdBuuStKdt3XxmKVjj2jspzfRkfIS0/jaImDoBmGM8SJpR6ti CWnw3kFaIAR22wFQOBFyYil6NX9pqpWOx05HqJdJ+eCpgLFVD6+7UZy6VwEdzb13J92S GYLLdEm3S3bVHG7tgv8SvXR5CQundJE7Qpq94Ie8fB5lBeiqDWjnD8Cv3xT/cGGmLyRt kw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ntn90sbrg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Feb 2023 00:20:07 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31MMPovA027301; Thu, 23 Feb 2023 00:20:06 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2044.outbound.protection.outlook.com [104.47.74.44]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ntn47j3v1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Feb 2023 00:20:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nyrn9SFzoKb3iIf1Swqg/Q8KF3ulf2N4OlmiVj8PXxQogqOrmC8ff3/fZT+F8kMazqbywmp6SIEPc6ujeKZlnFktQInjjJZTPvxQn7XOoJzW2aMcjB96edWmtOegQeobjSNucp/0Fkpd+MyPNF2BCSLmvlKqIM7hUntvfwtNpVvOiqdV9m8FTRHrfHOgH2fTZPX9xIlPYjNLO0sn2ICL89CtHoYAN6Imf2Qqr+FQNVLy4yblusDJZPCoC0YwFSBfNw4niJ/vd5Pf3RIn4JpBTJ4f+i7yWKdpX0OgEyKgtEWeRZHtXhFPa6CCSZ6HBoMZ83iZS7R3BVCTKimwIHXrIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jW3HSCGNQzDFxSxggapaugLhqWKpwDvq5NdU9JGGR3c=; b=SX633bLBLLG5XMrSvEk8CjgR2hCJZKvi8WVvno/oCPqcfmMTxlSu3YAvTtmd2Ucii2TZHuELP/gcrDHGJzXtGjRlr4xyaMhxW3clifSt9bl7nweywuu6Fft0/qsyNtwazG5K+JHZsfVEYhrz5jtjvgB4tfzU482GcG++Rb01VxHXUJNCbNmRIw3ut7/3VN23dBzq5hRrGmQVDCRYea0TroxzYHTG1lbOFb0Og+Vin7n/Dbv581FTODZ16CZG7f43MppuhM3dMyEiwGJJOCVx5H1VbQFYe4tkeEQvLTtNPXA+iiAsmWzPxgXE1jpaCaNE3OChfJXCBcyFKX3FBpPtFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jW3HSCGNQzDFxSxggapaugLhqWKpwDvq5NdU9JGGR3c=; b=s0dhco4qb23Z3+W/YjvFRZOV8Wi6+ymKqPe0JvexKNs9LXFJgKhPfTeNShy91cyO3UK3ceX2/glDGPuHYX6ubNGPibTFH5H5p1/HeVMioGlOd1zwFcDF+0snj0tUu52VTaNNtHnokq/ywg+zt3Y7JL98qsfgIuUJn0lwIORndVM= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BN0PR10MB5286.namprd10.prod.outlook.com (2603:10b6:408:127::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.6; Thu, 23 Feb 2023 00:20:04 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6134.019; Thu, 23 Feb 2023 00:20:04 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 3/5] vhost-scsi: Remove vhost_scsi_mutex from port link/unlink Date: Wed, 22 Feb 2023 18:19:47 -0600 Message-Id: <20230223001949.2884-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230223001949.2884-1-michael.christie@oracle.com> References: <20230223001949.2884-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0166.namprd03.prod.outlook.com (2603:10b6:5:3b2::21) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|BN0PR10MB5286:EE_ X-MS-Office365-Filtering-Correlation-Id: cfea0f79-aaa6-4dc6-a4f4-08db1533b60e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C4Iw60UX1a4LIxeb50eBSunybkWMNwp0vWZAjM+FmP+HRQE9gxrP+E2aHD11APcCO8VT2V2REvavhzjv3eYzZ0CyirR/R6MYXmiEvCp3DDjWaFZmQdaX5LD/M0v7RrYWpdsphi4iI0k8jeOx1MuiiDDvTpwya1Cab02oXHK0EePsI04mp6T/CjfwNk/9fw7BFM9iCughig9+6jdToPhgGmu6qtbjLcBBeWW1/Q9sWSqYuxvsF1TncOiP9ge4rBkaCJiBn7ngP/kZvVZKSV+WCP5kGdOovZokOmpxsRqCoUCtF8FwpvXRIDvcmSJ0YROAqKzTqZZEnpeVmsozvGWI/C3LJNP0P7NCFnIFlqp3l3+/sKjwV8DBCtOz93dgD1iyHszi963YCzLsQFynPYk82DYvFfoM45QaFDjGq//hbCoe5niIoJxOUJMnu70A+jc2XhpA3x+x2VsYS1HwJMrSFQBRkMtzrXkzdU5jta3WgMcJ81Dg7eDDWECQAekTEUl6uyJMDst1zWVfwij2T67Oq9CV4LzFrOsmhgq9n9ZOrp6ZbKqW1MPNvJv2QlLouWKMT7XXB/xrfb93yh0aFkIGsROYsfOPAxCGkVFtXa4RIDrKXjDMUkMKsIv6MmEkhjVzbEOGNs1E1FNwc6Y8e/7RkQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(346002)(39860400002)(376002)(136003)(366004)(451199018)(5660300002)(38100700002)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(8936002)(2616005)(26005)(186003)(1076003)(6506007)(6666004)(6512007)(2906002)(83380400001)(478600001)(36756003)(6486002)(107886003)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ixm2APumW1NCIu4aDq8mapzRdjVQ/ua2yVTOmKKhQxiOC8fxZFqq10BeHUHn/Ql1CQutR8JqNZWpAScq7eiVGFsvdamnJ9Qeka3Mn81wVSSsaYffH5jaRicyadkSCey0BIA2QfA6HKQQcilhenDsqc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ifJBJxl93EUTD3KXDCFxw8Lti7RMk72R40kgCMX0Slsz5o7eftqPiL0LpCVKYVeHevYpiyE1q6AEjkeHZEujSrBRnAmCd93LRVwppD4QLuLVCBXARt1b3giwQciub+NhQVPmhbz2CkXBYpSyKLkokvNd8dWXx1ECmnflpT6weJLGbo7UpIgrk3hhvXlKzoDlKd6FREAuBRXkZqpn7MNzRE11s0xjFr5uDozVLdNuX2p69q/OuJMmm/UU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cfea0f79-aaa6-4dc6-a4f4-08db1533b60e X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2023 00:20:04.6547 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: l0+FMVYJqErRD7CMldimd31kUZB0Feb+iVQLr1bNrWcK891jSzStvaqDqjBSJ9RUVdYIUOPHYu7+bcKkLXw33E5wjuIBO6cp71uJt0pmIYE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5286 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-22_11,2023-02-22_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302230001 X-Proofpoint-ORIG-GUID: Iprwf26T4ozvu1kHzJiO4TP_qosUjuEA X-Proofpoint-GUID: Iprwf26T4ozvu1kHzJiO4TP_qosUjuEA Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We don't need the vhost_scsi_mutex in vhost_scsi_port_link and vhost_scsi_port_unlink because LIO has a refcount on the se_tpg for us, so it can't be removed while these functions are called. This removes the vhost_scsi_mutex from those functions to avoid cases where we are adding or removing LUNs to vhost-deviceA but are stuck waiting on the vhost_scsi_mutex because we are running vhost_scsi_clear_endpoint on vhost-deviceB and it's stuck in vhost_scsi_flush waiting for a flakey physical device. Signed-off-by: Mike Christie --- drivers/vhost/scsi.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 502d64b53d9c..9e154e568438 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -232,7 +232,7 @@ struct vhost_scsi_ctx { struct iov_iter out_iter; }; -/* Global spinlock to protect vhost_scsi TPG list for vhost IOCTL access */ +/* Global mutex to protect vhost_scsi TPG list for vhost IOCTL access */ static DEFINE_MUTEX(vhost_scsi_mutex); static LIST_HEAD(vhost_scsi_list); @@ -2038,17 +2038,12 @@ static int vhost_scsi_port_link(struct se_portal_group *se_tpg, INIT_LIST_HEAD(&tmf->queue_entry); vhost_work_init(&tmf->vwork, vhost_scsi_tmf_resp_work); - mutex_lock(&vhost_scsi_mutex); - mutex_lock(&tpg->tv_tpg_mutex); tpg->tv_tpg_port_count++; list_add_tail(&tmf->queue_entry, &tpg->tmf_queue); mutex_unlock(&tpg->tv_tpg_mutex); vhost_scsi_hotplug(tpg, lun); - - mutex_unlock(&vhost_scsi_mutex); - return 0; } @@ -2059,8 +2054,6 @@ static void vhost_scsi_port_unlink(struct se_portal_group *se_tpg, struct vhost_scsi_tpg, se_tpg); struct vhost_scsi_tmf *tmf; - mutex_lock(&vhost_scsi_mutex); - mutex_lock(&tpg->tv_tpg_mutex); tpg->tv_tpg_port_count--; tmf = list_first_entry(&tpg->tmf_queue, struct vhost_scsi_tmf, @@ -2070,8 +2063,6 @@ static void vhost_scsi_port_unlink(struct se_portal_group *se_tpg, mutex_unlock(&tpg->tv_tpg_mutex); vhost_scsi_hotunplug(tpg, lun); - - mutex_unlock(&vhost_scsi_mutex); } static ssize_t vhost_scsi_tpg_attrib_fabric_prot_type_store( From patchwork Thu Feb 23 00:19:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13149729 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3802C61DA4 for ; Thu, 23 Feb 2023 00:20:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232880AbjBWAUR (ORCPT ); Wed, 22 Feb 2023 19:20:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231901AbjBWAUN (ORCPT ); Wed, 22 Feb 2023 19:20:13 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9B8023867; Wed, 22 Feb 2023 16:20:12 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31N029kp022694; Thu, 23 Feb 2023 00:20:09 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 : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=WT+D58Mm/6m5WJdmwoMcIEWA+gkAk8jkSTlxzNZiDT8=; b=X8GCn1la5UAwtN3lU4Bj9yPuDj/0cgE3nAvk1Q9dXT50gxu7lQ68nuwcDHZrQFlh8zCl liecDmgCgID0pT09x+14HF+HYQZA2+j5KmCYJ9vHmqAMj8mcHvswrnf73+kCpu21eRk7 CF2tGmf8i18iFZpZqM7D83oLf93lTDKcy2I8qxRP11VBHNbWO9I1bK/v8As9i9PAsZ26 DqwCBHRyRxO6i7WYOTMOIwHG7736e8kS4fWKAO6Tgp5vyF9yJZNHACwLIlNYkPd6w7YD noe1qvzfB3NoXsv5lvpKpKo1nAIXZknsa6cVMwBWCL6+EZUSo9nRx2Tc8cGX8JSRICYv Vw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ntnkbs9c6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Feb 2023 00:20:09 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31N0Cq4h027367; Thu, 23 Feb 2023 00:20:08 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2046.outbound.protection.outlook.com [104.47.74.46]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ntn47j3vw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Feb 2023 00:20:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YCJu9NVwUUBjsrlSVNoQgMPPmgAh0Ksyq+tsOrYXOisBHQTo55yh1MoLZv6k0RGvA7g0/qZGqa7o3YmSSjBzoXXIR5vjJsDzDsMNxOuulwTSGgN20NT11wZDFJtEd2FFc9TJjcTqSmyuNZhqfj9dIHEapYkRC7la6sVnSUcVMC2DDICITrdIw7PG/XoJ+8DYRIM4fMek1m4rLvKj6VB4QHht+GeNx4bk8tR97ar0vtSSh2qU4Kw69+KszpGbI9qmpIBTbMDwGKQJZjtmPwS7JalpM48OjssryoEXhIgVkFHiwVKQvKGn9WMF2zPFPKE78Gth1WOw3EekfYTc8TvOZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WT+D58Mm/6m5WJdmwoMcIEWA+gkAk8jkSTlxzNZiDT8=; b=afU9rEGrHdI5Uap2opOUPaILYX/kx0q7m3u5ft6MCkRUW6rlKWJtv5wtorPg5IHNxZZ3Lzc8Ng3zaeb+EfFIEpwK+KJiyMAjMLeXXqQXvaQZMA7QI1FCusyed67KQ4r/Jo3/jjrXy8Dt/+mB57qxXti0mruVJBXX91QtCzffHR/p3/SyVkyo5p6oJk0JC1idH4xo8vEIzX+Dy6vQRR/T6IS0ImUwJNfZGgak7HkDRk+2+gYlBU4+QSzT0jePLBQxHgVoNQrHcEu3a5dh61zUnEFlQoX9XIlxdIKnlNEmULZOf2iwGX3CKmRFhp+J5YwuW6Fth6XHO8/04+UF38YbAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WT+D58Mm/6m5WJdmwoMcIEWA+gkAk8jkSTlxzNZiDT8=; b=epJwEoLrLsZ7Pw/5E2VuaM7hBiGBIRh/rIH9SX1lG7XRvyR6Y4FNEZ2nO04hihptezdhBK3I62qkHCIXTDHpUFTneO/42QgGhwtg5ogie5CqHimdfSbNqIneekw4JcVmJOoTgYFrmAu4sUvjFhE57vEV1orKYyu3VYXXoEKz3MY= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BN0PR10MB5286.namprd10.prod.outlook.com (2603:10b6:408:127::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.6; Thu, 23 Feb 2023 00:20:06 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6134.019; Thu, 23 Feb 2023 00:20:06 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 4/5] vhost-scsi: Delay releasing our refcount on the tpg Date: Wed, 22 Feb 2023 18:19:48 -0600 Message-Id: <20230223001949.2884-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230223001949.2884-1-michael.christie@oracle.com> References: <20230223001949.2884-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR06CA0047.namprd06.prod.outlook.com (2603:10b6:5:54::24) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|BN0PR10MB5286:EE_ X-MS-Office365-Filtering-Correlation-Id: b20e4834-ef35-4f73-426b-08db1533b736 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c0gKLrbdzxfwtHomuqlHw8KqEYWn/xa8+mwdwhYSqOg3+JTn5uc3PuQ8312R7d3XwgQd9aBhDgNRp3+Ljs8QbkdrZtMmUUtHtMcI7ObzyWoBVTRIsaNdwfr1aTu2OXDUvT7I7cR3Y3V/n0zK8dl4aDHBj/oY9h33pGEGzUI6VyC5P7H5o2nriZ9FfYJSLXFPoe4K4PvdsRw47F/fDkQ8dvtFFkMAtmDnvA4Lwc3fYpBthqKiqUsNMNTb4+1Cxrll3y0VRZfzknBGqs/UlpAAG0GV8K/4YtgTocBiwjAxHEgJDry9CewxGFcoT60Ct7SguRgRcKqsLMkfcOpjilXdlkesLfjS6L1WtqpWxwSdbexDiGevePZe+/bEdf6RX3dv1ilhv76mWffwKJKoeOYNSwL4vP/LTt2mI523DtMjBm5o+Rb/9SYmgxtPUPnL76iK90rdi3Bj3ol+evUoqaUWGE9eFpF2B0oq4cQ+mOp8XdzzKgNWzysPbky9Gn8hhm3QIcCx8+ShPTMOcv5MG9o3eat67VoAGxzUr/uvrqaugG2Fxn8rhbRIpIhsTB0kTQ5hxdk2n0uj+PjNcxnGaIKi3kxDLC0IVVYEgY3IwCQgFrZXUdb/VTRIaP7IQWqFU6GwQwbCmIf2bHylW1WgbX0dsw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(346002)(39860400002)(376002)(136003)(366004)(451199018)(5660300002)(38100700002)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(8936002)(2616005)(26005)(186003)(1076003)(6506007)(6666004)(6512007)(2906002)(83380400001)(478600001)(36756003)(6486002)(107886003)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HrFZKzwQFtULC/fnygsARav0zxdtAZQCk7t0jX/Arlrj/CP5W3ytUqMiKzWmPk4ooimp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zBgSqpsVzZElg8W1owveswtqH+M9uuVjC2V2CPaZ0Rlj7yLGlge2gF5waO8VOf3LOoNu2EwoPVwmlj81N2VC6u0ytWrP/l0DsOH0SWCjdNBc5Kec3h6soXc7ekx//Lh6XpG0Qzcq2HvoRUOpd4ZCIJo9LLYFm82s5wq4RdWQ+OvQcI71v/gzn986CN6O5APhzSlFVWbe0aSJD+pVg1PYHvbVpbv683rcbKZuUbE/FFeqDE9ior+gPlQvis1QmZx9NSluoiOj6s6fDS9/svH20+ui8I2cQmxxI20cGhcHTZbi5BxYKETJeKz8Xx+PzxLE73w1kikxYFFG7skDT7BhDNGYflJE1vh1AmE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b20e4834-ef35-4f73-426b-08db1533b736 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2023 00:20:06.6077 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Z5cCeRV7yUw1Mc3D3tjdBVdWUo1fpjIJhM2s4ZVnoMQ/bQ6/txeNLBlKWeV/AXCFgwQlvlFUOn+IKk7a38TdV4USF7tYNqpw0HBlaZDOxsw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5286 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-22_11,2023-02-22_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302230001 X-Proofpoint-GUID: f4hPl-MkA0EKsB9bu6fR_NnHB5q2bSBR X-Proofpoint-ORIG-GUID: f4hPl-MkA0EKsB9bu6fR_NnHB5q2bSBR Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We currently hold the vhost_scsi_mutex the entire time we are running vhost_scsi_clear_endpoint. This prevents userspace from being able to free the se_tpg from under us after we have called target_undepend_item. However, it forces vhost_scsi_set_endpoint calls for other devices to have to wait on a flakey device's: vhost_scsi_clear_endpoint -> vhost_scsi_flush() call which can which can take a long time. This moves the target_undepend_item call and tv_tpg_vhost_count-- to after we have stopped new IO from starting up and after we have waited on running IO. We can then release our refcount on the tpg and session knowing our device is no longer accessing them. This also moves the tv_tpg_vhost_count-- to prevent a similar possible use after free with the session. Signed-off-by: Mike Christie --- drivers/vhost/scsi.c | 62 ++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 9e154e568438..c405ab5c232a 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -1704,11 +1704,10 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs, if (!tpg) continue; - mutex_lock(&tpg->tv_tpg_mutex); tv_tport = tpg->tport; if (!tv_tport) { ret = -ENODEV; - goto err_tpg; + goto err_dev; } if (strcmp(tv_tport->tport_name, t->vhost_wwpn)) { @@ -1717,36 +1716,51 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs, tv_tport->tport_name, tpg->tport_tpgt, t->vhost_wwpn, t->vhost_tpgt); ret = -EINVAL; - goto err_tpg; + goto err_dev; } + match = true; + } + if (!match) + goto free_vs_tpg; + + /* Prevent new cmds from starting and accessing the tpgs/sessions */ + for (i = 0; i < vs->dev.nvqs; i++) { + vq = &vs->vqs[i].vq; + mutex_lock(&vq->mutex); + vhost_vq_set_backend(vq, NULL); + mutex_unlock(&vq->mutex); + } + /* Make sure cmds are not running before tearing them down. */ + vhost_scsi_flush(vs); + + for (i = 0; i < vs->dev.nvqs; i++) { + vq = &vs->vqs[i].vq; + vhost_scsi_destroy_vq_cmds(vq); + } + + /* + * We can now release our hold on the tpg and sessions and userspace + * can free them after this point. + */ + for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) { + target = i; + tpg = vs->vs_tpg[target]; + if (!tpg) + continue; + + mutex_lock(&tpg->tv_tpg_mutex); + tpg->tv_tpg_vhost_count--; tpg->vhost_scsi = NULL; vs->vs_tpg[target] = NULL; - match = true; + mutex_unlock(&tpg->tv_tpg_mutex); - /* - * Release se_tpg->tpg_group.cg_item configfs dependency now - * to allow vhost-scsi WWPN se_tpg->tpg_group shutdown to occur. - */ + se_tpg = &tpg->se_tpg; target_undepend_item(&se_tpg->tpg_group.cg_item); } - if (match) { - for (i = 0; i < vs->dev.nvqs; i++) { - vq = &vs->vqs[i].vq; - mutex_lock(&vq->mutex); - vhost_vq_set_backend(vq, NULL); - mutex_unlock(&vq->mutex); - } - /* Make sure cmds are not running before tearing them down. */ - vhost_scsi_flush(vs); - - for (i = 0; i < vs->dev.nvqs; i++) { - vq = &vs->vqs[i].vq; - vhost_scsi_destroy_vq_cmds(vq); - } - } +free_vs_tpg: kfree(vs->vs_tpg); vs->vs_tpg = NULL; WARN_ON(vs->vs_events_nr); @@ -1754,8 +1768,6 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs, mutex_unlock(&vhost_scsi_mutex); return 0; -err_tpg: - mutex_unlock(&tpg->tv_tpg_mutex); err_dev: mutex_unlock(&vs->dev.mutex); mutex_unlock(&vhost_scsi_mutex); From patchwork Thu Feb 23 00:19:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13149730 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56603C64EC7 for ; Thu, 23 Feb 2023 00:20:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232881AbjBWAUY (ORCPT ); Wed, 22 Feb 2023 19:20:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231901AbjBWAUS (ORCPT ); Wed, 22 Feb 2023 19:20:18 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C8EE41090; Wed, 22 Feb 2023 16:20:17 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31MNiMoO007598; Thu, 23 Feb 2023 00:20:13 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 : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=84jH3CnPM8YKlqExlJ2c48psiUYuVdTLqireivngPP8=; b=Xq0Za9yTzZAM3AVOAWqFrL+43IdVHwjfSos2Vt1YdyEJFkE3M6LIMGao326cOTDVJMOD R9lDBdYBDhdxyBUgWN4vWzEmFJwkBQHNp1CcEQV2RmiWuzmS4zj/tVBI8Bt2cNkyvF7k ADIYSCvt1y8+wcizWHoYSZd0+ir28wb8b45KCEWhbYuWgtmW2YvVvXrnELfDFvyu3tHC bpawkse6PxINjeGlhoUt4b0QOY3lHdaAaDgKzYOKz9PVZDWCbkcB0UtE+H9Kz42iVwZD btNnFpkXN68x5rLeYHRVbZ9yx9KVMtjh8Iu1YW4cs3haRKm3gg1j7jPunt0bgdpP6/XB 0g== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ntp9tsdqr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Feb 2023 00:20:13 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31MMPovE027301; Thu, 23 Feb 2023 00:20:12 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ntn47j3xc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Feb 2023 00:20:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ffp8aywnKtNX+XX5SUMBaYQ8N0RHDzsfY2n/2r3KXbST5v7C7I8x3iIcYG1ViRfKoQ5F2Hz4Bucj7ov3qZwGmyynK9eNmnDN1+F3wlwsSP96t39FMlWRFa6YbgrIQspdjkly9p8tbah5nEOImrsoLcjOQiZ0dKOIjPoB/80Ra/m1Jx/HZwiFbqUoOCZMP/K1WWimo6L6sxM8T7FPZohi62JasUdRsgzxjAZDKi12R/aKMVGbxUKBE0gRN+PX7h3NDUYl6EaOYTdAj0qwJFXAcYmoC5Hutm3E8dlpTsagkodQD2w4u1n8l6harpwFpsFP+dBwcAA4VasZLAOYyBDRKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=84jH3CnPM8YKlqExlJ2c48psiUYuVdTLqireivngPP8=; b=lfsqhu/cgu9osHhjzid3eNu8ybHBSnj4KumE/pQ4JcOCGJttGYk21HIhH5gR37bOlCeM2+bamPvKTEfkj1tAwO9frcZrQ1p4OzByXCfYKcG6D4hjQwfUXh4y5dCEsyOanN63DOQVEV+3yMsPVPk8m+WBGJHnRJPhcJmLlhVmTSPBh4qZDydXbZhlkSiKd0Yx+zqIhZLheaP73ZZHz3DXyjMzqBAxDRUYbgqwJRdxCVboRrwDLbhocVf/How+0gQIXWUvmzxFSttGZufFJ3HZ3yuhIC1aAHhYzPEuxfrNyD9O/xslYx4ZBivc/z/tZgSjthaRTknObvpbsx7zUnfxjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=84jH3CnPM8YKlqExlJ2c48psiUYuVdTLqireivngPP8=; b=qOowPMIyAjCuW9uNZWL/pTM0KVR8F7kJ9hTLM7mLMC4dOV7ugWit/8Wu5wrjRUQjlixRIap/fA2Q46KFGSUkf8gAT0rjNYW7OWsMe3xHcaOXAZisXaw79IGq1PKV1cBI3N1TxjbJAFZuKSi02/GWUhDOSm0DmWpN4H8gqQeAsqc= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BN0PR10MB5286.namprd10.prod.outlook.com (2603:10b6:408:127::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.6; Thu, 23 Feb 2023 00:20:09 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6134.019; Thu, 23 Feb 2023 00:20:09 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 5/5] vhost-scsi: Reduce vhost_scsi_mutex use Date: Wed, 22 Feb 2023 18:19:49 -0600 Message-Id: <20230223001949.2884-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230223001949.2884-1-michael.christie@oracle.com> References: <20230223001949.2884-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0020.namprd03.prod.outlook.com (2603:10b6:5:3b8::25) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|BN0PR10MB5286:EE_ X-MS-Office365-Filtering-Correlation-Id: 08a60072-7c9b-443a-8de3-08db1533b88d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OEC7vDLki9yMscdyB7xvCSG9xHcSNxH3/dmezyCyrBYkXKSllvHEy6jIIGl0Nuf/zTXnU8tpFu5JhtyHYjxYJGAo60/TyGNEi9P2WtvhEhPcYhJWr59e47B6Ch482So5O4ziknnEW0ES8Um1fCGUs4y0k5AHjJ1WsdOURYupp9qczTIqqv5yN22KPtgNQX/OseQLWYwGknQDLewpjv2ADEX+eenpfg18HwJQ52N+vtGsWKCBAkN9wF7oZOLGluPmm7ejojPMHd1lpHpivHkzm4vIHVL9eKk5xISrjVPtJQkT0JT0a7ArcCiGqB+1Av40lNJwUjv9jti5gBU+9HRQNNimr0Acl0W+25GON9tVjIJMJdFiKR16nQrNAgJyHf2KKxsgBp+YyFUOLphVmrdWB3D8xQ7j8S+OD7vqgqJeD8amn7woT4b5wthtEyeW30xSr+xhhnpBPsoG5QwvjS6CQ59lHltxdJhd2391phxi9L6jnWSfaELImeILYtl4dy4OwVZFox7VX90cPlkiUdFQ6iY2tauYc+9525TIpEBpes9ai2MJFKcO/tjYrADgMMS86SSF87Qkyih+Oa1HusSEEMN9yA1SaeVAlk82fH6ea3XHGwSTivVtIY5zzCh2j+kKac2y/GmJLG+wB06HMZCvdg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(346002)(39860400002)(376002)(136003)(366004)(451199018)(5660300002)(38100700002)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(8936002)(2616005)(26005)(186003)(1076003)(6506007)(6666004)(6512007)(2906002)(83380400001)(478600001)(36756003)(6486002)(107886003)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TAWkOZLpC7RxEMke9yZDfCeibMmAJN4HmRxf4BK7wDoVsPIIOu4n6mGlzE7eiY2r5URhAVSTZEXY+mNxLF4i8Bm068Ku1YTQSPuotycFgV4TM2MitF5Vmx9CVj6e5o7fj2KljOXrP2WwyAiwNgkHcy2GqMMfQVO7As31VA2EYeD1/Sv6bosWJqYVnoA4UV2sw0utPAFqTRBgzWLuHHBrQ9vMV/fAHjgH2qnMiua3fC4QF5oz0JupMRl5CYXbZ8RkTBQM52JGZXGqJh7Wu7PI/uqKJqYLZtiJu9cQ0HfdbcRZ1p6f6cP3hvMSRhsLklp02dCdFKBfF+oWU48pzpeIio4v0YNfnsaoerlc0k9IxT+yzmwrNvq+1ak6lsDZq0oMH6NS8V4eVQQTh6vlmqg6aZON3gvGP0FG3wuhFuw+5lQe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eVK7QQejBscIWFT80mY6XGX+wRuyESXk4OBW+5ZeiPf6omEKb/q2s5gR+/Z9p4ZL6iuH9LfJUnb/SZUVl5iv0j3hhuXnSxkOrewDW5CupA8s0RYyStK9HouCHs9Yw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Ji/FS2gymTjodcCusYOZlq5cwXb/3NDkCA46OZEaOQJ4ZPvGGLZlgAJ8yPvb/rjB8nR+kGDHNYCMeMfXohHsXOLLHK4gf2/udyr1KD6pfJyxDELRhmPeZ+2zyQXG45GmkF2ktkbtlJUNkiH463g9huoj1/Sxyhh9++6qmYcqG+w35UI/ujP6iiOEHVHWKaj8HlOhZwkrdRfsH9HncDfwO13XcG01zAeLfQALqpy69bDSDL7r8z2o8GXMsXlCPiDOFZrArwvZ2n6HXvweD29INLxT/0BEv/rR05GDVBKaHT/T5cow3rpl0JT71TqzDiqep9hjaAoM9DprxbZl0uicOzppGqmXCg4Qkj2berXrL6DILCnV+yomtnLP6giBOInWmlFhpbwEy4tZ9PZrHLzirYkyVRi2RjE32lBopUBWg7w1jZbq2iqic/gpIkgZoC0+ABECuUfUfQv3kIM5NIc0us5N+TUuFIq/9VAGKdRejDsg1AS8rdlcrF9xIMyBGlDyzFPxdkdzg2WbABAQJBb8XVBM9TUs4vBb02n/rdMpxySQxkfHMRSzGkXGMiczGV92y3x3iWDXGDAPtnbD9+xZINnBSt+x0E8Wlgfz71M+gG8fgGZDgB8N9AAKVtklrruzYF8VFQpEhQhMV843Uf+h9g9pmRyQpgGHP+YUHfbt1gQWKkRhvEU9z2uooJhVjFhhvsQJDAVERf4NUMqS4PlsLyxiGtkyyY0OS23vjQKQcfKokBmTc/dF+UhDT+iZnIsMk7g7PKBrU1IilohuL+MM1kptEYlxyq4s3EjzCERefWdLEAd8p83cK49DYs6utLCcO1QF4PZMUYqjGZbGNfh1uD3jqxyVnYsGr0LY/i1d/p4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08a60072-7c9b-443a-8de3-08db1533b88d X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2023 00:20:08.8575 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: C9hrbjiscahBSoi6Qt0ehYf7JHX7/Kgoc/rtfr7/ZB/ZwsH6I3I+bW/2cdCSrVTzUWhQjfxmsw9kEnH2hxtr4RGh5/OwxhSbE2COGcc8vkg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5286 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-22_11,2023-02-22_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302230001 X-Proofpoint-GUID: Jb6yT_rOu0HOl2sX57o3i3Zmh7RjbowP X-Proofpoint-ORIG-GUID: Jb6yT_rOu0HOl2sX57o3i3Zmh7RjbowP Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Now that vhost_scsi_clear_endpoint will prevent new IO and flush running IO before dropping it's refcounts on the tpg, we only need to hold the vhost_scsi_mutex while looping over tpgs and taking a refcount, and when manipulating the tpg list. This removes the vhost_scsi_mutex from vhost_scsi_clear_endpoint and moves the vhost_scsi_mutex use in vhost_scsi_set_endpoint so it's only taken while looping over the tpgs and taking a refcount. We can then now avoid issues where vhost_scsi_set_endpoint has to wait for another device's vhost_scsi_clear_endpoint call. Signed-off-by: Mike Christie --- drivers/vhost/scsi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index c405ab5c232a..75ea24f1c571 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -1540,7 +1540,7 @@ static int vhost_scsi_setup_vq_cmds(struct vhost_virtqueue *vq, int max_cmds) * vhost_scsi_tpg with an active struct vhost_scsi_nexus * * The lock nesting rule is: - * vhost_scsi_mutex -> vs->dev.mutex -> tpg->tv_tpg_mutex -> vq->mutex + * vs->dev.mutex -> vhost_scsi_mutex -> tpg->tv_tpg_mutex -> vq->mutex */ static int vhost_scsi_set_endpoint(struct vhost_scsi *vs, @@ -1554,7 +1554,6 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs, int index, ret, i, len; bool match = false; - mutex_lock(&vhost_scsi_mutex); mutex_lock(&vs->dev.mutex); /* Verify that ring has been setup correctly. */ @@ -1575,6 +1574,7 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs, if (vs->vs_tpg) memcpy(vs_tpg, vs->vs_tpg, len); + mutex_lock(&vhost_scsi_mutex); list_for_each_entry(tpg, &vhost_scsi_list, tv_tpg_list) { mutex_lock(&tpg->tv_tpg_mutex); if (!tpg->tpg_nexus) { @@ -1590,6 +1590,7 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs, if (!strcmp(tv_tport->tport_name, t->vhost_wwpn)) { if (vs->vs_tpg && vs->vs_tpg[tpg->tport_tpgt]) { mutex_unlock(&tpg->tv_tpg_mutex); + mutex_unlock(&vhost_scsi_mutex); ret = -EEXIST; goto undepend; } @@ -1604,6 +1605,7 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs, if (ret) { pr_warn("target_depend_item() failed: %d\n", ret); mutex_unlock(&tpg->tv_tpg_mutex); + mutex_unlock(&vhost_scsi_mutex); goto undepend; } tpg->tv_tpg_vhost_count++; @@ -1613,6 +1615,7 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs, } mutex_unlock(&tpg->tv_tpg_mutex); } + mutex_unlock(&vhost_scsi_mutex); if (match) { memcpy(vs->vs_vhost_wwpn, t->vhost_wwpn, @@ -1667,7 +1670,6 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs, kfree(vs_tpg); out: mutex_unlock(&vs->dev.mutex); - mutex_unlock(&vhost_scsi_mutex); return ret; } @@ -1683,7 +1685,6 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs, int index, ret, i; u8 target; - mutex_lock(&vhost_scsi_mutex); mutex_lock(&vs->dev.mutex); /* Verify that ring has been setup correctly. */ for (index = 0; index < vs->dev.nvqs; ++index) { @@ -1765,12 +1766,10 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs, vs->vs_tpg = NULL; WARN_ON(vs->vs_events_nr); mutex_unlock(&vs->dev.mutex); - mutex_unlock(&vhost_scsi_mutex); return 0; err_dev: mutex_unlock(&vs->dev.mutex); - mutex_unlock(&vhost_scsi_mutex); return ret; }