NFSv3 client reordering RENAMEs
G'd day,
Looks like that given async NFS mount Linux NFS client can reorder RENAMEs as well. For me this caused several eaten files :/. Didn't really expect RENAME to be reordered as mv is generally considered atomic. That, and RFC 1813 mandates RENAME to be atomic. Is this a known thing and do you guys consider this feature or a bug?
Signature · 1 line
// Janne
Quoted 8 lines · Janne Karhunen
G'd day,
Looks like that given async NFS mount Linux NFS client can reorder RENAMEs as well. For me this caused several eaten files :/. Didn't really expect RENAME to be reordered as mv is generally considered atomic. That, and RFC 1813 mandates RENAME to be atomic. Is this a known thing and do you guys consider this feature or a bug?
Can you construct a testcase which exhibits this behavior?
Thanx...
ps
Quoted 5 lines · Peter Staubach
Quoted 3 lines
really expect RENAME to be reordered as mv is generally considered atomic. That, and RFC 1813 mandates RENAME to be atomic. Is this a known thing and do you guys consider this feature or a bug?
Can you construct a testcase which exhibits this behavior?
Possibly .. if someone first acks that this indeed would be considered as bug and not as a feature :/
Signature · 1 line
// Janne
Quoted 9 lines · Janne Karhunen
Quoted 5 lines · Peter Staubach
Quoted 5 lines
really expect RENAME to be reordered as mv is generally considered atomic. That, and RFC 1813 mandates RENAME to be atomic. Is this a known thing and do you guys consider this feature or a bug?
Quoted 7 lines
Quoted 3 lines
Can you construct a testcase which exhibits this behavior?
Possibly .. if someone first acks that this indeed would be considered as bug and not as a feature :/
Yes, I believe that this would be considered to be a bug...
ps
Quoted 4 lines · Peter Staubach
Quoted 2 lines
Possibly .. if someone first acks that this indeed would be considered as bug and not as a feature :/
Yes, I believe that this would be considered to be a bug...
Looks that this is a vendor kernel issue, couldn't get it to barf on mainline. Without any more knowledge of the extent of the problem testcase attached. Given that you suffer from the problem you should occasionally see files vanishing.
Signature · 1 line
// Janne
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
#ifndef ROTATION_CYCLE
#define ROTATION_CYCLE 60
#endif
char* str = "Quick brown fox jumped over lazy dog %d\n";
char buf[50] = { 0 };
int rl=1;
int rr=1;pthread_t thr[2];
void* logger_thread ( void* ptr ) {
int i=0, r, fd;
fd = open ( "/mnt/nfs/file", O_RDWR|O_CREAT, 00600 ); printf ( "logger starting, fd %d\n", fd );
if ( fd <= 0 ) {
printf ("%s\n", strerror(errno));
return NULL;
}
while ( rl ) {
r = sprintf ( &buf[0], str, i );
r = write ( fd, &buf[0], strlen(&buf[0]) );
if ( r <= 0 ) {
printf ("\n\n%s\n", strerror(errno));
goto exit;
}
i++;
usleep ( 10000 ); }
exit:
printf ("logger exiting\n");
close (fd);
return NULL;
}
void* logrotate_thread ( void* ptr ) {
int r;
printf ( "rotater starting\n" );
while ( rr ) {
sleep(ROTATION_CYCLE); r = system ( "mv /mnt/nfs/file.4 /mnt/nfs/file.5" );
r = system ( "mv /mnt/nfs/file.3 /mnt/nfs/file.4" );
r = system ( "mv /mnt/nfs/file.2 /mnt/nfs/file.3" );
r = system ( "mv /mnt/nfs/file.1 /mnt/nfs/file.2" );
r = system ( "mv /mnt/nfs/file /mnt/nfs/file.1" );
rl=0;
sleep(2);
rl=1;
pthread_create ( &thr[1], 0, logger_thread, 0 ); }
printf ( "rotater exiting\n" );
return NULL;
}
int main ( int a, char** b ) {
pthread_create ( &thr[0], 0, logrotate_thread, 0 ); pthread_create ( &thr[0], 0, logger_thread, 0 );
while ( 1 )
usleep ( 100000 );
return 0;
}
Quoted 8 lines · Janne Karhunen
Quoted 4 lines · Peter Staubach
Quoted 4 lines
Possibly .. if someone first acks that this indeed would be considered as bug and not as a feature :/
Quoted 8 lines
Quoted 3 lines
Yes, I believe that this would be considered to be a bug...
Looks that this is a vendor kernel issue, couldn't get it to
barf on mainline. Without any more knowledge of the extent of the problem testcase attached. Given that you suffer from the problem you should occasionally see files vanishing.
Although this is a little timing dependent, it mostly should work. How long does it need to run before failures will be seen? I have been running it for about half an hour and it seems to be operating as I expected.
I would suggest reporting this issue to your vendor and see what they have to say.
Thanx...
ps