From 1a6e9cb35de381bc27337aea643ee775192c7c88 Mon Sep 17 00:00:00 2001 From: yury Date: Mon, 30 Oct 2006 10:07:45 +0000 Subject: [PATCH] - handle empty page in cmm_split_remove_page() at Tom's suggestion; - fixes about le_to_cpu in mdt_write_dir_page() --- lustre/cmm/cmm_split.c | 11 +++++++++-- lustre/mdt/mdt_handler.c | 10 +++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lustre/cmm/cmm_split.c b/lustre/cmm/cmm_split.c index cb538a0..8277337 100644 --- a/lustre/cmm/cmm_split.c +++ b/lustre/cmm/cmm_split.c @@ -430,6 +430,13 @@ static int cmm_split_remove_page(const struct lu_env *env, kmap(rdpg->rp_pages[0]); dp = page_address(rdpg->rp_pages[0]); + + /* If page is empty return zero len. */ + if (lu_dirent_start(dp) == NULL) { + *len = 0; + GOTO(unmap, rc = 0); + } + for (ent = lu_dirent_start(dp); ent != NULL; ent = lu_dirent_next(ent)) { if (ent->lde_hash < hash_end) { @@ -444,10 +451,10 @@ static int cmm_split_remove_page(const struct lu_env *env, *len = (int)((__u32)ent - (__u32)dp); else *len = 0; - GOTO(unmap, rc); + GOTO(unmap, 0); } } - *len = CFS_PAGE_SIZE; + *len = CFS_PAGE_SIZE; EXIT; unmap: kunmap(rdpg->rp_pages[0]); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 0b0aad0..ed66076 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1061,23 +1061,23 @@ static int mdt_write_dir_page(struct mdt_thread_info *info, struct page *page, struct lu_fid *lf = &ent->lde_fid; char *name; - if (le32_to_cpu(ent->lde_namelen) == 0) + if (le16_to_cpu(ent->lde_namelen) == 0) continue; is_dir = le32_to_cpu(ent->lde_hash) & MAX_HASH_HIGHEST_BIT; - OBD_ALLOC(name, le32_to_cpu(ent->lde_namelen) + 1); + OBD_ALLOC(name, le16_to_cpu(ent->lde_namelen) + 1); if (name == NULL) GOTO(out, rc = -ENOMEM); - memcpy(name, ent->lde_name, le32_to_cpu(ent->lde_namelen)); + memcpy(name, ent->lde_name, le16_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, le32_to_cpu(ent->lde_namelen) + 1); + OBD_FREE(name, le16_to_cpu(ent->lde_namelen) + 1); if (rc) GOTO(out, rc); - offset += le32_to_cpu(ent->lde_reclen); + offset += le16_to_cpu(ent->lde_reclen); if (offset >= size) break; } -- 1.8.3.1