diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/osc/osc_request.c')
-rw-r--r-- | drivers/staging/lustre/lustre/osc/osc_request.c | 635 |
1 files changed, 182 insertions, 453 deletions
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index fb0d9fb9cebc..44657a06b8a5 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -43,18 +43,58 @@ #include "../include/lustre_net.h" #include "../include/lustre/lustre_user.h" #include "../include/obd_cksum.h" -#include "../include/obd_ost.h" #include "../include/lustre_ha.h" #include "../include/lprocfs_status.h" -#include "../include/lustre_log.h" #include "../include/lustre_debug.h" #include "../include/lustre_param.h" #include "../include/lustre_fid.h" +#include "../include/obd_class.h" #include "osc_internal.h" #include "osc_cl_internal.h" -static void osc_release_ppga(struct brw_page **ppga, obd_count count); +struct osc_brw_async_args { + struct obdo *aa_oa; + int aa_requested_nob; + int aa_nio_count; + u32 aa_page_count; + int aa_resends; + struct brw_page **aa_ppga; + struct client_obd *aa_cli; + struct list_head aa_oaps; + struct list_head aa_exts; + struct obd_capa *aa_ocapa; + struct cl_req *aa_clerq; +}; + +struct osc_async_args { + struct obd_info *aa_oi; +}; + +struct osc_setattr_args { + struct obdo *sa_oa; + obd_enqueue_update_f sa_upcall; + void *sa_cookie; +}; + +struct osc_fsync_args { + struct obd_info *fa_oi; + obd_enqueue_update_f fa_upcall; + void *fa_cookie; +}; + +struct osc_enqueue_args { + struct obd_export *oa_exp; + __u64 *oa_flags; + obd_enqueue_update_f oa_upcall; + void *oa_cookie; + struct ost_lvb *oa_lvb; + struct lustre_handle *oa_lockh; + struct ldlm_enqueue_info *oa_ei; + unsigned int oa_agl:1; +}; + +static void osc_release_ppga(struct brw_page **ppga, u32 count); static int brw_interpret(const struct lu_env *env, struct ptlrpc_request *req, void *data, int rc); int osc_cleanup(struct obd_device *obd); @@ -197,7 +237,7 @@ static int osc_getattr_interpret(const struct lu_env *env, struct ost_body *body; if (rc != 0) - GOTO(out, rc); + goto out; body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); if (body) { @@ -273,11 +313,13 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, rc = ptlrpc_queue_wait(req); if (rc) - GOTO(out, rc); + goto out; body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); - if (body == NULL) - GOTO(out, rc = -EPROTO); + if (body == NULL) { + rc = -EPROTO; + goto out; + } CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode); lustre_get_wire_obdo(&req->rq_import->imp_connect_data, oinfo->oi_oa, @@ -317,11 +359,13 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, rc = ptlrpc_queue_wait(req); if (rc) - GOTO(out, rc); + goto out; body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); - if (body == NULL) - GOTO(out, rc = -EPROTO); + if (body == NULL) { + rc = -EPROTO; + goto out; + } lustre_get_wire_obdo(&req->rq_import->imp_connect_data, oinfo->oi_oa, &body->oa); @@ -338,11 +382,13 @@ static int osc_setattr_interpret(const struct lu_env *env, struct ost_body *body; if (rc != 0) - GOTO(out, rc); + goto out; body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); - if (body == NULL) - GOTO(out, rc = -EPROTO); + if (body == NULL) { + rc = -EPROTO; + goto out; + } lustre_get_wire_obdo(&req->rq_import->imp_connect_data, sa->sa_oa, &body->oa); @@ -428,13 +474,15 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, } req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_CREATE); - if (req == NULL) - GOTO(out, rc = -ENOMEM); + if (req == NULL) { + rc = -ENOMEM; + goto out; + } rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_CREATE); if (rc) { ptlrpc_request_free(req); - GOTO(out, rc); + goto out; } body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY); @@ -454,11 +502,13 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, rc = ptlrpc_queue_wait(req); if (rc) - GOTO(out_req, rc); + goto out_req; body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); - if (body == NULL) - GOTO(out_req, rc = -EPROTO); + if (body == NULL) { + rc = -EPROTO; + goto out_req; + } CDEBUG(D_INFO, "oa flags %x\n", oa->o_flags); lustre_get_wire_obdo(&req->rq_import->imp_connect_data, oa, &body->oa); @@ -537,17 +587,6 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, return 0; } -static int osc_punch(const struct lu_env *env, struct obd_export *exp, - struct obd_info *oinfo, struct obd_trans_info *oti, - struct ptlrpc_request_set *rqset) -{ - oinfo->oi_oa->o_size = oinfo->oi_policy.l_extent.start; - oinfo->oi_oa->o_blocks = oinfo->oi_policy.l_extent.end; - oinfo->oi_oa->o_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS; - return osc_punch_base(exp, oinfo, - oinfo->oi_cb_up, oinfo, rqset); -} - static int osc_sync_interpret(const struct lu_env *env, struct ptlrpc_request *req, void *arg, int rc) @@ -556,12 +595,13 @@ static int osc_sync_interpret(const struct lu_env *env, struct ost_body *body; if (rc) - GOTO(out, rc); + goto out; body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); if (body == NULL) { CERROR ("can't unpack ost_body\n"); - GOTO(out, rc = -EPROTO); + rc = -EPROTO; + goto out; } *fa->fa_oi->oi_oa = body->oa; @@ -614,22 +654,6 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, return 0; } -static int osc_sync(const struct lu_env *env, struct obd_export *exp, - struct obd_info *oinfo, obd_size start, obd_size end, - struct ptlrpc_request_set *set) -{ - if (!oinfo->oi_oa) { - CDEBUG(D_INFO, "oa NULL\n"); - return -EINVAL; - } - - oinfo->oi_oa->o_size = start; - oinfo->oi_oa->o_blocks = end; - oinfo->oi_oa->o_valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS); - - return osc_sync_base(exp, oinfo, oinfo->oi_cb_up, oinfo, set); -} - /* Find and cancel locally locks matched by @mode in the resource found by * @objid. Found locks are added into @cancel list. Returns the amount of * locks added to @cancels list. */ @@ -799,7 +823,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, long writing_bytes) { - obd_flag bits = OBD_MD_FLBLOCKS|OBD_MD_FLGRANT; + u32 bits = OBD_MD_FLBLOCKS|OBD_MD_FLGRANT; LASSERT(!(oa->o_valid & bits)); @@ -836,7 +860,7 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, oa->o_dropped = cli->cl_lost_grant; cli->cl_lost_grant = 0; client_obd_list_unlock(&cli->cl_loi_list_lock); - CDEBUG(D_CACHE,"dirty: %llu undirty: %u dropped %u grant: %llu\n", + CDEBUG(D_CACHE, "dirty: %llu undirty: %u dropped %u grant: %llu\n", oa->o_dirty, oa->o_undirty, oa->o_dropped, oa->o_grant); } @@ -849,7 +873,7 @@ void osc_update_next_shrink(struct client_obd *cli) cli->cl_next_shrink_grant); } -static void __osc_update_grant(struct client_obd *cli, obd_size grant) +static void __osc_update_grant(struct client_obd *cli, u64 grant) { client_obd_list_lock(&cli->cl_loi_list_lock); cli->cl_avail_grant += grant; @@ -865,7 +889,7 @@ static void osc_update_grant(struct client_obd *cli, struct ost_body *body) } static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, - obd_count keylen, void *key, obd_count vallen, + u32 keylen, void *key, u32 vallen, void *val, struct ptlrpc_request_set *set); static int osc_shrink_grant_interpret(const struct lu_env *env, @@ -873,12 +897,12 @@ static int osc_shrink_grant_interpret(const struct lu_env *env, void *aa, int rc) { struct client_obd *cli = &req->rq_import->imp_obd->u.cli; - struct obdo *oa = ((struct osc_grant_args *)aa)->aa_oa; + struct obdo *oa = ((struct osc_brw_async_args *)aa)->aa_oa; struct ost_body *body; if (rc != 0) { __osc_update_grant(cli, oa->o_grant); - GOTO(out, rc); + goto out; } body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); @@ -1067,7 +1091,7 @@ static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd) * beyond the end of a stripe file; i.e. lustre is reading a sparse file * via the LOV, and it _knows_ it's reading inside the file, it's just that * this stripe never got written at or beyond this stripe offset yet. */ -static void handle_short_read(int nob_read, obd_count page_count, +static void handle_short_read(int nob_read, u32 page_count, struct brw_page **pga) { char *ptr; @@ -1104,7 +1128,7 @@ static void handle_short_read(int nob_read, obd_count page_count, static int check_write_rcs(struct ptlrpc_request *req, int requested_nob, int niocount, - obd_count page_count, struct brw_page **pga) + u32 page_count, struct brw_page **pga) { int i; __u32 *remote_rcs; @@ -1114,28 +1138,28 @@ static int check_write_rcs(struct ptlrpc_request *req, niocount); if (remote_rcs == NULL) { CDEBUG(D_INFO, "Missing/short RC vector on BRW_WRITE reply\n"); - return(-EPROTO); + return -EPROTO; } /* return error if any niobuf was in error */ for (i = 0; i < niocount; i++) { if ((int)remote_rcs[i] < 0) - return(remote_rcs[i]); + return remote_rcs[i]; if (remote_rcs[i] != 0) { CDEBUG(D_INFO, "rc[%d] invalid (%d) req %p\n", i, remote_rcs[i], req); - return(-EPROTO); + return -EPROTO; } } if (req->rq_bulk->bd_nob_transferred != requested_nob) { CERROR("Unexpected # bytes transferred: %d (requested %d)\n", req->rq_bulk->bd_nob_transferred, requested_nob); - return(-EPROTO); + return -EPROTO; } - return (0); + return 0; } static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2) @@ -1157,7 +1181,7 @@ static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2) return (p1->off + p1->count == p2->off); } -static obd_count osc_checksum_bulk(int nob, obd_count pg_count, +static u32 osc_checksum_bulk(int nob, u32 pg_count, struct brw_page **pga, int opc, cksum_type_t cksum_type) { @@ -1218,8 +1242,9 @@ static obd_count osc_checksum_bulk(int nob, obd_count pg_count, return cksum; } -static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, - struct lov_stripe_md *lsm, obd_count page_count, +static int osc_brw_prep_request(int cmd, struct client_obd *cli, + struct obdo *oa, + struct lov_stripe_md *lsm, u32 page_count, struct brw_page **pga, struct ptlrpc_request **reqp, struct obd_capa *ocapa, int reserve, @@ -1280,8 +1305,10 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, opc == OST_WRITE ? BULK_GET_SOURCE : BULK_PUT_SINK, OST_BULK_PORTAL); - if (desc == NULL) - GOTO(out, rc = -ENOMEM); + if (desc == NULL) { + rc = -ENOMEM; + goto out; + } /* NB request now owns desc and will free it when it gets freed */ body = req_capsule_client_get(pill, &RMF_OST_BODY); @@ -1422,7 +1449,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, static int check_write_checksum(struct obdo *oa, const lnet_process_id_t *peer, __u32 client_cksum, __u32 server_cksum, int nob, - obd_count page_count, struct brw_page **pga, + u32 page_count, struct brw_page **pga, cksum_type_t client_cksum_type) { __u32 new_cksum; @@ -1523,17 +1550,20 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) cksum_type_unpack(aa->aa_oa->o_flags))) return -EAGAIN; - rc = check_write_rcs(req, aa->aa_requested_nob,aa->aa_nio_count, + rc = check_write_rcs(req, aa->aa_requested_nob, + aa->aa_nio_count, aa->aa_page_count, aa->aa_ppga); - GOTO(out, rc); + goto out; } /* The rest of this function executes only for OST_READs */ /* if unwrap_bulk failed, return -EAGAIN to retry */ rc = sptlrpc_cli_unwrap_bulk_read(req, req->rq_bulk, rc); - if (rc < 0) - GOTO(out, rc = -EAGAIN); + if (rc < 0) { + rc = -EAGAIN; + goto out; + } if (rc > aa->aa_requested_nob) { CERROR("Unexpected rc %d (%d requested)\n", rc, @@ -1544,7 +1574,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) if (rc != req->rq_bulk->bd_nob_transferred) { CERROR ("Unexpected rc %d (%d transferred)\n", rc, req->rq_bulk->bd_nob_transferred); - return (-EPROTO); + return -EPROTO; } if (rc < aa->aa_requested_nob) @@ -1616,74 +1646,6 @@ out: return rc; } -static int osc_brw_internal(int cmd, struct obd_export *exp, struct obdo *oa, - struct lov_stripe_md *lsm, - obd_count page_count, struct brw_page **pga, - struct obd_capa *ocapa) -{ - struct ptlrpc_request *req; - int rc; - wait_queue_head_t waitq; - int generation, resends = 0; - struct l_wait_info lwi; - - init_waitqueue_head(&waitq); - generation = exp->exp_obd->u.cli.cl_import->imp_generation; - -restart_bulk: - rc = osc_brw_prep_request(cmd, &exp->exp_obd->u.cli, oa, lsm, - page_count, pga, &req, ocapa, 0, resends); - if (rc != 0) - return (rc); - - if (resends) { - req->rq_generation_set = 1; - req->rq_import_generation = generation; - req->rq_sent = get_seconds() + resends; - } - - rc = ptlrpc_queue_wait(req); - - if (rc == -ETIMEDOUT && req->rq_resend) { - DEBUG_REQ(D_HA, req, "BULK TIMEOUT"); - ptlrpc_req_finished(req); - goto restart_bulk; - } - - rc = osc_brw_fini_request(req, rc); - - ptlrpc_req_finished(req); - /* When server return -EINPROGRESS, client should always retry - * regardless of the number of times the bulk was resent already.*/ - if (osc_recoverable_error(rc)) { - resends++; - if (rc != -EINPROGRESS && - !client_should_resend(resends, &exp->exp_obd->u.cli)) { - CERROR("%s: too many resend retries for object: " - ""DOSTID", rc = %d.\n", exp->exp_obd->obd_name, - POSTID(&oa->o_oi), rc); - goto out; - } - if (generation != - exp->exp_obd->u.cli.cl_import->imp_generation) { - CDEBUG(D_HA, "%s: resend cross eviction for object: " - ""DOSTID", rc = %d.\n", exp->exp_obd->obd_name, - POSTID(&oa->o_oi), rc); - goto out; - } - - lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(resends), NULL, NULL, - NULL); - l_wait_event(waitq, 0, &lwi); - - goto restart_bulk; - } -out: - if (rc == -EAGAIN || rc == -EINPROGRESS) - rc = -EIO; - return rc; -} - static int osc_brw_redo_request(struct ptlrpc_request *request, struct osc_brw_async_args *aa, int rc) { @@ -1787,125 +1749,12 @@ static void sort_brw_pages(struct brw_page **array, int num) } while (stride > 1); } -static obd_count max_unfragmented_pages(struct brw_page **pg, obd_count pages) -{ - int count = 1; - int offset; - int i = 0; - - LASSERT (pages > 0); - offset = pg[i]->off & ~CFS_PAGE_MASK; - - for (;;) { - pages--; - if (pages == 0) /* that's all */ - return count; - - if (offset + pg[i]->count < PAGE_CACHE_SIZE) - return count; /* doesn't end on page boundary */ - - i++; - offset = pg[i]->off & ~CFS_PAGE_MASK; - if (offset != 0) /* doesn't start on page boundary */ - return count; - - count++; - } -} - -static struct brw_page **osc_build_ppga(struct brw_page *pga, obd_count count) -{ - struct brw_page **ppga; - int i; - - OBD_ALLOC(ppga, sizeof(*ppga) * count); - if (ppga == NULL) - return NULL; - - for (i = 0; i < count; i++) - ppga[i] = pga + i; - return ppga; -} - -static void osc_release_ppga(struct brw_page **ppga, obd_count count) +static void osc_release_ppga(struct brw_page **ppga, u32 count) { LASSERT(ppga != NULL); OBD_FREE(ppga, sizeof(*ppga) * count); } -static int osc_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, - obd_count page_count, struct brw_page *pga, - struct obd_trans_info *oti) -{ - struct obdo *saved_oa = NULL; - struct brw_page **ppga, **orig; - struct obd_import *imp = class_exp2cliimp(exp); - struct client_obd *cli; - int rc, page_count_orig; - - LASSERT((imp != NULL) && (imp->imp_obd != NULL)); - cli = &imp->imp_obd->u.cli; - - if (cmd & OBD_BRW_CHECK) { - /* The caller just wants to know if there's a chance that this - * I/O can succeed */ - - if (imp->imp_invalid) - return -EIO; - return 0; - } - - /* test_brw with a failed create can trip this, maybe others. */ - LASSERT(cli->cl_max_pages_per_rpc); - - rc = 0; - - orig = ppga = osc_build_ppga(pga, page_count); - if (ppga == NULL) - return -ENOMEM; - page_count_orig = page_count; - - sort_brw_pages(ppga, page_count); - while (page_count) { - obd_count pages_per_brw; - - if (page_count > cli->cl_max_pages_per_rpc) - pages_per_brw = cli->cl_max_pages_per_rpc; - else - pages_per_brw = page_count; - - pages_per_brw = max_unfragmented_pages(ppga, pages_per_brw); - - if (saved_oa != NULL) { - /* restore previously saved oa */ - *oinfo->oi_oa = *saved_oa; - } else if (page_count > pages_per_brw) { - /* save a copy of oa (brw will clobber it) */ - OBDO_ALLOC(saved_oa); - if (saved_oa == NULL) - GOTO(out, rc = -ENOMEM); - *saved_oa = *oinfo->oi_oa; - } - - rc = osc_brw_internal(cmd, exp, oinfo->oi_oa, oinfo->oi_md, - pages_per_brw, ppga, oinfo->oi_capa); - - if (rc != 0) - break; - - page_count -= pages_per_brw; - ppga += pages_per_brw; - } - -out: - osc_release_ppga(orig, page_count_orig); - - if (saved_oa != NULL) - OBDO_FREE(saved_oa); - - return rc; -} - static int brw_interpret(const struct lu_env *env, struct ptlrpc_request *req, void *data, int rc) { @@ -2029,8 +1878,8 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, CRT_READ; struct ldlm_lock *lock = NULL; struct cl_req_attr *crattr = NULL; - obd_off starting_offset = OBD_OBJECT_EOF; - obd_off ending_offset = 0; + u64 starting_offset = OBD_OBJECT_EOF; + u64 ending_offset = 0; int mpflag = 0; int mem_tight = 0; int page_count = 0; @@ -2064,16 +1913,22 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, mpflag = cfs_memory_pressure_get_and_set(); OBD_ALLOC(crattr, sizeof(*crattr)); - if (crattr == NULL) - GOTO(out, rc = -ENOMEM); + if (crattr == NULL) { + rc = -ENOMEM; + goto out; + } OBD_ALLOC(pga, sizeof(*pga) * page_count); - if (pga == NULL) - GOTO(out, rc = -ENOMEM); + if (pga == NULL) { + rc = -ENOMEM; + goto out; + } OBDO_ALLOC(oa); - if (oa == NULL) - GOTO(out, rc = -ENOMEM); + if (oa == NULL) { + rc = -ENOMEM; + goto out; + } i = 0; list_for_each_entry(oap, &rpc_list, oap_rpc_item) { @@ -2081,8 +1936,10 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, if (clerq == NULL) { clerq = cl_req_alloc(env, page, crt, 1 /* only 1-object rpcs for now */); - if (IS_ERR(clerq)) - GOTO(out, rc = PTR_ERR(clerq)); + if (IS_ERR(clerq)) { + rc = PTR_ERR(clerq); + goto out; + } lock = oap->oap_ldlm_lock; } if (mem_tight) @@ -2108,7 +1965,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, rc = cl_req_prep(env, clerq); if (rc != 0) { CERROR("cl_req_prep failed: %d\n", rc); - GOTO(out, rc); + goto out; } sort_brw_pages(pga, page_count); @@ -2116,7 +1973,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, pga, &req, crattr->cra_capa, 1, 0); if (rc != 0) { CERROR("prep_req failed: %d\n", rc); - GOTO(out, rc); + goto out; } req->rq_interpret_reply = brw_interpret; @@ -2265,17 +2122,6 @@ static int osc_set_data_with_check(struct lustre_handle *lockh, return set; } -static int osc_change_cbdata(struct obd_export *exp, struct lov_stripe_md *lsm, - ldlm_iterator_t replace, void *data) -{ - struct ldlm_res_id res_id; - struct obd_device *obd = class_exp2obd(exp); - - ostid_build_res_name(&lsm->lsm_oi, &res_id); - ldlm_resource_iterate(obd->obd_namespace, &res_id, replace, data); - return 0; -} - /* find any ldlm lock of the inode in osc * return 0 not find * 1 find one @@ -2290,10 +2136,10 @@ static int osc_find_cbdata(struct obd_export *exp, struct lov_stripe_md *lsm, ostid_build_res_name(&lsm->lsm_oi, &res_id); rc = ldlm_resource_iterate(obd->obd_namespace, &res_id, replace, data); if (rc == LDLM_ITER_STOP) - return(1); + return 1; if (rc == LDLM_ITER_CONTINUE) - return(0); - return(rc); + return 0; + return rc; } static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb, @@ -2320,7 +2166,7 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb, if ((intent != 0 && rc == ELDLM_LOCK_ABORTED && agl == 0) || (rc == 0)) { *flags |= LDLM_FL_LVB_READY; - CDEBUG(D_INODE,"got kms %llu blocks %llu mtime %llu\n", + CDEBUG(D_INODE, "got kms %llu blocks %llu mtime %llu\n", lvb->lvb_size, lvb->lvb_blocks, lvb->lvb_mtime); } @@ -2391,50 +2237,6 @@ static int osc_enqueue_interpret(const struct lu_env *env, return rc; } -void osc_update_enqueue(struct lustre_handle *lov_lockhp, - struct lov_oinfo *loi, __u64 flags, - struct ost_lvb *lvb, __u32 mode, int rc) -{ - struct ldlm_lock *lock = ldlm_handle2lock(lov_lockhp); - - if (rc == ELDLM_OK) { - __u64 tmp; - - LASSERT(lock != NULL); - loi->loi_lvb = *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! */ - if (tmp > lock->l_policy_data.l_extent.end) - tmp = lock->l_policy_data.l_extent.end + 1; - if (tmp >= loi->loi_kms) { - LDLM_DEBUG(lock, "lock acquired, setting rss=%llu, kms=%llu", - loi->loi_lvb.lvb_size, tmp); - loi_kms_set(loi, tmp); - } else { - LDLM_DEBUG(lock, "lock acquired, setting rss=%llu; leaving kms=%llu, end=%llu", - loi->loi_lvb.lvb_size, loi->loi_kms, - lock->l_policy_data.l_extent.end); - } - ldlm_lock_allow_match(lock); - } else if (rc == ELDLM_LOCK_ABORTED && (flags & LDLM_FL_HAS_INTENT)) { - LASSERT(lock != NULL); - loi->loi_lvb = *lvb; - ldlm_lock_allow_match(lock); - CDEBUG(D_INODE, "glimpsed, setting rss=%llu; leaving kms=%llu\n", - loi->loi_lvb.lvb_size, loi->loi_kms); - rc = ELDLM_OK; - } - - if (lock != NULL) { - if (rc != ELDLM_OK) - ldlm_lock_fail_match(lock); - - LDLM_LOCK_PUT(lock); - } -} -EXPORT_SYMBOL(osc_update_enqueue); - struct ptlrpc_request_set *PTLRPCD_SET = (void *)1; /* When enqueuing asynchronously, locks are not ordered, we can obtain a lock @@ -2588,22 +2390,6 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, return rc; } -static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, - struct ldlm_enqueue_info *einfo, - struct ptlrpc_request_set *rqset) -{ - struct ldlm_res_id res_id; - int rc; - - ostid_build_res_name(&oinfo->oi_md->lsm_oi, &res_id); - rc = osc_enqueue_base(exp, &res_id, &oinfo->oi_flags, &oinfo->oi_policy, - &oinfo->oi_md->lsm_oinfo[0]->loi_lvb, - oinfo->oi_md->lsm_oinfo[0]->loi_kms_valid, - oinfo->oi_cb_up, oinfo, einfo, oinfo->oi_lockh, - rqset, rqset != NULL, 0); - return rc; -} - int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, __u32 type, ldlm_policy_data_t *policy, __u32 mode, __u64 *flags, void *data, struct lustre_handle *lockh, @@ -2657,28 +2443,6 @@ int osc_cancel_base(struct lustre_handle *lockh, __u32 mode) return 0; } -static int osc_cancel(struct obd_export *exp, struct lov_stripe_md *md, - __u32 mode, struct lustre_handle *lockh) -{ - return osc_cancel_base(lockh, mode); -} - -static int osc_cancel_unused(struct obd_export *exp, - struct lov_stripe_md *lsm, - ldlm_cancel_flags_t flags, - void *opaque) -{ - struct obd_device *obd = class_exp2obd(exp); - struct ldlm_res_id res_id, *resp = NULL; - - if (lsm != NULL) { - ostid_build_res_name(&lsm->lsm_oi, &res_id); - resp = &res_id; - } - - return ldlm_cli_cancel_unused(obd->obd_namespace, resp, flags, opaque); -} - static int osc_statfs_interpret(const struct lu_env *env, struct ptlrpc_request *req, struct osc_async_args *aa, int rc) @@ -2694,15 +2458,18 @@ static int osc_statfs_interpret(const struct lu_env *env, return rc; if ((rc == -ENOTCONN || rc == -EAGAIN) && - (aa->aa_oi->oi_flags & OBD_STATFS_NODELAY)) - GOTO(out, rc = 0); + (aa->aa_oi->oi_flags & OBD_STATFS_NODELAY)) { + rc = 0; + goto out; + } if (rc != 0) - GOTO(out, rc); + goto out; msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS); if (msfs == NULL) { - GOTO(out, rc = -EPROTO); + rc = -EPROTO; + goto out; } *aa->aa_oi->oi_osfs = *msfs; @@ -2802,11 +2569,12 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, rc = ptlrpc_queue_wait(req); if (rc) - GOTO(out, rc); + goto out; msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS); if (msfs == NULL) { - GOTO(out, rc = -EPROTO); + rc = -EPROTO; + goto out; } *osfs = *msfs; @@ -2898,19 +2666,23 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, buf = NULL; len = 0; - if (obd_ioctl_getdata(&buf, &len, (void *)uarg)) - GOTO(out, err = -EINVAL); + if (obd_ioctl_getdata(&buf, &len, (void *)uarg)) { + err = -EINVAL; + goto out; + } data = (struct obd_ioctl_data *)buf; if (sizeof(*desc) > data->ioc_inllen1) { obd_ioctl_freedata(buf, len); - GOTO(out, err = -EINVAL); + err = -EINVAL; + goto out; } if (data->ioc_inllen2 < sizeof(uuid)) { obd_ioctl_freedata(buf, len); - GOTO(out, err = -EINVAL); + err = -EINVAL; + goto out; } desc = (struct lov_desc *)data->ioc_inlbuf1; @@ -2928,36 +2700,37 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (err) err = -EFAULT; obd_ioctl_freedata(buf, len); - GOTO(out, err); + goto out; } case LL_IOC_LOV_SETSTRIPE: err = obd_alloc_memmd(exp, karg); if (err > 0) err = 0; - GOTO(out, err); + goto out; case LL_IOC_LOV_GETSTRIPE: err = osc_getstripe(karg, uarg); - GOTO(out, err); + goto out; case OBD_IOC_CLIENT_RECOVER: err = ptlrpc_recover_import(obd->u.cli.cl_import, data->ioc_inlbuf1, 0); if (err > 0) err = 0; - GOTO(out, err); + goto out; case IOC_OSC_SET_ACTIVE: err = ptlrpc_set_import_active(obd->u.cli.cl_import, data->ioc_offset); - GOTO(out, err); + goto out; case OBD_IOC_POLL_QUOTACHECK: err = osc_quota_poll_check(exp, (struct if_quotacheck *)karg); - GOTO(out, err); + goto out; case OBD_IOC_PING_TARGET: err = ptlrpc_obd_ping(obd); - GOTO(out, err); + goto out; default: CDEBUG(D_INODE, "unrecognised ioctl %#x by %s\n", cmd, current_comm()); - GOTO(out, err = -ENOTTY); + err = -ENOTTY; + goto out; } out: module_put(THIS_MODULE); @@ -2965,7 +2738,7 @@ out: } static int osc_get_info(const struct lu_env *env, struct obd_export *exp, - obd_count keylen, void *key, __u32 *vallen, void *val, + u32 keylen, void *key, __u32 *vallen, void *val, struct lov_stripe_md *lsm) { if (!vallen || !val) @@ -2978,7 +2751,7 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, return 0; } else if (KEY_IS(KEY_LAST_ID)) { struct ptlrpc_request *req; - obd_id *reply; + u64 *reply; char *tmp; int rc; @@ -3002,13 +2775,15 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); if (rc) - GOTO(out, rc); + goto out; reply = req_capsule_server_get(&req->rq_pill, &RMF_OBD_ID); - if (reply == NULL) - GOTO(out, rc = -EPROTO); + if (reply == NULL) { + rc = -EPROTO; + goto out; + } - *((obd_id *)val) = *reply; + *((u64 *)val) = *reply; out: ptlrpc_req_finished(req); return rc; @@ -3057,8 +2832,10 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, skip_locking: req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GET_INFO_FIEMAP); - if (req == NULL) - GOTO(drop_lock, rc = -ENOMEM); + if (req == NULL) { + rc = -ENOMEM; + goto drop_lock; + } req_capsule_set_size(&req->rq_pill, &RMF_FIEMAP_KEY, RCL_CLIENT, keylen); @@ -3070,7 +2847,7 @@ skip_locking: rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GET_INFO); if (rc) { ptlrpc_request_free(req); - GOTO(drop_lock, rc); + goto drop_lock; } tmp = req_capsule_client_get(&req->rq_pill, &RMF_FIEMAP_KEY); @@ -3081,11 +2858,13 @@ skip_locking: ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); if (rc) - GOTO(fini_req, rc); + goto fini_req; reply = req_capsule_server_get(&req->rq_pill, &RMF_FIEMAP_VAL); - if (reply == NULL) - GOTO(fini_req, rc = -EPROTO); + if (reply == NULL) { + rc = -EPROTO; + goto fini_req; + } memcpy(val, reply, *vallen); fini_req: @@ -3100,7 +2879,7 @@ drop_lock: } static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, - obd_count keylen, void *key, obd_count vallen, + u32 keylen, void *key, u32 vallen, void *val, struct ptlrpc_request_set *set) { struct ptlrpc_request *req; @@ -3190,7 +2969,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, memcpy(tmp, val, vallen); if (KEY_IS(KEY_GRANT_SHRINK)) { - struct osc_grant_args *aa; + struct osc_brw_async_args *aa; struct obdo *oa; CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); @@ -3216,32 +2995,6 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, return 0; } - -static int osc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *disk_obd, int *index) -{ - /* this code is not supposed to be used with LOD/OSP - * to be removed soon */ - LBUG(); - return 0; -} - -static int osc_llog_finish(struct obd_device *obd, int count) -{ - struct llog_ctxt *ctxt; - - ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); - if (ctxt) { - llog_cat_close(NULL, ctxt->loc_handle); - llog_cleanup(NULL, ctxt); - } - - ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); - if (ctxt) - llog_cleanup(NULL, ctxt); - return 0; -} - static int osc_reconnect(const struct lu_env *env, struct obd_export *exp, struct obd_device *obd, struct obd_uuid *cluuid, @@ -3271,22 +3024,8 @@ static int osc_reconnect(const struct lu_env *env, static int osc_disconnect(struct obd_export *exp) { struct obd_device *obd = class_exp2obd(exp); - struct llog_ctxt *ctxt; int rc; - ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); - if (ctxt) { - if (obd->u.cli.cl_conn_count == 1) { - /* Flush any remaining cancel messages out to the - * target */ - llog_sync(ctxt, exp, 0); - } - llog_ctxt_put(ctxt); - } else { - CDEBUG(D_HA, "No LLOG_SIZE_REPL_CTXT found in obd %p\n", - obd); - } - rc = client_disconnect_export(exp); /** * Initially we put del_shrink_grant before disconnect_export, but it @@ -3432,16 +3171,18 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) rc = client_obd_setup(obd, lcfg); if (rc) - GOTO(out_ptlrpcd, rc); + goto out_ptlrpcd; handler = ptlrpcd_alloc_work(cli->cl_import, brw_queue_work, cli); - if (IS_ERR(handler)) - GOTO(out_client_setup, rc = PTR_ERR(handler)); + if (IS_ERR(handler)) { + rc = PTR_ERR(handler); + goto out_client_setup; + } cli->cl_writeback_work = handler; rc = osc_quota_setup(obd); if (rc) - GOTO(out_ptlrpcd_work, rc); + goto out_ptlrpcd_work; cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL; lprocfs_osc_init_vars(&lvars); @@ -3509,9 +3250,6 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) obd_cleanup_client_import(obd); ptlrpc_lprocfs_unregister_obd(obd); lprocfs_obd_cleanup(obd); - rc = obd_llog_finish(obd, 0); - if (rc != 0) - CERROR("failed to cleanup llogging subsystems\n"); break; } } @@ -3559,10 +3297,10 @@ int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg) break; } - return(rc); + return rc; } -static int osc_process_config(struct obd_device *obd, obd_count len, void *buf) +static int osc_process_config(struct obd_device *obd, u32 len, void *buf) { return osc_process_config_base(obd, buf); } @@ -3587,20 +3325,11 @@ struct obd_ops osc_obd_ops = { .o_getattr_async = osc_getattr_async, .o_setattr = osc_setattr, .o_setattr_async = osc_setattr_async, - .o_brw = osc_brw, - .o_punch = osc_punch, - .o_sync = osc_sync, - .o_enqueue = osc_enqueue, - .o_change_cbdata = osc_change_cbdata, .o_find_cbdata = osc_find_cbdata, - .o_cancel = osc_cancel, - .o_cancel_unused = osc_cancel_unused, .o_iocontrol = osc_iocontrol, .o_get_info = osc_get_info, .o_set_info_async = osc_set_info_async, .o_import_event = osc_import_event, - .o_llog_init = osc_llog_init, - .o_llog_finish = osc_llog_finish, .o_process_config = osc_process_config, .o_quotactl = osc_quotactl, .o_quotacheck = osc_quotacheck, |