From patchwork Fri Apr 7 18:15:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schumaker, Anna" X-Patchwork-Id: 9670133 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 6EFC860364 for ; Fri, 7 Apr 2017 18:16:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66F272862A for ; Fri, 7 Apr 2017 18:16:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BDC628636; Fri, 7 Apr 2017 18:16:15 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 CEE1C2862A for ; Fri, 7 Apr 2017 18:16:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755578AbdDGSQN (ORCPT ); Fri, 7 Apr 2017 14:16:13 -0400 Received: from mx144.netapp.com ([216.240.21.25]:42074 "EHLO mx144.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933619AbdDGSQC (ORCPT ); Fri, 7 Apr 2017 14:16:02 -0400 X-IronPort-AV: E=Sophos;i="5.37,167,1488873600"; d="scan'208";a="186669778" Received: from hioexcmbx06-prd.hq.netapp.com ([10.122.105.39]) by mx144-out.netapp.com with ESMTP; 07 Apr 2017 11:02:35 -0700 Received: from VMWEXCCAS06-PRD.hq.netapp.com (10.122.105.22) by hioexcmbx06-prd.hq.netapp.com (10.122.105.39) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Fri, 7 Apr 2017 11:15:54 -0700 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (10.120.60.153) by VMWEXCCAS06-PRD.hq.netapp.com (10.122.105.22) with Microsoft SMTP Server (TLS) id 15.0.1210.3 via Frontend Transport; Fri, 7 Apr 2017 11:15:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netapp.onmicrosoft.com; s=selector1-netapp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=WjApjWzBQ/af2r8amxUACRJ4cbbGv72Z1ZT32YpHZnU=; b=dy0cg6x6nZC39vst2GEAO3dtt7OQ+uxVVcPjfmnogAOri/CNWdrIN9ge1bpxOO48kaNb7bdBAS1OQjvHu/FhHF0rbU/R/zBZ9ZMOxMjwcYuvbYhmC+F2jnW3tlqsmw8+DByPYRB0oJRlpAD1nfT0L7DCRyzIDtWBkHTyBNrKgcE= Authentication-Results: primarydata.com; dkim=none (message not signed) header.d=none; primarydata.com; dmarc=none action=none header.from=Netapp.com; Received: from gouda.nowheycreamery.com.nowheycreamery.com (68.40.188.1) by CY4PR06MB2472.namprd06.prod.outlook.com (10.169.186.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17; Fri, 7 Apr 2017 18:15:54 +0000 From: To: , Subject: [PATCH 19/34] NFS: Create a common nfs4_match_client() function Date: Fri, 7 Apr 2017 14:15:13 -0400 Message-ID: <20170407181528.2832-20-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170407181528.2832-1-Anna.Schumaker@Netapp.com> References: <20170407181528.2832-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 X-Originating-IP: [68.40.188.1] X-ClientProxiedBy: DM5PR20CA0021.namprd20.prod.outlook.com (10.173.136.159) To CY4PR06MB2472.namprd06.prod.outlook.com (10.169.186.140) X-MS-Office365-Filtering-Correlation-Id: 27adc972-1142-4ac1-cc18-08d47de2216c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:CY4PR06MB2472; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2472; 3:BPf134y0de48CK7h3m/t5U8aNoGFwNByl/FJcVXHnlos4o4z89NZa70VmcHbgrA7p1MEuMRXBlacdEMV6yXST9mydIiD5D9Q5Q2pOxPwbhURvqeSCkmENOB1EUVfgt6tixWH+HsMrIsSFi+i+biJCLKRQtq81K9kqq17P0C+szRX7F2zRqR+m1ZuL1YbwjRiEyo4p/yqv6BN91Vxxl07cst6U1cD0ufsjYoImGf0UA+rege1o+8+K5VUsUEGWNxgjtuQuIrQY9TTTU3lYfaVaG7C2ALgf8BoHLQeVSTUFak4aneI4XjaI3Vbwztyd9Cx/LbX8MhuFbl6wNWor+QEjQ==; 25:MAPPONAAMlvNOUJDnQPwbr6RmX9wNuKOP8NnpWYGpsrc0xNQtBhn2+i3KD633KWZ+NyACcGLaPi+Ec1PVrP7XOYVJVNgQu9YtDUhKygjfIg16EVRIcfRT+aiFOS5xx1P+m76lKgGc8bx+VlIK5lj0x07xtS+lOmUBUxQ9D8LoLtLYGPW58ZNZa6yNx1ZOM1rlh9KVdUVo5Krt4hOy68dfe9VwMxcrZsdlXL79skN8EVYaETJAFnrNhxJPyRwKEDDF9faTY99Lm+LaAAdMxdGMazlCbcbvspYR3PR8n2Yuh/zReFBqvviCcefY0aiuP6HoVgWRz0SRnqkNm396UGeTcMr6ln/BB6O6MVsDUIbvNrJZ6CoxtlsMNOXH554cgmJ9yJyg1YIs/DfhmFCW8axjfP2qEQ25st97ya4dqbJXEvR0sYsDg0F/D6nALv91PRe X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2472; 31:FCKZItfENuQzACrGTkNGdZaeMvzvTt20xH0By4XLm7JSH5aTXvy20vEJ3eDPpiB9eG8rwTMeQqlI+eK2ZsclYb9ughGXICGhxzGrYuLS8bB3HU0vFujIdzuR6R1K7XkwxtBjTVYML3qg1HoEsJG0OHX3cZD6g7d/S9oWzLqu6uo6Jd5QJYbRe+m4C01cTzeOOZZZJwJxQ/fv+fi6c+o+VsmU5r+w0H5nciTbsWzEBvOb5g4PtWg5nZy8iduTmxPcMBcgt05zFZU14cqlH0ykII3KYJEap2CwVbom6TdF5pA=; 20:KD8JoDEBfwJpv95jOu4F16xATXd+RQDUQIHaOd+Gf1R7e9vd3Bqv4Dq+kSY1HMVjgrD7ATaPbXHRlQcQA748QL82V5ppThGitCNJlCu/NP0bmfz0kIY/GS+RjSfLoEU9amYsZzY2qWV8mr2lQJinQLna8vimyidBtz66xk7Hne0ET9UZ4hKBzuPqsEIa8MP1FwPwYUj4MF6qyGiEQtdlNPSIXsOEPER/bBaK8HcFUlldYD8F0wOH8YAMBMt/luXWIuiGIAI8eHWYJcpZ0jdaSnwAQb9TaJhR+UEaUgQhQapC80pkNKah7uGaycmJK31Y+MSWhDh8gFkibiYjmED70tvYxwgaLtQ1MH4DZrNBRsk8MBj1IGHu7spL9tq71hD9wsUSefMZADQ4CvQenqjzxPcxEefvFyhSOzo5vuA5xyk9jhmlg4VzbQsU/Kr28olcNewvzwDBXN0z4sTmtGIV8xN3ALWMFZMk9lCac0WBgwGbi6JgBYaYsxMeZyeWbPnm X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(158342451672863); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123562025)(20161123560025)(20161123564025)(20161123555025)(6072148); SRVR:CY4PR06MB2472; BCL:0; PCL:0; RULEID:; SRVR:CY4PR06MB2472; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2472; 4:noZ0VDyKZpnAyaRcRL+YAs4QS5VjRV77ksJvodH/ZRJbN8fVPpiZOvfhlUnR/qMFBQAo2HrAv6VP+FRzuOcQi2dozdpjLLUMfRmhDXvaZbY0xMc7alP2S2YhWh1zoz2haCOcOovtkwCKk4A74OcS4WVd0gyvm2IhxkdSnFh+pARGR1EHlnb+i6BIgxHcsSC8zA1934v3WFCBAZLEJUe8RLpVIMLHn1wuNbw4g741TuEcBiqagquzvOya+AgCguQ6zUwgnxImhRLIH/HHPRdizwcoKbunSX3wrT2/kKcyCR4Cr2EmuCQ9B+6Mn8VA1Ni4saOw8346nZQO0wrJrHVVTzknWo1DX+NXpo7HeBSU8iejdChANaAzlChl+8FeRST+kIC/pT/8iP7iH57M3vj2zKJST2n5GNqyVWSqWWcA6/ax1rtrcLOe7d3MFDoVtwjnsdOHpEHTPwRectOQr4sXK81Yy/9bjq3rienq8cEUjWLQI5F80wBmf/lkViSKd82kTV6ICNrkMEIHY0U8LkykM5ncNUh7D8DmeNe9hFrYyn/VtYobscvo0dopXtWMgSZGBnggrgL0zVKfjnLfgtJF9JeYE5mXBZo0y4GPS51MZ/yCkOVaNHIcqDN8CPwyJ0jaHOR9LBjZmSWmDOXWorCqYiriviCT9CWVXSh/JBRmvmcrOO/RyrVi6jzSL5VKP948qVM1ya3/Sh/d9To9NTvh626x6Zdx9V/D3Wbv9a9hTK0N69Gv1sxDfFLRptISAkFm+g62jChFbaTE7opflX7XWw== X-Forefront-PRVS: 0270ED2845 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39840400002)(39400400002)(39410400002)(39850400002)(39450400003)(305945005)(189998001)(2950100002)(5003940100001)(6666003)(7736002)(86152003)(6512007)(2876002)(6506006)(6486002)(36756003)(5660300001)(53936002)(25786009)(38730400002)(76176999)(50466002)(81166006)(8676002)(50226002)(1076002)(6116002)(66066001)(42186005)(2906002)(50986999)(47776003)(86362001)(3846002)(15760500002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR06MB2472; H:gouda.nowheycreamery.com.nowheycreamery.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR06MB2472; 23:Ygd8tvclsHTVJgds4hogrbZSW2XuOlq3E+65FgRB3?= =?us-ascii?Q?tu89BkMUZR5oi5z6ffZeu8uNoNVz3hu5ksuikbKOwoXptcnK9weLFcidJr4N?= =?us-ascii?Q?bniXA4I+ymoFDyE95Ji1drsM+r/x7nwzswAHl499yhqVBLIw32+AgmsEq9Vw?= =?us-ascii?Q?Pluj8ZoZF83aXVRGS5PTRCJ6bfFQcfskpbnoMa0lhF5yrYawSF33AEl6/JGO?= =?us-ascii?Q?yDBuRdmWelItAvZMEszSfkgaMbqstnASvpnqZO45DFmrGUY7servS724qsXQ?= =?us-ascii?Q?qUBXEtsJ3J+FDKfk2ELLEX75WkwPIqqCXwLpG/H3z02GT+nEkhLqZTZfNcPy?= =?us-ascii?Q?6qMfOh2hVxkeet9oS3udVmKnN4pw9OnG0zI+W7hPkT+PULWHq1qnVmLzSPUD?= =?us-ascii?Q?r96p7QEDhi/B5sCwVY3Fqfk5r8sBtuV0hawSMRgvL4+8IYYHWlLvRWuh3fC0?= =?us-ascii?Q?Dxe6dIPigSNMtTVTEXY9E/3CabniTQ/Fksu/QuYqIQEHS6H4uyDzQGXfAtUr?= =?us-ascii?Q?2ecoeY5hMeWF1RoMjlEeFGGuP2xYZDiCMq4CLTkfD7mh3CabyCktPo0xRCFY?= =?us-ascii?Q?7gXs0n5/AeiLJTipo7vSrgBtN/EEXg+zSm38L8gmDF16Wohs+wAbcecHbPvE?= =?us-ascii?Q?bswkdR3I6Z8m6XVlzjIP7rGa4AIELSmVb69HOom1mPOLqu+y2rEffb7X4+Pn?= =?us-ascii?Q?qObSYidrQCuzDB1cGGUMrpEcLbhIZpmGGSJBrSp63tWUD/QrFpL2iFbedqQG?= =?us-ascii?Q?4uJcjEFePxu3MFC2WmstR+BWc6Hkvo4PxgT6lnOuR0neTz+oVVq8OenjvfqH?= =?us-ascii?Q?+0e132JbF6kMbUkSQYeoDDVhaTXkofVH59KyfT7enCGFlW/zLbV490d2udZ1?= =?us-ascii?Q?xksXOvqDTC2o1lCcq05Ztfqa60hiOEWsW30nlTYJtljndRBRD7mFDqsZ1bZ3?= =?us-ascii?Q?MYGU/nIgTRODjXbWsXCFMgmiIBCW+z2j/bADvmPfLYCZh5W2ja6L+X3Gcq1D?= =?us-ascii?Q?zw=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2472; 6:a5MwxKBsaxMc4FEKe1rwaGWHSIrhtx4ccYn94dJV5NvBGMpYV6Z5BE1Jx0iRYEwt9s3SdMDgAE7TIG7Nm9ClyYp7LtFrUysOLPtq8qrObEN94MI+9kIs2+4uUXilcxkWiYx38KBCt/LOR/Vd6Cf92q1CvntOQWddsorJbOCqpKhfq47so4UrBu0LuFZynnsv3pupWRPR+5p4lKv705t6+3yQrWO1yP6o7sOS5htdHJi2wJMtLNpoJSZaS9qYpvnJN0aklYUoYIXFiMVIHrvwEXM15kYDsaFpOxRCggXQNwvP3on0oqSxQSmln49oJ5VmJrXRZuuTX7wPl1e30sjxdXS0wPrPLkUNp6WJbWosbjYDIRD53g8SBPbq8Vibs9xlqAF9hpbwQna1KG6EPxSqxJ2Ayp2oCsDMF3H8HWga2mZicjyO8jBHa75CmzuXB3liglr1HGaafKQQAQrGl2AgSw==; 5:gEaVx6Gm0a+SuDF1yqPCkShh4ISwH0xdLLSI6hmT09BvA9a3KEHDONB1ip4zriAOjYZIWM5XlNuCjLbGPRvAY4vbtUg+3Cbi37yFT1NEhGzV2IkjAB9eEbl5HKSrT/0lngR0u5chGlIp29b5cPyAIA==; 24:AVwPp2B2+EAU2+bRs/TmYyU2kxL+59IjeylolLvh9C8ocDkFhLa6Ev27yd26uo1yiP0GDWGwcxbRiXGF8pZcSc8qEKCl8P+orLZCLnowtgE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2472; 7:clgXlYIyml9M09arOMt4S0S9wYLccoskfK1OHfUNon7WhK0vtNhuXTJzNbpMDEurlmMADhuR8JwebXtZoUQTu6jLigVgZTcgla/Q0UxSDzqRBr182M51GXYqWxbzHiU4/z5O4rmFP4x3anVC9hghDkGAkXmMvlPBDo/HtHrgkHd/pOz0JFj277vlX5EquPvH7C1FL1YhasSuL3m3VskWhM2y0frHaTeFuqJyEk1tnDEoktUsaq/a1f9VUpdE1mq1A+vnKBN3LxY4YtJyR8g7lgxhyTqhHvbUZXETBRI+5jHS88a8BF0Yufy2WFO4+a/umakvDe+Um4F7d1/O2j9L6A== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2017 18:15:54.0019 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR06MB2472 X-OriginatorOrg: netapp.com Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Anna Schumaker This puts all the common code in a single place for the walk_client_list() functions. Signed-off-by: Anna Schumaker --- fs/nfs/nfs4client.c | 119 ++++++++++++++++++++++++---------------------------- 1 file changed, 55 insertions(+), 64 deletions(-) diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 4f4f179cb849..8853c32eedf5 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -469,6 +469,50 @@ static bool nfs4_same_verifier(nfs4_verifier *v1, nfs4_verifier *v2) return memcmp(v1->data, v2->data, sizeof(v1->data)) == 0; } +static int nfs4_match_client(struct nfs_client *pos, struct nfs_client *new, + struct nfs_client **prev, struct nfs_net *nn) +{ + int status; + + if (pos->rpc_ops != new->rpc_ops) + return 1; + + if (pos->cl_minorversion != new->cl_minorversion) + return 1; + + /* If "pos" isn't marked ready, we can't trust the + * remaining fields in "pos", especially the client + * ID and serverowner fields. Wait for CREATE_SESSION + * to finish. */ + if (pos->cl_cons_state > NFS_CS_READY) { + atomic_inc(&pos->cl_count); + spin_unlock(&nn->nfs_client_lock); + + nfs_put_client(*prev); + *prev = pos; + + status = nfs_wait_client_init_complete(pos); + spin_lock(&nn->nfs_client_lock); + + if (status < 0) + return status; + } + + if (pos->cl_cons_state != NFS_CS_READY) + return 1; + + if (pos->cl_clientid != new->cl_clientid) + return 1; + + /* NFSv4.1 always uses the uniform string, however someone + * might switch the uniquifier string on us. + */ + if (!nfs4_match_client_owner_id(pos, new)) + return 1; + + return 0; +} + /** * nfs40_walk_client_list - Find server that recognizes a client ID * @@ -497,34 +541,10 @@ int nfs40_walk_client_list(struct nfs_client *new, spin_lock(&nn->nfs_client_lock); list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) { - if (pos->rpc_ops != new->rpc_ops) - continue; - - if (pos->cl_minorversion != new->cl_minorversion) - continue; - - /* If "pos" isn't marked ready, we can't trust the - * remaining fields in "pos" */ - if (pos->cl_cons_state > NFS_CS_READY) { - atomic_inc(&pos->cl_count); - spin_unlock(&nn->nfs_client_lock); - - nfs_put_client(prev); - prev = pos; - - status = nfs_wait_client_init_complete(pos); - if (status < 0) - goto out; - status = -NFS4ERR_STALE_CLIENTID; - spin_lock(&nn->nfs_client_lock); - } - if (pos->cl_cons_state != NFS_CS_READY) - continue; - - if (pos->cl_clientid != new->cl_clientid) - continue; - - if (!nfs4_match_client_owner_id(pos, new)) + status = nfs4_match_client(pos, new, &prev, nn); + if (status < 0) + goto out_unlock; + if (status != 0) continue; /* * We just sent a new SETCLIENTID, which should have @@ -567,11 +587,13 @@ int nfs40_walk_client_list(struct nfs_client *new, */ nfs4_schedule_path_down_recovery(pos); default: + spin_lock(&nn->nfs_client_lock); goto out; } spin_lock(&nn->nfs_client_lock); } +out_unlock: spin_unlock(&nn->nfs_client_lock); /* No match found. The server lost our clientid */ @@ -704,33 +726,10 @@ int nfs41_walk_client_list(struct nfs_client *new, if (pos == new) goto found; - if (pos->rpc_ops != new->rpc_ops) - continue; - - if (pos->cl_minorversion != new->cl_minorversion) - continue; - - /* If "pos" isn't marked ready, we can't trust the - * remaining fields in "pos", especially the client - * ID and serverowner fields. Wait for CREATE_SESSION - * to finish. */ - if (pos->cl_cons_state > NFS_CS_READY) { - atomic_inc(&pos->cl_count); - spin_unlock(&nn->nfs_client_lock); - - nfs_put_client(prev); - prev = pos; - - status = nfs_wait_client_init_complete(pos); - spin_lock(&nn->nfs_client_lock); - if (status < 0) - break; - status = -NFS4ERR_STALE_CLIENTID; - } - if (pos->cl_cons_state != NFS_CS_READY) - continue; - - if (pos->cl_clientid != new->cl_clientid) + status = nfs4_match_client(pos, new, &prev, nn); + if (status < 0) + goto out; + if (status != 0) continue; /* @@ -742,23 +741,15 @@ int nfs41_walk_client_list(struct nfs_client *new, new->cl_serverowner)) continue; - /* Unlike NFSv4.0, we know that NFSv4.1 always uses the - * uniform string, however someone might switch the - * uniquifier string on us. - */ - if (!nfs4_match_client_owner_id(pos, new)) - continue; found: atomic_inc(&pos->cl_count); *result = pos; status = 0; - dprintk("NFS: <-- %s using nfs_client = %p ({%d})\n", - __func__, pos, atomic_read(&pos->cl_count)); break; } +out: spin_unlock(&nn->nfs_client_lock); - dprintk("NFS: <-- %s status = %d\n", __func__, status); nfs_put_client(prev); return status; }