From patchwork Mon May 12 03:50:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 4155301 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6B5529F170 for ; Mon, 12 May 2014 03:50:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1E0E2018E for ; Mon, 12 May 2014 03:50:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E44FB2018A for ; Mon, 12 May 2014 03:50:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751401AbaELDu3 (ORCPT ); Sun, 11 May 2014 23:50:29 -0400 Received: from cantor2.suse.de ([195.135.220.15]:48674 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751393AbaELDu2 (ORCPT ); Sun, 11 May 2014 23:50:28 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 44C07AC4F; Mon, 12 May 2014 03:50:27 +0000 (UTC) Date: Mon, 12 May 2014 13:50:19 +1000 From: NeilBrown To: Trond Myklebust Cc: NFS Subject: [PATCH] NFS: revalidate on open if dcache is negative. Message-ID: <20140512135019.56e5c465@notabene.brown> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.22; x86_64-suse-linux-gnu) Mime-Version: 1.0 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.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, 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 NFS CTO semantics require that (absent a delegation) the server must be contacted at each open. nfs_lookup_verify_inode() implements this when the dcache contains a positive cached entry. However it is not called when the dcache contains a negative cached entry. That path uses nfs_neg_need_reval() which doesn't impose CTO semantics. So a sequence like: rm -f testfile ls -l testfile ssh $server touch testfile cat testfile will fail: cat: testfile: No such file or directory an 'strace' will confirm that this resulted from an 'open' system call. So add code to nfs_neg_need_reval implement CTO semantics much like that in nfs_lookup_verify_inode(). Signed-off-by: NeilBrown diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index d9f3d067cd15..f8022da72460 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1062,6 +1062,8 @@ int nfs_neg_need_reval(struct inode *dir, struct dentry *dentry, /* Don't revalidate a negative dentry if we're creating a new file */ if (flags & LOOKUP_CREATE) return 0; + if ((flags & LOOKUP_OPEN) && !(NFS_SERVER(dir)->flags & NFS_MOUNT_NOCTO)) + return 1; if (NFS_SERVER(dir)->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG) return 1; return !nfs_check_verifier(dir, dentry);