[sheepdog] [PATCH v5 8/8] sheep: make gateway requests only retry when requested object is local
levin li
levin108 at gmail.com
Mon May 28 05:43:44 CEST 2012
From: levin li <xingke.lwp at taobao.com>
We should not make gateway retry in check_request when the
requested object in recovery is not local, in the case of requesting a
non-local object we should make it retry in io_op_done(), if the
requesting object is local, then we should make the gateway request
to retry.
Signed-off-by: levin li <xingke.lwp at taobao.com>
---
sheep/sdnet.c | 39 ++++++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 13 deletions(-)
diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index 7cbaff8..18a1ced 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -215,22 +215,35 @@ static int check_request(struct request *req)
retrying mechanism. */
if (is_recoverying_oid(req->local_oid) &&
!(req->rq.flags & SD_FLAG_CMD_RECOVERY)) {
- if (req->rq.flags & SD_FLAG_CMD_IO_LOCAL) {
- /* Sheep peer request */
- if (is_recovery_init()) {
- req->rp.result = SD_RES_OBJ_RECOVERING;
- list_add_tail(&req->request_list,
- &sys->wait_rw_queue);
- } else
- list_add_tail(&req->request_list,
- &sys->wait_obj_queue);
- } else {
- /* Gateway request */
- list_add_tail(&req->request_list, &sys->req_wait_for_obj_list);
+ /* Only if the requested object stays in gateway, then
+ the gateway request should be retried. */
+ if (!(req->rq.flags & SD_FLAG_CMD_IO_LOCAL)) {
+ struct sd_vnode *vnodes[SD_MAX_COPIES];
+ int i, nr_copies;
+
+ nr_copies = get_nr_copies(req->vnodes);
+ oid_to_vnodes(req->vnodes, req->local_oid,
+ nr_copies, vnodes);
+ for (i = 0; i < nr_copies; i++) {
+ struct sd_vnode *vnode = vnodes[i];
+ if (is_myself(vnode->addr, vnode->port))
+ break;
+ }
+ if (i == nr_copies)
+ goto out;
}
+
+ /* Sheep peer request */
+ if (is_recovery_init()) {
+ req->rp.result = SD_RES_OBJ_RECOVERING;
+ list_add_tail(&req->request_list,
+ &sys->wait_rw_queue);
+ } else
+ list_add_tail(&req->request_list,
+ &sys->wait_obj_queue);
return -1;
}
-
+out:
if (is_access_to_busy_objects(req->local_oid)) {
list_add_tail(&req->request_list, &sys->req_wait_for_obj_list);
return -1;
--
1.7.10
More information about the sheepdog
mailing list