X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fptlrpc%2Fnodemap_storage.c;h=f4abb34a6389ca0d6b023de84b19a26df88fe6d0;hb=8d8a153e12437900a876293dedc3cc657810ee83;hp=f53a84198585243515cb06b273c24011365cd65e;hpb=be7efb4ce06996444c08914305a73833a7123eeb;p=fs%2Flustre-release.git diff --git a/lustre/ptlrpc/nodemap_storage.c b/lustre/ptlrpc/nodemap_storage.c index f53a841..f4abb34 100644 --- a/lustre/ptlrpc/nodemap_storage.c +++ b/lustre/ptlrpc/nodemap_storage.c @@ -779,20 +779,30 @@ static int nodemap_load_entries(const struct lu_env *env, GOTO(out, rc = PTR_ERR(it)); rc = iops->load(env, it, hash); + if (rc < 0) + GOTO(out_iops_fini, rc); + + /* rc == 0 means we need to advance to record */ if (rc == 0) { rc = iops->next(env, it); - if (rc != 0) - GOTO(out_iops, rc = 0); + + if (rc < 0) + GOTO(out_iops_put, rc); + /* rc > 0 is eof, will be checked in while below */ + } else { + /* rc == 1, we found initial record and can process below */ + rc = 0; } new_config = nodemap_config_alloc(); if (IS_ERR(new_config)) { rc = PTR_ERR(new_config); new_config = NULL; - GOTO(out_lock, rc); + GOTO(out_iops_put, rc); } - do { + /* rc > 0 is eof, check initial iops->next here as well */ + while (rc == 0) { struct nodemap_key *key; union nodemap_rec rec; @@ -800,11 +810,11 @@ static int nodemap_load_entries(const struct lu_env *env, rc = iops->rec(env, it, (struct dt_rec *)&rec, 0); if (rc != -ESTALE) { if (rc != 0) - GOTO(out_lock, rc); + GOTO(out_nodemap_config, rc); rc = nodemap_process_keyrec(new_config, key, &rec, &recent_nodemap); if (rc < 0) - GOTO(out_lock, rc); + GOTO(out_nodemap_config, rc); if (rc == NODEMAP_GLOBAL_IDX) loaded_global_idx = true; } @@ -812,19 +822,20 @@ static int nodemap_load_entries(const struct lu_env *env, do rc = iops->next(env, it); while (rc == -ESTALE); - } while (rc == 0); + } if (rc > 0) rc = 0; -out_lock: +out_nodemap_config: if (rc != 0) nodemap_config_dealloc(new_config); else /* creating new default needs to be done outside dt read lock */ activate_nodemap = true; -out_iops: +out_iops_put: iops->put(env, it); +out_iops_fini: iops->fini(env, it); out: dt_read_unlock(env, nodemap_idx); @@ -1221,8 +1232,8 @@ int nodemap_get_config_req(struct obd_device *mgs_obd, RETURN(-EINVAL); rdpg.rp_count = (body->mcb_units << body->mcb_bits); - rdpg.rp_npages = (rdpg.rp_count + PAGE_CACHE_SIZE - 1) >> - PAGE_CACHE_SHIFT; + rdpg.rp_npages = (rdpg.rp_count + PAGE_SIZE - 1) >> + PAGE_SHIFT; if (rdpg.rp_npages > PTLRPC_MAX_BRW_PAGES) RETURN(-EINVAL); @@ -1234,7 +1245,7 @@ int nodemap_get_config_req(struct obd_device *mgs_obd, if (rdpg.rp_pages == NULL) RETURN(-ENOMEM); for (i = 0; i < rdpg.rp_npages; i++) { - rdpg.rp_pages[i] = alloc_page(GFP_IOFS); + rdpg.rp_pages[i] = alloc_page(GFP_NOFS); if (rdpg.rp_pages[i] == NULL) GOTO(out, rc = -ENOMEM); } @@ -1258,7 +1269,7 @@ int nodemap_get_config_req(struct obd_device *mgs_obd, res->mcr_offset = nodemap_ii.ii_hash_end; res->mcr_size = bytes; - page_count = (bytes + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + page_count = (bytes + PAGE_SIZE - 1) >> PAGE_SHIFT; LASSERT(page_count <= rdpg.rp_count); desc = ptlrpc_prep_bulk_exp(req, page_count, 1, PTLRPC_BULK_PUT_SOURCE | @@ -1270,8 +1281,8 @@ int nodemap_get_config_req(struct obd_device *mgs_obd, for (i = 0; i < page_count && bytes > 0; i++) { ptlrpc_prep_bulk_page_pin(desc, rdpg.rp_pages[i], 0, - min_t(int, bytes, PAGE_CACHE_SIZE)); - bytes -= PAGE_CACHE_SIZE; + min_t(int, bytes, PAGE_SIZE)); + bytes -= PAGE_SIZE; } rc = target_bulk_io(req->rq_export, desc, &lwi);