+ return ret;
+}
+
+void lock_file(struct thread_data *td, struct fio_file *f)
+{
+ if (f && f->sem) {
+ if (f->sem_owner == td && f->sem_batch--)
+ return;
+
+ fio_sem_down(f->sem);
+ f->sem_owner = td;
+ f->sem_batch = td->o.lockfile_batch;
+ }
+}
+
+void unlock_file(struct fio_file *f)
+{
+ if (f && f->sem) {
+ int sem_val;
+
+ if (f->sem_batch)
+ return;
+
+ sem_getvalue(&f->sem->sem, &sem_val);
+ if (!sem_val)
+ f->sem_owner = NULL;
+ fio_sem_up(f->sem);
+ }