From patchwork Tue Nov 17 11:52:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 7636161 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5C435BF90C for ; Tue, 17 Nov 2015 11:53:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7BF1E204E2 for ; Tue, 17 Nov 2015 11:53:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 265F620501 for ; Tue, 17 Nov 2015 11:53:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753567AbbKQLxy (ORCPT ); Tue, 17 Nov 2015 06:53:54 -0500 Received: from mail-qg0-f46.google.com ([209.85.192.46]:34808 "EHLO mail-qg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753538AbbKQLxs (ORCPT ); Tue, 17 Nov 2015 06:53:48 -0500 Received: by qgeb1 with SMTP id b1so3413911qge.1 for ; Tue, 17 Nov 2015 03:53:47 -0800 (PST) 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=Umjry/iCIht5TS+V0CHeY7SJ1SNc4Dj+ZsZovaI7ouE=; b=wTvgLnGWV/qXkw7m9TyTEwIZG+WzvxptDRCNsGEQCVcBGUG/6lQRP8ibDlCc6sR6g6 k8ZmhaJxX1SbiTvw+b23pTnYpMh6CqvRG9AUd/GlXfU2Er4FnPwbN8juInMTehY+7obV yvuMsDl6Gd94AMec7wOc5kkssm+WcPvKMFKX+LdXw0GH40aBP75zarssTXoUWzdE10hP vIZRG6qt8AVOFwkU5GgMSzvGyK3e/EswO8ktycnVTlgups8cgo/MiSpNnLnkAtxhEVs+ YrJg7yUiToVjy0cey6nDS7fOsgtRh0NpqJQen/zmP10LI5zudNf0E5QHVIlYW59QQcW9 ULHA== 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=Umjry/iCIht5TS+V0CHeY7SJ1SNc4Dj+ZsZovaI7ouE=; b=lccj3fFgZ2UZwbh5iSuJaSK2d+/MG6gNpfT9XGCgj8VYOhVSnMrzxc2Rcb6dm663uR k9+pyZlm+pCkIOvzM0iKEgBBfXPT/jer0IrQU0tDoEXzR2sHZLCOmQauZ+dktiXuJqrX 4UNgTnuqnYTvVOmR+IgQJ0j4HIwFXZHTnixn3eSD5rkg6uVXuyfFSvwLsvP9a0gDDNEW MKeWF7A8AUJDWVrNuxzDr1ZmPW0lYTMaj3hY21hJiZzVDUr58BHhAbFwINxzGgpiYzGO Kuqva92MYDgwP+Ivnqqr3NTYF4AjMGuytvD7A1RXYihVIFiUsXV/WvA6Q51DyGGJVdzA xZLQ== X-Gm-Message-State: ALoCoQl7rp1ozNX4Zydfa3V8v20yPupl0l2LDmGb2MRyTOIgtAMSVgmFApETbvxqulnGnWt/8TYC X-Received: by 10.140.196.69 with SMTP id r66mr27764840qha.40.1447761227575; Tue, 17 Nov 2015 03:53:47 -0800 (PST) Received: from tlielax.poochiereds.net ([2606:a000:1125:4075::d5a]) by smtp.googlemail.com with ESMTPSA id w10sm1583910qhc.16.2015.11.17.03.53.46 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Nov 2015 03:53:46 -0800 (PST) From: Jeff Layton X-Google-Original-From: Jeff Layton To: bfields@fieldses.org, trond.myklebust@primarydata.com Cc: linux-nfs@vger.kernel.org, Eric Paris , Alexander Viro , linux-fsdevel@vger.kernel.org Subject: [PATCH v1 29/38] nfsd: retry once in nfsd_open on an -EOPENSTALE return Date: Tue, 17 Nov 2015 06:52:51 -0500 Message-Id: <1447761180-4250-30-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1447761180-4250-1-git-send-email-jeff.layton@primarydata.com> References: <1447761180-4250-1-git-send-email-jeff.layton@primarydata.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 If we get back -EOPENSTALE from an NFSv4 open, then we either got some unhandled error or the inode we got back was not the same as the one associated with the dentry. We really have no recourse in that situation other than to retry the open, and if it fails to just return nfserr_stale back to the client. Signed-off-by: Jeff Layton --- fs/nfsd/nfsproc.c | 1 + fs/nfsd/vfs.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index 5a82d20a50b4..697fc0b9ba09 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -795,6 +795,7 @@ nfserrno (int errno) { nfserr_serverfault, -ESERVERFAULT }, { nfserr_serverfault, -ENFILE }, { nfserr_io, -EREMOTEIO }, + { nfserr_stale, -EOPENSTALE }, }; int i; diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 9bf194be2b8e..5293cba6b8f8 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -622,9 +622,9 @@ __nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int flags = O_RDONLY|O_LARGEFILE; __be32 err; int host_err = 0; + bool retried = false; - BUG_ON(!fhp->fh_dentry); - +retry: path.mnt = fhp->fh_export->ex_path.mnt; path.dentry = fhp->fh_dentry; inode = d_inode(path.dentry); @@ -659,6 +659,14 @@ __nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, file = dentry_open(&path, flags, current_cred()); if (IS_ERR(file)) { + if (file == ERR_PTR(-EOPENSTALE) && !retried) { + retried = true; + fh_put(fhp); + err = fh_verify(rqstp, fhp, type, may_flags); + if (err) + goto out; + goto retry; + } host_err = PTR_ERR(file); goto out_nfserr; }