Received: from hasmsx413.ger.corp.intel.com ([143.185.64.170]) by
	swsmsx413.ger.corp.intel.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 30
	Oct 2008 21:32:11 +0000
Received: from orsmsx335.jf.intel.com ([10.22.226.40]) by
	hasmsx413.ger.corp.intel.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 30
	Oct 2008 23:32:10 +0200
Received: from azsmsx333.amr.corp.intel.com ([10.2.121.77]) by
	orsmsx335.jf.intel.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 30 Oct
	2008 14:31:28 -0700
Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by
	azsmsx333.amr.corp.intel.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 30
	Oct 2008 14:31:28 -0700
Received: from fmsmga102.fm.intel.com ([10.1.193.69]) by
	fmsmga002-1.fm.intel.com with ESMTP; 30 Oct 2008 14:27:40 -0700
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AtECAK/ECUlCXQLWgWdsb2JhbACUCwEBFiKtUYpDg1E
X-IronPort-AV: E=Sophos;i="4.33,518,1220252400";  d="scan'208";a="704586773"
Received: from mail.fieldses.org (HELO fieldses.org) ([66.93.2.214]) by
	mga11.intel.com with ESMTP; 30 Oct 2008 14:26:37 -0700
Received: from bfields by fieldses.org with local (Exim 4.69)
	(envelope-from <bfields@fieldses.org>) id 1Kvf6z-0006pW-4A; Thu, 30 Oct
	2008 17:31:25 -0400
Date: Thu, 30 Oct 2008 17:31:25 -0400
To: linux-nfs@vger.kernel.org
Cc: David Woodhouse <David.Woodhouse@intel.com>, Al Viro <viro@zeniv.linux.org.uk>
Subject: [PATCH] nfsd: fix failure to set eof in readdir in some situations
Message-ID: <20081030213125.GC24156@fieldses.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.18 (2008-05-17)
From: "J. Bruce Fields" <bfields@fieldses.org>
Return-Path: bfields@fieldses.org
X-OriginalArrivalTime: 30 Oct 2008 21:31:28.0771 (UTC)
	FILETIME=[DE891D30:01C93AD6]
X-Evolution-Source: imap://GER%5cdwoodhou@imap.intel.com/
Content-Transfer-Encoding: 7bit

From: J. Bruce Fields <bfields@citi.umich.edu>

Before 14f7dd632011bb89c035722edd6ea0d90ca6b078 "[PATCH] Copy XFS
readdir hack into nfsd code", readdir_cd->err was reset to eof before
each call to vfs_readdir; afterwards, it is set only once.  Similarly,
c002a6c7977320f95b5edede5ce4e0eeecf291ff "[PATCH] Optimise NFS readdir
hack slightly", can cause us to exit without nfserr_eof set.  Fix this.

This ensures the "eof" bit is set when needed in readdir replies.  (The
particular case I saw was an nfsv4 readdir of an empty directory, which
returned with no entries (the protocol requires "." and ".." to be
filtered out), but with eof unset.)

Cc: David Woodhouse <David.Woodhouse@intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
---
 fs/nfsd/vfs.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

I'm queuing this up for 2.6.28.--b.

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 0bc56f6..848a03e 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1912,6 +1912,7 @@ static int nfsd_buffered_readdir(struct file *file, filldir_t func,
 			de = (struct buffered_dirent *)((char *)de + reclen);
 		}
 		offset = vfs_llseek(file, 0, SEEK_CUR);
+		cdp->err = nfserr_eof;
 		if (!buf.full)
 			break;
 	}
-- 
1.5.5.rc1

