[BUG] NFS no longer updates file modification times appropriately

From: Joe Korty
Date: Thu Jun 03 2004 - 15:29:51 EST


Trond,
Paraphrased from one of my inhouse customers: "The timestamp of an
NFS-mounted file does not change when written to, when the below test is
run on a 2.6.6-rc1 to 2.6.7-rc2 kernel. The timestamp is appropriately
updated when the test is run on a 2.6.5 kernel. This is with NFSv3.
The type of system serving up the files does not seem to be a factor."

I was not able to narrow the problem/featureset change down to a cset.

Attached is the test program my customer used.

Regards,
Joe

#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>

#define PATH "./my_file"

int
main()
{
int status;
int count = 0;
int fd;
struct stat wuz;
struct stat iz;

(void) unlink(PATH);

fd = open (PATH, O_RDWR+O_CREAT+O_SYNC, 0666);
if (fd < 0) {
fprintf (stderr, "open(%s) fails, errno = %d\n", PATH, errno);
return 1;
}

status = fstat (fd, &wuz);
if (status) {
fprintf (stderr, "fstat(%s) fails, errno = %d\n", PATH, errno);
return 1;
}

for (;;) {
status = write (fd, &status, sizeof(status));
if (status != sizeof(status)) {
fprintf (stderr, "write(%s) fails, errno = %d\n", PATH, errno);
return 1;
}
status = fstat (fd, &iz);
if (status) {
fprintf (stderr, "fstat(%s) fails, errno = %d\n", PATH, errno);
return 1;
}
if (iz.st_mtime != wuz.st_mtime) break;
count++;
if (count % 1000 == 0) {
printf ("count = %d\n", count);
}
}

printf ("File modification time changed after %d iterations\n", count);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/