From patchwork Fri Aug 5 23:37:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9266155 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 B9FEE60760 for ; Sun, 7 Aug 2016 01:14:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CA8227F88 for ; Sun, 7 Aug 2016 01:14:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F82C2840A; Sun, 7 Aug 2016 01:14:01 +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 E38EE27F88 for ; Sun, 7 Aug 2016 01:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751040AbcHGBN6 (ORCPT ); Sat, 6 Aug 2016 21:13:58 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:33122 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750954AbcHGBN5 (ORCPT ); Sat, 6 Aug 2016 21:13:57 -0400 Received: by mail-io0-f195.google.com with SMTP id y195so26647041iod.0 for ; Sat, 06 Aug 2016 18:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=aJz1AhRqrwww2GsqoQVxJAQKPGfht2T4v4116Oxr7qg=; b=nJRg2FHXAtyLozVqYFqR1Y7xVReVn0CW+DNgS8iOizei3hcvF7B3LyswM0XrM1BgdU Qpu39boIIcP71sFDMslYUlIBPHv5QOo/KdPeeGwbat6lXo+pgr2dx1lhr9ubALUGIa2P yH8LEJJUa8aALqQLZm1ZQyR55CNj94EwBtN+5/oknrl8yP+jS/qLJXLj544FBKIPB5Qp J+sGzGthMjATlPwAEb//3b9g30PRIkZXeiCzNPA0Jm5MJvo1dMHQoz74SonN0ADY0WnY kznkiIvREZfLCu3Xo9G6ua05WKct3UVtoTWovLvzcV9OIhtrzo12i6gw195DzCOR1Ct0 UWPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=aJz1AhRqrwww2GsqoQVxJAQKPGfht2T4v4116Oxr7qg=; b=ee7CB/CcYPFrRSN0xEGFeI2+H5hfbk8SM+FhjNSBZvCel6EhSDG+hXw0+1g/ZZScu+ gdNqRYAsLR5pRCs9WRB3JiPy8NIE66Y4xFg7E4rsx7uX9m+Vs9Du7LhZgeirE1CtZk4M kK+v5+KB9Iy3CN/4vaoA5Gv2vMXUOggN/TW6hC1B5EmCFVzq+USINCdlIwyTg1OK8l8o oUAwmMtg1NZM82SZsNTJ/pjXLjGofyktza9c76k7G7gKCl70Kh7KAkvtGSg2dBrWlCZj OkyfXk4kDk3cpejk2jgAeQ6ksyHsfjmRmqqBQXOMENJ+xZa4Sy75ojBEmWUuahsvgaax qOnQ== X-Gm-Message-State: AEkoouvaRxHtFpm+3DB/kWcZWAj4XWXSKTBJcvooPoVLo4h0h+NDqYrj9kA4xdbUQiCiGw== X-Received: by 10.107.160.207 with SMTP id j198mr9551160ioe.70.1470440298675; Fri, 05 Aug 2016 16:38:18 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (c-68-49-162-121.hsd1.mi.comcast.net. [68.49.162.121]) by smtp.gmail.com with ESMTPSA id v7sm4874775itd.6.2016.08.05.16.38.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Aug 2016 16:38:18 -0700 (PDT) From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 2/3] NFSv4: Cleanup the setting of the nfs4 lease period Date: Fri, 5 Aug 2016 19:37:34 -0400 Message-Id: <1470440255-8612-3-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470440255-8612-2-git-send-email-trond.myklebust@primarydata.com> References: <1470440255-8612-1-git-send-email-trond.myklebust@primarydata.com> <1470440255-8612-2-git-send-email-trond.myklebust@primarydata.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 Make a helper function nfs4_set_lease_period() and have nfs41_setup_state_renewal() and nfs4_do_fsinfo() use it. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4_fs.h | 4 ++++ fs/nfs/nfs4proc.c | 9 +++------ fs/nfs/nfs4renewd.c | 17 +++++++++++++++++ fs/nfs/nfs4state.c | 9 +++------ 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 4be567a54958..74a0e34e5ded 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -395,6 +395,10 @@ extern void nfs4_schedule_state_renewal(struct nfs_client *); extern void nfs4_renewd_prepare_shutdown(struct nfs_server *); extern void nfs4_kill_renewd(struct nfs_client *); extern void nfs4_renew_state(struct work_struct *); +extern void nfs4_set_lease_period(struct nfs_client *clp, + unsigned long lease, + unsigned long lastrenewed); + /* nfs4state.c */ struct rpc_cred *nfs4_get_clid_cred(struct nfs_client *clp); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index da5c9e58e907..b9e18679af50 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -4237,12 +4237,9 @@ static int nfs4_do_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, str err = _nfs4_do_fsinfo(server, fhandle, fsinfo); trace_nfs4_fsinfo(server, fhandle, fsinfo->fattr, err); if (err == 0) { - struct nfs_client *clp = server->nfs_client; - - spin_lock(&clp->cl_lock); - clp->cl_lease_time = fsinfo->lease_time * HZ; - clp->cl_last_renewal = now; - spin_unlock(&clp->cl_lock); + nfs4_set_lease_period(server->nfs_client, + fsinfo->lease_time * HZ, + now); break; } err = nfs4_handle_exception(server, err, &exception); diff --git a/fs/nfs/nfs4renewd.c b/fs/nfs/nfs4renewd.c index e1ba58c3d1ad..062029ab344a 100644 --- a/fs/nfs/nfs4renewd.c +++ b/fs/nfs/nfs4renewd.c @@ -136,6 +136,23 @@ nfs4_kill_renewd(struct nfs_client *clp) cancel_delayed_work_sync(&clp->cl_renewd); } +/** + * nfs4_set_lease_period - Sets the lease period on a nfs_client + * + * @clp: pointer to nfs_client + * @lease: new value for lease period + * @lastrenewed: time at which lease was last renewed + */ +void nfs4_set_lease_period(struct nfs_client *clp, + unsigned long lease, + unsigned long lastrenewed) +{ + spin_lock(&clp->cl_lock); + clp->cl_lease_time = lease; + clp->cl_last_renewal = lastrenewed; + spin_unlock(&clp->cl_lock); +} + /* * Local variables: * c-basic-offset: 8 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 834b875900d6..cada00aa5096 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -277,20 +277,17 @@ static int nfs41_setup_state_renewal(struct nfs_client *clp) { int status; struct nfs_fsinfo fsinfo; + unsigned long now; if (!test_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state)) { nfs4_schedule_state_renewal(clp); return 0; } + now = jiffies; status = nfs4_proc_get_lease_time(clp, &fsinfo); if (status == 0) { - /* Update lease time and schedule renewal */ - spin_lock(&clp->cl_lock); - clp->cl_lease_time = fsinfo.lease_time * HZ; - clp->cl_last_renewal = jiffies; - spin_unlock(&clp->cl_lock); - + nfs4_set_lease_period(clp, fsinfo.lease_time * HZ, now); nfs4_schedule_state_renewal(clp); }