From patchwork Tue Nov 20 20:27:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 200510 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "userp1040.oracle.com", Issuer "VeriSign Class 3 International Server CA - G3" (not verified)) by ozlabs.org (Postfix) with ESMTPS id C6B292C007C for ; Wed, 21 Nov 2012 07:27:32 +1100 (EST) Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id qAKKRSW5027614 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 20 Nov 2012 20:27:29 GMT Received: from oss.oracle.com (oss-external.oracle.com [137.254.96.51]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id qAKKRSkZ001837 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 20 Nov 2012 20:27:28 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1TauPo-0002EM-0f; Tue, 20 Nov 2012 12:27:28 -0800 Received: from acsinet22.oracle.com ([141.146.126.238]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1TauPg-0002Dc-PY for fedfs-utils-devel@oss.oracle.com; Tue, 20 Nov 2012 12:27:20 -0800 Received: from acsinet12.oracle.com (acsinet12.oracle.com [141.146.126.234]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id qAKKRKor001707 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 20 Nov 2012 20:27:20 GMT Received: from mail-ia0-f171.google.com (mail-ia0-f171.google.com [209.85.210.171]) by acsinet12.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id qAKKQjXD026864 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 20 Nov 2012 20:27:20 GMT Received: by mail-ia0-f171.google.com with SMTP id b35so2152578iac.2 for ; Tue, 20 Nov 2012 12:27:19 -0800 (PST) Received: by 10.50.87.199 with SMTP id ba7mr11491773igb.6.1353443239823; Tue, 20 Nov 2012 12:27:19 -0800 (PST) Received: from seurat.1015granger.net (adsl-99-26-161-222.dsl.sfldmi.sbcglobal.net. [99.26.161.222]) by mx.google.com with ESMTPS id gz10sm11219685igc.9.2012.11.20.12.27.19 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Nov 2012 12:27:19 -0800 (PST) From: Chuck Lever To: fedfs-utils-devel@oss.oracle.com Date: Tue, 20 Nov 2012 15:27:18 -0500 Message-ID: <20121120202718.47389.3633.stgit@seurat.1015granger.net> In-Reply-To: <20121120201753.47389.51902.stgit@seurat.1015granger.net> References: <20121120201753.47389.51902.stgit@seurat.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Flow-Control-Info: class=Default reputation=ipRepBelow100 ip=209.85.210.171 ct-class=R5 ct-vol1=0 ct-vol2=8 ct-vol3=7 ct-risk=50 ct-spam1=80 ct-spam2=7 ct-bulk=6 rcpts=1 size=3439 X-MM-CT-Classification: not spam X-MM-CT-RefID: str=0001.0A090209.50ABE7A8.0023,ss=1,re=0.000,fgs=0 Subject: [fedfs-utils] [PATCH 6/7] plug-in: Handle FsnTTL X-BeenThere: fedfs-utils-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list Reply-To: fedfs-utils Developers List-Id: fedfs-utils Developers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: fedfs-utils-devel-bounces@oss.oracle.com Errors-To: fedfs-utils-devel-bounces@oss.oracle.com X-Source-IP: acsinet22.oracle.com [141.146.126.238] Now that nsdb_resolve_fsn_s() returns a TTL, the NFS plug-in is also updated. Instead of reporting the FSL TTL for each location, the FSN TTL is always reported. It's a little awkward, but it avoids a change to the plug-in API. Signed-off-by: Chuck Lever --- src/include/fedfs.h | 5 +++++ src/plug-ins/nfs-plugin.c | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletions(-) diff --git a/src/include/fedfs.h b/src/include/fedfs.h index 9c4670a..0a2186c 100644 --- a/src/include/fedfs.h +++ b/src/include/fedfs.h @@ -57,6 +57,11 @@ #define FEDFS_DELAY_MAX_SECS (FEDFS_DELAY_MIN_SECS << 4) /** + * Number of seconds an NFS basic junction should be cached + */ +#define FEDFS_NFS_BASIC_TTL (300) + +/** * Compute seconds to wait after receiving FEDFS_ERR_DELAY */ static inline unsigned int fedfs_delay(unsigned int seconds) diff --git a/src/plug-ins/nfs-plugin.c b/src/plug-ins/nfs-plugin.c index 767d660..d55a9f7 100644 --- a/src/plug-ins/nfs-plugin.c +++ b/src/plug-ins/nfs-plugin.c @@ -44,6 +44,7 @@ #include "junction.h" struct nfs_fsloc_set { + int ns_ttl; struct nfs_fsloc *ns_current; struct nfs_fsloc *ns_list; }; @@ -225,6 +226,7 @@ nfs_jp_get_basic(const char *junct_path, nfs_fsloc_set_t *locset) nfs_jp_debug("%s: Returning location set %p\n", __func__, new); nfs_jp_do_rewind_locations(new); + new->ns_ttl = FEDFS_NFS_BASIC_TTL; *locset = new; return JP_OK; } @@ -342,16 +344,44 @@ nfs_jp_resolve_fsn(const char *fsn_uuid, nsdb_t host, { enum jp_status status = JP_NSDBREMOTE; struct fedfs_fsl *fsls; + struct fedfs_fsn *fsn; unsigned int ldap_err; FedFsStatus retval; + int fsn_ttl; if (nsdb_open_nsdb(host, NULL, NULL, &ldap_err) != FEDFS_OK) return JP_NSDBLOCAL; + retval = nsdb_get_fsn_s(host, NULL, fsn_uuid, &fsn, &ldap_err); + switch (retval) { + case FEDFS_OK: + fsn_ttl = fsn->fn_fsnttl; + nsdb_free_fedfs_fsn(fsn); + break; + case FEDFS_ERR_NSDB_NOFSL: + nfs_jp_debug("%s: No FSL entries for FSN %s\n", + __func__, fsn_uuid); + goto out_close; + case FEDFS_ERR_NSDB_NOFSN: + nfs_jp_debug("%s: No FSN %s found\n", + __func__, fsn_uuid); + goto out_close; + case FEDFS_ERR_NSDB_LDAP_VAL: + nfs_jp_debug("%s: NSDB operation failed with %s\n", + __func__, ldap_err2string(ldap_err)); + goto out_close; + default: + nfs_jp_debug("%s: Failed to resolve FSN %s: %s\n", + __func__, fsn_uuid, nsdb_display_fedfsstatus(retval)); + goto out_close; + } + retval = nsdb_resolve_fsn_s(host, NULL, fsn_uuid, &fsls, &ldap_err); switch (retval) { case FEDFS_OK: status = nfs_jp_convert_fedfs_fsls(fsls, new); + if (status == JP_OK) + new->ns_ttl = fsn_ttl; nfs_jp_debug("%s: Returning %p, ns_list=%p\n", __func__, new, new->ns_list); nsdb_free_fedfs_fsls(fsls); @@ -373,6 +403,7 @@ nfs_jp_resolve_fsn(const char *fsn_uuid, nsdb_t host, __func__, fsn_uuid, nsdb_display_fedfsstatus(retval)); } +out_close: nsdb_close_nsdb(host); return status; } @@ -544,7 +575,7 @@ nfs_jp_get_next_location(nfs_fsloc_set_t locset, __func__, hostname_tmp, export_path_tmp); *hostname = hostname_tmp; *export_path = export_path_tmp; - *ttl = fsloc->nfl_ttl; + *ttl = locset->ns_ttl; locset->ns_current = locset->ns_current->nfl_next; return JP_OK; }