From patchwork Sun Nov 17 23:45:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshula Jayasuriya X-Patchwork-Id: 3195121 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0EFB6C045B for ; Sun, 17 Nov 2013 23:46:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0B612206B0 for ; Sun, 17 Nov 2013 23:46:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08E3B206AF for ; Sun, 17 Nov 2013 23:46:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751936Ab3KQXpz (ORCPT ); Sun, 17 Nov 2013 18:45:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15845 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751750Ab3KQXpz (ORCPT ); Sun, 17 Nov 2013 18:45:55 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAHNjqYl000557 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 17 Nov 2013 18:45:52 -0500 Received: from [10.3.113.32] (ovpn-113-32.phx2.redhat.com [10.3.113.32]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rAHNjnG1016283; Sun, 17 Nov 2013 18:45:50 -0500 Message-ID: <1384731949.14391.120.camel@serendib> Subject: [PATCH v2] exportfs: modify can_test() to use LONG_MAX when appropriate From: Harshula Jayasuriya To: Steve Dickson , linux-nfs@vger.kernel.org Cc: Jeff Layton , "J.Bruce Fields" , NeilBrown Date: Mon, 18 Nov 2013 10:45:49 +1100 In-Reply-To: <1384511960.14391.115.camel@serendib> References: <1376588800.17754.14.camel@serendib> <20130815175258.GS17781@fieldses.org> <1384154434.16759.39.camel@serendib> <20131111185356.6e0fd0a9@notabene.brown> <1384168843.16759.50.camel@serendib> <1384496133.14391.112.camel@serendib> <20131115173845.5ff064cd@notabene.brown> <1384511960.14391.115.camel@serendib> Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch is the nfs-utils patch corresponding to the kernel patch "sunrpc: prepare NFS for 2038": "The kernel sunrpc code needs to handle seconds since epoch greater than 2147483647. This means functions that parse time as an int need to handle it as time_t." When appropriate exportfs should use LONG_MAX in can_test() instead of INT_MAX. kernel INT_MAX + exportfs INT_MAX: "Tue Jan 19 03:14:08 UTC 2038" ================================================================= exportfs: /mnt/export does not support NFS export: ------------------------------------------------------------ # cat /proc/net/rpc/auth.unix.ip/content #class IP domain ------------------------------------------------------------ + mount fail: ------------------------------------------------------------ # cat /proc/net/rpc/auth.unix.ip/content #class IP domain # expiry=2147483768 refcnt=2 flags=4 # nfsd 192.168.1.6 -no-domain- ------------------------------------------------------------ kernel LONG_MAX + exportfs INT_MAX: "Tue Jan 19 03:14:08 UTC 2038" ================================================================== "exportfs: /mnt/export does not support NFS export": ------------------------------------------------------------ # cat /proc/net/rpc/auth.unix.ip/content #class IP domain ------------------------------------------------------------ + mount success: ------------------------------------------------------------ # cat /proc/net/rpc/auth.unix.ip/content #class IP domain # expiry=2147485448 refcnt=2 flags=1 nfsd 192.168.1.6 * ------------------------------------------------------------ kernel LONG_MAX + exportfs LONG_MAX: "Tue Jan 19 03:14:08 UTC 2038" =================================================================== exportfs: ------------------------------------------------------------ # cat /proc/net/rpc/auth.unix.ip/content #class IP domain # expiry=9223372036854775807 refcnt=1 flags=1 nfsd 0.0.0.0 -test-client- ------------------------------------------------------------ + mount success: ------------------------------------------------------------ # cat /proc/net/rpc/auth.unix.ip/content #class IP domain # expiry=2147485448 refcnt=2 flags=1 nfsd 192.168.1.6 * # expiry=9223372036854775807 refcnt=1 flags=1 nfsd 0.0.0.0 -test-client- ------------------------------------------------------------ Signed-off-by: Harshula Jayasuriya --- utils/exportfs/exportfs.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c index da5fe21..9f13858 100644 --- a/utils/exportfs/exportfs.c +++ b/utils/exportfs/exportfs.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include "sockaddr.h" #include "misc.h" @@ -406,17 +408,34 @@ unexportfs(char *arg, int verbose) static int can_test(void) { + char buf[1024]; int fd; int n; - char *setup = "nfsd 0.0.0.0 2147483647 -test-client-\n"; + fd = open("/proc/net/rpc/auth.unix.ip/channel", O_WRONLY); - if ( fd < 0) return 0; - n = write(fd, setup, strlen(setup)); + if (fd < 0) + return 0; + + /* We introduce tolerance of 1 day to ensure that we use a + * LONG_MAX for the expiry timestamp before it is actually + * needed. To use LONG_MAX, the kernel code must have commit + * 2f74f972d4cc7d83408ea0c32d424edcb44887bf + * (sunrpc: prepare NFS for 2038). + */ +#define INT_TO_LONG_THRESHOLD_SECS (INT_MAX - (60 * 60 * 24)) + if (time(NULL) > INT_TO_LONG_THRESHOLD_SECS) + sprintf(buf, "nfsd 0.0.0.0 %ld -test-client-\n", LONG_MAX); + else + sprintf(buf, "nfsd 0.0.0.0 %d -test-client-\n", INT_MAX); + + n = write(fd, buf, strlen(buf)); close(fd); if (n < 0) return 0; + fd = open("/proc/net/rpc/nfsd.export/channel", O_WRONLY); - if ( fd < 0) return 0; + if (fd < 0) + return 0; close(fd); return 1; }