From: yury Date: Sun, 8 Oct 2006 17:10:28 +0000 (+0000) Subject: - fixes and cleanups. Tom notice my comment in cmm_remove_dir_ent(). X-Git-Tag: v1_8_0_110~486^2~638 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=20fbc12b7c0483f4fbef726b112f0f91b77b8d48;p=fs%2Flustre-release.git - fixes and cleanups. Tom notice my comment in cmm_remove_dir_ent(). --- diff --git a/lustre/cmm/cmm_split.c b/lustre/cmm/cmm_split.c index bc4cd02..595be0d 100644 --- a/lustre/cmm/cmm_split.c +++ b/lustre/cmm/cmm_split.c @@ -264,11 +264,16 @@ static int cmm_remove_dir_ent(const struct lu_env *env, struct md_object *mo, if (IS_ERR(obj)) RETURN(PTR_ERR(obj)); - is_dir = S_ISDIR(lu_object_attr(&obj->cmo_obj.mo_lu)); + if (lu_object_exists(&obj->cmo_obj.mo_lu) > 0) + is_dir = S_ISDIR(lu_object_attr(&obj->cmo_obj.mo_lu)); + else + /* XXX: is this correct? */ + is_dir = 0; + OBD_ALLOC(name, ent->lde_namelen + 1); if (!name) GOTO(cleanup, rc = -ENOMEM); - + memcpy(name, ent->lde_name, ent->lde_namelen); rc = mdo_name_remove(env, md_object_next(mo), name, is_dir); @@ -276,10 +281,11 @@ static int cmm_remove_dir_ent(const struct lu_env *env, struct md_object *mo, if (rc) GOTO(cleanup, rc); - /* Because this ent will be transferred to slave MDS and - * insert it there, so in the slave MDS, we should know whether - * this object is dir or not, so use the highest bit of the hash - * to indicate that (because we do not use highest bit of hash) + /* + * This ent will be transferred to slave MDS and insert it there, so in + * the slave MDS, we should know whether this object is dir or not, so + * use the highest bit of the hash to indicate that (because we do not + * use highest bit of hash). */ if (is_dir) ent->lde_hash |= MAX_HASH_HIGHEST_BIT; @@ -301,7 +307,7 @@ static int cmm_remove_entries(const struct lu_env *env, kmap(rdpg->rp_pages[0]); dp = page_address(rdpg->rp_pages[0]); for (ent = lu_dirent_start(dp); ent != NULL; - ent = lu_dirent_next(ent)) { + ent = lu_dirent_next(ent)) { if (ent->lde_hash < hash_end) { rc = cmm_remove_dir_ent(env, mo, ent); if (rc) { @@ -331,8 +337,9 @@ static int cmm_split_entries(const struct lu_env *env, ENTRY; LASSERTF(rdpg->rp_npages == 1, "Now Only support split 1 page each time" - "npages %d \n", rdpg->rp_npages); - /* Read splitted page and send them to the slave master */ + "npages %d\n", rdpg->rp_npages); + + /* Read split page and send them to the slave master. */ do { struct lu_dirpage *ldp; __u32 len = 0; @@ -374,6 +381,7 @@ static int cmm_split_entries(const struct lu_env *env, RETURN(rc); } + #define SPLIT_PAGE_COUNT 1 static int cmm_scan_and_split(const struct lu_env *env, struct md_object *mo, struct md_attr *ma) @@ -417,7 +425,7 @@ cleanup: __free_pages(rdpg->rp_pages[i], 0); if (rdpg->rp_pages) OBD_FREE(rdpg->rp_pages, rdpg->rp_npages * - sizeof rdpg->rp_pages[0]); + sizeof rdpg->rp_pages[0]); free_rdpg: if (rdpg) OBD_FREE_PTR(rdpg); @@ -481,8 +489,8 @@ int cml_try_to_split(const struct lu_env *env, struct md_object *mo) /* step4: set mea to the master object */ rc = mo_xattr_set(env, md_object_next(mo), buf, MDS_LMV_MD_NAME, 0); if (rc == -ERESTART) - CWARN("Dir"DFID" has been split \n", - PFID(lu_object_fid(&mo->mo_lu))); + CWARN("Dir "DFID" has been split\n", + PFID(lu_object_fid(&mo->mo_lu))); cleanup: if (ma->ma_lmv_size && ma->ma_lmv) OBD_FREE(ma->ma_lmv, ma->ma_lmv_size); diff --git a/lustre/fid/fid_handler.c b/lustre/fid/fid_handler.c index bc8f3664..a0068d2 100644 --- a/lustre/fid/fid_handler.c +++ b/lustre/fid/fid_handler.c @@ -213,7 +213,7 @@ static int __seq_server_alloc_meta(struct lu_server_seq *seq, space->lr_start = in->lr_start; space->lr_end = space->lr_start + - LUSTRE_SEQ_SUPER_WIDTH; + seq->lss_width; } else { /* * Update super start by start from client's range. End diff --git a/lustre/fld/fld_cache.c b/lustre/fld/fld_cache.c index d9ad23c..58b1656 100644 --- a/lustre/fld/fld_cache.c +++ b/lustre/fld/fld_cache.c @@ -118,7 +118,7 @@ struct fld_cache_info *fld_cache_init(int hash_size, int cache_size, for (i = 0; i < hash_size; i++) INIT_HLIST_HEAD(&cache->fci_hash_table[i]); - CDEBUG(D_INFO|D_WARNING, "FLD cache: Size: %d, Threshold: %d\n", + CDEBUG(D_INFO|D_WARNING, "FLD cache - Size: %d, Threshold: %d\n", cache_size, cache_threshold); RETURN(cache); @@ -156,6 +156,7 @@ static int fld_cache_shrink(struct fld_cache_info *cache) { struct fld_cache_entry *flde; struct list_head *curr; + int num = 0; ENTRY; LASSERT(cache != NULL); @@ -175,8 +176,12 @@ static int fld_cache_shrink(struct fld_cache_info *cache) list_del_init(&flde->fce_lru); cache->fci_cache_count--; OBD_FREE_PTR(flde); + num++; } + CDEBUG(D_INFO|D_WARNING, "FLD cache - Shrinked by " + "%d entries\n", num); + RETURN(0); } diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index 67fe181..9606726 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -598,7 +598,7 @@ do_lookup: DLM_REPLY_REC_OFF, sizeof(*mdt_body)); /* see if we got same inode, if not - return error */ - if(lu_fid_eq(&op_data->fid2, &mdt_body->fid1)) { + if (lu_fid_eq(&op_data->fid2, &mdt_body->fid1)) { ll_finish_md_op_data(op_data); op_data = NULL; goto revalidate_finish; diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index ba64885..2abfcf6 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -918,10 +918,11 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, ptlrpc_req_set_repsize(req, 2, size); rc = ptlrpc_queue_wait(req); - str = lustre_msg_string(req->rq_repmsg, REPLY_REC_OFF, - data->ioc_plen1); - if (!rc) - rc = copy_to_user(data->ioc_pbuf1, str,data->ioc_plen1); + if (!rc) { + str = lustre_msg_string(req->rq_repmsg, REPLY_REC_OFF, + data->ioc_plen1); + rc = copy_to_user(data->ioc_pbuf1, str, data->ioc_plen1); + } ptlrpc_req_finished(req); out_catinfo: obd_ioctl_freedata(buf, len); diff --git a/lustre/llite/llite_capa.c b/lustre/llite/llite_capa.c index d1963d0..7a9f126 100644 --- a/lustre/llite/llite_capa.c +++ b/lustre/llite/llite_capa.c @@ -360,17 +360,19 @@ struct obd_capa *ll_lookup_oss_capa(struct inode *inode, __u64 opc) struct obd_capa *ll_i2mdscapa(struct inode *inode) { - struct obd_capa *ocapa; struct ll_inode_info *lli = ll_i2info(inode); + struct obd_capa *ocapa; + ENTRY; - LASSERT(inode); + LASSERT(inode != NULL); + if ((ll_i2sbi(inode)->ll_flags & LL_SBI_MDS_CAPA) == 0) - return NULL; - ENTRY; + RETURN(NULL); spin_lock(&capa_lock); ocapa = capa_get(lli->lli_mds_capa); spin_unlock(&capa_lock); + if (ocapa && !obd_capa_is_valid(ocapa)) { DEBUG_CAPA(D_ERROR, &ocapa->c_capa, "invalid"); capa_put(ocapa); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index e919b4c..92757a4 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2249,9 +2249,10 @@ ll_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, { LASSERT(i1 != NULL); - if (!op_data) + if (op_data == NULL) OBD_ALLOC_PTR(op_data); - if (!op_data) + + if (op_data == NULL) return NULL; ll_i2gids(op_data->suppgids, i1, i2); diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 8ee7478..f189c30 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -959,6 +959,7 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, struct md_op_data *op_data; int err; ENTRY; + CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", name->len, name->name, dir->i_ino, dir->i_generation, dir); @@ -968,7 +969,7 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, if (op_data == NULL) RETURN(-ENOMEM); - /* allocate new fid */ + /* Allocate new fid. */ err = ll_fid_md_alloc(ll_i2sbi(dir), &op_data->fid2, &hint); if (err) { CERROR("can't allocate new fid, rc %d\n", err); @@ -978,6 +979,7 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, err = md_create(sbi->ll_md_exp, op_data, NULL, 0, mode, current->fsuid, current->fsgid, current->cap_effective, 0, &request); + ll_finish_md_op_data(op_data); if (err == 0) { ll_update_times(request, REPLY_REC_OFF, dir); @@ -988,10 +990,9 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, d_instantiate(dchild, inode); } } - EXIT; -out: - ptlrpc_req_finished(request); - return err; + if (request != NULL) + ptlrpc_req_finished(request); + RETURN(err); } static int ll_rmdir_generic(struct inode *dir, struct dentry *dparent, diff --git a/lustre/lmv/lmv_intent.c b/lustre/lmv/lmv_intent.c index 3acbd66..593fd36 100644 --- a/lustre/lmv/lmv_intent.c +++ b/lustre/lmv/lmv_intent.c @@ -139,8 +139,8 @@ out: int lmv_alloc_fid_for_split(struct obd_device *obd, struct lu_fid *pid, struct md_op_data *op, struct lu_fid *fid) { - struct lmv_obj *obj; struct lmv_obd *lmv = &obd->u.lmv; + struct lmv_obj *obj; struct lu_fid *rpid; mdsno_t mds; int rc; diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index a396430..75c3084 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -1233,8 +1233,10 @@ static int lmv_close(struct obd_export *exp, RETURN(rc); } -/* called in the case MDS returns -ERESTART on create on open, what means that - * directory is split and its LMV presentation object has to be updated. */ +/* + * Called in the case MDS returns -ERESTART on create on open, what means that + * directory is split and its LMV presentation object has to be updated. + */ int lmv_handle_split(struct obd_export *exp, const struct lu_fid *fid) { struct obd_device *obd = exp->exp_obd; @@ -1280,10 +1282,11 @@ int lmv_handle_split(struct obd_export *exp, const struct lu_fid *fid) obd_free_memmd(exp, (struct lov_stripe_md **)&md.mea); + EXIT; cleanup: if (req) ptlrpc_req_finished(req); - RETURN(rc); + return rc; } int lmv_create(struct obd_export *exp, struct md_op_data *op_data, @@ -1328,18 +1331,17 @@ repeat: if (rc == 0) { if (*request == NULL) RETURN(rc); - CDEBUG(D_OTHER, "created. "DFID"\n", - PFID(&op_data->fid1)); + CDEBUG(D_OTHER, "created. "DFID"\n", PFID(&op_data->fid1)); } else if (rc == -ERESTART) { /* - * Directory got split. time to update local object and repeat + * Directory got split. Time to update local object and repeat * the request with proper MDS. */ rc = lmv_handle_split(exp, &op_data->fid1); if (rc == 0) { ptlrpc_req_finished(*request); rc = lmv_alloc_fid_for_split(obd, &op_data->fid1, - op_data, &op_data->fid2); + op_data, &op_data->fid2); if (rc) RETURN(rc); goto repeat; diff --git a/lustre/mdc/mdc_lib.c b/lustre/mdc/mdc_lib.c index baea7ba..c72dea9 100644 --- a/lustre/mdc/mdc_lib.c +++ b/lustre/mdc/mdc_lib.c @@ -99,8 +99,7 @@ void mdc_pack_req_body(struct ptlrpc_request *req, int offset, } void mdc_readdir_pack(struct ptlrpc_request *req, int offset, __u64 pgoff, - __u32 size, const struct lu_fid *fid, - struct obd_capa *oc) + __u32 size, const struct lu_fid *fid, struct obd_capa *oc) { struct mdt_body *b; @@ -121,7 +120,8 @@ void mdc_create_pack(struct ptlrpc_request *req, int offset, { struct mdt_rec_create *rec; char *tmp; - rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec)); + + rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*rec)); rec->cr_opcode = REINT_CREATE; rec->cr_fsuid = uid; @@ -142,7 +142,7 @@ void mdc_create_pack(struct ptlrpc_request *req, int offset, if (data) { tmp = lustre_msg_buf(req->rq_reqmsg, offset + 3, datalen); - memcpy (tmp, data, datalen); + memcpy(tmp, data, datalen); } } diff --git a/lustre/mdc/mdc_reint.c b/lustre/mdc/mdc_reint.c index f86f5f9..d5ae1e9 100644 --- a/lustre/mdc/mdc_reint.c +++ b/lustre/mdc/mdc_reint.c @@ -127,12 +127,12 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data, const void *data, int datalen, int mode, __u32 uid, __u32 gid, __u32 cap_effective, __u64 rdev, struct ptlrpc_request **request) { - struct obd_device *obd = exp->exp_obd; - struct ptlrpc_request *req; int size[5] = { sizeof(struct ptlrpc_body), sizeof(struct mdt_rec_create), 0, op_data->namelen + 1 }; + struct obd_device *obd = exp->exp_obd; int level, bufcount = 4, rc; + struct ptlrpc_request *req; ENTRY; if (op_data->mod_capa1) @@ -148,8 +148,10 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data, if (req == NULL) RETURN(-ENOMEM); - /* mdc_create_pack fills msg->bufs[1] with name - * and msg->bufs[2] with tgt, for symlinks or lov MD data */ + /* + * mdc_create_pack() fills msg->bufs[1] with name and msg->bufs[2] with + * tgt, for symlinks or lov MD data. + */ mdc_create_pack(req, REQ_REC_OFF, op_data, data, datalen, mode, uid, gid, cap_effective, rdev); @@ -159,6 +161,7 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data, level = LUSTRE_IMP_FULL; resend: rc = mdc_reint(req, obd->u.cli.cl_rpc_lock, level); + /* Resend if we were told to. */ if (rc == -ERESTARTSYS) { level = LUSTRE_IMP_RECOVER; diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index c3539e7..2175b72 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -906,17 +906,16 @@ int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, int mdc_sendpage(struct obd_export *exp, const struct lu_fid *fid, const struct page *page, int offset) { + int rc, size[3] = { sizeof(struct ptlrpc_body), sizeof(struct mdt_body) }; struct obd_import *imp = class_exp2cliimp(exp); - struct ptlrpc_request *req = NULL; struct ptlrpc_bulk_desc *desc = NULL; - struct mdt_body *body; - int rc, size[3] = { sizeof(struct ptlrpc_body), sizeof(*body) }; + struct ptlrpc_request *req = NULL; ENTRY; CDEBUG(D_INODE, "object: "DFID"\n", PFID(fid)); - req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_WRITEPAGE, 3, size, - NULL); + req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_WRITEPAGE, 3, + size, NULL); if (req == NULL) GOTO(out, rc = -ENOMEM); @@ -925,16 +924,18 @@ int mdc_sendpage(struct obd_export *exp, const struct lu_fid *fid, desc = ptlrpc_prep_bulk_imp(req, 1, BULK_GET_SOURCE, MDS_BULK_PORTAL); if (desc == NULL) GOTO(out, rc = -ENOMEM); - /* NB req now owns desc and will free it when it gets freed */ - ptlrpc_prep_bulk_page(desc, (struct page*)page, 0, offset); - + + /* NB req now owns desc and will free it when it gets freed. */ + ptlrpc_prep_bulk_page(desc, (struct page *)page, 0, offset); mdc_readdir_pack(req, REQ_REC_OFF, 0, offset, fid, NULL); ptlrpc_req_set_repsize(req, 2, size); rc = ptlrpc_queue_wait(req); + EXIT; out: - ptlrpc_req_finished(req); - RETURN(rc); + if (req != NULL) + ptlrpc_req_finished(req); + return rc; } EXPORT_SYMBOL(mdc_sendpage); #endif @@ -943,19 +944,20 @@ int mdc_readpage(struct obd_export *exp, const struct lu_fid *fid, struct obd_capa *oc, __u64 offset, struct page *page, struct ptlrpc_request **request) { + int rc, size[3] = { sizeof(struct ptlrpc_body), sizeof(struct mdt_body) }; struct obd_import *imp = class_exp2cliimp(exp); - struct ptlrpc_request *req = NULL; struct ptlrpc_bulk_desc *desc = NULL; + struct ptlrpc_request *req = NULL; struct mdt_body *body; - int rc, size[3] = { sizeof(struct ptlrpc_body), sizeof(*body) }; ENTRY; CDEBUG(D_INODE, "object: "DFID"\n", PFID(fid)); - if (oc) + if (oc != NULL) size[REQ_REC_OFF + 1] = sizeof(struct lustre_capa); - req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_READPAGE, 3, size, - NULL); + + req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_READPAGE, 3, + size, NULL); if (req == NULL) GOTO(out, rc = -ENOMEM); @@ -965,10 +967,9 @@ int mdc_readpage(struct obd_export *exp, const struct lu_fid *fid, desc = ptlrpc_prep_bulk_imp(req, 1, BULK_PUT_SINK, MDS_BULK_PORTAL); if (desc == NULL) GOTO(out, rc = -ENOMEM); - /* NB req now owns desc and will free it when it gets freed */ + /* NB req now owns desc and will free it when it gets freed */ ptlrpc_prep_bulk_page(desc, page, 0, PAGE_CACHE_SIZE); - mdc_readdir_pack(req, REQ_REC_OFF, offset, PAGE_CACHE_SIZE, fid, oc); ptlrpc_req_set_repsize(req, 2, size); @@ -987,7 +988,7 @@ int mdc_readpage(struct obd_export *exp, const struct lu_fid *fid, " (%ld expected)\n", req->rq_bulk->bd_nob_transferred, PAGE_CACHE_SIZE); - GOTO (out, rc = -EPROTO); + GOTO(out, rc = -EPROTO); } } diff --git a/lustre/tests/cfg/lmv.sh b/lustre/tests/cfg/lmv.sh index 47a3779..7eaf4e0 100644 --- a/lustre/tests/cfg/lmv.sh +++ b/lustre/tests/cfg/lmv.sh @@ -20,7 +20,7 @@ STRIPE_BYTES=${STRIPE_BYTES:-1048576} STRIPES_PER_OBJ=${STRIPES_PER_OBJ:-$((OSTCOUNT -1))} TIMEOUT=${TIMEOUT:-20} PTLDEBUG=${PTLDEBUG:-0x33f0404} -SUBSYSTEM=${SUBSYSTEM:- 0xffb7e3ff} +SUBSYSTEM=${SUBSYSTEM:-0xffb7e3ff} TMP=${TMP:-/tmp}