infinite loop? with mmap, nfs, pwrite, O_DIRECT

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

 



I have a smaller test case (4 system calls, and a memset), that causes the test case to hang in an
unkillable state*, and makes the system load consume an entire CPU.

*the process is killable if run under strace, but the system load does not drop when the strace is
killed.

Pass this the name of a target file on an NFS mount.

(tested to fail on 2.6.15-rc1).

-Kenny


Here is the test:

#define _GNU_SOURCE

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

int main(int argc, char* argv[])
{
  if (argc != 2) {
    printf("usage: %0 <filename>\n", argv[0]);
    return 0;
  }

  {
    int fd = open(argv[1], O_RDWR | O_CREAT | O_LARGEFILE | O_DIRECT, 0644);
    if (fd < 0) {
      perror("open");
      return 0;
    }

    int window_size = 2 * 1024 * 1024;
    long long file_size = window_size;

    /* fast-forward */
    file_size += 2047u * (2 * 1024 * 1024);
    file_size += window_size + window_size;

    /* grow file */
    pwrite64(fd, "", 1, file_size);

    {
      char* mapping_start = (char*)mmap64(0, window_size,
                                          PROT_READ | PROT_WRITE,
                                          MAP_SHARED,
                                          fd, file_size - window_size);

      /* test only fails with this: */
      memset(mapping_start, 0, window_size);
    }

    /* grow file */
    file_size += window_size;

    /* this never returns */
    pwrite64(fd, "", 1, file_size);
  }
  return 0;
}



		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[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