From patchwork Tue Jun 7 10:38:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 9160261 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 63A4260572 for ; Tue, 7 Jun 2016 10:38:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51B6425EF7 for ; Tue, 7 Jun 2016 10:38:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46A42281F9; Tue, 7 Jun 2016 10:38:24 +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 D72A128179 for ; Tue, 7 Jun 2016 10:38:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754086AbcFGKiW (ORCPT ); Tue, 7 Jun 2016 06:38:22 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:33009 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753058AbcFGKiV (ORCPT ); Tue, 7 Jun 2016 06:38:21 -0400 Received: by mail-yw0-f196.google.com with SMTP id y6so22381910ywe.0 for ; Tue, 07 Jun 2016 03:38:20 -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=KTFnujqGMLMVMW1orunGzWU6ghp/v/0Bv4C4Arlp1Ps=; b=EDygOBcv2p9w1pBXdz/Ly0/eT4t1nyCoXK7iQmM1ODlI30cevWMkE+Y/YuBa+n95O/ JWXA1EE8BskuhMHWs82/f/qlNX59rbweIyQiVaGB60thrrwDsXhWYkLRXbtQJ8Ih4dPT TZKA/J5OkSejEOeOC3gHGKdVHXEHG0i3KpKdCsm83RPzX3i4glKGfXLxl1En6k4kOcZQ ADIggXmW8+UNYd64z8bJ73Y7rV/G1v12WRUY4MOMb9U0hhKEr6xFwbuOpEzGXDIvJ0kd bJnvTdGVAwZzWtqszXgWn35TgdL+yprh3GC0YTHEFgSlxYhUfNqtiCcXZUjjJdNuMQIL 9x1A== 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=KTFnujqGMLMVMW1orunGzWU6ghp/v/0Bv4C4Arlp1Ps=; b=X+qjyPNql5c0QVycMVWak6q+8suV3FZfII5K2uqOEVzOZcZnL9FvfT/chL6XALqopZ PO8Wbbb5DF6hN6ZMRcuBlOmQkT1NMtiMU6u+ECRYLkxLa1nKXIMayt1ZOzP3Sd+IhK/L 9cJqJKyGx5MiZEndnr1EBK9r565CfIu3fTa/soc7kHAvdu54XEiV4Co3L/hGTreCoJap mJB4rpnXkfpx8hXyJtiOdXtLahC2e7VGTg0eKyulpQwZrHwhI+imFoVliO37NIPR87kT SZhE0Wtyer8PEAQOPkxpwV+4nRFYLT11X3Sqi+ydUT5vjl4ogTs2kXY3BpFiypWJYcvA TDOw== X-Gm-Message-State: ALyK8tLtt08Hzsq1moaRbA3FNZ8+w+4ds3tuPlQd9hNyz8vkos4HUBjoogbjUtYL3buhTA== X-Received: by 10.13.216.147 with SMTP id a141mr13692617ywe.313.1465295900021; Tue, 07 Jun 2016 03:38:20 -0700 (PDT) Received: from tlielax.poochiereds.net ([2606:a000:1125:4074:3a60:77ff:fe93:a95d]) by smtp.googlemail.com with ESMTPSA id z2sm14077958ywd.43.2016.06.07.03.38.19 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 07 Jun 2016 03:38:19 -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 3/3] pnfs: add a new mechanism to select a layout driver according to an ordered list Date: Tue, 7 Jun 2016 06:38:11 -0400 Message-Id: <1465295891-4952-4-git-send-email-jlayton@poochiereds.net> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465295891-4952-1-git-send-email-jlayton@poochiereds.net> References: <1465295891-4952-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 attempts to divine meaning from the order of the layout driver list sent by the server. Unfortunately, the spec doesn't place any significance on the order and the server is free to send them in any order it likes. Instead, set a list of preferred driver types in the kernel and have the selection code try them in order until it finds one that can be loaded. If we go through the whole list of preferred drivers and don't find one, then try any that weren't recognized in the first scan. This should allow the use of 3rd party and experimental drivers without needing to muck with the order of preference. For now, the order of preference is hardcoded, but it should be possible to make this configurable (via module param perhaps?). Signed-off-by: Jeff Layton --- fs/nfs/pnfs.c | 71 +++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index b02cad9c04bf..3ec5f2b392b6 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 something? + */ +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,7 +125,7 @@ set_pnfs_layoutdriver(struct nfs_server *server, const struct nfs_fh *mntfh, { struct pnfs_layoutdriver_type *ld_type = NULL; u32 id; - int i; + int i, j; if (!(server->nfs_client->cl_exchange_flags & (EXCHGID4_FLAG_USE_NON_PNFS | EXCHGID4_FLAG_USE_PNFS_MDS))) { @@ -118,31 +133,45 @@ set_pnfs_layoutdriver(struct nfs_server *server, const struct nfs_fh *mntfh, __func__, server->nfs_client->cl_exchange_flags); goto out_no_driver; } - /* - * If server supports more than one layout types. - * By assuming, that server will put 'common default' as the first - * entry, try all following entries ibefore and fall back to the default - * if we did not found a matching one. - */ - for(i = 1; i < NFS_MAX_LAYOUT_TYPES && ids[i] != 0; i++) { - id = ids[i]; - request_module("%s-%u", LAYOUT_NFSV4_1_MODULE_PREFIX, id); - ld_type = find_pnfs_driver(id); - if(ld_type) - goto found_module; - dprintk("%s: No pNFS module found for %u.\n", __func__, id); + /* scan the list for each layout type in order of preference */ + for (j = 0; ld_prefs[j] != 0; j++) { + for (i = 0; i < NFS_MAX_LAYOUT_TYPES && ids[i] != 0; i++) { + id = ids[i]; + + if (ld_prefs[j] == id) { + request_module("%s-%u", LAYOUT_NFSV4_1_MODULE_PREFIX, id); + ld_type = find_pnfs_driver(id); + if (ld_type) + goto found_module; + } + } } - /* - * no other layout types found. Try default one. - */ - id = ids[0]; - request_module("%s-%u", LAYOUT_NFSV4_1_MODULE_PREFIX, id); - ld_type = find_pnfs_driver(id); + /* didn't find one -- make sure we try any that weren't in ld_prefs */ + for (i = 0; i < NFS_MAX_LAYOUT_TYPES && ids[i] != 0; i++) { + bool match = false; + + id = ids[i]; + + /* Was it in the prefs list? */ + for (j = 0; ld_prefs[j] != 0; j++) { + if (ld_prefs[j] != id) { + match = true; + break; + } + } + + if (!match) { + request_module("%s-%u", LAYOUT_NFSV4_1_MODULE_PREFIX, id); + ld_type = find_pnfs_driver(id); + if (ld_type) + goto found_module; + } + } 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; }