Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LU-12616 obclass: fix MDS start/stop race
[fs/lustre-release.git]
/
lustre
/
mdd
/
mdd_orphans.c
diff --git
a/lustre/mdd/mdd_orphans.c
b/lustre/mdd/mdd_orphans.c
index
7b99a93
..
de1500b
100644
(file)
--- a/
lustre/mdd/mdd_orphans.c
+++ b/
lustre/mdd/mdd_orphans.c
@@
-45,7
+45,7
@@
#include <lustre_fid.h>
#include "mdd_internal.h"
#include <lustre_fid.h>
#include "mdd_internal.h"
-static const char mdd_orphan_index_name[] =
"PENDING"
;
+static const char mdd_orphan_index_name[] =
MDT_ORPHAN_DIR
;
static const char dotdot[] = "..";
enum {
static const char dotdot[] = "..";
enum {
@@
-164,7
+164,7
@@
int mdd_orphan_insert(const struct lu_env *env, struct mdd_object *obj,
LASSERT(mdd_write_locked(env, obj) != 0);
LASSERT(!(obj->mod_flags & ORPHAN_OBJ));
LASSERT(mdd_write_locked(env, obj) != 0);
LASSERT(!(obj->mod_flags & ORPHAN_OBJ));
- dt_write_lock(env, mdd->mdd_orphans,
MOR
_TGT_ORPHAN);
+ dt_write_lock(env, mdd->mdd_orphans,
DT
_TGT_ORPHAN);
rc = mdd_orphan_insert_obj(env, mdd, obj, th);
if (rc)
rc = mdd_orphan_insert_obj(env, mdd, obj, th);
if (rc)
@@
-210,13
+210,13
@@
int mdd_orphan_declare_delete(const struct lu_env *env, struct mdd_object *obj,
if (rc)
return rc;
if (rc)
return rc;
+ if (!mdd_object_exists(obj))
+ return -ENOENT;
+
rc = mdo_declare_ref_del(env, obj, th);
if (rc)
return rc;
rc = mdo_declare_ref_del(env, obj, th);
if (rc)
return rc;
- if (!lu_object_exists(&obj->mod_obj.mo_lu))
- return -ENOENT;
-
if (S_ISDIR(mdd_object_type(obj))) {
rc = mdo_declare_ref_del(env, obj, th);
if (rc)
if (S_ISDIR(mdd_object_type(obj))) {
rc = mdo_declare_ref_del(env, obj, th);
if (rc)
@@
-244,7
+244,7
@@
int mdd_orphan_delete(const struct lu_env *env, struct mdd_object *obj,
struct mdd_device *mdd = mdo2mdd(&obj->mod_obj);
struct dt_object *dor = mdd->mdd_orphans;
struct dt_key *key;
struct mdd_device *mdd = mdo2mdd(&obj->mod_obj);
struct dt_object *dor = mdd->mdd_orphans;
struct dt_key *key;
- int rc;
+ int rc
= 0
;
ENTRY;
ENTRY;
@@
-255,7
+255,10
@@
int mdd_orphan_delete(const struct lu_env *env, struct mdd_object *obj,
LASSERT(dor);
key = mdd_orphan_key_fill(env, mdo2fid(obj));
LASSERT(dor);
key = mdd_orphan_key_fill(env, mdo2fid(obj));
- dt_write_lock(env, mdd->mdd_orphans, MOR_TGT_ORPHAN);
+ dt_write_lock(env, mdd->mdd_orphans, DT_TGT_ORPHAN);
+
+ if (OBD_FAIL_CHECK(OBD_FAIL_MDS_ORPHAN_DELETE))
+ goto ref_del;
rc = dt_delete(env, mdd->mdd_orphans, key, th);
if (rc == -ENOENT) {
rc = dt_delete(env, mdd->mdd_orphans, key, th);
if (rc == -ENOENT) {
@@
-263,6
+266,7
@@
int mdd_orphan_delete(const struct lu_env *env, struct mdd_object *obj,
rc = dt_delete(env, mdd->mdd_orphans, key, th);
}
rc = dt_delete(env, mdd->mdd_orphans, key, th);
}
+ref_del:
if (!rc) {
/* lov objects will be destroyed by caller */
mdo_ref_del(env, obj, th);
if (!rc) {
/* lov objects will be destroyed by caller */
mdo_ref_del(env, obj, th);
@@
-286,6
+290,7
@@
static int mdd_orphan_destroy(const struct lu_env *env, struct mdd_object *obj,
{
struct thandle *th = NULL;
struct mdd_device *mdd = mdo2mdd(&obj->mod_obj);
{
struct thandle *th = NULL;
struct mdd_device *mdd = mdo2mdd(&obj->mod_obj);
+ bool orphan_exists = true;
int rc = 0;
ENTRY;
int rc = 0;
ENTRY;
@@
-298,23
+303,31
@@
static int mdd_orphan_destroy(const struct lu_env *env, struct mdd_object *obj,
RETURN(rc);
}
RETURN(rc);
}
+ mdd_write_lock(env, obj, DT_TGT_CHILD);
rc = mdd_orphan_declare_delete(env, obj, th);
rc = mdd_orphan_declare_delete(env, obj, th);
- if (rc)
- GOTO(stop, rc);
-
- rc = mdo_declare_destroy(env, obj, th);
- if (rc)
- GOTO(stop, rc);
+ if (rc == -ENOENT)
+ orphan_exists = false;
+ else if (rc)
+ GOTO(unlock, rc);
+
+ if (orphan_exists) {
+ rc = mdo_declare_destroy(env, obj, th);
+ if (rc)
+ GOTO(unlock, rc);
+ }
rc = mdd_trans_start(env, mdd, th);
if (rc)
rc = mdd_trans_start(env, mdd, th);
if (rc)
- GOTO(
stop
, rc);
+ GOTO(
unlock
, rc);
- mdd_write_lock(env, obj, MOR_TGT_CHILD);
if (likely(obj->mod_count == 0)) {
if (likely(obj->mod_count == 0)) {
- dt_write_lock(env, mdd->mdd_orphans,
MOR
_TGT_ORPHAN);
+ dt_write_lock(env, mdd->mdd_orphans,
DT
_TGT_ORPHAN);
rc = dt_delete(env, mdd->mdd_orphans, key, th);
rc = dt_delete(env, mdd->mdd_orphans, key, th);
- if (rc == 0) {
+ if (rc) {
+ CERROR("%s: could not delete orphan "DFID": rc = %d\n",
+ mdd2obd_dev(mdd)->obd_name, PFID(mdo2fid(obj)),
+ rc);
+ } else if (orphan_exists) {
mdo_ref_del(env, obj, th);
if (S_ISDIR(mdd_object_type(obj))) {
mdo_ref_del(env, obj, th);
mdo_ref_del(env, obj, th);
if (S_ISDIR(mdd_object_type(obj))) {
mdo_ref_del(env, obj, th);
@@
-322,15
+335,15
@@
static int mdd_orphan_destroy(const struct lu_env *env, struct mdd_object *obj,
}
rc = mdo_destroy(env, obj, th);
} else {
}
rc = mdo_destroy(env, obj, th);
} else {
- C
ERROR("%s: could not delete orphan "DFID": rc = %d
\n",
-
mdd2obd_dev(mdd)->obd_name, PFID(mdo2fid(obj))
,
-
rc
);
+ C
WARN("%s: orphan %s "DFID" doesn't exist
\n",
+
mdd2obd_dev(mdd)->obd_name, (char *)key
,
+
PFID(mdo2fid(obj))
);
}
dt_write_unlock(env, mdd->mdd_orphans);
}
}
dt_write_unlock(env, mdd->mdd_orphans);
}
+unlock:
mdd_write_unlock(env, obj);
mdd_write_unlock(env, obj);
-stop:
rc = mdd_trans_stop(env, mdd, 0, th);
RETURN(rc);
rc = mdd_trans_stop(env, mdd, 0, th);
RETURN(rc);
@@
-366,7
+379,7
@@
static int mdd_orphan_key_test_and_delete(const struct lu_env *env,
CERROR("%s: error unlinking orphan "DFID": rc = %d\n",
mdd2obd_dev(mdd)->obd_name, PFID(lf), rc);
} else {
CERROR("%s: error unlinking orphan "DFID": rc = %d\n",
mdd2obd_dev(mdd)->obd_name, PFID(lf), rc);
} else {
-
mdd_write_lock(env, mdo, MOR
_TGT_CHILD);
+
mdd_write_lock(env, mdo, DT
_TGT_CHILD);
if (likely(mdo->mod_count > 0)) {
CDEBUG(D_HA, "Found orphan "DFID" count %d, skip it\n",
PFID(lf), mdo->mod_count);
if (likely(mdo->mod_count > 0)) {
CDEBUG(D_HA, "Found orphan "DFID" count %d, skip it\n",
PFID(lf), mdo->mod_count);