-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* Pravin B Shelar <pravin.shelar@sun.com>
*/
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
#define DEBUG_SUBSYSTEM S_MDS
#include <obd.h>
return ERR_PTR(rc);
}
-static int orphan_key_to_fid(char *key, struct lu_fid *lf)
-{
- int rc = 0;
- unsigned int op;
-
- rc = sscanf(key, ORPHAN_FILE_NAME_FORMAT,
- (long long unsigned int *)&lf->f_seq, &lf->f_oid,
- &lf->f_ver, &op);
- if (rc == 4)
- return 0;
-
- /* build igif */
- rc = sscanf(key, ORPHAN_FILE_NAME_FORMAT_18,
- (long long unsigned int *)&lf->f_seq, &lf->f_oid);
- if (rc == 2) {
- lf->f_ver = 0;
- return 0;
- }
-
- CERROR("can not parse orphan file name %s\n", key);
- return -EINVAL;
-}
-
static inline void mdd_orphan_write_lock(const struct lu_env *env,
struct mdd_device *mdd)
{
* \retval -ve error
*/
static int orph_index_iterate(const struct lu_env *env,
- struct mdd_device *mdd)
+ struct mdd_device *mdd)
{
- struct dt_object *dor = mdd->mdd_orphans;
- char *mti_key = mdd_env_info(env)->mti_orph_key;
- const struct dt_it_ops *iops;
- struct dt_it *it;
- char *key;
- struct lu_fid fid;
- int result = 0;
+ struct dt_object *dor = mdd->mdd_orphans;
+ struct lu_dirent *ent = &mdd_env_info(env)->mti_orph_ent;
+ const struct dt_it_ops *iops;
+ struct dt_it *it;
+ struct lu_fid fid;
int key_sz = 0;
int rc;
__u64 cookie;
GOTO(out_put, rc = -EIO);
}
- do {
- key = (void *)iops->key(env, it);
- if (IS_ERR(key)) {
- CERROR("%s: key failed when clean PENDING: rc = %ld\n",
- mdd->mdd_obd_dev->obd_name, PTR_ERR(key));
- goto next;
- }
- key_sz = iops->key_size(env, it);
-
- /* filter out "." and ".." entries from PENDING dir. */
- if (key_sz < 8)
- goto next;
-
- memcpy(mti_key, key, key_sz);
- mti_key[key_sz] = 0;
-
- if (orphan_key_to_fid(mti_key, &fid))
- goto next;
- if (!fid_is_sane(&fid)) {
- CERROR("%s: bad FID "DFID" cleaning PENDING\n",
- mdd->mdd_obd_dev->obd_name, PFID(&fid));
- goto next;
- }
-
- /* kill orphan object */
- cookie = iops->store(env, it);
- iops->put(env, it);
- rc = orph_key_test_and_del(env, mdd, &fid,
- (struct dt_key *)mti_key);
-
- /* after index delete reset iterator */
- if (rc == 0)
- result = iops->get(env, it, (const void *)"");
- else
- result = iops->load(env, it, cookie);
+ do {
+ key_sz = iops->key_size(env, it);
+ /* filter out "." and ".." entries from PENDING dir. */
+ if (key_sz < 8)
+ goto next;
+
+ rc = iops->rec(env, it, (struct dt_rec *)ent, LUDA_64BITHASH);
+ if (rc != 0) {
+ CERROR("%s: fail to get FID for orphan it: rc = %d\n",
+ mdd->mdd_obd_dev->obd_name, rc);
+ goto next;
+ }
+
+ fid_le_to_cpu(&fid, &ent->lde_fid);
+ if (!fid_is_sane(&fid)) {
+ CERROR("%s: bad FID "DFID" cleaning PENDING\n",
+ mdd->mdd_obd_dev->obd_name, PFID(&fid));
+ goto next;
+ }
+
+ /* kill orphan object */
+ cookie = iops->store(env, it);
+ iops->put(env, it);
+ rc = orph_key_test_and_del(env, mdd, &fid,
+ (struct dt_key *)ent->lde_name);
+
+ /* after index delete reset iterator */
+ if (rc == 0)
+ rc = iops->get(env, it, (const void *)"");
+ else
+ rc = iops->load(env, it, cookie);
next:
- result = iops->next(env, it);
- } while (result == 0);
+ rc = iops->next(env, it);
+ } while (rc == 0);
- GOTO(out_put, rc = 0);
+ GOTO(out_put, rc = 0);
out_put:
- iops->put(env, it);
- iops->fini(env, it);
+ iops->put(env, it);
+ iops->fini(env, it);
out:
- return rc;
+ return rc;
}
/**