sheep: dont resume pending requests or recovery when retrying

If we have to retry a request that means it still blocks any other request
or recovery item waiting for it, so calling resume_pending_requests or
resume_recovery_work for this case is pointless.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: use requeue_request to retry requests in io_op_done

If we retry a request from io_op_done we currenly opencode the sequence in
queue_request, except that the call to check_request is missing.  Given
that the epoch may change the call to check_request is nesscary and we
should call queue_request in io_op_done as well.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: merge process_io_request into queue_io_request

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: split queue_io_request

Split queue_io_request into separate versions for gateway and peer requests,
and merge the respective versions of setup_access_to_local_objects into their
only callers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: split io_op_done

Use a trivial completion handler for peer I/O requests and a slightly more
complicated one for gateway requests instead of interwinding the two.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: split check_request

Split check_request into helpers to check the request epoch, and to check
if the request access a busy object.  Peer I/O requests call both helpers,
while gateway requests never need to call check_request_epoch because
we just assigned the epoch to be the current one.

Also lift the check for cached objects into queue_gateway_request and remove
the now unused local_cow_oid field in struct request.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: fix SD_RES_OLD_NODE_VER handling in check_request_epoch

Just complete the request with SD_RES_OLD_NODE_VER instead of trying to
call the end_io handler to do that, which causes a list deletion while
the request hasn't been added to any list.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
farm: add concurrent access support to the same object

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: remove sys->req_wait_for_obj_list

Since now farm has a per-object lock, thus support concurrent access to
the same object, there is no need for sys->req_wait_for_obj_list

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: rename check_request_busy()

It only checks if the targeted oid is in recovery, so better rename it to
reflect the change.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: refactor recovery.c

- split object_list handling from object recovering process
- factor recover_object_main

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: remove resume_recovery_work()

When the requested object is in sys->outstanding_req_list, the object is already
being recovered, so we don't need check this busy status and should proceed.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: handle recovery request in check_request_in_recovery()

We should call req_done() when is_recoverying_oid() returns true for recovery
request, instead of going down to find nothing recovered.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: add two assertion to clarify the code a bit

This two cases are actually executed with two different context, adding
two assertion both make code readable and safe.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: fix gateway_op_done()

We should return after queueing it on wait_rw_queue.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>