-/**
- * Read one directory entry from the cache.
- */
-int mdc_read_entry(struct obd_export *exp, struct md_op_data *op_data,
- struct md_callback *cb_op, struct lu_dirent **entp,
- struct page **ppage)
-{
- struct page *page = NULL;
- struct lu_dirpage *dp;
- struct lu_dirent *ent;
- int rc = 0;
- ENTRY;
-
- CDEBUG(D_INFO, DFID "offset = "LPU64"\n", PFID(&op_data->op_fid1),
- op_data->op_hash_offset);
-
- *ppage = NULL;
- *entp = NULL;
-
- if (op_data->op_hash_offset == MDS_DIR_END_OFF)
- RETURN(0);
-
- rc = mdc_read_page(exp, op_data, cb_op, &page);
- if (rc != 0)
- RETURN(rc);
-
- dp = page_address(page);
- for (ent = lu_dirent_start(dp); ent != NULL;
- ent = lu_dirent_next(ent)) {
- /* Skip dummy entry */
- if (le16_to_cpu(ent->lde_namelen) == 0)
- continue;
-
- if (le64_to_cpu(ent->lde_hash) > op_data->op_hash_offset)
- break;
- }
-
- /* If it can not find entry in current page, try next page. */
- if (ent == NULL) {
- __u64 orig_offset = op_data->op_hash_offset;
-
- if (le64_to_cpu(dp->ldp_hash_end) == MDS_DIR_END_OFF) {
- mdc_release_page(page, 0);
- RETURN(0);
- }
-
- op_data->op_hash_offset = le64_to_cpu(dp->ldp_hash_end);
- mdc_release_page(page,
- le32_to_cpu(dp->ldp_flags) & LDF_COLLIDE);
- rc = mdc_read_page(exp, op_data, cb_op, &page);
- if (rc != 0)
- RETURN(rc);
-
- if (page != NULL) {
- dp = page_address(page);
- ent = lu_dirent_start(dp);
- }
-
- op_data->op_hash_offset = orig_offset;
- }
-
- *ppage = page;
- *entp = ent;
-
- RETURN(rc);
-}
-
-#else /* __KERNEL__ */
-
-static struct page
-*mdc_read_page_remote(struct obd_export *exp, const struct lmv_oinfo *lmo,
- const __u64 hash, struct obd_capa *oc)
-{
- struct ptlrpc_request *req = NULL;
- struct page *page;
- int rc;
-
- OBD_PAGE_ALLOC(page, 0);
- if (page == NULL)
- return ERR_PTR(-ENOMEM);
-
- rc = mdc_getpage(exp, &lmo->lmo_fid, hash, oc, &page, 1, &req);
- if (req != NULL)
- ptlrpc_req_finished(req);
-
- if (unlikely(rc)) {
- OBD_PAGE_FREE(page);
- return ERR_PTR(rc);
- }
- return page;
-}
-
-
-static int mdc_read_page(struct obd_export *exp, struct md_op_data *op_data,
- struct md_callback *cb_op,
- struct page **ppage)
-{
- struct page *page;
- struct lmv_oinfo *lmo;
- int rc = 0;
-
- /* No local cache for liblustre, always read entry remotely */
- lmo = &op_data->op_mea1->lsm_md_oinfo[op_data->op_stripe_offset];
- page = mdc_read_page_remote(exp, lmo, op_data->op_hash_offset,
- op_data->op_capa1);
- if (IS_ERR(page))
- return PTR_ERR(page);
-
- *ppage = page;
-
- return rc;
-}
-
-int mdc_read_entry(struct obd_export *exp, struct md_op_data *op_data,
- struct md_callback *cb_op, struct lu_dirent **entp,
- struct page **ppage)
-{
- struct page *page = NULL;
- struct lu_dirpage *dp;
- struct lu_dirent *ent;
- int rc;
- ENTRY;
-
- rc = mdc_read_page(exp, op_data, cb_op, &page);
- if (rc != 0)
- RETURN(rc);
-
- dp = page_address(page);
- if (le64_to_cpu(dp->ldp_hash_end) < op_data->op_hash_offset)
- GOTO(out, *entp = NULL);
-
- for (ent = lu_dirent_start(dp); ent != NULL;
- ent = lu_dirent_next(ent))
- if (le64_to_cpu(ent->lde_hash) >= op_data->op_hash_offset)
- break;
- *entp = ent;
-out:
-
- OBD_PAGE_FREE(page);
- RETURN(rc);
-}
-
-#endif