2007-11-23 08:30:54

by Timo Sirainen

[permalink] [raw]
Subject: [NFS] NFSv4 close-to-open attr cache flushing broken in 2.6.23

In v2.6.23 (but not in v2.6.22) a file's attribute cache doesn't get
flushed with close()+open() if the file is open in any process on the
same server. Test program below demonstrates it.

BTW. I thought delegations were supposed to fix most of these caching
issues automatically? I don't see any difference in caching behavior
compared to NFSv3 (Linux 2.6.23 as NFS server).

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

int main(void)
{
int fd = open("foo", O_RDWR | O_CREAT, 0600);
int fd2 = open("foo", O_RDWR);
struct stat st;
char buf[1024];

if (fstat(fd2, &st) < 0) perror("fstat()");
printf("mtime before = %ld\n", st.st_mtime);

printf("now modify the file on server\n");
fgets(buf, sizeof(buf), stdin);

close(fd2);
fd2 = open("foo", O_RDWR);
if (fstat(fd2, &st) < 0) perror("fstat()");
printf("mtime after = %ld\n", st.st_mtime);
return 0;
}


Attachments:
signature.asc (189.00 B)
This is a digitally signed message part
(No filename) (228.00 B)
(No filename) (362.00 B)
Download all attachments