#define DEBUG_SUBSYSTEM S_LFSCK
+#include <linux/kthread.h>
#include <libcfs/list.h>
#include <lu_object.h>
#include <dt_object.h>
}
cfs_foreach_bit(ltds->ltd_tgts_bitmap, idx) {
- ltd = LTD_TGT(ltds, idx);
+ ltd = lfsck_ltd2tgt(ltds, idx);
if (likely(ltd != NULL)) {
LASSERT(list_empty(<d->ltd_layout_list));
LASSERT(list_empty(<d->ltd_layout_phase_list));
ltds->ltd_tgtnr--;
cfs_bitmap_clear(ltds->ltd_tgts_bitmap, idx);
- LTD_TGT(ltds, idx) = NULL;
+ lfsck_assign_tgt(ltds, NULL, idx);
lfsck_tgt_put(ltd);
}
}
GOTO(unlock, rc = -ENOMEM);
}
- LTD_TGT(ltds, index) = ltd;
+ lfsck_assign_tgt(ltds, ltd, index);
cfs_bitmap_set(ltds->ltd_tgts_bitmap, index);
ltds->ltd_tgtnr++;
if (rc != 0)
GOTO(stop, rc);
- rc = dt_delete(env, parent, (const struct dt_key *)name, th,
- BYPASS_CAPA);
+ rc = dt_delete(env, parent, (const struct dt_key *)name, th);
if (rc != 0)
GOTO(stop, rc);
/* 1b.2. insert dot into child dir */
rec->rec_fid = cfid;
rc = dt_insert(env, child, (const struct dt_rec *)rec,
- (const struct dt_key *)dot, th, BYPASS_CAPA, 1);
+ (const struct dt_key *)dot, th, 1);
if (rc != 0)
GOTO(unlock, rc);
/* 1b.3. insert dotdot into child dir */
rec->rec_fid = &LU_LPF_FID;
rc = dt_insert(env, child, (const struct dt_rec *)rec,
- (const struct dt_key *)dotdot, th, BYPASS_CAPA, 1);
+ (const struct dt_key *)dotdot, th, 1);
if (rc != 0)
GOTO(unlock, rc);
/* 3b. insert linkEA for child. */
rc = dt_xattr_set(env, child, &linkea_buf,
- XATTR_NAME_LINK, 0, th, BYPASS_CAPA);
+ XATTR_NAME_LINK, 0, th);
dt_write_unlock(env, child);
if (rc != 0)
GOTO(stop, rc);
/* 4b. insert name into parent dir */
rec->rec_fid = cfid;
rc = dt_insert(env, parent, (const struct dt_rec *)rec,
- (const struct dt_key *)name, th, BYPASS_CAPA, 1);
+ (const struct dt_key *)name, th, 1);
if (rc != 0)
GOTO(stop, rc);
rec->rec_type = S_IFDIR;
rec->rec_fid = cfid;
rc = dt_insert(env, child, (const struct dt_rec *)rec,
- (const struct dt_key *)dot, th, BYPASS_CAPA, 1);
+ (const struct dt_key *)dot, th, 1);
if (rc != 0)
GOTO(unlock, rc);
/* 1b.3. insert dotdot into child dir */
rec->rec_fid = &LU_LPF_FID;
rc = dt_insert(env, child, (const struct dt_rec *)rec,
- (const struct dt_key *)dotdot, th, BYPASS_CAPA, 1);
+ (const struct dt_key *)dotdot, th, 1);
if (rc != 0)
GOTO(unlock, rc);
/* 3b. insert linkEA for child */
rc = dt_xattr_set(env, child, &linkea_buf,
- XATTR_NAME_LINK, 0, th, BYPASS_CAPA);
+ XATTR_NAME_LINK, 0, th);
if (rc != 0)
GOTO(unlock, rc);
/* 5b. insert name into parent dir */
rc = dt_insert(env, parent, (const struct dt_rec *)rec,
- (const struct dt_key *)name, th, BYPASS_CAPA, 1);
+ (const struct dt_key *)name, th, 1);
if (rc != 0)
GOTO(stop, rc);
* the lfsck_bookmark::lb_lpf_fid successfully. So need lookup
* it from MDT0 firstly. */
rc = dt_lookup(env, parent, (struct dt_rec *)cfid,
- (const struct dt_key *)name, BYPASS_CAPA);
+ (const struct dt_key *)name);
if (rc != 0 && rc != -ENOENT)
GOTO(unlock, rc);
int rc;
ENTRY;
- it = iops->init(env, parent, LUDA_64BITHASH, BYPASS_CAPA);
+ it = iops->init(env, parent, LUDA_64BITHASH);
if (IS_ERR(it))
RETURN(PTR_ERR(it));
fid_zero(fid);
rc = dt_lookup(env, child, (struct dt_rec *)fid,
- (const struct dt_key *)dotdot, BYPASS_CAPA);
+ (const struct dt_key *)dotdot);
if (rc != 0)
GOTO(linkea, rc);
}
rc = dt_lookup(env, parent2, (struct dt_rec *)fid,
- (const struct dt_key *)name2, BYPASS_CAPA);
+ (const struct dt_key *)name2);
dt_read_unlock(env, child);
lfsck_ibits_unlock(&lh, LCK_PR);
if (rc != 0 && rc != -ENOENT)
find_child2:
snprintf(name, 8, "MDT%04x", node);
rc = dt_lookup(env, parent, (struct dt_rec *)cfid,
- (const struct dt_key *)name, BYPASS_CAPA);
+ (const struct dt_key *)name);
if (rc == -ENOENT) {
if (!fid_is_zero(&bk->lb_lpf_fid))
goto check_child1;
return lad;
}
+struct lfsck_assistant_object *
+lfsck_assistant_object_init(const struct lu_env *env, const struct lu_fid *fid,
+ const struct lu_attr *attr, __u64 cookie,
+ bool is_dir)
+{
+ struct lfsck_assistant_object *lso;
+
+ OBD_ALLOC_PTR(lso);
+ if (lso == NULL)
+ return ERR_PTR(-ENOMEM);
+
+ lso->lso_fid = *fid;
+ if (attr != NULL)
+ lso->lso_attr = *attr;
+
+ atomic_set(&lso->lso_ref, 1);
+ lso->lso_oit_cookie = cookie;
+ if (is_dir)
+ lso->lso_is_dir = 1;
+
+ return lso;
+}
+
+struct dt_object *
+lfsck_assistant_object_load(const struct lu_env *env,
+ struct lfsck_instance *lfsck,
+ struct lfsck_assistant_object *lso)
+{
+ struct dt_object *obj;
+
+ obj = lfsck_object_find_bottom(env, lfsck, &lso->lso_fid);
+ if (IS_ERR(obj))
+ return obj;
+
+ if (unlikely(!dt_object_exists(obj) || lfsck_is_dead_obj(obj))) {
+ lso->lso_dead = 1;
+ lfsck_object_put(env, obj);
+
+ return ERR_PTR(-ENOENT);
+ }
+
+ if (lso->lso_is_dir && unlikely(!dt_try_as_dir(env, obj))) {
+ lfsck_object_put(env, obj);
+
+ return ERR_PTR(-ENOTDIR);
+ }
+
+ return obj;
+}
+
/**
* Generic LFSCK asynchronous communication interpretor function.
* The LFSCK RPC reply for both the event notification and status
lad->lad_to_double_scan = 0;
lad->lad_in_double_scan = 0;
lad->lad_exit = 0;
+ lad->lad_advance_lock = false;
thread_set_flags(athread, 0);
lta = lfsck_thread_args_init(lfsck, com, lsp);
rc = dt_lookup(env, root,
(struct dt_rec *)(&lfsck->li_global_root_fid),
- (const struct dt_key *)"ROOT", BYPASS_CAPA);
+ (const struct dt_key *)"ROOT");
if (rc != 0)
GOTO(out, rc);
GOTO(out, rc = -ENOTDIR);
rc = dt_lookup(env, obj, (struct dt_rec *)fid,
- (const struct dt_key *)dotlustre, BYPASS_CAPA);
+ (const struct dt_key *)dotlustre);
if (rc != 0)
GOTO(out, rc);
*pfid = *fid;
rc = dt_lookup(env, obj, (struct dt_rec *)fid,
- (const struct dt_key *)lostfound,
- BYPASS_CAPA);
+ (const struct dt_key *)lostfound);
if (rc != 0)
GOTO(out, rc);
if (unlikely(index >= ltds->ltd_tgts_bitmap->size))
goto unlock;
- ltd = LTD_TGT(ltds, index);
+ ltd = lfsck_ltd2tgt(ltds, index);
if (unlikely(ltd == NULL))
goto unlock;
ltds->ltd_tgtnr--;
cfs_bitmap_clear(ltds->ltd_tgts_bitmap, index);
- LTD_TGT(ltds, index) = NULL;
+ lfsck_assign_tgt(ltds, NULL, index);
unlock:
if (ltd == NULL) {
MODULE_AUTHOR("Intel Corporation <http://www.intel.com/>");
MODULE_DESCRIPTION("LFSCK");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
MODULE_LICENSE("GPL");
-cfs_module(lfsck, LUSTRE_VERSION_STRING, lfsck_init, lfsck_exit);
+module_init(lfsck_init);
+module_exit(lfsck_exit);