From de1e16658ece203a662464c78553c9f21c82c87b Mon Sep 17 00:00:00 2001 From: yury Date: Sun, 29 Oct 2006 19:48:28 +0000 Subject: [PATCH] - more fixes in split, now 24o works and split is "counted" as bug free ;) at least I do not know any of them. --- lustre/cmm/cmm_split.c | 1 - lustre/mdt/mdt_handler.c | 57 ++++++++++++++++++++++++++++-------------------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/lustre/cmm/cmm_split.c b/lustre/cmm/cmm_split.c index 97f3e82..4ddb0e8 100644 --- a/lustre/cmm/cmm_split.c +++ b/lustre/cmm/cmm_split.c @@ -354,7 +354,6 @@ static int cmm_split_entries(const struct lu_env *env, struct lu_dirpage *ldp; __u32 len = 0; - /* init page with '0' */ memset(kmap(rdpg->rp_pages[0]), 0, CFS_PAGE_SIZE); kunmap(rdpg->rp_pages[0]); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 30de234..0b0aad0 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1029,53 +1029,62 @@ out: #ifdef HAVE_SPLIT_SUPPORT /* - * Retrieve dir entry from the page and insert it to the - * slave object, actually, this should be in osd layer, - * but since it will not in the final product, so just do - * it here and do not define more moo api anymore for - * this. + * Retrieve dir entry from the page and insert it to the slave object, actually, + * this should be in osd layer, but since it will not in the final product, so + * just do it here and do not define more moo api anymore for this. */ static int mdt_write_dir_page(struct mdt_thread_info *info, struct page *page, int size) { struct mdt_object *object = info->mti_object; + int rc = 0, offset = 0, is_dir; struct lu_dirpage *dp; struct lu_dirent *ent; - int rc = 0, offset = 0, is_dir; - ENTRY; - /* Disable trans for this name insert, since it will - * include many trans for this */ + /* Make sure we have at least one entry. */ + if (size == 0) + RETURN(-EINVAL); + + /* + * Disable trans for this name insert, since it will include many trans + * for this. + */ info->mti_no_need_trans = 1; + kmap(page); dp = page_address(page); offset = (int)((__u32)lu_dirent_start(dp) - (__u32)dp); for (ent = lu_dirent_start(dp); ent != NULL; - ent = lu_dirent_next(ent)) { + ent = lu_dirent_next(ent)) { struct lu_fid *lf = &ent->lde_fid; char *name; - offset += ent->lde_reclen; - if (ent->lde_namelen == 0) + if (le32_to_cpu(ent->lde_namelen) == 0) continue; - - if (offset > size) - break; + is_dir = le32_to_cpu(ent->lde_hash) & MAX_HASH_HIGHEST_BIT; - OBD_ALLOC(name, ent->lde_namelen + 1); - memcpy(name, ent->lde_name, ent->lde_namelen); + OBD_ALLOC(name, le32_to_cpu(ent->lde_namelen) + 1); + if (name == NULL) + GOTO(out, rc = -ENOMEM); + + memcpy(name, ent->lde_name, le32_to_cpu(ent->lde_namelen)); rc = mdo_name_insert(info->mti_env, md_object_next(&object->mot_obj), name, lf, is_dir); - OBD_FREE(name, ent->lde_namelen + 1); + OBD_FREE(name, le32_to_cpu(ent->lde_namelen) + 1); if (rc) GOTO(out, rc); + + offset += le32_to_cpu(ent->lde_reclen); + if (offset >= size) + break; } + EXIT; out: kunmap(page); - RETURN(rc); + return rc; } static int mdt_bulk_timeout(void *data) @@ -1112,15 +1121,15 @@ static int mdt_writepage(struct mdt_thread_info *info) GOTO(desc_cleanup, rc = -ENOMEM); CDEBUG(D_INFO, "Received page offset %d size %d \n", - (int)reqbody->size, (int)reqbody->nlink); + (int)reqbody->size, (int)reqbody->nlink); ptlrpc_prep_bulk_page(desc, page, (int)reqbody->size, (int)reqbody->nlink); - /* FIXME: following parts are copied from ost_brw_write */ - - /* Check if client was evicted while we were doing i/o before touching - network */ + /* + * Check if client was evicted while we were doing i/o before touching + * network. + */ OBD_ALLOC_PTR(lwi); if (!lwi) GOTO(cleanup_page, rc = -ENOMEM); -- 1.8.3.1