libceph: call r_unsafe_callback when unsafe reply is received
authorYan, Zheng <zheng.z.yan@intel.com>
Mon, 24 Jun 2013 06:41:27 +0000 (14:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jan 2014 20:24:25 +0000 (12:24 -0800)
commitef0b67e4b1f57d14f314a206338e5dd806a08b21
tree747e98c1472a24f299eda29b1e84e4213745033c
parent724184c7a1fc44955f8900c382f18545423bc486
libceph: call r_unsafe_callback when unsafe reply is received

commit 61c5d6bf7074ee32d014dcdf7698dc8c59eb712d upstream.

We can't use !req->r_sent to check if OSD request is sent for the
first time, this is because __cancel_request() zeros req->r_sent
when OSD map changes. Rather than adding a new variable to struct
ceph_osd_request to indicate if it's sent for the first time, We
can call the unsafe callback only when unsafe OSD reply is received.
If OSD's first reply is safe, just skip calling the unsafe callback.

The purpose of unsafe callback is adding unsafe request to a list,
so that fsync(2) can wait for the safe reply. fsync(2) doesn't need
to wait for a write(2) that hasn't returned yet. So it's OK to add
request to the unsafe list when the first OSD reply is received.
(ceph_sync_write() returns after receiving the first OSD reply)

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Reviewed-by: Sage Weil <sage@inktank.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ceph/osd_client.c