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

Bug#1017720: nfs-common: No such file or directory



On 2024-04-09 14:09:43 +0200, Vincent Lefevre wrote:
> Some additional information: created only once, but data may be
> appended (on the creator's side, the file is created for writing,
> and data are written occasionally, and at some point, the file is
> closed). The error with "open" may occur even several hours after
> the last time data were written to the file.

This is actually reproducible with a read-only directory.
I've attached a Perl script to reproduce the issue, just
based on "stat".

The conditions seem to be:
  * The directory and the files need to be recent enough: I can't
    reproduce the issue with an old directory, even if I add many
    new files into it.
  * Concurrent "stat": with the attached script, the issue is
    reproducible with 2 threads or more, but not with a single
    thread.

Example of errors:

./dir-stat: can't stat . (x 2)
./dir-stat: can't stat 775 (x 148)
./dir-stat: can't stat 772 (x 1)
./dir-stat: can't stat 415 (x 1)
./dir-stat: can't stat 716 (x 1)
./dir-stat: can't stat 453 (x 1)
./dir-stat: can't stat 9 (x 1)
./dir-stat: can't stat 201 (x 1)
./dir-stat: can't stat 981 (x 1)
./dir-stat: can't stat 660 (x 1)
./dir-stat: can't stat 120 (x 1)
./dir-stat: can't stat 127 (x 1)
./dir-stat: can't stat 663 (x 1)

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
#!/usr/bin/env perl

# Create a directory with several hundreds of files, for instance with
#   mkdir test && cd test && touch `seq 999`
# then run this Perl script with the directory name in argument.

use strict;
use threads;

my $maxthreads = 2;
my $nthreads = 0;

@ARGV == 1 or die "Usage: $0 <dir>\n";
my $dir = $ARGV[0];
-d $dir or die "$0: $dir is not a directory\n";

sub thr ($) {
  my $file = $_[0];
  my $err = 0;
  until (stat "$dir/$file")
    {
      $err++;
      sleep 0.25;
    }
  warn "$0: can't stat $file (x $err)\n" if $err;
}

sub join_threads () {
  my @thr;
  sleep 0.25 until @thr = threads->list(threads::joinable);
  foreach my $thr (@thr)
    { $thr->join(); }
  $nthreads -= @thr;
}

opendir DIR, $dir or die "$0: opendir failed ($!)\n";
while (my $file = readdir DIR)
  {
    $nthreads < $maxthreads or join_threads;
    $nthreads++ < $maxthreads or die "$0: internal error\n";
    threads->create(\&thr, $file);
  }
closedir DIR or die "$0: closedir failed ($!)\n";
join_threads while $nthreads;

Reply to: