fix trunc_size calculation in case of append_size == 1
Don't allow to specify write_max and append_max < 2.
Change-Id: I2a9ded4b10ef90a9e02b1b0f1229c87177f046d4
Xyratex-bug-id: MRP-1779
Signed-off-by: Andriy Skulysh <Andriy_Skulysh@xyratex.com>
Reviewed-on: http://review.whamcloud.com/9948
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Emoly Liu <emoly.liu@intel.com>
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
switch(c) {
case 'a':
append_max = strtoul(optarg, &end, 0);
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);
fprintf(stderr, "%s: bad append option '%s'\n",
prog, optarg);
usage(prog);
break;
case 'w':
write_max = strtoul(optarg, &end, 0);
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);
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;
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)
trunc_offset = write_size + trunc_size;
if (verbose || n % 1000 == 0)