Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
        struct bio_vec *bv;
        unsigned unaligned;
        u64 new_i_size;
-       bool sync;
+       bool sync = dio->sync;
        long ret;
 
        if (dio->loop)
 
                if (!dio->sync && !dio->loop && dio->iter.count) {
                        if (bch2_dio_write_copy_iov(dio)) {
-                               dio->sync = true;
+                               dio->sync = sync = true;
                                goto do_io;
                        }
                }
                dio->loop = true;
                closure_call(&dio->op.cl, bch2_write, NULL, NULL);
 
-               if (dio->sync)
+               if (sync)
                        wait_for_completion(&dio->done);
                else
                        return -EIOCBQUEUED;
        if (dio->free_iov)
                kfree(dio->iter.__iov);
 
-       sync = dio->sync;
        bio_put(bio);
 
        /* inode->i_dio_count is our ref on inode and thus bch_fs */