Always make job use open() instead of dup(), even for shared files
authorJens Axboe <jens.axboe@oracle.com>
Thu, 6 Mar 2008 11:06:30 +0000 (12:06 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 6 Mar 2008 11:06:30 +0000 (12:06 +0100)
The fd may be opened after other jobs are forked, thus they wont
share fd space (unless the 'thread' option is used).

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
filesetup.c

index eedb3dc341706f1914da0e8ccbde44474edc764f..3eba27e13d24e4491c42132979e8bad917b00060 100644 (file)
@@ -245,15 +245,13 @@ static int file_lookup_open(struct fio_file *f, int flags)
                f->lock_owner = __f->lock_owner;
                f->lock_batch = __f->lock_batch;
                f->lock_ddir = __f->lock_ddir;
-               f->fd = dup(__f->fd);
-               f->references++;
                from_hash = 1;
        } else {
                dprint(FD_FILE, "file not found in hash %s\n", f->file_name);
-               f->fd = open(f->file_name, flags, 0600);
                from_hash = 0;
        }
 
+       f->fd = open(f->file_name, flags, 0600);
        return from_hash;
 }
 
@@ -320,10 +318,7 @@ open_again:
                        goto open_again;
                }
 
-               if (from_hash)
-                       snprintf(buf, sizeof(buf) - 1, "dup(%s)", f->file_name);
-               else
-                       snprintf(buf, sizeof(buf) - 1, "open(%s)",f->file_name);
+               snprintf(buf, sizeof(buf) - 1, "open(%s)", f->file_name);
 
                td_verror(td, __e, buf);
        }