From 5ebc00ec79565ad62e978af65b023343ad360675 Mon Sep 17 00:00:00 2001 From: Hongchao Zhang Date: Fri, 27 Nov 2015 16:07:29 +0800 Subject: [PATCH] LU-7309 lod: notify client retry creation In lod_alloc_rr, if there is no available OSTs to allocate the object required by some client and there is OSP connecting to OST at the same time, then it should indicate the client to retry the creation request later. Change-Id: I6740edf830dbe736e33e24c92387df371f070570 Signed-off-by: Hongchao Zhang Reviewed-on: http://review.whamcloud.com/17839 Reviewed-by: Fan Yong Tested-by: Jenkins Reviewed-by: wangdi Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/lod/lod_internal.h | 3 ++- lustre/lod/lod_qos.c | 15 ++++++++++++++- lustre/osp/osp_dev.c | 4 ++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lustre/lod/lod_internal.h b/lustre/lod/lod_internal.h index 32f295b..484ba8e 100644 --- a/lustre/lod/lod_internal.h +++ b/lustre/lod/lod_internal.h @@ -128,7 +128,8 @@ struct lod_tgt_desc { unsigned long ltd_active:1,/* is this target up for requests */ ltd_activate:1,/* should target be activated */ ltd_reap:1, /* should this target be deleted */ - ltd_got_update_log:1; /* Already got update log */ + ltd_got_update_log:1, /* Already got update log */ + ltd_connecting:1; /* target is connecting */ }; #define TGT_PTRS 256 /* number of pointers at 1st level */ diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index d064f62..cd7b7f5 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -212,6 +212,9 @@ static int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d, spin_lock(&d->lod_desc_lock); if (ost->ltd_active) { ost->ltd_active = 0; + if (rc == -ENOTCONN) + ost->ltd_connecting = 1; + LASSERT(d->lod_desc.ld_active_tgt_count > 0); d->lod_desc.ld_active_tgt_count--; d->lod_qos.lq_dirty = 1; @@ -228,6 +231,7 @@ static int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d, spin_lock(&d->lod_desc_lock); if (ost->ltd_active == 0) { ost->ltd_active = 1; + ost->ltd_connecting = 0; d->lod_desc.ld_active_tgt_count++; d->lod_qos.lq_dirty = 1; d->lod_qos.lq_rr.lqr_dirty = 1; @@ -939,6 +943,7 @@ static int lod_alloc_rr(const struct lu_env *env, struct lod_object *lo, int rc; __u32 ost_start_idx_temp; int speed = 0; + int ost_connecting = 0; __u32 stripe_idx = 0; __u32 stripe_cnt = lo->ldo_stripenr; __u32 stripe_cnt_min = min_stripe_count(stripe_cnt, flags); @@ -1014,11 +1019,16 @@ repeat_find: rc = lod_check_and_reserve_ost(env, m, sfs, ost_idx, speed, &stripe_idx, stripe, th); spin_lock(&lqr->lqr_alloc); + + if (rc != 0 && OST_TGT(m, ost_idx)->ltd_connecting) + ost_connecting = 1; } if ((speed < 2) && (stripe_idx < stripe_cnt_min)) { /* Try again, allowing slower OSCs */ speed++; lqr->lqr_start_idx = ost_start_idx_temp; + + ost_connecting = 0; goto repeat_find; } @@ -1031,7 +1041,10 @@ repeat_find: rc = 0; } else { /* nobody provided us with a single object */ - rc = -ENOSPC; + if (ost_connecting) + rc = -EINPROGRESS; + else + rc = -ENOSPC; } out: diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c index b2a6da9..06d6e4d 100644 --- a/lustre/osp/osp_dev.c +++ b/lustre/osp/osp_dev.c @@ -719,9 +719,13 @@ static int osp_statfs(const struct lu_env *env, struct dt_device *dev, struct obd_statfs *sfs) { struct osp_device *d = dt2osp_dev(dev); + struct obd_import *imp = d->opd_obd->u.cli.cl_import; ENTRY; + if (imp->imp_state == LUSTRE_IMP_CLOSED) + RETURN(-ESHUTDOWN); + if (unlikely(d->opd_imp_active == 0)) RETURN(-ENOTCONN); -- 1.8.3.1