From 45006597080721052cdd858b52054290f9992898 Mon Sep 17 00:00:00 2001 From: tianzy Date: Thu, 15 Feb 2007 07:11:12 +0000 Subject: [PATCH] port the patch(9414) on HEAD(b1_5) b=11471 --- lustre/include/obd.h | 2 +- lustre/include/obd_lov.h | 2 +- lustre/liblustre/rw.c | 10 +++---- lustre/llite/file.c | 26 +++++++++--------- lustre/lov/lov_ea.c | 57 ++++++++++++++++++++++++++++++++------- lustre/lov/lov_internal.h | 4 +++ lustre/lov/lov_log.c | 9 +++---- lustre/lov/lov_merge.c | 10 +++---- lustre/lov/lov_obd.c | 59 ++++++++++++++++++++++++++--------------- lustre/lov/lov_pack.c | 33 +++++++++++------------ lustre/lov/lov_qos.c | 24 ++++++++++++----- lustre/lov/lov_request.c | 63 ++++++++++++++++++++++++-------------------- lustre/obdecho/echo_client.c | 46 ++++++++++++++++++-------------- lustre/obdfilter/filter.c | 9 +++++-- lustre/osc/osc_request.c | 36 ++++++++++++++----------- lustre/utils/obd.c | 24 ++++++++++++----- 16 files changed, 257 insertions(+), 157 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index aaa3b10..ab24189 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -114,7 +114,7 @@ struct lov_stripe_md { } lsm_wire; struct lov_array_info *lsm_array; /*Only for joined file array info*/ - struct lov_oinfo lsm_oinfo[0]; + struct lov_oinfo *lsm_oinfo[0]; }; #define lsm_object_id lsm_wire.lw_object_id diff --git a/lustre/include/obd_lov.h b/lustre/include/obd_lov.h index 057fb9d..c0f302d 100644 --- a/lustre/include/obd_lov.h +++ b/lustre/include/obd_lov.h @@ -7,7 +7,7 @@ static inline int lov_stripe_md_size(int stripes) { - return sizeof(struct lov_stripe_md) + stripes*sizeof(struct lov_oinfo); + return sizeof(struct lov_stripe_md) + stripes*sizeof(struct lov_oinfo*); } #define lov_mds_md_size(stripes) lov_mds_md_v1_size(stripes) diff --git a/lustre/liblustre/rw.c b/lustre/liblustre/rw.c index fbdca31..eb22812 100644 --- a/lustre/liblustre/rw.c +++ b/lustre/liblustre/rw.c @@ -156,12 +156,12 @@ static int llu_extent_lock_callback(struct ldlm_lock *lock, stripe = llu_lock_to_stripe_offset(inode, lock); lock_res_and_lock(lock); kms = ldlm_extent_shift_kms(lock, - lsm->lsm_oinfo[stripe].loi_kms); + lsm->lsm_oinfo[stripe]->loi_kms); unlock_res_and_lock(lock); - if (lsm->lsm_oinfo[stripe].loi_kms != kms) + if (lsm->lsm_oinfo[stripe]->loi_kms != kms) LDLM_DEBUG(lock, "updating kms from "LPU64" to "LPU64, - lsm->lsm_oinfo[stripe].loi_kms, kms); - lsm->lsm_oinfo[stripe].loi_kms = kms; + lsm->lsm_oinfo[stripe]->loi_kms, kms); + lsm->lsm_oinfo[stripe]->loi_kms = kms; iput: I_RELE(inode); break; @@ -202,7 +202,7 @@ static int llu_glimpse_callback(struct ldlm_lock *lock, void *reqp) } lvb = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*lvb)); - lvb->lvb_size = lli->lli_smd->lsm_oinfo[stripe].loi_kms; + lvb->lvb_size = lli->lli_smd->lsm_oinfo[stripe]->loi_kms; LDLM_DEBUG(lock, "i_size: %llu -> stripe number %u -> kms "LPU64, (long long)llu_i2stat(inode)->st_size, stripe,lvb->lvb_size); diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 7c0981f..bc69af0 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -603,11 +603,11 @@ static int ll_lock_to_stripe_offset(struct inode *inode, struct ldlm_lock *lock) LASSERT(stripe < lsm->lsm_stripe_count); check: - if (lsm->lsm_oinfo[stripe].loi_id != lock->l_resource->lr_name.name[0]|| - lsm->lsm_oinfo[stripe].loi_gr != lock->l_resource->lr_name.name[1]){ + if (lsm->lsm_oinfo[stripe]->loi_id != lock->l_resource->lr_name.name[0]|| + lsm->lsm_oinfo[stripe]->loi_gr != lock->l_resource->lr_name.name[1]){ LDLM_ERROR(lock, "resource doesn't match object "LPU64"/"LPU64, - lsm->lsm_oinfo[stripe].loi_id, - lsm->lsm_oinfo[stripe].loi_gr); + lsm->lsm_oinfo[stripe]->loi_id, + lsm->lsm_oinfo[stripe]->loi_gr); RETURN(-ELDLM_NO_LOCK_DATA); } @@ -804,12 +804,12 @@ static int ll_extent_lock_callback(struct ldlm_lock *lock, lov_stripe_lock(lsm); lock_res_and_lock(lock); kms = ldlm_extent_shift_kms(lock, - lsm->lsm_oinfo[stripe].loi_kms); + lsm->lsm_oinfo[stripe]->loi_kms); - if (lsm->lsm_oinfo[stripe].loi_kms != kms) + if (lsm->lsm_oinfo[stripe]->loi_kms != kms) LDLM_DEBUG(lock, "updating kms from "LPU64" to "LPU64, - lsm->lsm_oinfo[stripe].loi_kms, kms); - lsm->lsm_oinfo[stripe].loi_kms = kms; + lsm->lsm_oinfo[stripe]->loi_kms, kms); + lsm->lsm_oinfo[stripe]->loi_kms = kms; unlock_res_and_lock(lock); lov_stripe_unlock(lsm); //ll_try_done_writing(inode); @@ -911,7 +911,7 @@ static int ll_glimpse_callback(struct ldlm_lock *lock, void *reqp) } lvb = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*lvb)); - lvb->lvb_size = lli->lli_smd->lsm_oinfo[stripe].loi_kms; + lvb->lvb_size = lli->lli_smd->lsm_oinfo[stripe]->loi_kms; lvb->lvb_mtime = LTIME_S(inode->i_mtime); lvb->lvb_atime = LTIME_S(inode->i_atime); lvb->lvb_ctime = LTIME_S(inode->i_ctime); @@ -1706,13 +1706,13 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, lmj->lmm_objects[i].l_extent_end = lex->le_start + lex->le_len; lmj->lmm_objects[i].l_object_id = - lsm->lsm_oinfo[i].loi_id; + lsm->lsm_oinfo[i]->loi_id; lmj->lmm_objects[i].l_object_gr = - lsm->lsm_oinfo[i].loi_gr; + lsm->lsm_oinfo[i]->loi_gr; lmj->lmm_objects[i].l_ost_gen = - lsm->lsm_oinfo[i].loi_ost_gen; + lsm->lsm_oinfo[i]->loi_ost_gen; lmj->lmm_objects[i].l_ost_idx = - lsm->lsm_oinfo[i].loi_ost_idx; + lsm->lsm_oinfo[i]->loi_ost_idx; } lmm = (struct lov_mds_md *)lmj; lmmsize = lmj_size; diff --git a/lustre/lov/lov_ea.c b/lustre/lov/lov_ea.c index 50f2e86..05b9ea5 100755 --- a/lustre/lov/lov_ea.c +++ b/lustre/lov/lov_ea.c @@ -79,6 +79,49 @@ static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes, return 0; } +struct lov_stripe_md *lsm_alloc_plain(int stripe_count, int *size) +{ + struct lov_stripe_md *lsm; + int i, oinfo_ptrs_size; + struct lov_oinfo *loi; + + LASSERT(stripe_count > 0); + + oinfo_ptrs_size = sizeof(struct lov_oinfo *) * stripe_count; + *size = sizeof(struct lov_stripe_md) + oinfo_ptrs_size; + + OBD_ALLOC(lsm, *size); + if (!lsm) + return NULL;; + + for (i = 0; i < stripe_count; i++) { + OBD_SLAB_ALLOC(loi, lov_oinfo_slab, SLAB_NOFS, sizeof(*loi)); + if (loi == NULL) + goto err; + lsm->lsm_oinfo[i] = loi; + } + lsm->lsm_stripe_count = stripe_count; + return lsm; + +err: + while (--i >= 0) + OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab, sizeof(*loi)); + OBD_FREE(lsm, *size); + return NULL; +} + +void lsm_free_plain(struct lov_stripe_md *lsm) +{ + int stripe_count = lsm->lsm_stripe_count; + int i; + + for (i = 0; i < stripe_count; i++) + OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab, + sizeof(struct lov_oinfo)); + OBD_FREE(lsm, sizeof(struct lov_stripe_md) + + stripe_count * sizeof(struct lov_oinfo *)); +} + static void lsm_unpackmd_common(struct lov_stripe_md *lsm, struct lov_mds_md *lmm) { @@ -125,11 +168,6 @@ lsm_stripe_index_by_offset_plain(struct lov_stripe_md *lsm, return 0; } -static void lsm_free_plain(struct lov_stripe_md *lsm) -{ - OBD_FREE(lsm, lov_stripe_md_size(lsm->lsm_stripe_count)); -} - static int lsm_revalidate_plain(struct lov_stripe_md *lsm, struct obd_device *obd) { @@ -171,8 +209,9 @@ int lsm_unpackmd_plain(struct lov_obd *lov, struct lov_stripe_md *lsm, lsm_unpackmd_common(lsm, lmm); - for (i = 0, loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++) { + for (i = 0; i < lsm->lsm_stripe_count; i++) { /* XXX LOV STACKING call down to osc_unpackmd() */ + loi = lsm->lsm_oinfo[i]; loi->loi_id = le64_to_cpu(lmm->lmm_objects[i].l_object_id); loi->loi_gr = le64_to_cpu(lmm->lmm_objects[i].l_object_gr); loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx); @@ -188,7 +227,6 @@ int lsm_unpackmd_plain(struct lov_obd *lov, struct lov_stripe_md *lsm, lov_dump_lmm_v1(D_WARNING, lmm); return -EINVAL; } - loi++; } return 0; @@ -271,7 +309,7 @@ static void lovea_free_array_info(struct lov_stripe_md *lsm) static void lsm_free_join(struct lov_stripe_md *lsm) { lovea_free_array_info(lsm); - OBD_FREE(lsm, lov_stripe_md_size(lsm->lsm_stripe_count)); + lsm_free_plain(lsm); } static void @@ -393,18 +431,17 @@ static int lovea_unpack_array(struct llog_handle *handle, /* unpack extent's lmm to lov_oinfo array */ loi_index = lai->lai_ext_array[cursor].le_loi_idx; - loi = &lsm->lsm_oinfo[loi_index]; CDEBUG(D_INFO, "lovea upackmd cursor %d, loi_index %d extent " LPU64":"LPU64"\n", cursor, loi_index, med->med_start, med->med_len); for (i = 0; i < lmm->lmm_stripe_count; i ++) { /* XXX LOV STACKING call down to osc_unpackmd() */ + loi = lsm->lsm_oinfo[loi_index]; loi->loi_id = le64_to_cpu(lmm->lmm_objects[i].l_object_id); loi->loi_gr = le64_to_cpu(lmm->lmm_objects[i].l_object_gr); loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx); loi->loi_ost_gen = le32_to_cpu(lmm->lmm_objects[i].l_ost_gen); - loi++; } RETURN(0); diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h index aa14445..903aeb4 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -71,6 +71,8 @@ struct lov_async_page { (LASSERT(((struct lov_async_page *)(c))->lap_magic == LOV_AP_MAGIC), \ (struct lov_async_page *)(c)) +extern kmem_cache_t *lov_oinfo_slab; + static inline void lov_llh_addref(void *llhp) { struct lov_lock_handles *llh = llhp; @@ -245,6 +247,8 @@ void lov_dump_lmm_join(int level, struct lov_mds_md_join *lmmj); /* lov_ea.c */ int lov_unpackmd_join(struct lov_obd *lov, struct lov_stripe_md *lsm, struct lov_mds_md *lmm); +struct lov_stripe_md *lsm_alloc_plain(int stripe_count, int *size); +void lsm_free_plain(struct lov_stripe_md *lsm); struct lov_extent *lovea_idx2le(struct lov_stripe_md *lsm, int stripe_no); struct lov_extent *lovea_off2le(struct lov_stripe_md *lsm, obd_off lov_off); diff --git a/lustre/lov/lov_log.c b/lustre/lov/lov_log.c index b2aee8f..232df7a 100644 --- a/lustre/lov/lov_log.c +++ b/lustre/lov/lov_log.c @@ -59,7 +59,6 @@ static int lov_llog_origin_add(struct llog_ctxt *ctxt, { struct obd_device *obd = ctxt->loc_obd; struct lov_obd *lov = &obd->u.lov; - struct lov_oinfo *loi; int i, rc = 0; ENTRY; @@ -67,7 +66,8 @@ static int lov_llog_origin_add(struct llog_ctxt *ctxt, "logcookies %p, numcookies %d lsm->lsm_stripe_count %d \n", logcookies, numcookies, lsm->lsm_stripe_count); - for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) { + for (i = 0; i < lsm->lsm_stripe_count; i++) { + struct lov_oinfo *loi = lsm->lsm_oinfo[i]; struct obd_device *child = lov->lov_tgts[loi->loi_ost_idx]->ltd_exp->exp_obd; struct llog_ctxt *cctxt = llog_get_context(child, ctxt->loc_idx); @@ -137,17 +137,16 @@ static int lov_llog_repl_cancel(struct llog_ctxt *ctxt, struct lov_stripe_md *ls { struct lov_obd *lov; struct obd_device *obd = ctxt->loc_obd; - struct lov_oinfo *loi; int rc = 0, i; ENTRY; LASSERT(lsm != NULL); LASSERT(count == lsm->lsm_stripe_count); - loi = lsm->lsm_oinfo; lov = &obd->u.lov; lov_getref(obd); - for (i = 0; i < count; i++, cookies++, loi++) { + for (i = 0; i < count; i++, cookies++) { + struct lov_oinfo *loi = lsm->lsm_oinfo[i]; struct obd_device *child = lov->lov_tgts[loi->loi_ost_idx]->ltd_exp->exp_obd; struct llog_ctxt *cctxt = diff --git a/lustre/lov/lov_merge.c b/lustre/lov/lov_merge.c index 7ee1d56..984a8ee 100644 --- a/lustre/lov/lov_merge.c +++ b/lustre/lov/lov_merge.c @@ -63,10 +63,10 @@ int lov_merge_lvb(struct obd_export *exp, struct lov_stripe_md *lsm, LASSERT(lsm->lsm_lock_owner == cfs_current()); #endif - for (i = 0, loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; - i++, loi++) { + for (i = 0; i < lsm->lsm_stripe_count; i++) { obd_size lov_size, tmpsize; + loi = lsm->lsm_oinfo[i]; tmpsize = loi->loi_kms; if (kms_only == 0 && loi->loi_lvb.lvb_size > tmpsize) tmpsize = loi->loi_lvb.lvb_size; @@ -113,8 +113,8 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm, if (shrink) { struct lov_oinfo *loi; - for (loi = lsm->lsm_oinfo; stripe < lsm->lsm_stripe_count; - stripe++, loi++) { + for (; stripe < lsm->lsm_stripe_count; stripe++) { + loi = lsm->lsm_oinfo[stripe]; kms = lov_size_to_stripe(lsm, size, stripe); CDEBUG(D_INODE, "stripe %d KMS %sing "LPU64"->"LPU64"\n", @@ -129,7 +129,7 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm, if (size > 0) stripe = lov_stripe_number(lsm, size - 1); kms = lov_size_to_stripe(lsm, size, stripe); - loi = &(lsm->lsm_oinfo[stripe]); + loi = lsm->lsm_oinfo[stripe]; CDEBUG(D_INODE, "stripe %d KMS %sincreasing "LPU64"->"LPU64"\n", stripe, kms > loi->loi_kms ? "" : "not ", loi->loi_kms, kms); diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index a63d1a8..a533d91 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -964,8 +964,8 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa, GOTO(out, rc = -EINVAL); for (i = 0; i < lsm->lsm_stripe_count; i++) { - if (lsm->lsm_oinfo[i].loi_ost_idx == ost_idx) { - if (lsm->lsm_oinfo[i].loi_id != src_oa->o_id) + if (lsm->lsm_oinfo[i]->loi_ost_idx == ost_idx) { + if (lsm->lsm_oinfo[i]->loi_id != src_oa->o_id) GOTO(out, rc = -EINVAL); break; } @@ -1464,7 +1464,7 @@ static int lov_brw_check(struct lov_obd *lov, struct obd_info *lov_oinfo, * I/O can succeed */ for (i = 0; i < oa_bufs; i++) { int stripe = lov_stripe_number(lov_oinfo->oi_md, pga[i].off); - int ost = lov_oinfo->oi_md->lsm_oinfo[stripe].loi_ost_idx; + int ost = lov_oinfo->oi_md->lsm_oinfo[stripe]->loi_ost_idx; obd_off start, end; if (!lov_stripe_intersects(lov_oinfo->oi_md, i, pga[i].off, @@ -1680,7 +1680,7 @@ int lov_prep_async_page(struct obd_export *exp, struct lov_stripe_md *lsm, /* for now only raid 0 which passes through */ lap->lap_stripe = lov_stripe_number(lsm, offset); lov_stripe_offset(lsm, offset, lap->lap_stripe, &lap->lap_sub_offset); - loi = &lsm->lsm_oinfo[lap->lap_stripe]; + loi = lsm->lsm_oinfo[lap->lap_stripe]; /* so the callback doesn't need the lsm */ lap->lap_loi_id = loi->loi_id; @@ -1714,7 +1714,7 @@ static int lov_queue_async_io(struct obd_export *exp, lap = LAP_FROM_COOKIE(cookie); - loi = &lsm->lsm_oinfo[lap->lap_stripe]; + loi = lsm->lsm_oinfo[lap->lap_stripe]; rc = obd_queue_async_io(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp, lsm, loi, lap->lap_sub_cookie, cmd, off, count, @@ -1737,7 +1737,7 @@ static int lov_set_async_flags(struct obd_export *exp, lap = LAP_FROM_COOKIE(cookie); - loi = &lsm->lsm_oinfo[lap->lap_stripe]; + loi = lsm->lsm_oinfo[lap->lap_stripe]; rc = obd_set_async_flags(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp, lsm, loi, lap->lap_sub_cookie, async_flags); @@ -1761,7 +1761,7 @@ static int lov_queue_group_io(struct obd_export *exp, lap = LAP_FROM_COOKIE(cookie); - loi = &lsm->lsm_oinfo[lap->lap_stripe]; + loi = lsm->lsm_oinfo[lap->lap_stripe]; rc = obd_queue_group_io(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp, lsm, loi, oig, lap->lap_sub_cookie, cmd, off, count, @@ -1784,8 +1784,8 @@ static int lov_trigger_group_io(struct obd_export *exp, ASSERT_LSM_MAGIC(lsm); - loi = lsm->lsm_oinfo; - for (i = 0; i < lsm->lsm_stripe_count; i++, loi++) { + for (i = 0; i < lsm->lsm_stripe_count; i++) { + loi = lsm->lsm_oinfo[i]; if (!lov->lov_tgts[loi->loi_ost_idx] || !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) { CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx); @@ -1814,7 +1814,7 @@ static int lov_teardown_async_page(struct obd_export *exp, lap = LAP_FROM_COOKIE(cookie); - loi = &lsm->lsm_oinfo[lap->lap_stripe]; + loi = lsm->lsm_oinfo[lap->lap_stripe]; rc = obd_teardown_async_page(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp, lsm, loi, lap->lap_sub_cookie); @@ -1938,9 +1938,10 @@ static int lov_change_cbdata(struct obd_export *exp, RETURN(-ENODEV); lov = &exp->exp_obd->u.lov; - for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) { + for (i = 0; i < lsm->lsm_stripe_count; i++) { struct lov_stripe_md submd; + loi = lsm->lsm_oinfo[i]; submd.lsm_object_id = loi->loi_id; submd.lsm_stripe_count = 0; rc = obd_change_cbdata(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp, @@ -2021,10 +2022,11 @@ static int lov_cancel_unused(struct obd_export *exp, ASSERT_LSM_MAGIC(lsm); - for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) { + for (i = 0; i < lsm->lsm_stripe_count; i++) { struct lov_stripe_md submd; int err; + loi = lsm->lsm_oinfo[i]; if (!lov->lov_tgts[loi->loi_ost_idx] || !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx); @@ -2057,10 +2059,11 @@ static int lov_join_lru(struct obd_export *exp, RETURN(-ENODEV); lov = &exp->exp_obd->u.lov; - for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) { + for (i = 0; i < lsm->lsm_stripe_count; i++) { struct lov_stripe_md submd; int rc = 0; + loi = lsm->lsm_oinfo[i]; if (!lov->lov_tgts[loi->loi_ost_idx] || !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx); @@ -2312,9 +2315,8 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen, /* XXX - it's assumed all the locks for deleted OSTs have * been cancelled. Also, the export for deleted OSTs will * be NULL and won't match the lock's export. */ - for (i = 0, loi = data->lsm->lsm_oinfo; - i < data->lsm->lsm_stripe_count; - i++, loi++) { + for (i = 0; i < data->lsm->lsm_stripe_count; i++) { + loi = data->lsm->lsm_oinfo[i]; if (!lov->lov_tgts[loi->loi_ost_idx]) continue; if (lov->lov_tgts[loi->loi_ost_idx]->ltd_exp == @@ -2437,8 +2439,8 @@ int lov_test_and_clear_async_rc(struct lov_stripe_md *lsm) int i, rc = 0; ENTRY; - for (i = 0, loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; - i++, loi++) { + for (i = 0; i < lsm->lsm_stripe_count; i++) { + loi = lsm->lsm_oinfo[i]; if (loi->loi_ar.ar_rc && !rc) rc = loi->loi_ar.ar_rc; loi->loi_ar.ar_rc = 0; @@ -2626,12 +2628,19 @@ struct obd_ops lov_obd_ops = { static quota_interface_t *quota_interface; extern quota_interface_t lov_quota_interface; +kmem_cache_t *lov_oinfo_slab; + int __init lov_init(void) { struct lprocfs_static_vars lvars; - int rc; + int rc, rc2; ENTRY; + lov_oinfo_slab = kmem_cache_create("lov_oinfo", + sizeof(struct lov_oinfo), 0, + SLAB_HWCACHE_ALIGN, NULL, NULL); + if (lov_oinfo_slab == NULL) + return -ENOMEM; lprocfs_init_vars(lov, &lvars); request_module("lquota"); @@ -2640,8 +2649,12 @@ int __init lov_init(void) rc = class_register_type(&lov_obd_ops, lvars.module_vars, LUSTRE_LOV_NAME); - if (rc && quota_interface) - PORTAL_SYMBOL_PUT(lov_quota_interface); + if (rc) { + if (quota_interface) + PORTAL_SYMBOL_PUT(lov_quota_interface); + rc2 = kmem_cache_destroy(lov_oinfo_slab); + LASSERT(rc2 == 0); + } RETURN(rc); } @@ -2649,10 +2662,14 @@ int __init lov_init(void) #ifdef __KERNEL__ static void /*__exit*/ lov_exit(void) { + int rc; + if (quota_interface) PORTAL_SYMBOL_PUT(lov_quota_interface); class_unregister_type(LUSTRE_LOV_NAME); + rc = kmem_cache_destroy(lov_oinfo_slab); + LASSERT(rc == 0); } MODULE_AUTHOR("Cluster File Systems, Inc. "); diff --git a/lustre/lov/lov_pack.c b/lustre/lov/lov_pack.c index e8ec729..f9b5ee3 100644 --- a/lustre/lov/lov_pack.c +++ b/lustre/lov/lov_pack.c @@ -135,7 +135,8 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, lmm->lmm_stripe_count = cpu_to_le32(stripe_count); lmm->lmm_pattern = cpu_to_le32(lsm->lsm_pattern); - for (i = 0, loi = lsm->lsm_oinfo; i < stripe_count; i++, loi++) { + for (i = 0; i < stripe_count; i++) { + loi = lsm->lsm_oinfo[i]; /* XXX LOV STACKING call down to osc_packmd() to do packing */ LASSERTF(loi->loi_id, "lmm_oid "LPU64" stripe %u/%u idx %u\n", lmm->lmm_object_id, i, stripe_count, loi->loi_ost_idx); @@ -185,18 +186,14 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, int *stripe_count) int lov_alloc_memmd(struct lov_stripe_md **lsmp, int stripe_count, int pattern, int magic) { - int lsm_size = lov_stripe_md_size(stripe_count); - struct lov_oinfo *loi; - int i; + int i, lsm_size; ENTRY; - CDEBUG(D_INFO, "alloc lsm, stripe_count %d, lsm_size %d\n", - stripe_count, lsm_size); + CDEBUG(D_INFO, "alloc lsm, stripe_count %d\n", stripe_count); - OBD_ALLOC(*lsmp, lsm_size); + *lsmp = lsm_alloc_plain(stripe_count, &lsm_size); if (!*lsmp) { - CERROR("can not allocate lsmp lsm_size %d stripe_count %d\n", - lsm_size, stripe_count); + CERROR("can't allocate lsmp, stripe_count %d\n", stripe_count); RETURN(-ENOMEM); } @@ -205,10 +202,10 @@ int lov_alloc_memmd(struct lov_stripe_md **lsmp, int stripe_count, (*lsmp)->lsm_stripe_count = stripe_count; (*lsmp)->lsm_maxbytes = LUSTRE_STRIPE_MAXBYTES * stripe_count; (*lsmp)->lsm_pattern = pattern; - (*lsmp)->lsm_oinfo[0].loi_ost_idx = ~0; + (*lsmp)->lsm_oinfo[0]->loi_ost_idx = ~0; - for (i = 0, loi = (*lsmp)->lsm_oinfo; i < stripe_count; i++, loi++) - loi_init(loi); + for (i = 0; i < stripe_count; i++) + loi_init((*lsmp)->lsm_oinfo[i]); RETURN(lsm_size); } @@ -248,9 +245,11 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, } /* If we aren't passed an lsmp struct, we just want the size */ - if (!lsmp) + if (!lsmp) { /* XXX LOV STACKING call into osc for sizes */ + LBUG(); RETURN(lov_stripe_md_size(stripe_count)); + } /* If we are passed an allocated struct but nothing to unpack, free */ if (*lsmp && !lmm) { @@ -347,7 +346,7 @@ int lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp, if (rc < 0) RETURN(rc); - (*lsmp)->lsm_oinfo[0].loi_ost_idx = lum.lmm_stripe_offset; + (*lsmp)->lsm_oinfo[0]->loi_ost_idx = lum.lmm_stripe_offset; (*lsmp)->lsm_stripe_size = lum.lmm_stripe_size; RETURN(0); @@ -384,10 +383,10 @@ int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp, RETURN(rc); for (i = 0; i < lump->lmm_stripe_count; i++) { - (*lsmp)->lsm_oinfo[i].loi_ost_idx = + (*lsmp)->lsm_oinfo[i]->loi_ost_idx = lump->lmm_objects[i].l_ost_idx; - (*lsmp)->lsm_oinfo[i].loi_id = lump->lmm_objects[i].l_object_id; - (*lsmp)->lsm_oinfo[i].loi_gr = lump->lmm_objects[i].l_object_gr; + (*lsmp)->lsm_oinfo[i]->loi_id = lump->lmm_objects[i].l_object_id; + (*lsmp)->lsm_oinfo[i]->loi_gr = lump->lmm_objects[i].l_object_gr; } RETURN(0); } diff --git a/lustre/lov/lov_qos.c b/lustre/lov/lov_qos.c index 514a5d0..8b837d7 100644 --- a/lustre/lov/lov_qos.c +++ b/lustre/lov/lov_qos.c @@ -418,17 +418,27 @@ void qos_shrink_lsm(struct lov_request_set *set) CWARN("using fewer stripes for object "LPX64": old %u new %u\n", lsm->lsm_object_id, lsm->lsm_stripe_count, set->set_count); + LASSERT(lsm->lsm_stripe_count >= set->set_count); - oldsize = lov_stripe_md_size(lsm->lsm_stripe_count); newsize = lov_stripe_md_size(set->set_count); OBD_ALLOC(lsm_new, newsize); if (lsm_new != NULL) { - memcpy(lsm_new, lsm, newsize); + int i; + memcpy(lsm_new, lsm, sizeof(*lsm)); + for (i = 0; i < lsm->lsm_stripe_count; i++) { + if (i < set->set_count) { + lsm_new->lsm_oinfo[i] = lsm->lsm_oinfo[i]; + continue; + } + OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab, + sizeof(struct lov_oinfo)); + } lsm_new->lsm_stripe_count = set->set_count; - OBD_FREE(lsm, oldsize); + OBD_FREE(lsm, sizeof(struct lov_stripe_md) + + lsm->lsm_stripe_count * sizeof(struct lov_oinfo *)); set->set_oi->oi_md = lsm_new; } else { - CWARN("'leaking' %d bytes\n", oldsize - newsize); + CWARN("'leaking' few bytes\n"); } } @@ -449,7 +459,7 @@ int qos_remedy_create(struct lov_request_set *set, struct lov_request *req) for (stripe = 0; stripe < lsm->lsm_stripe_count; stripe++) { if (stripe == req->rq_stripe) continue; - if (ost_idx == lsm->lsm_oinfo[stripe].loi_ost_idx) + if (ost_idx == lsm->lsm_oinfo[stripe]->loi_ost_idx) break; } @@ -533,7 +543,7 @@ static int alloc_specific(struct lov_obd *lov, struct lov_stripe_md *lsm, int i, *idx_pos = idx_arr; ENTRY; - ost_idx = lsm->lsm_oinfo[0].loi_ost_idx; + ost_idx = lsm->lsm_oinfo[0]->loi_ost_idx; for (i = 0; i < ost_count; i++, ost_idx = (ost_idx + 1) % ost_count) { if (!lov->lov_tgts[ost_idx] || !lov->lov_tgts[ost_idx]->ltd_active) { @@ -715,7 +725,7 @@ static int alloc_idx_array(struct obd_export *exp, struct lov_stripe_md *lsm, tmp_arr[i] = -1; if (newea || - lsm->lsm_oinfo[0].loi_ost_idx >= lov->desc.ld_tgt_count) + lsm->lsm_oinfo[0]->loi_ost_idx >= lov->desc.ld_tgt_count) rc = alloc_qos(exp, tmp_arr, &stripe_cnt); else rc = alloc_specific(lov, lsm, tmp_arr); diff --git a/lustre/lov/lov_request.c b/lustre/lov/lov_request.c index 8262a86..c7d96a9 100644 --- a/lustre/lov/lov_request.c +++ b/lustre/lov/lov_request.c @@ -126,7 +126,7 @@ int lov_update_enqueue_set(struct lov_request *req, __u32 mode, int rc) LASSERT(set->set_oi != NULL); lov_lockhp = set->set_lockh->llh_handles + req->rq_stripe; - loi = &set->set_oi->oi_md->lsm_oinfo[req->rq_stripe]; + loi = set->set_oi->oi_md->lsm_oinfo[req->rq_stripe]; /* XXX LOV STACKING: OSC gets a copy, created in lov_prep_enqueue_set * and that copy can be arbitrarily out of date. @@ -140,7 +140,7 @@ int lov_update_enqueue_set(struct lov_request *req, __u32 mode, int rc) LASSERT(lock != NULL); lov_stripe_lock(set->set_oi->oi_md); - loi->loi_lvb = req->rq_oi.oi_md->lsm_oinfo->loi_lvb; + loi->loi_lvb = req->rq_oi.oi_md->lsm_oinfo[0]->loi_lvb; tmp = loi->loi_lvb.lvb_size; /* Extend KMS up to the end of this lock and no further * A lock on [x,y] means a KMS of up to y + 1 bytes! */ @@ -164,7 +164,7 @@ int lov_update_enqueue_set(struct lov_request *req, __u32 mode, int rc) (set->set_ei->ei_flags & LDLM_FL_HAS_INTENT)) { memset(lov_lockhp, 0, sizeof(*lov_lockhp)); lov_stripe_lock(set->set_oi->oi_md); - loi->loi_lvb = req->rq_oi.oi_md->lsm_oinfo->loi_lvb; + loi->loi_lvb = req->rq_oi.oi_md->lsm_oinfo[0]->loi_lvb; lov_stripe_unlock(set->set_oi->oi_md); CDEBUG(D_INODE, "glimpsed, setting rss="LPU64"; leaving" " kms="LPU64"\n", loi->loi_lvb.lvb_size, loi->loi_kms); @@ -283,11 +283,11 @@ int lov_prep_enqueue_set(struct obd_export *exp, struct obd_info *oinfo, GOTO(out_set, rc = -ENOMEM); oinfo->oi_lockh->cookie = set->set_lockh->llh_handle.h_cookie; - loi = oinfo->oi_md->lsm_oinfo; - for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++, loi++) { + for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) { struct lov_request *req; obd_off start, end; + loi = oinfo->oi_md->lsm_oinfo[i]; if (!lov_stripe_intersects(oinfo->oi_md, i, oinfo->oi_policy.l_extent.start, oinfo->oi_policy.l_extent.end, @@ -305,12 +305,17 @@ int lov_prep_enqueue_set(struct obd_export *exp, struct obd_info *oinfo, GOTO(out_set, rc = -ENOMEM); req->rq_buflen = sizeof(*req->rq_oi.oi_md) + + sizeof(struct lov_oinfo *) + sizeof(struct lov_oinfo); OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen); if (req->rq_oi.oi_md == NULL) { OBD_FREE(req, sizeof(*req)); GOTO(out_set, rc = -ENOMEM); } + req->rq_oi.oi_md->lsm_oinfo[0] = + ((void *)req->rq_oi.oi_md) + sizeof(*req->rq_oi.oi_md) + + sizeof(struct lov_oinfo *); + req->rq_rqset = set; /* Set lov request specific parameters. */ @@ -330,10 +335,10 @@ int lov_prep_enqueue_set(struct obd_export *exp, struct obd_info *oinfo, /* XXX LOV STACKING: submd should be from the subobj */ req->rq_oi.oi_md->lsm_object_id = loi->loi_id; req->rq_oi.oi_md->lsm_stripe_count = 0; - req->rq_oi.oi_md->lsm_oinfo->loi_kms_valid = + req->rq_oi.oi_md->lsm_oinfo[0]->loi_kms_valid = loi->loi_kms_valid; - req->rq_oi.oi_md->lsm_oinfo->loi_kms = loi->loi_kms; - req->rq_oi.oi_md->lsm_oinfo->loi_lvb = loi->loi_lvb; + req->rq_oi.oi_md->lsm_oinfo[0]->loi_kms = loi->loi_kms; + req->rq_oi.oi_md->lsm_oinfo[0]->loi_lvb = loi->loi_lvb; lov_set_add_req(req, set); } @@ -403,10 +408,11 @@ int lov_prep_match_set(struct obd_export *exp, struct obd_info *oinfo, GOTO(out_set, rc = -ENOMEM); lockh->cookie = set->set_lockh->llh_handle.h_cookie; - for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++, loi++){ + for (i = 0; i < lsm->lsm_stripe_count; i++){ struct lov_request *req; obd_off start, end; + loi = lsm->lsm_oinfo[i]; if (!lov_stripe_intersects(lsm, i, policy->l_extent.start, policy->l_extent.end, &start, &end)) continue; @@ -494,10 +500,11 @@ int lov_prep_cancel_set(struct obd_export *exp, struct obd_info *oinfo, } lockh->cookie = set->set_lockh->llh_handle.h_cookie; - for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++, loi++){ + for (i = 0; i < lsm->lsm_stripe_count; i++){ struct lov_request *req; struct lustre_handle *lov_lockhp; + loi = lsm->lsm_oinfo[i]; lov_lockhp = set->set_lockh->llh_handles + i; if (!lustre_handle_is_used(lov_lockhp)) { CDEBUG(D_HA, "lov idx %d subobj "LPX64" no lock?\n", @@ -660,7 +667,7 @@ int lov_update_create_set(struct lov_request_set *set, ENTRY; req->rq_stripe = set->set_success; - loi = &lsm->lsm_oinfo[req->rq_stripe]; + loi = lsm->lsm_oinfo[req->rq_stripe]; if (rc && lov->lov_tgts[req->rq_idx] && lov->lov_tgts[req->rq_idx]->ltd_active) { @@ -780,7 +787,7 @@ static int brw_done(struct lov_request_set *set) if (!req->rq_complete || req->rq_rc) continue; - loi = &lsm->lsm_oinfo[req->rq_stripe]; + loi = lsm->lsm_oinfo[req->rq_stripe]; if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLBLOCKS) loi->loi_lvb.lvb_blocks = req->rq_oi.oi_oa->o_blocks; @@ -848,13 +855,13 @@ int lov_prep_brw_set(struct obd_export *exp, struct obd_info *oinfo, /* alloc and initialize lov request */ shift = 0; - for (i = 0, loi = oinfo->oi_md->lsm_oinfo; - i < oinfo->oi_md->lsm_stripe_count; i++, loi++){ + for (i = 0 ; i < oinfo->oi_md->lsm_stripe_count; i++){ struct lov_request *req; if (info[i].count == 0) continue; + loi = oinfo->oi_md->lsm_oinfo[i]; if (!lov->lov_tgts[loi->loi_ost_idx] || !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) { CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx); @@ -970,10 +977,10 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, set->set_exp = exp; set->set_oi = oinfo; - loi = oinfo->oi_md->lsm_oinfo; - for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++, loi++) { + for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) { struct lov_request *req; + loi = oinfo->oi_md->lsm_oinfo[i]; if (!lov->lov_tgts[loi->loi_ost_idx] || !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) { CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx); @@ -1049,10 +1056,10 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, if (oti != NULL && src_oa->o_valid & OBD_MD_FLCOOKIE) set->set_cookies = oti->oti_logcookies; - loi = lsm->lsm_oinfo; - for (i = 0; i < lsm->lsm_stripe_count; i++, loi++) { + for (i = 0; i < lsm->lsm_stripe_count; i++) { struct lov_request *req; + loi = lsm->lsm_oinfo[i]; if (!lov->lov_tgts[loi->loi_ost_idx] || !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) { CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx); @@ -1118,13 +1125,13 @@ int lov_update_setattr_set(struct lov_request_set *set, if (rc == 0) { if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLCTIME) - lsm->lsm_oinfo[req->rq_stripe].loi_lvb.lvb_ctime = + lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_ctime = req->rq_oi.oi_oa->o_ctime; if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLMTIME) - lsm->lsm_oinfo[req->rq_stripe].loi_lvb.lvb_mtime = + lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_mtime = req->rq_oi.oi_oa->o_mtime; if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLATIME) - lsm->lsm_oinfo[req->rq_stripe].loi_lvb.lvb_atime = + lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_atime = req->rq_oi.oi_oa->o_atime; } @@ -1161,10 +1168,10 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, if (oti != NULL && oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE) set->set_cookies = oti->oti_logcookies; - loi = oinfo->oi_md->lsm_oinfo; - for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++, loi++) { + for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) { struct lov_request *req; + loi = oinfo->oi_md->lsm_oinfo[i]; if (!lov->lov_tgts[loi->loi_ost_idx] || !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) { CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx); @@ -1249,7 +1256,7 @@ int lov_update_punch_set(struct lov_request_set *set, if (rc == 0) { lov_stripe_lock(lsm); if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLBLOCKS) { - lsm->lsm_oinfo[req->rq_stripe].loi_lvb.lvb_blocks = + lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_blocks = req->rq_oi.oi_oa->o_blocks; } @@ -1288,11 +1295,11 @@ int lov_prep_punch_set(struct obd_export *exp, struct obd_info *oinfo, set->set_oi = oinfo; set->set_exp = exp; - loi = oinfo->oi_md->lsm_oinfo; - for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++, loi++) { + for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) { struct lov_request *req; obd_off rs, re; + loi = oinfo->oi_md->lsm_oinfo[i]; if (!lov->lov_tgts[loi->loi_ost_idx] || !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) { CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx); @@ -1379,11 +1386,11 @@ int lov_prep_sync_set(struct obd_export *exp, struct obd_info *oinfo, set->set_oi->oi_md = lsm; set->set_oi->oi_oa = src_oa; - loi = lsm->lsm_oinfo; - for (i = 0; i < lsm->lsm_stripe_count; i++, loi++) { + for (i = 0; i < lsm->lsm_stripe_count; i++) { struct lov_request *req; obd_off rs, re; + loi = lsm->lsm_oinfo[i]; if (!lov->lov_tgts[loi->loi_ost_idx] || !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) { CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx); diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 26192b4..83f4ab9 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -75,17 +75,23 @@ echo_find_object_locked (struct obd_device *obd, obd_id id) } static int -echo_copyout_lsm (struct lov_stripe_md *lsm, void *ulsm, int ulsm_nob) +echo_copyout_lsm (struct lov_stripe_md *lsm, void *_ulsm, int ulsm_nob) { - int nob; + struct lov_stripe_md *ulsm = _ulsm; + int nob, i; nob = offsetof (struct lov_stripe_md, lsm_oinfo[lsm->lsm_stripe_count]); if (nob > ulsm_nob) return (-EINVAL); - if (copy_to_user (ulsm, lsm, nob)) + if (copy_to_user (ulsm, lsm, sizeof(ulsm))) return (-EFAULT); + for (i = 0; i < lsm->lsm_stripe_count; i++) { + if (copy_to_user (ulsm->lsm_oinfo[i], lsm->lsm_oinfo[i], + sizeof(lsm->lsm_oinfo[0]))) + return (-EFAULT); + } return (0); } @@ -94,7 +100,7 @@ echo_copyin_lsm (struct obd_device *obd, struct lov_stripe_md *lsm, void *ulsm, int ulsm_nob) { struct echo_client_obd *ec = &obd->u.echo_client; - int nob; + int i; if (ulsm_nob < sizeof (*lsm)) return (-EINVAL); @@ -102,18 +108,18 @@ echo_copyin_lsm (struct obd_device *obd, struct lov_stripe_md *lsm, if (copy_from_user (lsm, ulsm, sizeof (*lsm))) return (-EFAULT); - nob = lsm->lsm_stripe_count * sizeof (lsm->lsm_oinfo[0]); - - if (ulsm_nob < nob || - lsm->lsm_stripe_count > ec->ec_nstripes || + if (lsm->lsm_stripe_count > ec->ec_nstripes || lsm->lsm_magic != LOV_MAGIC || (lsm->lsm_stripe_size & (~CFS_PAGE_MASK)) != 0 || ((__u64)lsm->lsm_stripe_size * lsm->lsm_stripe_count > ~0UL)) return (-EINVAL); - if (copy_from_user(lsm->lsm_oinfo, - ((struct lov_stripe_md *)ulsm)->lsm_oinfo, nob)) - return (-EFAULT); + for (i = 0; i < lsm->lsm_stripe_count; i++) { + if (copy_from_user(lsm->lsm_oinfo[i], + ((struct lov_stripe_md *)ulsm)->lsm_oinfo[i], + sizeof(lsm->lsm_oinfo[0]))) + return (-EFAULT); + } return (0); } @@ -201,10 +207,10 @@ static int echo_create_object(struct obd_device *obd, int on_target, /* setup stripes: indices + default ids if required */ for (i = 0; i < lsm->lsm_stripe_count; i++) { - if (lsm->lsm_oinfo[i].loi_id == 0) - lsm->lsm_oinfo[i].loi_id = lsm->lsm_object_id; + if (lsm->lsm_oinfo[i]->loi_id == 0) + lsm->lsm_oinfo[i]->loi_id = lsm->lsm_object_id; - lsm->lsm_oinfo[i].loi_ost_idx = + lsm->lsm_oinfo[i]->loi_ost_idx = (idx + i) % ec->ec_nstripes; } } else { @@ -257,7 +263,7 @@ static int echo_create_object(struct obd_device *obd, int on_target, eco, eco->eco_id, eco->eco_lsm->lsm_stripe_size, eco->eco_lsm->lsm_stripe_count, - eco->eco_lsm->lsm_oinfo[0].loi_ost_idx, + eco->eco_lsm->lsm_oinfo[0]->loi_ost_idx, eco->eco_refcount, eco->eco_deleted); return (0); @@ -300,7 +306,7 @@ echo_get_object (struct ec_object **ecop, struct obd_device *obd, eco, eco->eco_id, eco->eco_lsm->lsm_stripe_size, eco->eco_lsm->lsm_stripe_count, - eco->eco_lsm->lsm_oinfo[0].loi_ost_idx, + eco->eco_lsm->lsm_oinfo[0]->loi_ost_idx, eco->eco_refcount, eco->eco_deleted); return (0); } @@ -328,7 +334,7 @@ echo_get_object (struct ec_object **ecop, struct obd_device *obd, eco, eco->eco_id, eco->eco_lsm->lsm_stripe_size, eco->eco_lsm->lsm_stripe_count, - eco->eco_lsm->lsm_oinfo[0].loi_ost_idx, + eco->eco_lsm->lsm_oinfo[0]->loi_ost_idx, eco->eco_refcount, eco->eco_deleted); return (0); } @@ -345,7 +351,7 @@ echo_get_object (struct ec_object **ecop, struct obd_device *obd, eco2, eco2->eco_id, eco2->eco_lsm->lsm_stripe_size, eco2->eco_lsm->lsm_stripe_count, - eco2->eco_lsm->lsm_oinfo[0].loi_ost_idx, + eco2->eco_lsm->lsm_oinfo[0]->loi_ost_idx, eco2->eco_refcount, eco2->eco_deleted); } @@ -374,7 +380,7 @@ echo_put_object (struct ec_object *eco) eco, eco->eco_id, eco->eco_lsm->lsm_stripe_size, eco->eco_lsm->lsm_stripe_count, - eco->eco_lsm->lsm_oinfo[0].loi_ost_idx, + eco->eco_lsm->lsm_oinfo[0]->loi_ost_idx, eco->eco_refcount, eco->eco_deleted); if (eco->eco_refcount != 0 || !eco->eco_deleted) { @@ -425,7 +431,7 @@ echo_get_stripe_off_id (struct lov_stripe_md *lsm, obd_off *offp, obd_id *idp) stripe_index = woffset / stripe_size; - *idp = lsm->lsm_oinfo[stripe_index].loi_id; + *idp = lsm->lsm_oinfo[stripe_index]->loi_id; *offp = offset * stripe_size + woffset % stripe_size; } diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 71cb1cf..6501b60 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -2561,6 +2561,7 @@ static int filter_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, RETURN(lsm_size); if (*lsmp != NULL && lmm == NULL) { + OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); OBD_FREE(*lsmp, lsm_size); *lsmp = NULL; RETURN(0); @@ -2570,8 +2571,12 @@ static int filter_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, OBD_ALLOC(*lsmp, lsm_size); if (*lsmp == NULL) RETURN(-ENOMEM); - - loi_init((*lsmp)->lsm_oinfo); + OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); + if ((*lsmp)->lsm_oinfo[0] == NULL) { + OBD_FREE(*lsmp, lsm_size); + RETURN(-ENOMEM); + } + loi_init((*lsmp)->lsm_oinfo[0]); } if (lmm != NULL) { diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 3583f18..dca0fd9 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -123,6 +123,7 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, RETURN(lsm_size); if (*lsmp != NULL && lmm == NULL) { + OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); OBD_FREE(*lsmp, lsm_size); *lsmp = NULL; RETURN(0); @@ -132,7 +133,12 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, OBD_ALLOC(*lsmp, lsm_size); if (*lsmp == NULL) RETURN(-ENOMEM); - loi_init((*lsmp)->lsm_oinfo); + OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); + if ((*lsmp)->lsm_oinfo[0] == NULL) { + OBD_FREE(*lsmp, lsm_size); + RETURN(-ENOMEM); + } + loi_init((*lsmp)->lsm_oinfo[0]); } if (lmm != NULL) { @@ -2356,7 +2362,7 @@ static int osc_queue_async_io(struct obd_export *exp, struct lov_stripe_md *lsm, #endif if (loi == NULL) - loi = &lsm->lsm_oinfo[0]; + loi = lsm->lsm_oinfo[0]; client_obd_list_lock(&cli->cl_loi_list_lock); @@ -2418,7 +2424,7 @@ static int osc_set_async_flags(struct obd_export *exp, RETURN(-EIO); if (loi == NULL) - loi = &lsm->lsm_oinfo[0]; + loi = lsm->lsm_oinfo[0]; if (oap->oap_cmd & OBD_BRW_WRITE) { lop = &loi->loi_write_lop; @@ -2478,7 +2484,7 @@ static int osc_queue_group_io(struct obd_export *exp, struct lov_stripe_md *lsm, RETURN(-EBUSY); if (loi == NULL) - loi = &lsm->lsm_oinfo[0]; + loi = lsm->lsm_oinfo[0]; client_obd_list_lock(&cli->cl_loi_list_lock); @@ -2530,7 +2536,7 @@ static int osc_trigger_group_io(struct obd_export *exp, ENTRY; if (loi == NULL) - loi = &lsm->lsm_oinfo[0]; + loi = lsm->lsm_oinfo[0]; client_obd_list_lock(&cli->cl_loi_list_lock); @@ -2558,7 +2564,7 @@ static int osc_teardown_async_page(struct obd_export *exp, RETURN(PTR_ERR(oap)); if (loi == NULL) - loi = &lsm->lsm_oinfo[0]; + loi = lsm->lsm_oinfo[0]; if (oap->oap_cmd & OBD_BRW_WRITE) { lop = &loi->loi_write_lop; @@ -2655,9 +2661,9 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct obd_info *oinfo, if ((intent && rc == ELDLM_LOCK_ABORTED) || !rc) { CDEBUG(D_INODE,"got kms "LPU64" blocks "LPU64" mtime "LPU64"\n", - oinfo->oi_md->lsm_oinfo->loi_lvb.lvb_size, - oinfo->oi_md->lsm_oinfo->loi_lvb.lvb_blocks, - oinfo->oi_md->lsm_oinfo->loi_lvb.lvb_mtime); + oinfo->oi_md->lsm_oinfo[0]->loi_lvb.lvb_size, + oinfo->oi_md->lsm_oinfo[0]->loi_lvb.lvb_blocks, + oinfo->oi_md->lsm_oinfo[0]->loi_lvb.lvb_mtime); } /* Call the update callback. */ @@ -2680,8 +2686,8 @@ static int osc_enqueue_interpret(struct ptlrpc_request *req, rc = ldlm_cli_enqueue_fini(aa->oa_exp, req, aa->oa_ei->ei_type, 1, aa->oa_ei->ei_mode, &aa->oa_ei->ei_flags, - &lsm->lsm_oinfo->loi_lvb, - sizeof(lsm->lsm_oinfo->loi_lvb), + &lsm->lsm_oinfo[0]->loi_lvb, + sizeof(lsm->lsm_oinfo[0]->loi_lvb), lustre_swab_ost_lvb, aa->oa_oi->oi_lockh, rc); @@ -2722,7 +2728,7 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, oinfo->oi_policy.l_extent.start & ~CFS_PAGE_MASK; oinfo->oi_policy.l_extent.end |= ~CFS_PAGE_MASK; - if (oinfo->oi_md->lsm_oinfo->loi_kms_valid == 0) + if (oinfo->oi_md->lsm_oinfo[0]->loi_kms_valid == 0) goto no_match; /* Next, search for already existing extent locks that will cover us */ @@ -2793,7 +2799,7 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, size[DLM_LOCKREPLY_OFF] = sizeof(*rep); size[DLM_REPLY_REC_OFF] = - sizeof(oinfo->oi_md->lsm_oinfo->loi_lvb); + sizeof(oinfo->oi_md->lsm_oinfo[0]->loi_lvb); ptlrpc_req_set_repsize(req, 3, size); } @@ -2805,8 +2811,8 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, &einfo->ei_flags, einfo->ei_cb_bl, einfo->ei_cb_cp, einfo->ei_cb_gl, einfo->ei_cbdata, - &oinfo->oi_md->lsm_oinfo->loi_lvb, - sizeof(oinfo->oi_md->lsm_oinfo->loi_lvb), + &oinfo->oi_md->lsm_oinfo[0]->loi_lvb, + sizeof(oinfo->oi_md->lsm_oinfo[0]->loi_lvb), lustre_swab_ost_lvb, oinfo->oi_lockh, einfo->ei_rqset ? 1 : 0); if (einfo->ei_rqset) { diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 250f652..1172383 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -95,9 +95,13 @@ static int max = sizeof(rawbuf); static int cur_device = -1; -union lsm_buffer { - char space [4096]; + +#define MAX_STRIPES 170 +struct lov_oinfo lov_oinfos[MAX_STRIPES]; + +struct lsm_buffer { struct lov_stripe_md lsm; + struct lov_oinfo *ptrs[MAX_STRIPES]; } lsm_buffer; static int l2_ioctl(int dev_id, int opc, void *buf) @@ -256,14 +260,15 @@ int parse_devname(char *func, char *name) } static void -reset_lsmb (union lsm_buffer *lsmb) +reset_lsmb (struct lsm_buffer *lsmb) { - memset (lsmb->space, 0, sizeof (lsmb->space)); + memset (&lsmb->lsm, 0, sizeof (lsmb->lsm)); + memset(lov_oinfos, 0, sizeof(lov_oinfos)); lsmb->lsm.lsm_magic = LOV_MAGIC; } static int -parse_lsm (union lsm_buffer *lsmb, char *string) +parse_lsm (struct lsm_buffer *lsmb, char *string) { struct lov_stripe_md *lsm = &lsmb->lsm; char *end; @@ -308,11 +313,11 @@ parse_lsm (union lsm_buffer *lsmb, char *string) if (*string != '@') return (-1); string++; - lsm->lsm_oinfo[i].loi_ost_idx = strtoul(string, &end, 0); + lsm->lsm_oinfo[i]->loi_ost_idx = strtoul(string, &end, 0); if (*end != ':') return (-1); string = end + 1; - lsm->lsm_oinfo[i].loi_id = strtoull(string, &end, 0); + lsm->lsm_oinfo[i]->loi_id = strtoull(string, &end, 0); string = end; } @@ -2035,6 +2040,11 @@ static void signal_server(int sig) int obd_initialize(int argc, char **argv) { + int i; + + for (i = 0; i < MAX_STRIPES; i++) + lsm_buffer.lsm.lsm_oinfo[i] = lov_oinfos + i; + shmem_setup(); register_ioc_dev(OBD_DEV_ID, OBD_DEV_PATH, OBD_DEV_MAJOR, OBD_DEV_MINOR); -- 1.8.3.1