[sheepdog] [PATCH v2 1/3] sheep: change gateway_forward_request() for forwarding requests to all other nodes
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Wed Sep 5 07:12:50 CEST 2012
(2012/09/05 12:39), Liu Yuan wrote:
> On 09/02/2012 10:34 AM, Hitoshi Mitake wrote:
>> @@ -301,7 +319,7 @@ int gateway_write_obj(struct request *req)
>> if (sys->enable_write_cache && !req->local && !bypass_object_cache(req))
>> return object_cache_handle_request(req);
>>
>> - return gateway_forward_request(req);
>> + return gateway_forward_request(req, 0);
>> }
>>
>> int gateway_create_and_write_obj(struct request *req)
>> @@ -309,10 +327,10 @@ int gateway_create_and_write_obj(struct request *req)
>> if (sys->enable_write_cache && !req->local && !bypass_object_cache(req))
>> return object_cache_handle_request(req);
>>
>> - return gateway_forward_request(req);
>> + return gateway_forward_request(req, 0);
>> }
>>
>> int gateway_remove_obj(struct request *req)
>> {
>> - return gateway_forward_request(req);
>> + return gateway_forward_request(req, 0);
>> }
>
> I'd suggest following control flow structure if possible:
> ...
> nr_to_send= init_target_nodes(target_nodes, all_node);
> for (i = 0; i < nr_to_send; i++) {
> struct sockfd *sfd;
> struct node_id *nid;
> struct sd_node *n;
>
> n = target_nodes[i];
> if (node_is_local(n)) {
> local = i;
> continue;
> }
>
> nid = &v->nid;
>
> sfd = sheep_get_sockfd(nid);
> if (!sfd) {
> err_ret = SD_RES_NETWORK_ERROR;
> break;
> }
>
> ret = send_req(sfd->fd, &hdr, req->data, &wlen);
> if (ret) {
> sheep_del_sockfd(nid, sfd);
> err_ret = SD_RES_NETWORK_ERROR;
> dprintf("fail %d\n", ret);
> break;
> }
> write_info_advance(&wi, nid, sfd);
> }
> ...
>
> For init_target_nodes(), we need a new helper oid_to_nodes().
>
Do you mean that target_nodes is an array of struct node_id?
If so, I agree with your opinion. I'll be able to reduce the conditional
branches.
Thanks,
Hitoshi
More information about the sheepdog
mailing list