Re: NFSv3 client reordering RENAMEs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 15 June 2006 19:05, Peter Staubach wrote:

> >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.


-- 
// 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;
}


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux