}
EXPORT_SYMBOL(range_be_to_cpu);
#endif
+
+/* issues dlm lock on passed @ns, @f stores it lock handle into @lh. */
+int fid_lock(struct ldlm_namespace *ns, const struct lu_fid *f,
+ struct lustre_handle *lh, ldlm_mode_t mode,
+ ldlm_policy_data_t *policy,
+ struct ldlm_res_id *res_id)
+{
+ int flags = LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB;
+ int rc;
+
+ LASSERT(ns != NULL);
+ LASSERT(lh != NULL);
+ LASSERT(f != NULL);
+
+ rc = ldlm_cli_enqueue_local(ns, *fid_build_res_name(f, res_id),
+ LDLM_IBITS, policy, mode, &flags,
+ ldlm_blocking_ast, ldlm_completion_ast,
+ NULL, NULL, 0, NULL, lh);
+ return rc == ELDLM_OK ? 0 : -EIO;
+}
+EXPORT_SYMBOL(fid_lock);
+
+void fid_unlock(const struct lu_fid *f,
+ struct lustre_handle *lh, ldlm_mode_t mode)
+{
+ {
+ /* FIXME: this is debug stuff, remove it later. */
+ struct ldlm_lock *lock = ldlm_handle2lock(lh);
+ if (!lock) {
+ CERROR("Invalid lock handle "LPX64"\n",
+ lh->cookie);
+ LBUG();
+ }
+ LASSERT(fid_res_name_eq(f, &lock->l_resource->lr_name));
+ LDLM_LOCK_PUT(lock);
+ }
+ ldlm_lock_decref(lh, mode);
+}
+EXPORT_SYMBOL(fid_unlock);
+
void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src);
void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src);
+/* fid locking */
+
+struct ldlm_namespace;
+
+int fid_lock(struct ldlm_namespace *ns, const struct lu_fid *f,
+ struct lustre_handle *lh, ldlm_mode_t mode,
+ ldlm_policy_data_t *policy,
+ struct ldlm_res_id *res_id);
+void fid_unlock(const struct lu_fid *f,
+ struct lustre_handle *lh, ldlm_mode_t mode);
+
+/*
+ * Build (DLM) resource name from fid.
+ */
+static inline struct ldlm_res_id *
+fid_build_res_name(const struct lu_fid *f,
+ struct ldlm_res_id *name)
+{
+ memset(name, 0, sizeof *name);
+ name->name[0] = fid_seq(f);
+ name->name[1] = fid_oid(f);
+ name->name[2] = fid_ver(f);
+ return name;
+}
+
+
+
/* Range common stuff */
void range_cpu_to_le(struct lu_range *dst, const struct lu_range *src);
void range_cpu_to_be(struct lu_range *dst, const struct lu_range *src);
return 0;
}
-/* issues dlm lock on passed @ns, @f stores it lock handle into @lh. */
-int fid_lock(struct ldlm_namespace *ns, const struct lu_fid *f,
- struct lustre_handle *lh, ldlm_mode_t mode,
- ldlm_policy_data_t *policy,
- struct ldlm_res_id *res_id)
-{
- int flags = LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB;
- int rc;
-
- LASSERT(ns != NULL);
- LASSERT(lh != NULL);
- LASSERT(f != NULL);
-
- rc = ldlm_cli_enqueue_local(ns, *fid_build_res_name(f, res_id),
- LDLM_IBITS, policy, mode, &flags,
- ldlm_blocking_ast, ldlm_completion_ast,
- NULL, NULL, 0, NULL, lh);
- return rc == ELDLM_OK ? 0 : -EIO;
-}
-
-/*
- * Just call ldlm_lock_decref() if decref, else we only call ptlrpc_save_lock()
- * to save this lock in req. when transaction committed, req will be released,
- * and lock will, too.
- */
-void fid_unlock(struct ptlrpc_request *req, const struct lu_fid *f,
- struct lustre_handle *lh, ldlm_mode_t mode, int decref)
-{
- {
- /* FIXME: this is debug stuff, remove it later. */
- struct ldlm_lock *lock = ldlm_handle2lock(lh);
- if (!lock) {
- CERROR("Invalid lock handle "LPX64"\n",
- lh->cookie);
- LBUG();
- }
- LASSERT(fid_res_name_eq(f, &lock->l_resource->lr_name));
- LDLM_LOCK_PUT(lock);
- }
-
- if (decref)
- ldlm_lock_decref(lh, mode);
- else
- ptlrpc_save_lock(req, lh, mode);
-}
-
static struct mdt_object *mdt_obj(struct lu_object *o)
{
LASSERT(lu_device_is_mdt(o->lo_dev));
RETURN(rc);
}
+/*
+ * Just call ldlm_lock_decref() if decref, else we only call ptlrpc_save_lock()
+ * to save this lock in req. when transaction committed, req will be released,
+ * and lock will, too.
+ */
void mdt_object_unlock(struct mdt_thread_info *info, struct mdt_object *o,
struct mdt_lock_handle *lh, int decref)
{
- struct ptlrpc_request *req = mdt_info_req(info);
+ struct ptlrpc_request *req = mdt_info_req(info);
+ struct lustre_handle *handle = &lh->mlh_lh;
+ ldlm_mode_t mode = lh->mlh_mode;
ENTRY;
- if (lustre_handle_is_used(&lh->mlh_lh)) {
- fid_unlock(req, mdt_object_fid(o),
- &lh->mlh_lh, lh->mlh_mode, decref);
- lh->mlh_lh.cookie = 0;
+ if (lustre_handle_is_used(handle)) {
+
+ if (decref)
+ fid_unlock(mdt_object_fid(o), handle, mode);
+ else
+ ptlrpc_save_lock(req, handle, mode);
+ handle->cookie = 0;
}
EXIT;
}
} \
} while(0)
-/*
- * Build (DLM) resource name from fid.
- */
-static inline struct ldlm_res_id *
-fid_build_res_name(const struct lu_fid *f,
- struct ldlm_res_id *name)
-{
- memset(name, 0, sizeof *name);
- name->name[0] = fid_seq(f);
- name->name[1] = fid_oid(f);
- name->name[2] = fid_ver(f);
- return name;
-}
-
#endif /* __KERNEL__ */
#endif /* _MDT_H */