"Yan, Zheng" <zyan@xxxxxxxxxx> writes: >> On Sep 8, 2018, at 00:03, Luis Henriques <lhenriques@xxxxxxxx> wrote: >> >> "Yan, Zheng" <ukernel@xxxxxxxxx> writes: >> >>> On Fri, Sep 7, 2018 at 12:08 AM Luis Henriques <lhenriques@xxxxxxxx> wrote: >> <...> >> >>>> + if (objoff || (copy_len < src_ci->i_layout.object_size)) { >>>> + /* Do not copy beyond this object */ >>>> + if (copy_len > objlen) >>>> + copy_len = objlen; >>>> + err = do_splice_direct(src_file, &src_off, dst_file, >>>> + &dst_off, copy_len, flags); >>> >>> We should release caps refs before calling do_splice_direct(). >>> do_splice_direct calls read_iter and write_iter, which will get caps >>> refs again. >> >> That's... annoying. I could release caps, call do_slice_direct and get >> the caps again but this would introduce a race window. >> >> I could also re-write this loop so that it would: >> >> - do all the required do_splice_direct calls >> - get the caps >> - loop doing all the remote object copies >> - release caps >> >> But the whole operation would still not be atomic. Do you have any >> suggestion on how to make it atomic? > > The default implementation (using do_splice_direct) is not atomic. I > think we just need to ensure write on single object is atomic. Well... yep, that probably makes sense. In that case, I'll rework the code to do the get+release caps in the right places. Again, thanks for your valuable input! Cheers, -- Luis