int dt_record_write(const struct lu_env *env, struct dt_object *dt,
const struct lu_buf *buf, loff_t *pos, struct thandle *th);
typedef int (*dt_index_page_build_t)(const struct lu_env *env,
- union lu_page *lp, size_t nob,
- const struct dt_it_ops *iops,
+ struct dt_object *obj, union lu_page *lp,
+ size_t nob, const struct dt_it_ops *iops,
struct dt_it *it, __u32 attr, void *arg);
int dt_index_walk(const struct lu_env *env, struct dt_object *obj,
const struct lu_rdpg *rdpg, dt_index_page_build_t filler,
#define OBD_FAIL_MDS_REINT_OPEN 0x169
#define OBD_FAIL_MDS_REINT_OPEN2 0x16a
#define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
+#define OBD_FAIL_MDS_DIR_PAGE_WALK 0x16f
/* layout lock */
#define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
RETURN(rc);
}
-static int mdd_dir_page_build(const struct lu_env *env, union lu_page *lp,
- size_t nob, const struct dt_it_ops *iops,
+static int mdd_dir_page_build(const struct lu_env *env, struct dt_object *obj,
+ union lu_page *lp, size_t nob,
+ const struct dt_it_ops *iops,
struct dt_it *it, __u32 attr, void *arg)
{
struct lu_dirpage *dp = &lp->lp_dir;
int first = 1;
if (nob < sizeof(*dp))
- return -EINVAL;
+ GOTO(out_err, result = -EOVERFLOW);
memset(area, 0, sizeof (*dp));
area += sizeof (*dp);
/* IAM iterator can return record with zero len. */
if (len == 0)
- goto next;
+ GOTO(next, 0);
hash = iops->store(env, it);
if (unlikely(first)) {
/* calculate max space required for lu_dirent */
recsize = lu_dirent_calc_size(len, attr);
- if (nob >= recsize) {
- result = iops->rec(env, it, (struct dt_rec *)ent, attr);
- if (result == -ESTALE)
- goto next;
- if (result != 0)
- goto out;
+ if (nob >= recsize &&
+ !OBD_FAIL_CHECK(OBD_FAIL_MDS_DIR_PAGE_WALK)) {
+ result = iops->rec(env, it, (struct dt_rec *)ent, attr);
+ if (result == -ESTALE)
+ GOTO(next, result);
+ if (result != 0)
+ GOTO(out, result);
- /* osd might not able to pack all attributes,
- * so recheck rec length */
- recsize = le16_to_cpu(ent->lde_reclen);
+ /* osd might not able to pack all attributes,
+ * so recheck rec length */
+ recsize = le16_to_cpu(ent->lde_reclen);
if (le32_to_cpu(ent->lde_attrs) & LUDA_FID) {
fid_le_to_cpu(&fid, &ent->lde_fid);
if (fid_is_dot_lustre(&fid))
- goto next;
+ GOTO(next, recsize);
}
- } else {
- result = (last != NULL) ? 0 :-EINVAL;
- goto out;
- }
- last = ent;
- ent = (void *)ent + recsize;
- nob -= recsize;
+ } else {
+ result = (last != NULL) ? 0 : -EBADSLT;
+ GOTO(out, result);
+ }
+ last = ent;
+ ent = (void *)ent + recsize;
+ nob -= recsize;
next:
result = iops->next(env, it);
if (result == -ESTALE)
- goto next;
+ GOTO(next, result);
} while (result == 0);
out:
dp->ldp_flags |= cpu_to_le32(LDF_COLLIDE);
last->lde_reclen = 0; /* end mark */
}
+out_err:
if (result > 0)
/* end of directory */
dp->ldp_hash_end = cpu_to_le64(MDS_DIR_END_OFF);
else if (result < 0)
- CWARN("build page failed: %d!\n", result);
+ CWARN("%s: build page failed for "DFID": rc = %d\n",
+ lu_dev_name(obj->do_lu.lo_dev),
+ PFID(lu_object_fid(&obj->do_lu)), result);
return result;
}
* \param attr - is the index attribute to pass to iops->rec()
* \param arg - is a pointer to the idx_info structure
*/
-static int dt_index_page_build(const struct lu_env *env, union lu_page *lp,
- size_t nob, const struct dt_it_ops *iops,
+static int dt_index_page_build(const struct lu_env *env, struct dt_object *obj,
+ union lu_page *lp, size_t nob,
+ const struct dt_it_ops *iops,
struct dt_it *it, __u32 attr, void *arg)
{
struct idx_info *ii = (struct idx_info *)arg;
keysize = iops->key_size(env, it);
if (!(ii->ii_flags & II_FL_VARKEY) &&
keysize != ii->ii_keysize) {
- CERROR("keysize mismatch %hu != %hu.\n",
- keysize, ii->ii_keysize);
- GOTO(out, rc = -EINVAL);
+ rc = -EINVAL;
+ CERROR("%s: keysize mismatch %hu != %hu on "
+ DFID": rc = %d\n",
+ lu_dev_name(obj->do_lu.lo_dev),
+ keysize, ii->ii_keysize,
+ PFID(lu_object_fid(&obj->do_lu)), rc);
+ GOTO(out, rc);
}
}
/* fill lu pages */
for (i = 0; i < LU_PAGE_COUNT; i++, lp++, nob -= LU_PAGE_SIZE) {
- rc = filler(env, lp, min_t(size_t, nob, LU_PAGE_SIZE),
+ rc = filler(env, obj, lp,
+ min_t(size_t, nob, LU_PAGE_SIZE),
iops, it, rdpg->rp_attrs, arg);
if (rc < 0)
break;
}
EXPORT_SYMBOL(nodemap_process_idx_pages);
-static int nodemap_page_build(const struct lu_env *env, union lu_page *lp,
- size_t nob, const struct dt_it_ops *iops,
+static int nodemap_page_build(const struct lu_env *env, struct dt_object *obj,
+ union lu_page *lp, size_t nob,
+ const struct dt_it_ops *iops,
struct dt_it *it, __u32 attr, void *arg)
{
struct idx_info *ii = (struct idx_info *)arg;