From: shadow Date: Fri, 22 Feb 2008 13:11:35 +0000 (+0000) Subject: Implement get_info(last_id) in obdfilter. X-Git-Tag: v1_7_0_51~216 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=4b809256159c6ce7a9a7f8e9a73be51e9ace9dd8;p=fs%2Flustre-release.git Implement get_info(last_id) in obdfilter. b=14884 i=adilger i=umka --- diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 0c16ad4..ffe4380 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -12,6 +12,11 @@ tbd Sun Microsystems, Inc. * RHEL 4 and RHEL 5/SLES 10 clients behaves differently on 'cd' to a removed cwd "./" (refer to Bugzilla 14399). +Severity : major +Frequency : on start mds +Bugzilla : 14884 +Description: Implement get_info(last_id) in obdfilter. + Severity : normal Frequency : occasional Bugzilla : 13537 diff --git a/lustre/include/lustre_req_layout.h b/lustre/include/lustre_req_layout.h index 4c88a6b..d395309 100644 --- a/lustre/include/lustre_req_layout.h +++ b/lustre/include/lustre_req_layout.h @@ -172,7 +172,8 @@ extern const struct req_format RQF_OST_DESTROY; extern const struct req_format RQF_OST_BRW; extern const struct req_format RQF_OST_STATFS; extern const struct req_format RQF_OST_SET_INFO; -extern const struct req_format RQF_OST_GET_INFO; +extern const struct req_format RQF_OST_GET_INFO_GENERIC; +extern const struct req_format RQF_OST_GET_INFO_LAST_ID; /* LDLM req_format */ extern const struct req_format RQF_LDLM_ENQUEUE; @@ -198,6 +199,7 @@ extern const struct req_format RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK; extern const struct req_format RQF_LLOG_ORIGIN_HANDLE_READ_HEADER; extern const struct req_format RQF_LLOG_ORIGIN_CONNECT; +extern const struct req_msg_field RMF_GENERIC_DATA; extern const struct req_msg_field RMF_PTLRPC_BODY; extern const struct req_msg_field RMF_MDT_BODY; extern const struct req_msg_field RMF_MDT_EPOCH; diff --git a/lustre/include/obd.h b/lustre/include/obd.h index b325680..fef125f 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -988,6 +988,9 @@ enum obd_cleanup_stage { #define KEY_REVIMP_UPD "revimp_update" #define KEY_LOV_IDX "lov_idx" #define KEY_LAST_ID "last_id" +#define KEY_LOCK_TO_STRIPE "lock_to_stripe" +#define KEY_BLOCKSIZE "blocksize" +#define KEY_BLOCKSIZE_BITS "blocksize_bits" struct lu_context; diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index f15ede2..844fc68 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -2374,7 +2374,7 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen, lov_getref(obddev); - if (KEY_IS("lock_to_stripe")) { + if (KEY_IS(KEY_LOCK_TO_STRIPE)) { struct { char name[16]; struct ldlm_lock *lock; diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index 9846d22..79bc5fc 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -266,7 +266,7 @@ int mds_lov_write_objids(struct obd_device *obd) } EXPORT_SYMBOL(mds_lov_write_objids); -static int mds_lov_get_objid(struct obd_device * obd, struct obd_export *export, +static int mds_lov_get_objid(struct obd_device * obd, __u32 idx) { struct mds_obd *mds = &obd->u.mds; @@ -294,7 +294,7 @@ static int mds_lov_get_objid(struct obd_device * obd, struct obd_export *export, lastid.idx = idx; lastid.data = &data[off]; - rc = obd_get_info(export, sizeof(KEY_LAST_ID), + rc = obd_get_info(mds->mds_osc_exp, sizeof(KEY_LAST_ID), KEY_LAST_ID, &size, &lastid); if (rc) GOTO(out, rc); @@ -351,7 +351,6 @@ static int mds_lov_set_one_nextid(struct obd_device *obd, __u32 idx, obd_id *id) info.idx = idx; info.data = id; - rc = obd_set_info_async(mds->mds_osc_exp, sizeof(KEY_NEXT_ID), KEY_NEXT_ID, sizeof(info), &info, NULL); if (rc) @@ -380,7 +379,7 @@ static int mds_lov_update_desc(struct obd_device *obd, struct obd_export *lov) struct mds_obd *mds = &obd->u.mds; struct lov_desc *ld; __u32 stripes, valsize = sizeof(mds->mds_lov_desc); - int page, rc = 0; + int rc = 0; ENTRY; OBD_ALLOC(ld, sizeof(*ld)); @@ -392,18 +391,6 @@ static int mds_lov_update_desc(struct obd_device *obd, struct obd_export *lov) if (rc) GOTO(out, rc); - /* The size of the LOV target table may have increased. */ - page = ld->ld_tgt_count / OBJID_PER_PAGE(); - if (mds->mds_lov_page_array[page] == NULL) { - obd_id *ids; - - OBD_ALLOC(ids, MDS_LOV_ALLOC_SIZE); - if (ids == NULL) - GOTO(out, rc = -ENOMEM); - - mds->mds_lov_page_array[page] = ids; - } - /* Don't change the mds_lov_desc until the objids size matches the count (paranoia) */ mds->mds_lov_desc = *ld; @@ -441,10 +428,9 @@ out: /* Inform MDS about new/updated target */ static int mds_lov_update_mds(struct obd_device *obd, struct obd_device *watched, - __u32 idx, struct obd_uuid *uuid) + __u32 idx) { struct mds_obd *mds = &obd->u.mds; - __u32 old_count; int rc = 0; int page; int off; @@ -455,37 +441,32 @@ static int mds_lov_update_mds(struct obd_device *obd, /* Don't let anyone else mess with mds_lov_objids now */ mutex_down(&obd->obd_dev_sem); - old_count = mds->mds_lov_desc.ld_tgt_count; rc = mds_lov_update_desc(obd, mds->mds_osc_exp); if (rc) GOTO(out, rc); - CDEBUG(D_CONFIG, "idx=%d, recov=%d/%d, cnt=%d/%d\n", - idx, obd->obd_recovering, obd->obd_async_recov, old_count, + CDEBUG(D_CONFIG, "idx=%d, recov=%d/%d, cnt=%d\n", + idx, obd->obd_recovering, obd->obd_async_recov, mds->mds_lov_desc.ld_tgt_count); /* idx is set as data from lov_notify. */ if (obd->obd_recovering) GOTO(out, rc); - /* mds post recov not know about ost index - ask lov for it */ - if (idx == MDSLOV_NO_INDEX) - idx = mds_lov_get_idx(mds->mds_osc_exp, uuid); - if (idx >= mds->mds_lov_desc.ld_tgt_count) { CERROR("index %d > count %d!\n", idx, mds->mds_lov_desc.ld_tgt_count); GOTO(out, rc = -EINVAL); } + rc = mds_lov_get_objid(obd, idx); + if (rc) + GOTO(out, rc); + page = idx / OBJID_PER_PAGE(); off = idx % OBJID_PER_PAGE(); data = mds->mds_lov_page_array[page]; - CDEBUG(D_CONFIG, "idx %d - %p - %d/%d\n", idx, data, page, off); - if (data[off] == 0) { - rc = mds_lov_get_objid(obd, watched->obd_self_export, idx); - } /* We have read this lastid from disk; tell the osc. Don't call this during recovery. */ rc = mds_lov_set_one_nextid(obd, idx, &data[off]); @@ -493,10 +474,10 @@ static int mds_lov_update_mds(struct obd_device *obd, CERROR("Failed to set next id, idx=%d rc=%d\n", idx,rc); /* Don't abort the rest of the sync */ rc = 0; + } else { + CDEBUG(D_CONFIG, "last object "LPU64" from OST %d rc=%d\n", + data[off], idx, rc); } - - CDEBUG(D_CONFIG, "last object "LPU64" from OST %d rc=%d\n", - data[off], idx, rc); out: mutex_up(&obd->obd_dev_sem); RETURN(rc); @@ -571,7 +552,7 @@ int mds_lov_connect(struct obd_device *obd, char * lov_name) if (mds->mds_lov_desc.ld_tgt_count > mds->mds_lov_objid_count) { __u32 i = mds->mds_lov_objid_count; for(; i <= mds->mds_lov_desc.ld_tgt_count; i++) { - rc = mds_lov_get_objid(obd, mds->mds_osc_exp, i); + rc = mds_lov_get_objid(obd, i); if (rc != 0) break; } @@ -893,18 +874,17 @@ static int __mds_lov_synchronize(void *data) OBD_RACE(OBD_FAIL_MDS_LOV_SYNC_RACE); - rc = mds_lov_update_mds(obd, watched, idx, uuid); + rc = mds_lov_update_mds(obd, watched, idx); if (rc != 0) { CERROR("%s failed at update_mds: %d\n", obd_uuid2str(uuid), rc); GOTO(out, rc); } + mgi.group = FILTER_GROUP_MDS0 + mds->mds_id; mgi.uuid = uuid; rc = obd_set_info_async(mds->mds_osc_exp, sizeof(KEY_MDS_CONN), KEY_MDS_CONN, sizeof(mgi), &mgi, NULL); - if (rc != 0) - GOTO(out, rc); /* propagate capability keys */ rc = mds_propagate_capa_keys(mds); @@ -967,12 +947,7 @@ int mds_lov_synchronize(void *data) struct mds_lov_sync_info *mlsi = data; char name[20]; - if (mlsi->mlsi_index == MDSLOV_NO_INDEX) - /* There is still a watched target, - but we don't know its index */ - sprintf(name, "ll_sync_tgt"); - else - snprintf(name, sizeof(name), "ll_sync_%02u", mlsi->mlsi_index); + snprintf(name, sizeof(name), "ll_sync_%02u", mlsi->mlsi_index); ptlrpc_daemonize(name); RETURN(__mds_lov_synchronize(data)); @@ -984,10 +959,12 @@ int mds_lov_start_synchronize(struct obd_device *obd, { struct mds_lov_sync_info *mlsi; int rc; - + struct mds_obd *mds = &obd->u.mds; + struct obd_uuid *uuid; ENTRY; LASSERT(watched); + uuid = &watched->u.cli.cl_target_uuid; OBD_ALLOC(mlsi, sizeof(*mlsi)); if (mlsi == NULL) @@ -998,7 +975,7 @@ int mds_lov_start_synchronize(struct obd_device *obd, if (data) mlsi->mlsi_index = *(__u32 *)data; else - mlsi->mlsi_index = MDSLOV_NO_INDEX; + mlsi->mlsi_index = mds_lov_get_idx(mds->mds_osc_exp, uuid); /* Although class_export_get(obd->obd_self_export) would lock the MDS in place, since it's only a self-export diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index fdebc42..053c10f 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -3861,7 +3861,8 @@ static int filter_get_info(struct obd_export *exp, __u32 keylen, if (last_id) { if (*vallen < sizeof(*last_id)) RETURN(-EOVERFLOW); - *last_id = filter_last_id(&obd->u.filter, 0); + *last_id = filter_last_id(&obd->u.filter, + exp->exp_filter_data.fed_group); } *vallen = sizeof(*last_id); RETURN(0); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index f89cb19..853d6f3 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -3389,19 +3389,19 @@ static int osc_get_info(struct obd_export *exp, obd_count keylen, if (!vallen || !val) RETURN(-EFAULT); - if (KEY_IS("lock_to_stripe")) { + if (KEY_IS(KEY_LOCK_TO_STRIPE)) { __u32 *stripe = val; *vallen = sizeof(*stripe); *stripe = 0; RETURN(0); - } else if (KEY_IS("last_id")) { + } else if (KEY_IS(KEY_LAST_ID)) { struct ptlrpc_request *req; obd_id *reply; char *tmp; int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), - &RQF_OST_GET_INFO); + &RQF_OST_GET_INFO_LAST_ID); if (req == NULL) RETURN(-ENOMEM); @@ -3414,11 +3414,8 @@ static int osc_get_info(struct obd_export *exp, obd_count keylen, } tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY); - LASSERT(tmp); memcpy(tmp, key, keylen); - req_capsule_set_size(&req->rq_pill, &RMF_OBD_ID, - RCL_SERVER, *vallen); ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); if (rc) @@ -3479,6 +3476,8 @@ static int osc_set_info_async(struct obd_export *exp, obd_count keylen, if (KEY_IS(KEY_NEXT_ID)) { if (vallen != sizeof(obd_id)) + RETURN(-ERANGE); + if (val == NULL) RETURN(-EINVAL); obd->u.cli.cl_oscc.oscc_next_id = *((obd_id*)val) + 1; CDEBUG(D_HA, "%s: set oscc_next_id = "LPU64"\n", diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index c0c84e6..419a846 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -1268,31 +1268,39 @@ out: static int ost_get_info(struct obd_export *exp, struct ptlrpc_request *req) { void *key, *reply; - int keylen, rc = 0; - int size[2] = { sizeof(struct ptlrpc_body), 0 }; + int keylen, replylen, rc = 0; + struct req_capsule *pill = &req->rq_pill; ENTRY; - key = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, 1); + req_capsule_set(&req->rq_pill, &RQF_OST_GET_INFO_GENERIC); + + /* this common part for get_info rpc */ + key = req_capsule_client_get(pill, &RMF_SETINFO_KEY); if (key == NULL) { DEBUG_REQ(D_HA, req, "no get_info key"); RETURN(-EFAULT); } - keylen = lustre_msg_buflen(req->rq_reqmsg, REQ_REC_OFF); + keylen = req_capsule_get_size(pill, &RMF_SETINFO_KEY, RCL_CLIENT); - /* call once to get the size to allocate the reply buffer */ - rc = obd_get_info(exp, keylen, key, &size[1], NULL); + rc = obd_get_info(exp, keylen, key, &replylen, NULL); if (rc) RETURN(rc); - rc = lustre_pack_reply(req, 2, size, NULL); + req_capsule_set_size(pill, &RMF_GENERIC_DATA, + RCL_SERVER, replylen); + + rc = req_capsule_server_pack(pill); if (rc) RETURN(rc); - reply = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*reply)); + reply = req_capsule_server_get(pill, &RMF_GENERIC_DATA); + if (reply == NULL) + RETURN(-ENOMEM); + /* call again to fill in the reply buffer */ - rc = obd_get_info(exp, keylen, key, size, reply); - lustre_msg_set_status(req->rq_repmsg, 0); + rc = obd_get_info(exp, keylen, key, &replylen, reply); + lustre_msg_set_status(req->rq_repmsg, 0); RETURN(rc); } @@ -1654,6 +1662,7 @@ int ost_handle(struct ptlrpc_request *req) break; case OST_SET_INFO: DEBUG_REQ(D_INODE, req, "set_info"); + req_capsule_set(&req->rq_pill, &RQF_OST_SET_INFO); rc = ost_set_info(req->rq_export, req); break; case OST_GET_INFO: diff --git a/lustre/ptlrpc/layout.c b/lustre/ptlrpc/layout.c index 89ffe05..06b270f 100644 --- a/lustre/ptlrpc/layout.c +++ b/lustre/ptlrpc/layout.c @@ -475,15 +475,21 @@ static const struct req_msg_field *ost_set_info_client[] = { &RMF_SETINFO_VAL }; -static const struct req_msg_field *ost_get_info_client[] = { +static const struct req_msg_field *ost_get_info_generic_server[] = { + &RMF_PTLRPC_BODY, + &RMF_GENERIC_DATA, +}; + +static const struct req_msg_field *ost_get_info_generic_client[] = { &RMF_PTLRPC_BODY, &RMF_SETINFO_KEY }; -static const struct req_msg_field *ost_get_info_server[] = { +static const struct req_msg_field *ost_get_last_id_server[] = { &RMF_PTLRPC_BODY, &RMF_OBD_ID }; + static const struct req_format *req_formats[] = { &RQF_OBD_PING, &RQF_SEC_CTX, @@ -534,7 +540,8 @@ static const struct req_format *req_formats[] = { &RQF_OST_BRW, &RQF_OST_STATFS, &RQF_OST_SET_INFO, - &RQF_OST_GET_INFO, + &RQF_OST_GET_INFO_GENERIC, + &RQF_OST_GET_INFO_LAST_ID, &RQF_LDLM_ENQUEUE, &RQF_LDLM_ENQUEUE_LVB, &RQF_LDLM_CONVERT, @@ -585,6 +592,11 @@ struct req_capsule; .rmf_swabber = (void (*)(void*))(swabber) \ } +const struct req_msg_field RMF_GENERIC_DATA = + DEFINE_MSGF("generic_data", 0, + -1, NULL); +EXPORT_SYMBOL(RMF_GENERIC_DATA); + const struct req_msg_field RMF_MGS_TARGET_INFO = DEFINE_MSGF("mgs_target_info", 0, sizeof(struct mgs_target_info), @@ -1136,10 +1148,15 @@ const struct req_format RQF_OST_SET_INFO = DEFINE_REQ_FMT0("OST_SET_INFO", ost_set_info_client, empty); EXPORT_SYMBOL(RQF_OST_SET_INFO); -const struct req_format RQF_OST_GET_INFO = - DEFINE_REQ_FMT0("OST_GET_INFO", ost_get_info_client, - ost_get_info_server); -EXPORT_SYMBOL(RQF_OST_GET_INFO); +const struct req_format RQF_OST_GET_INFO_GENERIC = + DEFINE_REQ_FMT0("OST_GET_INFO", ost_get_info_generic_client, + ost_get_info_generic_server); +EXPORT_SYMBOL(RQF_OST_GET_INFO_GENERIC); + +const struct req_format RQF_OST_GET_INFO_LAST_ID = + DEFINE_REQ_FMT0("OST_GET_INFO_LAST_ID", ost_get_info_generic_client, + ost_get_last_id_server); +EXPORT_SYMBOL(RQF_OST_GET_INFO_LAST_ID); #if !defined(__REQ_LAYOUT_USER__) diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 46fd955..810e874 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -1459,8 +1459,7 @@ test_38() { # bug 14222 done do_facet mds "debugfs -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV" do_facet mds "od -Ax -td8 $TMP/lov_objid.new" - [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true - + [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true # check it's updates in sync umount_client $MOUNT