Fix crash with file locking and dup'ed files
authorJens Axboe <axboe@fb.com>
Fri, 7 Feb 2014 17:56:15 +0000 (10:56 -0700)
committerJens Axboe <axboe@fb.com>
Fri, 7 Feb 2014 17:56:15 +0000 (10:56 -0700)
Ensure that we properly inherit the file locks when
duplicating files.

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

index d67f1124618744db85595c2f037ffe07f9788794..d1702e29c75bf1b1f73dd0d2dc3ade1ac35f9e12 100644 (file)
@@ -1343,6 +1343,11 @@ void dup_files(struct thread_data *td, struct thread_data *org)
                        __f->filetype = f->filetype;
                }
 
                        __f->filetype = f->filetype;
                }
 
+               if (td->o.file_lock_mode == FILE_LOCK_EXCLUSIVE)
+                       __f->lock = f->lock;
+               else if (td->o.file_lock_mode == FILE_LOCK_READWRITE)
+                       __f->rwlock = f->rwlock;
+
                td->files[i] = __f;
        }
 }
                td->files[i] = __f;
        }
 }