X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flov%2Flov_obd.c;h=135458d85ca8b8a9a3a0cbbee89a43a8b2facc49;hb=b3f5156084edcebb714bb6d77fca4152fe3b045f;hp=0d4fe78f3b3f70877586a0974adee37ab20d48e7;hpb=8faf82a6b002ecab7eaf4c6a0ccfaa72ecdd0154;p=fs%2Flustre-release.git diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 0d4fe78..135458d 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -68,29 +68,28 @@ #include "lov_internal.h" - /* Keep a refcount of lov->tgt usage to prevent racing with addition/deletion. Any function that expects lov_tgts to remain stationary must take a ref. */ -void lov_getref(struct obd_device *obd) +static void lov_getref(struct obd_device *obd) { struct lov_obd *lov = &obd->u.lov; /* nobody gets through here until lov_putref is done */ - mutex_down(&lov->lov_lock); - atomic_inc(&lov->lov_refcount); - mutex_up(&lov->lov_lock); + cfs_mutex_down(&lov->lov_lock); + cfs_atomic_inc(&lov->lov_refcount); + cfs_mutex_up(&lov->lov_lock); return; } static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt); -void lov_putref(struct obd_device *obd) +static void lov_putref(struct obd_device *obd) { struct lov_obd *lov = &obd->u.lov; - mutex_down(&lov->lov_lock); + cfs_mutex_down(&lov->lov_lock); /* ok to dec to 0 more than once -- ltd_exp's will be null */ - if (atomic_dec_and_test(&lov->lov_refcount) && lov->lov_death_row) { + if (cfs_atomic_dec_and_test(&lov->lov_refcount) && lov->lov_death_row) { CFS_LIST_HEAD(kill); int i; struct lov_tgt_desc *tgt, *n; @@ -101,7 +100,7 @@ void lov_putref(struct obd_device *obd) if (!tgt || !tgt->ltd_reap) continue; - list_add(&tgt->ltd_kill, &kill); + cfs_list_add(&tgt->ltd_kill, &kill); /* XXX - right now there is a dependency on ld_tgt_count * being the maximum tgt index for computing the * mds_max_easize. So we can't shrink it. */ @@ -109,15 +108,15 @@ void lov_putref(struct obd_device *obd) lov->lov_tgts[i] = NULL; lov->lov_death_row--; } - mutex_up(&lov->lov_lock); + cfs_mutex_up(&lov->lov_lock); - list_for_each_entry_safe(tgt, n, &kill, ltd_kill) { - list_del(&tgt->ltd_kill); + cfs_list_for_each_entry_safe(tgt, n, &kill, ltd_kill) { + cfs_list_del(&tgt->ltd_kill); /* Disconnect */ __lov_del_obd(obd, tgt); } } else { - mutex_up(&lov->lov_lock); + cfs_mutex_up(&lov->lov_lock); } } @@ -134,7 +133,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, struct lov_obd *lov = &obd->u.lov; struct obd_uuid tgt_uuid; struct obd_device *tgt_obd; - struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; + static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; struct obd_import *imp; #ifdef __KERNEL__ @@ -147,14 +146,8 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, RETURN(-EINVAL); tgt_uuid = lov->lov_tgts[index]->ltd_uuid; + tgt_obd = lov->lov_tgts[index]->ltd_obd; - tgt_obd = class_find_client_obd(&tgt_uuid, LUSTRE_OSC_NAME, - &obd->obd_uuid); - - if (!tgt_obd) { - CERROR("Target %s not attached\n", obd_uuid2str(&tgt_uuid)); - RETURN(-EINVAL); - } if (!tgt_obd->obd_set_up) { CERROR("Target %s not set up\n", obd_uuid2str(&tgt_uuid)); RETURN(-EINVAL); @@ -201,11 +194,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, } lov->lov_tgts[index]->ltd_reap = 0; - if (activate) { - lov->lov_tgts[index]->ltd_active = 1; - lov->desc.ld_active_tgt_count++; - lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 0; - } + CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index, obd_uuid2str(&tgt_uuid), tgt_obd->obd_name, activate ? "":"in"); @@ -268,7 +257,7 @@ static int lov_connect(const struct lu_env *env, if (data) lov->lov_ocd = *data; - lov_getref(obd); + obd_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { tgt = lov->lov_tgts[i]; if (!tgt || obd_uuid_empty(&tgt->ltd_uuid)) @@ -291,7 +280,7 @@ static int lov_connect(const struct lu_env *env, obd->obd_name, rc); } } - lov_putref(obd); + obd_putref(obd); RETURN(0); } @@ -373,7 +362,7 @@ static int lov_disconnect(struct obd_export *exp) /* Let's hold another reference so lov_del_obd doesn't spin through putref every time */ - lov_getref(obd); + obd_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { if (lov->lov_tgts[i] && lov->lov_tgts[i]->ltd_exp) { @@ -381,7 +370,7 @@ static int lov_disconnect(struct obd_export *exp) lov_del_target(obd, i, 0, lov->lov_tgts[i]->ltd_gen); } } - lov_putref(obd); + obd_putref(obd); out: rc = class_disconnect(exp); /* bz 9811 */ @@ -406,7 +395,7 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, CDEBUG(D_INFO, "Searching in lov %p for uuid %s (activate=%d)\n", lov, uuid->uuid, activate); - lov_getref(obd); + obd_getref(obd); for (index = 0; index < lov->desc.ld_tgt_count; index++) { tgt = lov->lov_tgts[index]; if (!tgt || !tgt->ltd_exp) @@ -444,7 +433,7 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, lov->lov_tgts[index]->ltd_qos.ltq_penalty = 0; out: - lov_putref(obd); + obd_putref(obd); RETURN(index); } @@ -453,7 +442,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, { int rc = 0; ENTRY; - + if (ev == OBD_NOTIFY_ACTIVE || ev == OBD_NOTIFY_INACTIVE) { struct obd_uuid *uuid; @@ -490,7 +479,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, struct lov_obd *lov = &obd->u.lov; struct obd_device *tgt_obd; int i; - lov_getref(obd); + obd_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { /* don't send sync event if target not * connected/activated */ @@ -513,7 +502,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, break; } } - lov_putref(obd); + obd_putref(obd); } RETURN(rc); @@ -524,6 +513,7 @@ int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, { struct lov_obd *lov = &obd->u.lov; struct lov_tgt_desc *tgt; + struct obd_device *tgt_obd; int rc; ENTRY; @@ -536,13 +526,18 @@ int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, RETURN(-EINVAL); } - mutex_down(&lov->lov_lock); + tgt_obd = class_find_client_obd(uuidp, LUSTRE_OSC_NAME, + &obd->obd_uuid); + if (tgt_obd == NULL) + RETURN(-EINVAL); + + cfs_mutex_down(&lov->lov_lock); if ((index < lov->lov_tgt_size) && (lov->lov_tgts[index] != NULL)) { tgt = lov->lov_tgts[index]; CERROR("UUID %s already assigned at LOV target index %d\n", obd_uuid2str(&tgt->ltd_uuid), index); - mutex_up(&lov->lov_lock); + cfs_mutex_up(&lov->lov_lock); RETURN(-EEXIST); } @@ -556,7 +551,7 @@ int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, newsize = newsize << 1; OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize); if (newtgts == NULL) { - mutex_up(&lov->lov_lock); + cfs_mutex_up(&lov->lov_lock); RETURN(-ENOMEM); } @@ -581,12 +576,20 @@ int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, OBD_ALLOC_PTR(tgt); if (!tgt) { - mutex_up(&lov->lov_lock); + cfs_mutex_up(&lov->lov_lock); RETURN(-ENOMEM); } + rc = lov_ost_pool_add(&lov->lov_packed, index, lov->lov_tgt_size); + if (rc) { + cfs_mutex_up(&lov->lov_lock); + OBD_FREE_PTR(tgt); + RETURN(rc); + } + memset(tgt, 0, sizeof(*tgt)); tgt->ltd_uuid = *uuidp; + tgt->ltd_obd = tgt_obd; /* XXX - add a sanity check on the generation number. */ tgt->ltd_gen = gen; tgt->ltd_index = index; @@ -595,11 +598,7 @@ int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, if (index >= lov->desc.ld_tgt_count) lov->desc.ld_tgt_count = index + 1; - rc = lov_ost_pool_add(&lov->lov_packed, index, lov->lov_tgt_size); - if (rc) - RETURN(rc); - - mutex_up(&lov->lov_lock); + cfs_mutex_up(&lov->lov_lock); CDEBUG(D_CONFIG, "idx=%d ltd_gen=%d ld_tgt_count=%d\n", index, tgt->ltd_gen, lov->desc.ld_tgt_count); @@ -611,7 +610,7 @@ int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, RETURN(0); } - lov_getref(obd); + obd_getref(obd); rc = lov_connect_obd(obd, index, active, &lov->lov_ocd); if (rc) @@ -631,7 +630,7 @@ out: obd_uuid2str(&tgt->ltd_uuid)); lov_del_target(obd, index, 0, 0); } - lov_putref(obd); + obd_putref(obd); RETURN(rc); } @@ -650,7 +649,7 @@ int lov_del_target(struct obd_device *obd, __u32 index, RETURN(-EINVAL); } - lov_getref(obd); + obd_getref(obd); if (!lov->lov_tgts[index]) { CERROR("LOV target at index %d is not setup.\n", index); @@ -671,9 +670,9 @@ int lov_del_target(struct obd_device *obd, __u32 index, lov->lov_tgts[index]->ltd_reap = 1; lov->lov_death_row++; - /* we really delete it from lov_putref */ + /* we really delete it from obd_putref */ out: - lov_putref(obd); + obd_putref(obd); RETURN(rc); } @@ -752,7 +751,6 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) struct lprocfs_static_vars lvars = { 0 }; struct lov_desc *desc; struct lov_obd *lov = &obd->u.lov; - int count; int rc; ENTRY; @@ -783,25 +781,14 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lov_fix_desc(desc); - /* Because of 64-bit divide/mod operations only work with a 32-bit - * divisor in a 32-bit kernel, we cannot support a stripe width - * of 4GB or larger on 32-bit CPUs. */ - count = desc->ld_default_stripe_count; - if ((count > 0 ? count : desc->ld_tgt_count) * - desc->ld_default_stripe_size > 0xffffffff) { - CERROR("LOV: stripe width "LPU64"x%u > 4294967295 bytes\n", - desc->ld_default_stripe_size, count); - RETURN(-EINVAL); - } - desc->ld_active_tgt_count = 0; lov->desc = *desc; lov->lov_tgt_size = 0; - sema_init(&lov->lov_lock, 1); - atomic_set(&lov->lov_refcount, 0); + cfs_sema_init(&lov->lov_lock, 1); + cfs_atomic_set(&lov->lov_refcount, 0); CFS_INIT_LIST_HEAD(&lov->lov_qos.lq_oss_list); - init_rwsem(&lov->lov_qos.lq_rw_sem); + cfs_init_rwsem(&lov->lov_qos.lq_rw_sem); lov->lov_sp_me = LUSTRE_SP_CLI; lov->lov_qos.lq_dirty = 1; lov->lov_qos.lq_rr.lqr_dirty = 1; @@ -810,9 +797,15 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lov->lov_qos.lq_prio_free = 232; /* Default threshold for rr (roughly 17%) */ lov->lov_qos.lq_threshold_rr = 43; + /* Init statfs fields */ + OBD_ALLOC_PTR(lov->lov_qos.lq_statfs_data); + if (NULL == lov->lov_qos.lq_statfs_data) + RETURN(-ENOMEM); + cfs_waitq_init(&lov->lov_qos.lq_statfs_waitq); - lov->lov_pools_hash_body = lustre_hash_init("POOLS", 7, 7, - &pool_hash_operations, 0); + lov->lov_pools_hash_body = cfs_hash_create("POOLS", HASH_POOLS_CUR_BITS, + HASH_POOLS_MAX_BITS, + &pool_hash_operations, CFS_HASH_REHASH); CFS_INIT_LIST_HEAD(&lov->lov_pool_list); lov->lov_pool_count = 0; rc = lov_ost_pool_init(&lov->lov_packed, 0); @@ -873,39 +866,39 @@ static int lov_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) static int lov_cleanup(struct obd_device *obd) { struct lov_obd *lov = &obd->u.lov; - struct list_head *pos, *tmp; + cfs_list_t *pos, *tmp; struct pool_desc *pool; - list_for_each_safe(pos, tmp, &lov->lov_pool_list) { - pool = list_entry(pos, struct pool_desc, pool_list); + cfs_list_for_each_safe(pos, tmp, &lov->lov_pool_list) { + pool = cfs_list_entry(pos, struct pool_desc, pool_list); /* free pool structs */ CDEBUG(D_INFO, "delete pool %p\n", pool); lov_pool_del(obd, pool->pool_name); } - lustre_hash_exit(lov->lov_pools_hash_body); + cfs_hash_destroy(lov->lov_pools_hash_body); lov_ost_pool_free(&(lov->lov_qos.lq_rr.lqr_pool)); lov_ost_pool_free(&lov->lov_packed); if (lov->lov_tgts) { int i; - lov_getref(obd); + obd_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { if (!lov->lov_tgts[i]) continue; /* Inactive targets may never have connected */ if (lov->lov_tgts[i]->ltd_active || - atomic_read(&lov->lov_refcount)) + cfs_atomic_read(&lov->lov_refcount)) /* We should never get here - these should have been removed in the disconnect. */ CERROR("lov tgt %d not cleaned!" " deathrow=%d, lovrc=%d\n", i, lov->lov_death_row, - atomic_read(&lov->lov_refcount)); + cfs_atomic_read(&lov->lov_refcount)); lov_del_target(obd, i, 0, 0); } - lov_putref(obd); + obd_putref(obd); OBD_FREE(lov->lov_tgts, sizeof(*lov->lov_tgts) * lov->lov_tgt_size); lov->lov_tgt_size = 0; @@ -914,6 +907,7 @@ static int lov_cleanup(struct obd_device *obd) /* clear pools parent proc entry only after all pools is killed */ lprocfs_obd_cleanup(obd); + OBD_FREE_PTR(lov->lov_qos.lq_statfs_data); RETURN(0); } @@ -962,8 +956,8 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, rc = class_process_proc_param(PARAM_LOV, lvars.obd_vars, lcfg, obd); - if (rc > 0) - rc = 0; + if (rc > 0) + rc = 0; GOTO(out, rc); } case LCFG_POOL_NEW: @@ -983,7 +977,7 @@ out: } #ifndef log2 -#define log2(n) ffz(~(n)) +#define log2(n) cfs_ffz(~(n)) #endif static int lov_clear_orphans(struct obd_export *export, struct obdo *src_oa, @@ -1011,7 +1005,7 @@ static int lov_clear_orphans(struct obd_export *export, struct obdo *src_oa, ost_uuid->uuid); } - lov_getref(export->exp_obd); + obd_getref(export->exp_obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { struct lov_stripe_md obj_md; struct lov_stripe_md *obj_mdp = &obj_md; @@ -1052,7 +1046,7 @@ static int lov_clear_orphans(struct obd_export *export, struct obdo *src_oa, if (ost_uuid) break; } - lov_putref(export->exp_obd); + obd_putref(export->exp_obd); OBDO_FREE(tmp_oa); RETURN(rc); @@ -1106,8 +1100,7 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa, struct obd_info oinfo; struct lov_request_set *set = NULL; struct lov_request *req; - struct obd_statfs osfs; - __u64 maxage; + struct l_wait_info lwi = { 0 }; int rc = 0; ENTRY; @@ -1125,7 +1118,7 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa, if (!lov->desc.ld_active_tgt_count) RETURN(-EIO); - lov_getref(exp->exp_obd); + obd_getref(exp->exp_obd); /* Recreate a specific object id at the given OST index */ if ((src_oa->o_valid & OBD_MD_FLFLAGS) && (src_oa->o_flags & OBD_FL_RECREATE_OBJS)) { @@ -1133,22 +1126,34 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa, GOTO(out, rc); } - maxage = cfs_time_shift_64(-lov->desc.ld_qos_maxage); - obd_statfs_rqset(exp->exp_obd, &osfs, maxage, OBD_STATFS_NODELAY); + /* issue statfs rpcs if the osfs data is older than qos_maxage - 1s, + * later in alloc_qos(), we will wait for those rpcs to complete if + * the osfs age is older than 2 * qos_maxage */ + qos_statfs_update(exp->exp_obd, + cfs_time_shift_64(-lov->desc.ld_qos_maxage) + CFS_HZ, + 0); rc = lov_prep_create_set(exp, &oinfo, ea, src_oa, oti, &set); if (rc) GOTO(out, rc); - list_for_each_entry(req, &set->set_list, rq_link) { + cfs_list_for_each_entry(req, &set->set_list, rq_link) { /* XXX: LOV STACKING: use real "obj_mdp" sub-data */ - rc = obd_create(lov->lov_tgts[req->rq_idx]->ltd_exp, - req->rq_oi.oi_oa, &req->rq_oi.oi_md, oti); - lov_update_create_set(set, req, rc); + rc = obd_create_async(lov->lov_tgts[req->rq_idx]->ltd_exp, + &req->rq_oi, &req->rq_oi.oi_md, oti); } + + /* osc_create have timeout equ obd_timeout/2 so waiting don't be + * longer then this */ + l_wait_event(set->set_waitq, lov_finished_set(set), &lwi); + + /* we not have ptlrpc set for assign set->interpret and should + * be call interpret function himself. calling from cb_create_update + * not permited because lov_fini_create_set can sleep for long time, + * but we must avoid sleeping in ptlrpcd interpret function. */ rc = lov_fini_create_set(set, ea); out: - lov_putref(exp->exp_obd); + obd_putref(exp->exp_obd); RETURN(rc); } @@ -1156,9 +1161,8 @@ out: do { \ LASSERT((lsmp) != NULL); \ LASSERTF(((lsmp)->lsm_magic == LOV_MAGIC_V1 || \ - (lsmp)->lsm_magic == LOV_MAGIC_V3 || \ - (lsmp)->lsm_magic == LOV_MAGIC_JOIN), "%p->lsm_magic=%x\n", \ - (lsmp), (lsmp)->lsm_magic); \ + (lsmp)->lsm_magic == LOV_MAGIC_V3), \ + "%p->lsm_magic=%x\n", (lsmp), (lsmp)->lsm_magic); \ } while (0) static int lov_destroy(struct obd_export *exp, struct obdo *oa, @@ -1168,7 +1172,7 @@ static int lov_destroy(struct obd_export *exp, struct obdo *oa, struct lov_request_set *set; struct obd_info oinfo; struct lov_request *req; - struct list_head *pos; + cfs_list_t *pos; struct lov_obd *lov; int rc = 0, err = 0; ENTRY; @@ -1184,13 +1188,13 @@ static int lov_destroy(struct obd_export *exp, struct obdo *oa, } lov = &exp->exp_obd->u.lov; - lov_getref(exp->exp_obd); + obd_getref(exp->exp_obd); rc = lov_prep_destroy_set(exp, &oinfo, oa, lsm, oti, &set); if (rc) GOTO(out, rc); - list_for_each (pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); + cfs_list_for_each (pos, &set->set_list) { + req = cfs_list_entry(pos, struct lov_request, rq_link); if (oa->o_valid & OBD_MD_FLCOOKIE) oti->oti_logcookies = set->set_cookies + req->rq_stripe; @@ -1214,7 +1218,7 @@ static int lov_destroy(struct obd_export *exp, struct obdo *oa, } err = lov_fini_destroy_set(set); out: - lov_putref(exp->exp_obd); + obd_putref(exp->exp_obd); RETURN(rc ? rc : err); } @@ -1222,7 +1226,7 @@ static int lov_getattr(struct obd_export *exp, struct obd_info *oinfo) { struct lov_request_set *set; struct lov_request *req; - struct list_head *pos; + cfs_list_t *pos; struct lov_obd *lov; int err = 0, rc = 0; ENTRY; @@ -1239,8 +1243,8 @@ static int lov_getattr(struct obd_export *exp, struct obd_info *oinfo) if (rc) RETURN(rc); - list_for_each (pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); + cfs_list_for_each (pos, &set->set_list) { + req = cfs_list_entry(pos, struct lov_request, rq_link); CDEBUG(D_INFO, "objid "LPX64"[%d] has subobj "LPX64" at idx " "%u\n", oinfo->oi_oa->o_id, req->rq_stripe, @@ -1283,7 +1287,7 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, { struct lov_request_set *lovset; struct lov_obd *lov; - struct list_head *pos; + cfs_list_t *pos; struct lov_request *req; int rc = 0, err; ENTRY; @@ -1304,8 +1308,8 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, oinfo->oi_md->lsm_object_id, oinfo->oi_md->lsm_stripe_count, oinfo->oi_md->lsm_stripe_size); - list_for_each (pos, &lovset->set_list) { - req = list_entry(pos, struct lov_request, rq_link); + cfs_list_for_each (pos, &lovset->set_list) { + req = cfs_list_entry(pos, struct lov_request, rq_link); CDEBUG(D_INFO, "objid "LPX64"[%d] has subobj "LPX64" at idx " "%u\n", oinfo->oi_oa->o_id, req->rq_stripe, @@ -1321,7 +1325,7 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, } } - if (!list_empty(&rqset->set_requests)) { + if (!cfs_list_empty(&rqset->set_requests)) { LASSERT(rc == 0); LASSERT (rqset->set_interpret == NULL); rqset->set_interpret = lov_getattr_interpret; @@ -1340,7 +1344,7 @@ static int lov_setattr(struct obd_export *exp, struct obd_info *oinfo, { struct lov_request_set *set; struct lov_obd *lov; - struct list_head *pos; + cfs_list_t *pos; struct lov_request *req; int err = 0, rc = 0; ENTRY; @@ -1364,8 +1368,8 @@ static int lov_setattr(struct obd_export *exp, struct obd_info *oinfo, if (rc) RETURN(rc); - list_for_each (pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); + cfs_list_for_each (pos, &set->set_list) { + req = cfs_list_entry(pos, struct lov_request, rq_link); rc = obd_setattr(lov->lov_tgts[req->rq_idx]->ltd_exp, &req->rq_oi, NULL); @@ -1406,7 +1410,7 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, { struct lov_request_set *set; struct lov_request *req; - struct list_head *pos; + cfs_list_t *pos; struct lov_obd *lov; int rc = 0; ENTRY; @@ -1430,8 +1434,8 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, oinfo->oi_md->lsm_object_id, oinfo->oi_md->lsm_stripe_count, oinfo->oi_md->lsm_stripe_size); - list_for_each (pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); + cfs_list_for_each (pos, &set->set_list) { + req = cfs_list_entry(pos, struct lov_request, rq_link); if (oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE) oti->oti_logcookies = set->set_cookies + req->rq_stripe; @@ -1453,7 +1457,7 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, } /* If we are not waiting for responses on async requests, return. */ - if (rc || !rqset || list_empty(&rqset->set_requests)) { + if (rc || !rqset || cfs_list_empty(&rqset->set_requests)) { int err; if (rc) set->set_completes = 0; @@ -1490,7 +1494,7 @@ static int lov_punch(struct obd_export *exp, struct obd_info *oinfo, { struct lov_request_set *set; struct lov_obd *lov; - struct list_head *pos; + cfs_list_t *pos; struct lov_request *req; int rc = 0; ENTRY; @@ -1506,8 +1510,8 @@ static int lov_punch(struct obd_export *exp, struct obd_info *oinfo, if (rc) RETURN(rc); - list_for_each (pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); + cfs_list_for_each (pos, &set->set_list) { + req = cfs_list_entry(pos, struct lov_request, rq_link); rc = obd_punch(lov->lov_tgts[req->rq_idx]->ltd_exp, &req->rq_oi, NULL, rqset); @@ -1520,7 +1524,7 @@ static int lov_punch(struct obd_export *exp, struct obd_info *oinfo, } } - if (rc || list_empty(&rqset->set_requests)) { + if (rc || cfs_list_empty(&rqset->set_requests)) { int err; err = lov_fini_punch_set(set); RETURN(rc ? rc : err); @@ -1540,7 +1544,7 @@ static int lov_sync(struct obd_export *exp, struct obdo *oa, struct lov_request_set *set; struct obd_info oinfo; struct lov_obd *lov; - struct list_head *pos; + cfs_list_t *pos; struct lov_request *req; int err = 0, rc = 0; ENTRY; @@ -1555,8 +1559,8 @@ static int lov_sync(struct obd_export *exp, struct obdo *oa, if (rc) RETURN(rc); - list_for_each (pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); + cfs_list_for_each (pos, &set->set_list) { + req = cfs_list_entry(pos, struct lov_request, rq_link); rc = obd_sync(lov->lov_tgts[req->rq_idx]->ltd_exp, req->rq_oi.oi_oa, NULL, @@ -1617,7 +1621,7 @@ static int lov_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, { struct lov_request_set *set; struct lov_request *req; - struct list_head *pos; + cfs_list_t *pos; struct lov_obd *lov = &exp->exp_obd->u.lov; int err, rc = 0; ENTRY; @@ -1633,10 +1637,10 @@ static int lov_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, if (rc) RETURN(rc); - list_for_each (pos, &set->set_list) { + cfs_list_for_each (pos, &set->set_list) { struct obd_export *sub_exp; struct brw_page *sub_pga; - req = list_entry(pos, struct lov_request, rq_link); + req = cfs_list_entry(pos, struct lov_request, rq_link); sub_exp = lov->lov_tgts[req->rq_idx]->ltd_exp; sub_pga = set->set_pga + req->rq_pgaidx; @@ -1669,7 +1673,7 @@ static int lov_enqueue(struct obd_export *exp, struct obd_info *oinfo, ldlm_mode_t mode = einfo->ei_mode; struct lov_request_set *set; struct lov_request *req; - struct list_head *pos; + cfs_list_t *pos; struct lov_obd *lov; ldlm_error_t rc; ENTRY; @@ -1689,8 +1693,8 @@ static int lov_enqueue(struct obd_export *exp, struct obd_info *oinfo, if (rc) RETURN(rc); - list_for_each (pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); + cfs_list_for_each (pos, &set->set_list) { + req = cfs_list_entry(pos, struct lov_request, rq_link); rc = obd_enqueue(lov->lov_tgts[req->rq_idx]->ltd_exp, &req->rq_oi, einfo, rqset); @@ -1698,7 +1702,7 @@ static int lov_enqueue(struct obd_export *exp, struct obd_info *oinfo, GOTO(out, rc); } - if (rqset && !list_empty(&rqset->set_requests)) { + if (rqset && !cfs_list_empty(&rqset->set_requests)) { LASSERT(rc == 0); LASSERT(rqset->set_interpret == NULL); rqset->set_interpret = lov_enqueue_interpret; @@ -1750,7 +1754,7 @@ static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm, struct lov_request_set *set; struct obd_info oinfo; struct lov_request *req; - struct list_head *pos; + cfs_list_t *pos; struct lov_obd *lov; struct lustre_handle *lov_lockhp; int err = 0, rc = 0; @@ -1768,8 +1772,8 @@ static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm, if (rc) RETURN(rc); - list_for_each (pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); + cfs_list_for_each (pos, &set->set_list) { + req = cfs_list_entry(pos, struct lov_request, rq_link); lov_lockhp = set->set_lockh->llh_handles + req->rq_stripe; rc = obd_cancel(lov->lov_tgts[req->rq_idx]->ltd_exp, @@ -1847,8 +1851,7 @@ static int lov_cancel_unused(struct obd_export *exp, RETURN(rc); } -static int lov_statfs_interpret(struct ptlrpc_request_set *rqset, - void *data, int rc) +int lov_statfs_interpret(struct ptlrpc_request_set *rqset, void *data, int rc) { struct lov_request_set *lovset = (struct lov_request_set *)data; int err; @@ -1866,7 +1869,7 @@ static int lov_statfs_async(struct obd_device *obd, struct obd_info *oinfo, { struct lov_request_set *set; struct lov_request *req; - struct list_head *pos; + cfs_list_t *pos; struct lov_obd *lov; int rc = 0; ENTRY; @@ -1879,10 +1882,10 @@ static int lov_statfs_async(struct obd_device *obd, struct obd_info *oinfo, if (rc) RETURN(rc); - list_for_each (pos, &set->set_list) { + cfs_list_for_each (pos, &set->set_list) { struct obd_device *osc_obd; - req = list_entry(pos, struct lov_request, rq_link); + req = cfs_list_entry(pos, struct lov_request, rq_link); osc_obd = class_exp2obd(lov->lov_tgts[req->rq_idx]->ltd_exp); rc = obd_statfs_async(osc_obd, &req->rq_oi, max_age, rqset); @@ -1890,7 +1893,7 @@ static int lov_statfs_async(struct obd_device *obd, struct obd_info *oinfo, break; } - if (rc || list_empty(&rqset->set_requests)) { + if (rc || cfs_list_empty(&rqset->set_requests)) { int err; if (rc) set->set_completes = 0; @@ -1963,14 +1966,15 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, /* got statfs data */ rc = obd_statfs(osc_obd, &stat_buf, - cfs_time_current_64() - HZ, 0); + cfs_time_current_64() - CFS_HZ, 0); if (rc) RETURN(rc); - if (copy_to_user(data->ioc_pbuf1, &stat_buf, data->ioc_plen1)) + if (cfs_copy_to_user(data->ioc_pbuf1, &stat_buf, + data->ioc_plen1)) RETURN(-EFAULT); /* copy UUID */ - if (copy_to_user(data->ioc_pbuf2, obd2cli_tgt(osc_obd), - data->ioc_plen2)) + if (cfs_copy_to_user(data->ioc_pbuf2, obd2cli_tgt(osc_obd), + data->ioc_plen2)) RETURN(-EFAULT); break; } @@ -2014,13 +2018,13 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, *genp = lov->lov_tgts[i]->ltd_gen; } - if (copy_to_user((void *)uarg, buf, len)) + if (cfs_copy_to_user((void *)uarg, buf, len)) rc = -EFAULT; obd_ioctl_freedata(buf, len); break; } case LL_IOC_LOV_SETSTRIPE: - rc = lov_setstripe(exp, karg, uarg); + rc = lov_setstripe(exp, len, karg, uarg); break; case LL_IOC_LOV_GETSTRIPE: rc = lov_getstripe(exp, karg, uarg); @@ -2479,7 +2483,7 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen, if (!vallen || !val) RETURN(-EFAULT); - lov_getref(obddev); + obd_getref(obddev); if (KEY_IS(KEY_LOCK_TO_STRIPE)) { struct { @@ -2540,7 +2544,7 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen, rc = -EINVAL; out: - lov_putref(obddev); + obd_putref(obddev); RETURN(rc); } @@ -2555,7 +2559,7 @@ static int lov_set_info_async(struct obd_export *exp, obd_count keylen, struct lov_tgt_desc *tgt; unsigned incr, check_uuid, do_inactive, no_set; - unsigned next_id = 0, mds_con = 0; + unsigned next_id = 0, mds_con = 0, capa = 0; ENTRY; incr = check_uuid = do_inactive = no_set = 0; @@ -2566,7 +2570,7 @@ static int lov_set_info_async(struct obd_export *exp, obd_count keylen, RETURN(-ENOMEM); } - lov_getref(obddev); + obd_getref(obddev); count = lov->desc.ld_tgt_count; if (KEY_IS(KEY_NEXT_ID)) { @@ -2577,12 +2581,12 @@ static int lov_set_info_async(struct obd_export *exp, obd_count keylen, next_id = 1; } else if (KEY_IS(KEY_CHECKSUM)) { do_inactive = 1; - } else if (KEY_IS(KEY_UNLINKED)) { - check_uuid = val ? 1 : 0; } else if (KEY_IS(KEY_EVICT_BY_NID)) { /* use defaults: do_inactive = incr = 0; */ } else if (KEY_IS(KEY_MDS_CONN)) { mds_con = 1; + } else if (KEY_IS(KEY_CAPA_KEY)) { + capa = 1; } for (i = 0; i < count; i++, val = (char *)val + incr) { @@ -2617,7 +2621,21 @@ static int lov_set_info_async(struct obd_export *exp, obd_count keylen, err = obd_set_info_async(tgt->ltd_exp, keylen, key, vallen, ((struct obd_id_info*)val)->data, set); - } else { + } else if (capa) { + struct mds_capa_info *info = (struct mds_capa_info*)val; + + LASSERT(vallen == sizeof(*info)); + + /* Only want a specific OSC */ + if (info->uuid && + !obd_uuid_equals(info->uuid, &tgt->ltd_uuid)) + continue; + + err = obd_set_info_async(tgt->ltd_exp, keylen, key, + sizeof(*info->capa), + info->capa, set); + + } else { /* Only want a specific OSC */ if (check_uuid && !obd_uuid_equals(val, &tgt->ltd_uuid)) @@ -2631,7 +2649,7 @@ static int lov_set_info_async(struct obd_export *exp, obd_count keylen, rc = err; } - lov_putref(obddev); + obd_putref(obddev); if (no_set) { err = ptlrpc_set_wait(set); if (!rc) @@ -2641,21 +2659,6 @@ static int lov_set_info_async(struct obd_export *exp, obd_count keylen, RETURN(rc); } -static int lov_checkmd(struct obd_export *exp, struct obd_export *md_exp, - struct lov_stripe_md *lsm) -{ - int rc; - ENTRY; - - if (!lsm) - RETURN(0); - LASSERT(md_exp); - LASSERT(lsm_op_find(lsm->lsm_magic) != NULL); - rc = lsm_op_find(lsm->lsm_magic)->lsm_revalidate(lsm, md_exp->exp_obd); - - RETURN(rc); -} - int lov_test_and_clear_async_rc(struct lov_stripe_md *lsm) { int i, rc = 0; @@ -2699,7 +2702,7 @@ static int lov_extent_calc(struct obd_export *exp, struct lov_stripe_md *lsm, void lov_stripe_lock(struct lov_stripe_md *md) { LASSERT(md->lsm_lock_owner != cfs_curproc_pid()); - spin_lock(&md->lsm_lock); + cfs_spin_lock(&md->lsm_lock); LASSERT(md->lsm_lock_owner == 0); md->lsm_lock_owner = cfs_curproc_pid(); } @@ -2709,7 +2712,7 @@ void lov_stripe_unlock(struct lov_stripe_md *md) { LASSERT(md->lsm_lock_owner == cfs_curproc_pid()); md->lsm_lock_owner = 0; - spin_unlock(&md->lsm_lock); + cfs_spin_unlock(&md->lsm_lock); } EXPORT_SYMBOL(lov_stripe_unlock); @@ -2726,7 +2729,6 @@ struct obd_ops lov_obd_ops = { .o_statfs_async = lov_statfs_async, .o_packmd = lov_packmd, .o_unpackmd = lov_unpackmd, - .o_checkmd = lov_checkmd, .o_create = lov_create, .o_destroy = lov_destroy, .o_getattr = lov_getattr, @@ -2753,6 +2755,8 @@ struct obd_ops lov_obd_ops = { .o_pool_rem = lov_pool_remove, .o_pool_add = lov_pool_add, .o_pool_del = lov_pool_del, + .o_getref = lov_getref, + .o_putref = lov_putref, }; static quota_interface_t *quota_interface; @@ -2779,14 +2783,14 @@ int __init lov_init(void) lov_oinfo_slab = cfs_mem_cache_create("lov_oinfo", sizeof(struct lov_oinfo), - 0, SLAB_HWCACHE_ALIGN); + 0, CFS_SLAB_HWCACHE_ALIGN); if (lov_oinfo_slab == NULL) { lu_kmem_fini(lov_caches); return -ENOMEM; } lprocfs_lov_init_vars(&lvars); - request_module("lquota"); + cfs_request_module("lquota"); quota_interface = PORTAL_SYMBOL_GET(lov_quota_interface); init_obd_quota_ops(quota_interface, &lov_obd_ops);