Linux NFS development
 help / color / mirror / Atom feed
From: "Stephen C. Tweedie" <sct@redhat.com>
To: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: "Stephen C. Tweedie" <sct@redhat.com>,
	Jeremy Fitzhardinge <jeremy@goop.org>,
	Ext2 devel <ext2-devel@lists.sourceforge.net>,
	NFS maillist <nfs@lists.sourceforge.net>,
	Linux Kernel List <linux-kernel@vger.kernel.org>
Subject: Re: Re: [NFS] htree+NFS (NFS client bug?)
Date: Thu, 28 Nov 2002 16:44:39 +0000	[thread overview]
Message-ID: <20021128164439.E2362@redhat.com> (raw)
In-Reply-To: <20021127205554.J2948@redhat.com>; from sct@redhat.com on Wed, Nov 27, 2002 at 08:55:54PM +0000

[-- Attachment #1: Type: text/plain, Size: 1351 bytes --]

Hi,

On Wed, Nov 27, 2002 at 08:55:54PM +0000, Stephen C. Tweedie wrote:
 
> Having said that, the server is clearly in error in sending a
> duplicate cookie in the first place, and if it did so we'd never get
> into such a state.

And it's ext3's fault.  Reproducer below.  Run the attached readdir
against an htree directory and you get something like:

[root@host1 htest]# ~sct/test/fs/readdir 
getdents at f_pos 0000000000000000 returned 4084.
getdents at f_pos 0X0000000B753BE7 returned 4080.
getdents at f_pos 0X000000158C4C61 returned 4080.
getdents at f_pos 0X00000021E86BDC returned 4080.
getdents at f_pos 0X0000002D60F25D returned 4080.
getdents at f_pos 0X00000037BC95D7 returned 4096.
getdents at f_pos 0X000000434E2AA3 returned 4080.
getdents at f_pos 0X0000004EF11AE6 returned 4080.
getdents at f_pos 0X000000596EBC2F returned 4080.
getdents at f_pos 0X00000065A76668 returned 4080.
getdents at f_pos 0X0000007060CF8B returned 4080.
getdents at f_pos 0X0000007B9213FA returned 1464.
getdents at f_pos 0X0000007B9213FA returned 0.
Final f_pos is 0X0000007B9213FA.
[root@host1 htest]# 

The problem is that the htree readdir code is not updating f_pos after
returning the very last chunk of data to the caller.  That doesn't
hurt most callers because the location is cached in the filp->private
data, but it really upsets NFS.

--Stephen

[-- Attachment #2: readdir.c --]
[-- Type: text/plain, Size: 1083 bytes --]

#define _LARGEFILE64_SOURCE
#include <assert.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <sys/vfs.h>
#include <sys/resource.h>

#include <linux/types.h>
#include <linux/unistd.h>
#include <linux/dirent.h>
_syscall3(int, getdents, uint, fd, struct dirent *, dirp, uint, count);
 
void try(const char *what, int err)
{
	if (!err)
		return;
	fprintf (stderr, "Unexpected result %d.  %s: %s\n",
		 err, what, strerror(errno));
	exit(1);
}

int test_readdir(int fd)
{
	loff_t offset;
	char dirbuf[4096];
	int res;

	offset = lseek64(fd, 0, SEEK_CUR);
	res = getdents(fd, (struct dirent *)dirbuf, sizeof(dirbuf));
	printf("getdents at f_pos %#016llX returned %d.\n", offset, res);
	return res;
}

int main()
{
	int fd;
	int res;
	loff_t offset;
	
	fd = open64(".", O_RDONLY, 0);
	try ("open \".\"", fd < 0);

	do {
		res = test_readdir(fd);
	} while (res > 0);

	offset = lseek64(fd, 0, SEEK_CUR);
	printf("Final f_pos is %#016llX.\n", offset);
	return 0;
}

  parent reply	other threads:[~2002-11-28 16:44 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-26 23:44 htree+NFS (NFS client bug?) Jeremy Fitzhardinge
2002-11-27  3:26 ` [NFS] " Trond Myklebust
2002-11-27  2:59   ` [Ext2-devel] " chrisl
2002-11-27  8:58   ` Jeremy Fitzhardinge
2002-11-27 15:00     ` Stephen C. Tweedie
2002-11-27 20:25       ` [Ext2-devel] " Trond Myklebust
2002-11-27 20:55         ` Stephen C. Tweedie
2002-11-27 22:44           ` [Ext2-devel] " Trond Myklebust
2002-11-28 16:41             ` Stephen C. Tweedie
2002-11-28 16:58               ` Trond Myklebust
2002-11-28 17:09                 ` Stephen C. Tweedie
2002-11-28 17:57                   ` Trond Myklebust
2002-11-28 16:44           ` Stephen C. Tweedie [this message]
2002-11-28 17:13             ` Stephen C. Tweedie
2002-11-28 17:44               ` Trond Myklebust
2002-11-28 20:00               ` [Ext2-devel] " Jeremy Fitzhardinge
2002-11-28  2:07       ` Jeremy Fitzhardinge
2002-11-28  2:46         ` Trond Myklebust
2002-11-27 13:33 ` Theodore Ts'o
2002-11-27 20:42   ` Trond Myklebust

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021128164439.E2362@redhat.com \
    --to=sct@redhat.com \
    --cc=ext2-devel@lists.sourceforge.net \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nfs@lists.sourceforge.net \
    --cc=trond.myklebust@fys.uio.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox