From patchwork Thu Jun 9 12:21:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 9166935 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 49112604DB for ; Thu, 9 Jun 2016 12:21:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A4BC28340 for ; Thu, 9 Jun 2016 12:21:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F2A528345; Thu, 9 Jun 2016 12:21:19 +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 BD00528340 for ; Thu, 9 Jun 2016 12:21:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751366AbcFIMVR (ORCPT ); Thu, 9 Jun 2016 08:21:17 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:33726 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750964AbcFIMVP (ORCPT ); Thu, 9 Jun 2016 08:21:15 -0400 Received: by mail-yw0-f193.google.com with SMTP id y6so4501401ywe.0 for ; Thu, 09 Jun 2016 05:21:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poochiereds-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nsm2MmQ5DGn0W0OUYkaAOIAPWr7isPz/kjjFbcuDLtY=; b=gCcUlOyS+JwrNmckKje39We3JGhty2WXlh66EYlt8ARuqdDv7fP7tnLH9j83tA4F90 PIBb2/sDwo+sOm+7v1Shli9h0UOTjJL3fYzuicaGUmGrZ8cwYye9LXgWEN+hdtwjqp17 AFGeJVoaMrsTssDyqKVuRqrVL7SEQLLKxpxec4CPTEedLlZqtlQ0u7kuKtd3VD7RUQDL /zbjfO/5bt6/6F9SYIlzO9grx4JCTX8P9PBaG4nYZfhruuTnPoJYeqSKzpgeUtUuf0Tz fCYmYM1TDh8RoZKxsx9X75/FZiWbjQxcOeCwvKu0j68oH6Z7IyCBatsZqbWVeIot0NKq OgfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nsm2MmQ5DGn0W0OUYkaAOIAPWr7isPz/kjjFbcuDLtY=; b=ft8m/UtjC9mf5NHdmLEaIa0Rmqw3cb0BCBUi5d/a+L/PhFYeXDaLHC6LdfmSAo0tuS VHLRpziR7eAoKxwHB3GRqtHWtCV8bVNQUZtpKNF4NzjA8il5wTdKglmTaRw2YGHsPWes KFzslIell6wCEnR2XA6IJ7qY+Xcwe8NX6+S3q7KMl+aeo20shHuxWhAYVUf0GwLJdzH9 dH3sg3dMAm+Qa2Jbl4aSlFMsWOFbBcY6G6rS49T80SJSaSwOKomd3I7TAUppBY61IO8y Xi9Hf+ZfT3j6NYI34zSDVvSd9wi9jt66jUP5QjMv+wwfdMYc+YnyItPT8RJWkqGU9IZ4 IT+Q== X-Gm-Message-State: ALyK8tI0Qz2pq3phm2qWXQ3WDifzbG3Vpw0ejZO7ONA+vDkAoDcAEo4HbasexkUQIL5ZEA== X-Received: by 10.129.53.139 with SMTP id c133mr1335940ywa.259.1465474874808; Thu, 09 Jun 2016 05:21:14 -0700 (PDT) Received: from tlielax.poochiereds.net ([2606:a000:1125:4074:3a60:77ff:fe93:a95d]) by smtp.googlemail.com with ESMTPSA id w124sm3098324ywb.36.2016.06.09.05.21.13 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Jun 2016 05:21:14 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org, anna.schumaker@netapp.com, trondmy@primarydata.com Cc: tigran.mkrtchyan@desy.de, thomas.haynes@primarydata.com, linux-nfs@vger.kernel.org Subject: [PATCH v2 3/3] pnfs: add a new mechanism to select a layout driver according to an ordered list Date: Thu, 9 Jun 2016 08:21:05 -0400 Message-Id: <1465474865-15285-4-git-send-email-jlayton@poochiereds.net> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465474865-15285-1-git-send-email-jlayton@poochiereds.net> References: <1465474865-15285-1-git-send-email-jlayton@poochiereds.net> 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 Currently, the layout driver selection code always chooses the first one from the list. That's not really ideal however, as the server can send the list of layout types in any order that it likes. It's up to the client to select the best one for its needs. This patch adds an ordered list of preferred driver types and has the selection code sort the list of avaiable layout drivers according to it. Any unrecognized layout type is sorted to the end of the list. For now, the order of preference is hardcoded, but it should be possible to make this configurable in the future. Signed-off-by: Jeff Layton --- fs/nfs/pnfs.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 2fc1b9354345..c31d30f1e5f2 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -99,6 +99,21 @@ unset_pnfs_layoutdriver(struct nfs_server *nfss) } /* + * When the server sends a list of layout types, we choose one in the order + * given in the list below. + * + * FIXME: should this list be configurable via module_param or mount option? + */ +static const u32 ld_prefs[] = { + LAYOUT_SCSI, + LAYOUT_BLOCK_VOLUME, + LAYOUT_OSD2_OBJECTS, + LAYOUT_FLEX_FILES, + LAYOUT_NFSV4_1_FILES, + 0 +}; + +/* * Try to set the server's pnfs module to the pnfs layout type specified by id. * Currently only one pNFS layout driver per filesystem is supported. * @@ -110,6 +125,8 @@ set_pnfs_layoutdriver(struct nfs_server *server, const struct nfs_fh *mntfh, { struct pnfs_layoutdriver_type *ld_type = NULL; u32 id; + int i, j; + bool swapped; if (!(server->nfs_client->cl_exchange_flags & (EXCHGID4_FLAG_USE_NON_PNFS | EXCHGID4_FLAG_USE_PNFS_MDS))) { @@ -118,18 +135,44 @@ set_pnfs_layoutdriver(struct nfs_server *server, const struct nfs_fh *mntfh, goto out_no_driver; } - id = ids[0]; - if (!id) - goto out_no_driver; + /* bubble sort into ld_prefs order */ + do { + swapped = false; + for (i = 0; i < (NFS_MAX_LAYOUT_TYPES - 1); i++) { - ld_type = find_pnfs_driver(id); - if (!ld_type) { - request_module("%s-%u", LAYOUT_NFSV4_1_MODULE_PREFIX, id); + /* If either is zero then we're done with this pass */ + if (ids[i] == 0 || ids[i + 1] == 0) + break; + + for (j = 0; ld_prefs[j] != 0; j++) { + /* If we match left entry first, no swap */ + if (ids[i] == ld_prefs[j]) + break; + + /* if we match the right, we need to swap */ + if (ids[i + 1] == ld_prefs[j]) { + swap(ids[i], ids[i + 1]); + swapped = true; + break; + } + } + } + } while (swapped); + + for (i = 0; i < NFS_MAX_LAYOUT_TYPES && ids[i] != 0; i++) { + id = ids[i]; ld_type = find_pnfs_driver(id); + if (!ld_type) { + request_module("%s-%u", LAYOUT_NFSV4_1_MODULE_PREFIX, + id); + ld_type = find_pnfs_driver(id); + } + if (ld_type) + break; } if (!ld_type) { - dprintk("%s: No pNFS module found for %u.\n", __func__, id); + dprintk("%s: No pNFS module found!\n", __func__); goto out_no_driver; }