[sheepdog] [PATCH 2/9] sheep: recover from local if possible
Liu Yuan
namei.unix at gmail.com
Tue May 7 08:25:48 CEST 2013
On 05/07/2013 01:45 AM, MORITA Kazutaka wrote:
> From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
>
> Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> ---
> sheep/recovery.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/sheep/recovery.c b/sheep/recovery.c
> index dc38dac..688058a 100644
> --- a/sheep/recovery.c
> +++ b/sheep/recovery.c
> @@ -141,7 +141,7 @@ static int do_recover_object(struct recovery_work *rw)
> struct vnode_info *old;
> uint64_t oid = rw->oids[rw->done];
> uint32_t epoch = rw->epoch, tgt_epoch = rw->epoch;
> - int nr_copies, ret, i;
> + int nr_copies, ret, i, start = 0;
>
> old = grab_vnode_info(rw->old_vinfo);
>
> @@ -149,13 +149,26 @@ again:
> sd_dprintf("try recover object %"PRIx64" from epoch %"PRIu32, oid,
> tgt_epoch);
>
> - /* Let's do a breadth-first search */
> nr_copies = get_obj_copy_number(oid, old->nr_zones);
> + /* find local node first to try to recover from local */
> for (i = 0; i < nr_copies; i++) {
> const struct sd_vnode *tgt_vnode;
>
> tgt_vnode = oid_to_vnode(old->vnodes, old->nr_vnodes, oid, i);
>
> + if (vnode_is_local(tgt_vnode)) {
> + start = i;
> + break;
> + }
> + }
> +
> + /* Let's do a breadth-first search */
> + for (i = 0; i < nr_copies; i++) {
> + const struct sd_vnode *tgt_vnode;
> + int idx = (i + start) % nr_copies;
> +
> + tgt_vnode = oid_to_vnode(old->vnodes, old->nr_vnodes, oid, idx);
> +
> if (is_invalid_vnode(tgt_vnode, rw->cur_vinfo->nodes,
> rw->cur_vinfo->nr_nodes))
> continue;
>
I think we'd better stop bloating the do_recover_object by squashing
more lines. How about putting all these two for loop in
recover_object_from_replica(), thus duplicate vnode_is_local() will be
eliminated and resulting in smaller function do_recover_object.
Thanks,
Yuan
More information about the sheepdog
mailing list