X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fost%2Fost_handler.c;h=83dc74d638d2704fd030d67876728049eaaf9d46;hp=16d7201eb83a037d157f02ebe9c1ee2ff05d355f;hb=84a3fd67356c8073a917ea6abd63928055e38156;hpb=c1e490a9db157f3947f51750b6975e10ea515be3 diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index 16d7201..83dc74d 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -41,9 +39,6 @@ * Author: Phil Schwan */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_OST #include @@ -98,8 +93,8 @@ static int ost_validate_obdo(struct obd_export *exp, struct obdo *oa, if (ioobj) ioobj->ioo_seq = FID_SEQ_OST_MDT0; /* remove fid_seq_is_rsvd() after FID-on-OST allows SEQ > 9 */ - } else if (oa == NULL || - !(fid_seq_is_rsvd(oa->o_seq) || fid_seq_is_idif(oa->o_seq))) { + } else if (oa == NULL || !(fid_seq_is_rsvd(oa->o_seq) || + fid_seq_is_mdt0(oa->o_seq))) { CERROR("%s: client %s sent invalid object "POSTID"\n", exp->exp_obd->obd_name, obd_export_nid2str(exp), oa ? oa->o_id : -1, oa ? oa->o_seq : -1); @@ -189,7 +184,8 @@ static int ost_destroy(struct obd_export *exp, struct ptlrpc_request *req, memcpy(&repbody->oa, &body->oa, sizeof(body->oa)); /* Do the destroy and set the reply status accordingly */ - req->rq_status = obd_destroy(exp, &repbody->oa, NULL, oti, NULL, capa); + req->rq_status = obd_destroy(req->rq_svc_thread->t_env, exp, + &repbody->oa, NULL, oti, NULL, capa); RETURN(0); } @@ -288,7 +284,7 @@ static int ost_getattr(struct obd_export *exp, struct ptlrpc_request *req) oinfo->oi_oa = &repbody->oa; oinfo->oi_capa = capa; - req->rq_status = obd_getattr(exp, oinfo); + req->rq_status = obd_getattr(req->rq_svc_thread->t_env, exp, oinfo); OBD_FREE_PTR(oinfo); @@ -311,7 +307,8 @@ static int ost_statfs(struct ptlrpc_request *req) osfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS); - req->rq_status = obd_statfs(req->rq_export->exp_obd, osfs, + req->rq_status = obd_statfs(req->rq_svc_thread->t_env, req->rq_export, + osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), 0); if (req->rq_status != 0) @@ -343,7 +340,8 @@ static int ost_create(struct obd_export *exp, struct ptlrpc_request *req, repbody->oa = body->oa; oti->oti_logcookies = &body->oa.o_lcookie; - req->rq_status = obd_create(exp, &repbody->oa, NULL, oti); + req->rq_status = obd_create(req->rq_svc_thread->t_env, exp, + &repbody->oa, NULL, oti); //obd_log_cancel(conn, NULL, 1, oti->oti_logcookies, 0); RETURN(0); } @@ -416,7 +414,8 @@ static int ost_punch(struct obd_export *exp, struct ptlrpc_request *req, oinfo->oi_capa = capa; oinfo->oi_flags = OBD_FL_PUNCH; - req->rq_status = obd_punch(exp, oinfo, oti, NULL); + req->rq_status = obd_punch(req->rq_svc_thread->t_env, exp, + oinfo, oti, NULL); OBD_FREE_PTR(oinfo); unlock: ost_lock_put(exp, &lh, LCK_PW); @@ -426,7 +425,8 @@ unlock: RETURN(rc); } -static int ost_sync(struct obd_export *exp, struct ptlrpc_request *req) +static int ost_sync(struct obd_export *exp, struct ptlrpc_request *req, + struct obd_trans_info *oti) { struct ost_body *body, *repbody; struct obd_info *oinfo; @@ -463,8 +463,10 @@ static int ost_sync(struct obd_export *exp, struct ptlrpc_request *req) oinfo->oi_oa = &repbody->oa; oinfo->oi_capa = capa; - req->rq_status = obd_sync(exp, oinfo, repbody->oa.o_size, - repbody->oa.o_blocks, NULL); + oinfo->oi_jobid = oti->oti_jobid; + req->rq_status = obd_sync(req->rq_svc_thread->t_env, exp, oinfo, + repbody->oa.o_size, repbody->oa.o_blocks, + NULL); OBD_FREE_PTR(oinfo); ost_drop_id(exp, &repbody->oa); @@ -509,7 +511,8 @@ static int ost_setattr(struct obd_export *exp, struct ptlrpc_request *req, oinfo->oi_oa = &repbody->oa; oinfo->oi_capa = capa; - req->rq_status = obd_setattr(exp, oinfo, oti); + req->rq_status = obd_setattr(req->rq_svc_thread->t_env, exp, oinfo, + oti); OBD_FREE_PTR(oinfo); @@ -518,36 +521,57 @@ static int ost_setattr(struct obd_export *exp, struct ptlrpc_request *req, } static __u32 ost_checksum_bulk(struct ptlrpc_bulk_desc *desc, int opc, - cksum_type_t cksum_type) + cksum_type_t cksum_type) { - __u32 cksum; - int i; - - cksum = init_checksum(cksum_type); - for (i = 0; i < desc->bd_iov_count; i++) { - struct page *page = desc->bd_iov[i].kiov_page; - int off = desc->bd_iov[i].kiov_offset & ~CFS_PAGE_MASK; - char *ptr = kmap(page) + off; - int len = desc->bd_iov[i].kiov_len; - - /* corrupt the data before we compute the checksum, to - * simulate a client->OST data error */ - if (i == 0 && opc == OST_WRITE && - OBD_FAIL_CHECK(OBD_FAIL_OST_CHECKSUM_RECEIVE)) - memcpy(ptr, "bad3", min(4, len)); - cksum = compute_checksum(cksum, ptr, len, cksum_type); - /* corrupt the data after we compute the checksum, to - * simulate an OST->client data error */ - if (i == 0 && opc == OST_READ && - OBD_FAIL_CHECK(OBD_FAIL_OST_CHECKSUM_SEND)) { - memcpy(ptr, "bad4", min(4, len)); - /* nobody should use corrupted page again */ - ClearPageUptodate(page); - } - kunmap(page); - } - - return fini_checksum(cksum, cksum_type); + struct cfs_crypto_hash_desc *hdesc; + unsigned int bufsize; + int i, err; + unsigned char cfs_alg = cksum_obd2cfs(cksum_type); + __u32 cksum; + + hdesc = cfs_crypto_hash_init(cfs_alg, NULL, 0); + if (IS_ERR(hdesc)) { + CERROR("Unable to initialize checksum hash %s\n", + cfs_crypto_hash_name(cfs_alg)); + return PTR_ERR(hdesc); + } + CDEBUG(D_INFO, "Checksum for algo %s\n", cfs_crypto_hash_name(cfs_alg)); + for (i = 0; i < desc->bd_iov_count; i++) { + + /* corrupt the data before we compute the checksum, to + * simulate a client->OST data error */ + if (i == 0 && opc == OST_WRITE && + OBD_FAIL_CHECK(OBD_FAIL_OST_CHECKSUM_RECEIVE)) { + int off = desc->bd_iov[i].kiov_offset & ~CFS_PAGE_MASK; + int len = desc->bd_iov[i].kiov_len; + char *ptr = kmap(desc->bd_iov[i].kiov_page) + off; + memcpy(ptr, "bad3", min(4, len)); + kunmap(desc->bd_iov[i].kiov_page); + } + cfs_crypto_hash_update_page(hdesc, desc->bd_iov[i].kiov_page, + desc->bd_iov[i].kiov_offset & ~CFS_PAGE_MASK, + desc->bd_iov[i].kiov_len); + + /* corrupt the data after we compute the checksum, to + * simulate an OST->client data error */ + if (i == 0 && opc == OST_READ && + OBD_FAIL_CHECK(OBD_FAIL_OST_CHECKSUM_SEND)) { + int off = desc->bd_iov[i].kiov_offset & ~CFS_PAGE_MASK; + int len = desc->bd_iov[i].kiov_len; + char *ptr = kmap(desc->bd_iov[i].kiov_page) + off; + memcpy(ptr, "bad4", min(4, len)); + kunmap(desc->bd_iov[i].kiov_page); + /* nobody should use corrupted page again */ + ClearPageUptodate(desc->bd_iov[i].kiov_page); + } + } + + bufsize = 4; + err = cfs_crypto_hash_final(hdesc, (unsigned char *)&cksum, &bufsize); + if (err) + cfs_crypto_hash_final(hdesc, NULL, NULL); + + return cksum; } static int ost_brw_lock_get(int mode, struct obd_export *exp, @@ -731,8 +755,9 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti) memcpy(&repbody->oa, &body->oa, sizeof(repbody->oa)); npages = OST_THREAD_POOL_SIZE; - rc = obd_preprw(OBD_BRW_READ, exp, &repbody->oa, 1, ioo, - remote_nb, &npages, local_nb, oti, capa); + rc = obd_preprw(req->rq_svc_thread->t_env, OBD_BRW_READ, exp, + &repbody->oa, 1, ioo, remote_nb, &npages, local_nb, + oti, capa); if (rc != 0) GOTO(out_lock, rc); @@ -790,8 +815,9 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti) out_commitrw: /* Must commit after prep above in all cases */ - rc = obd_commitrw(OBD_BRW_READ, exp, &repbody->oa, 1, ioo, - remote_nb, npages, local_nb, oti, rc); + rc = obd_commitrw(req->rq_svc_thread->t_env, OBD_BRW_READ, exp, + &repbody->oa, 1, ioo, remote_nb, npages, local_nb, + oti, rc); if (rc == 0) ost_drop_id(exp, &repbody->oa); @@ -818,12 +844,11 @@ out: } else { /* reply out callback would free */ ptlrpc_req_drop_rs(req); - CWARN("%s: ignoring bulk IO comm error with %s@%s id %s - " - "client will retry\n", - exp->exp_obd->obd_name, - exp->exp_client_uuid.uuid, - exp->exp_connection->c_remote_uuid.uuid, - libcfs_id2str(req->rq_peer)); + LCONSOLE_WARN("%s: Bulk IO read error with %s (at %s), " + "client will retry: rc %d\n", + exp->exp_obd->obd_name, + obd_uuid2str(&exp->exp_client_uuid), + obd_export_nid2str(exp), rc); } /* send a bulk after reply to simulate a network delay or reordering * by a router */ @@ -973,8 +998,9 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti) memcpy(&repbody->oa, &body->oa, sizeof(repbody->oa)); npages = OST_THREAD_POOL_SIZE; - rc = obd_preprw(OBD_BRW_WRITE, exp, &repbody->oa, objcount, - ioo, remote_nb, &npages, local_nb, oti, capa); + rc = obd_preprw(req->rq_svc_thread->t_env, OBD_BRW_WRITE, exp, + &repbody->oa, objcount, ioo, remote_nb, &npages, + local_nb, oti, capa); if (rc != 0) GOTO(out_lock, rc); @@ -1019,8 +1045,9 @@ skip_transfer: } /* Must commit after prep above in all cases */ - rc = obd_commitrw(OBD_BRW_WRITE, exp, &repbody->oa, objcount, ioo, - remote_nb, npages, local_nb, oti, rc); + rc = obd_commitrw(req->rq_svc_thread->t_env, OBD_BRW_WRITE, exp, + &repbody->oa, objcount, ioo, remote_nb, npages, + local_nb, oti, rc); if (rc == -ENOTCONN) /* quota acquire process has been given up because * either the client has been evicted or the client @@ -1124,12 +1151,11 @@ out: } else { /* reply out callback would free */ ptlrpc_req_drop_rs(req); - CWARN("%s: ignoring bulk IO comm error with %s@%s id %s - " - "client will retry\n", - exp->exp_obd->obd_name, - exp->exp_client_uuid.uuid, - exp->exp_connection->c_remote_uuid.uuid, - libcfs_id2str(req->rq_peer)); + LCONSOLE_WARN("%s: Bulk IO write error with %s (at %s), " + "client will retry: rc %d\n", + exp->exp_obd->obd_name, + obd_uuid2str(&exp->exp_client_uuid), + obd_export_nid2str(exp), rc); } cfs_memory_pressure_clr(); RETURN(rc); @@ -1207,7 +1233,8 @@ static int ost_set_info(struct obd_export *exp, struct ptlrpc_request *req) /* OBD will also check if KEY_IS(KEY_GRANT_SHRINK), and will cast val to * a struct ost_body * value */ - rc = obd_set_info_async(exp, keylen, key, vallen, val, NULL); + rc = obd_set_info_async(req->rq_svc_thread->t_env, exp, keylen, + key, vallen, val, NULL); out: lustre_msg_set_status(req->rq_repmsg, 0); RETURN(rc); @@ -1237,7 +1264,8 @@ static int ost_get_info(struct obd_export *exp, struct ptlrpc_request *req) RETURN(rc); } - rc = obd_get_info(exp, keylen, key, &replylen, NULL, NULL); + rc = obd_get_info(req->rq_svc_thread->t_env, exp, keylen, key, + &replylen, NULL, NULL); if (rc) RETURN(rc); @@ -1253,7 +1281,8 @@ static int ost_get_info(struct obd_export *exp, struct ptlrpc_request *req) RETURN(-ENOMEM); /* call again to fill in the reply buffer */ - rc = obd_get_info(exp, keylen, key, &replylen, reply, NULL); + rc = obd_get_info(req->rq_svc_thread->t_env, exp, keylen, key, + &replylen, reply, NULL); lustre_msg_set_status(req->rq_repmsg, 0); RETURN(rc); @@ -1523,7 +1552,7 @@ int ost_blocking_ast(struct ldlm_lock *lock, int rc = 0; ENTRY; - rc = obd_get_info(lock->l_export, sizeof(KEY_SYNC_LOCK_CANCEL), + rc = obd_get_info(NULL, lock->l_export, sizeof(KEY_SYNC_LOCK_CANCEL), KEY_SYNC_LOCK_CANCEL, &len, &sync_lock_cancel, NULL); if (!rc && flag == LDLM_CB_CANCELING && @@ -1548,7 +1577,7 @@ int ost_blocking_ast(struct ldlm_lock *lock, oa->o_valid = OBD_MD_FLID|OBD_MD_FLGROUP; oinfo->oi_oa = oa; - rc = obd_sync(lock->l_export, oinfo, + rc = obd_sync(NULL, lock->l_export, oinfo, lock->l_policy_data.l_extent.start, lock->l_policy_data.l_extent.end, NULL); if (rc) @@ -1584,7 +1613,7 @@ static int ost_filter_recovery_request(struct ptlrpc_request *req, RETURN(0); default: - DEBUG_REQ(D_ERROR, req, "not permitted during recovery"); + DEBUG_REQ(D_WARNING, req, "not permitted during recovery"); *process = -EAGAIN; RETURN(0); } @@ -1686,8 +1715,10 @@ static inline int prolong_timeout(struct ptlrpc_request *req) static void ost_prolong_lock_one(struct ost_prolong_data *opd, struct ldlm_lock *lock) { - LASSERT(lock->l_req_mode == lock->l_granted_mode); - LASSERT(lock->l_export == opd->opd_exp); + LASSERT(lock->l_export == opd->opd_exp); + + if (lock->l_destroyed) /* lock already cancelled */ + return; /* XXX: never try to grab resource lock here because we're inside * exp_bl_list_lock; in ldlm_lockd.c to handle waiting list we take @@ -2061,6 +2092,12 @@ int ost_handle(struct ptlrpc_request *req) struct obd_device *obd = NULL; ENTRY; + /* OST module is kept between remounts, but the last reference + * to specific module (say, osd or ofd) kills all related keys + * from the environment. so we have to refill it until the root + * cause is fixed properly */ + lu_env_refill(req->rq_svc_thread->t_env); + LASSERT(current->journal_info == NULL); /* primordial rpcs don't affect server recovery */ @@ -2104,6 +2141,10 @@ int ost_handle(struct ptlrpc_request *req) if (rc) RETURN(rc); + if (req && req->rq_reqmsg && req->rq_export && + (req->rq_export->exp_connect_flags & OBD_CONNECT_JOBSTATS)) + oti->oti_jobid = lustre_msg_get_jobid(req->rq_reqmsg); + switch (lustre_msg_get_opc(req->rq_reqmsg)) { case OST_CONNECT: { CDEBUG(D_INODE, "connect\n"); @@ -2218,7 +2259,7 @@ int ost_handle(struct ptlrpc_request *req) req_capsule_set(&req->rq_pill, &RQF_OST_SYNC); if (OBD_FAIL_CHECK(OBD_FAIL_OST_SYNC_NET)) RETURN(0); - rc = ost_sync(req->rq_export, req); + rc = ost_sync(req->rq_export, req, oti); break; case OST_SET_INFO: DEBUG_REQ(D_INODE, req, "set_info"); @@ -2405,18 +2446,18 @@ static int ost_setup(struct obd_device *obd, struct lustre_cfg* lcfg) if (oss_num_threads < OSS_THREADS_MIN) oss_num_threads = OSS_THREADS_MIN; oss_max_threads = oss_min_threads = oss_num_threads; - } else { - /* Base min threads on memory and cpus */ - oss_min_threads = - cfs_num_possible_cpus() * CFS_NUM_CACHEPAGES >> - (27 - CFS_PAGE_SHIFT); - if (oss_min_threads < OSS_THREADS_MIN) - oss_min_threads = OSS_THREADS_MIN; - /* Insure a 4x range for dynamic threads */ - if (oss_min_threads > OSS_THREADS_MAX / 4) - oss_min_threads = OSS_THREADS_MAX / 4; - oss_max_threads = min(OSS_THREADS_MAX, oss_min_threads * 4 + 1); - } + } else { + /* Base min threads on memory and cpus */ + oss_min_threads = + cfs_num_online_cpus() * CFS_NUM_CACHEPAGES >> + (27 - CFS_PAGE_SHIFT); + if (oss_min_threads < OSS_THREADS_MIN) + oss_min_threads = OSS_THREADS_MIN; + /* Insure a 4x range for dynamic threads */ + if (oss_min_threads > OSS_THREADS_MAX / 4) + oss_min_threads = OSS_THREADS_MAX / 4; + oss_max_threads = min(OSS_THREADS_MAX, oss_min_threads * 4 + 1); + } ost->ost_service = ptlrpc_init_svc(OST_NBUFS, OST_BUFSIZE, OST_MAXREQSIZE, @@ -2526,7 +2567,7 @@ static int ost_cleanup(struct obd_device *obd) RETURN(err); } -static int ost_health_check(struct obd_device *obd) +static int ost_health_check(const struct lu_env *env, struct obd_device *obd) { struct ost_obd *ost = &obd->u.ost; int rc = 0;