From a729537f950e9d7fadc56f6d70767d06945e997a Mon Sep 17 00:00:00 2001 From: tappro Date: Mon, 4 Sep 2006 08:50:25 +0000 Subject: [PATCH] proper locking for the mod_count, remove assert for transaction while write_lock --- lustre/mdd/mdd_handler.c | 6 +++--- lustre/mdd/mdd_orphans.c | 2 ++ lustre/osd/osd_handler.c | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 00098c7..8da7e1d 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -1149,7 +1149,7 @@ int __mdd_object_kill(const struct lu_context *ctxt, } return rc; } - +/* caller should take a lock before calling */ static int __mdd_finish_unlink(const struct lu_context *ctxt, struct mdd_object *obj, struct md_attr *ma, struct thandle *th) @@ -2035,7 +2035,7 @@ static int mdd_open(const struct lu_context *ctxt, struct md_object *obj, int mode = accmode(md2mdd_obj(obj), flags); int rc = 0; - mdd_read_lock(ctxt, md2mdd_obj(obj)); + mdd_write_lock(ctxt, md2mdd_obj(obj)); if (mode & MAY_WRITE) { if (mdd_is_immutable(md2mdd_obj(obj))) @@ -2045,7 +2045,7 @@ static int mdd_open(const struct lu_context *ctxt, struct md_object *obj, if (rc == 0) md2mdd_obj(obj)->mod_count ++; - mdd_read_unlock(ctxt, md2mdd_obj(obj)); + mdd_write_unlock(ctxt, md2mdd_obj(obj)); return rc; } diff --git a/lustre/mdd/mdd_orphans.c b/lustre/mdd/mdd_orphans.c index 6adce75..4f35c92 100644 --- a/lustre/mdd/mdd_orphans.c +++ b/lustre/mdd/mdd_orphans.c @@ -118,6 +118,7 @@ static void orph_key_test_and_del(const struct lu_context *ctx, if (IS_ERR(mdo)) CERROR("Invalid orphan!\n"); else { + mdd_write_lock(ctx, mdo); if (mdo->mod_count == 0) { /* non-opened orphan, let's delete it */ struct md_attr *ma = &mdd_ctx_info(ctx)->mti_ma; @@ -126,6 +127,7 @@ static void orph_key_test_and_del(const struct lu_context *ctx, //mdd_ost_objects_destroy(ctx, ma); /* TODO: destroy index entry */ } + mdd_write_unlock(ctx, mdo); mdd_object_put(ctx, mdo); } } diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index 24cd390..238596a 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -638,7 +638,9 @@ static void osd_object_write_lock(const struct lu_context *ctx, /* * Write lock assumes transaction. */ - LASSERT(oti->oti_txns > 0); + /* open need it without transaction + * LASSERT(oti->oti_txns > 0); + */ obj->oo_owner = ctx; oti->oti_w_locks++; } -- 1.8.3.1