+static int __fill_file_completions(struct thread_data *td,
+ struct thread_io_list *s,
+ struct fio_file *f, unsigned int *index)
+{
+ unsigned int comps;
+ int i, j;
+
+ if (!f->last_write_comp)
+ return 0;
+
+ if (td->io_blocks[DDIR_WRITE] < td->o.iodepth)
+ comps = td->io_blocks[DDIR_WRITE];
+ else
+ comps = td->o.iodepth;
+
+ j = f->last_write_idx - 1;
+ for (i = 0; i < comps; i++) {
+ if (j == -1)
+ j = td->o.iodepth - 1;
+ s->comps[*index].fileno = __cpu_to_le64(f->fileno);
+ s->comps[*index].offset = cpu_to_le64(f->last_write_comp[j]);
+ (*index)++;
+ j--;
+ }
+
+ return comps;
+}
+
+static int fill_file_completions(struct thread_data *td,
+ struct thread_io_list *s, unsigned int *index)
+{
+ struct fio_file *f;
+ unsigned int i;
+ int comps = 0;
+
+ for_each_file(td, f, i)
+ comps += __fill_file_completions(td, s, f, index);
+
+ return comps;
+}
+