-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
switch(c) {
case 'a':
append_max = strtoul(optarg, &end, 0);
- if (append_max == 0 || *end) {
+ if (append_max < 2 || *end) {
fprintf(stderr, "%s: bad append option '%s'\n",
prog, optarg);
usage(prog);
break;
case 'w':
write_max = strtoul(optarg, &end, 0);
- if (write_max == 0 || *end) {
+ if (write_max < 2 || *end) {
fprintf(stderr, "%s: bad write option '%s'\n",
prog, optarg);
usage(prog);
if (rank == 0) {
write_size = (rand() % (write_max - 1)) + 1;
append_size = (rand() % (append_max - 1)) + 1;
- trunc_size = (rand() % ((trunc_max?: append_size)-1))+1;
+ trunc_size = (append_size == 1) ? 1 :
+ (rand() % ((trunc_max?: append_size)-1))+1;
trunc_offset = write_size + trunc_size;
if (verbose || n % 1000 == 0)
done = 0;
do {
ret = write(fd, write_buf+done,write_size-done);
- if (verbose > 1 || ret <= 0) {
- rprintf(rank, n, ret <= 0,
+ if (verbose > 1 || ret < 0) {
+ rprintf(rank, n,
+ ret < 0 && errno != EINTR,
"write %d/%d @ %d: %s\n",
ret + done, write_size, done,
strerror(errno));
- if (ret <= 0)
+ if (ret < 0 && errno != EINTR)
break;
}
- done += ret;
+ if (ret > 0)
+ done += ret;
} while (done != write_size);
}
ret = write(fd, append_buf + done,
append_size - done);
if (ret < 0) {
- rprintf(rank, n, ret < 0,
+ rprintf(rank, n, errno != EINTR,
"append %u/%u: %s\n",
ret + done, append_size,
strerror(errno));
- break;
+ if (errno != EINTR)
+ break;
} else if (verbose > 1 || ret != append_size) {
rprintf(rank, n, ret != append_size,
"append %u/%u\n",
ret + done, append_size);
}
- done += ret;
+ if (ret > 0)
+ done += ret;
} while (done != append_size);
} else if (rank == trunc_rank) {
/* XXX: truncating the same file descriptor as the
if (error == 1) {
char command[4096];
- int rc;
rprintf(rank, n, 0, STATUS_FMT"\n",
write_char, write_size, write_size,
trunc_offset, trunc_offset);
sprintf(command, "od -Ax -a %s", fnames[0]);
- rc = system(command);
+ ret = system(command);
MPI_Abort(MPI_COMM_WORLD, 1);
}
}