From 97fe58c7ec2b5c88c4ecbc2e3597317792d985d6 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Fri, 6 Nov 2015 11:17:54 -0600 Subject: [PATCH] LU-7403 dlm: const qualify struct lustre_handle * params Add a const qualifier to several struct lustre_handle * parameters in the LDLM interface. Signed-off-by: John L. Hammond Change-Id: I65bc949af4ee78118ce9118801434b906dddf49b Reviewed-on: http://review.whamcloud.com/17071 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons --- lustre/include/lustre_dlm.h | 24 ++++++++++++------------ lustre/ldlm/ldlm_lock.c | 14 +++++++------- lustre/ldlm/ldlm_lockd.c | 4 ++-- lustre/ldlm/ldlm_request.c | 8 +++++--- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 57ec18e..0afbad7 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -1265,7 +1265,7 @@ void ldlm_lock2handle(const struct ldlm_lock *lock, struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *, __u64 flags); void ldlm_cancel_callback(struct ldlm_lock *); int ldlm_lock_remove_from_lru(struct ldlm_lock *); -int ldlm_lock_set_data(struct lustre_handle *, void *); +int ldlm_lock_set_data(const struct lustre_handle *lockh, void *data); /** * Obtain a lock reference by its handle. @@ -1365,10 +1365,11 @@ struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock); void ldlm_lock_put(struct ldlm_lock *lock); void ldlm_lock_destroy(struct ldlm_lock *lock); void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc); -void ldlm_lock_addref(struct lustre_handle *lockh, enum ldlm_mode mode); -int ldlm_lock_addref_try(struct lustre_handle *lockh, enum ldlm_mode mode); -void ldlm_lock_decref(struct lustre_handle *lockh, enum ldlm_mode mode); -void ldlm_lock_decref_and_cancel(struct lustre_handle *lockh, +void ldlm_lock_addref(const struct lustre_handle *lockh, enum ldlm_mode mode); +int ldlm_lock_addref_try(const struct lustre_handle *lockh, + enum ldlm_mode mode); +void ldlm_lock_decref(const struct lustre_handle *lockh, enum ldlm_mode mode); +void ldlm_lock_decref_and_cancel(const struct lustre_handle *lockh, enum ldlm_mode mode); void ldlm_lock_fail_match_locked(struct ldlm_lock *lock); void ldlm_lock_fail_match(struct ldlm_lock *lock); @@ -1378,7 +1379,7 @@ enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, const struct ldlm_res_id *, enum ldlm_type type, union ldlm_policy_data *, enum ldlm_mode mode, struct lustre_handle *, int unref); -enum ldlm_mode ldlm_revalidate_lock_handle(struct lustre_handle *lockh, +enum ldlm_mode ldlm_revalidate_lock_handle(const struct lustre_handle *lockh, __u64 *bits); struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, enum ldlm_mode new_mode, __u32 *flags); @@ -1386,7 +1387,7 @@ void ldlm_lock_downgrade(struct ldlm_lock *lock, enum ldlm_mode new_mode); void ldlm_lock_cancel(struct ldlm_lock *lock); void ldlm_reprocess_all(struct ldlm_resource *res); void ldlm_reprocess_all_ns(struct ldlm_namespace *ns); -void ldlm_lock_dump_handle(int level, struct lustre_handle *); +void ldlm_lock_dump_handle(int level, const struct lustre_handle *lockh); void ldlm_unlink_lock_skiplist(struct ldlm_lock *req); /* resource.c */ @@ -1480,7 +1481,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, enum ldlm_type type, __u8 with_policy, enum ldlm_mode mode, __u64 *flags, void *lvb, __u32 lvb_len, - struct lustre_handle *lockh, int rc); + const struct lustre_handle *lockh, int rc); int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, const struct ldlm_res_id *res_id, enum ldlm_type type, union ldlm_policy_data *policy, @@ -1491,11 +1492,10 @@ int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, void *data, __u32 lvb_len, enum lvb_type lvb_type, const __u64 *client_cookie, struct lustre_handle *lockh); -int ldlm_server_ast(struct lustre_handle *lockh, struct ldlm_lock_desc *new, - void *data, __u32 data_len); -int ldlm_cli_convert(struct lustre_handle *, int new_mode, __u32 *flags); +int ldlm_cli_convert(const struct lustre_handle *lockh, int new_mode, + __u32 *flags); int ldlm_cli_update_pool(struct ptlrpc_request *req); -int ldlm_cli_cancel(struct lustre_handle *lockh, +int ldlm_cli_cancel(const struct lustre_handle *lockh, enum ldlm_cancel_flags cancel_flags); int ldlm_cli_cancel_unused(struct ldlm_namespace *, const struct ldlm_res_id *, enum ldlm_cancel_flags flags, void *opaque); diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 28c2039..183cfac 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -714,7 +714,7 @@ void ldlm_add_ast_work_item(struct ldlm_lock *lock, struct ldlm_lock *new, * r/w reference type is determined by \a mode * Calls ldlm_lock_addref_internal. */ -void ldlm_lock_addref(struct lustre_handle *lockh, enum ldlm_mode mode) +void ldlm_lock_addref(const struct lustre_handle *lockh, enum ldlm_mode mode) { struct ldlm_lock *lock; @@ -757,7 +757,7 @@ void ldlm_lock_addref_internal_nolock(struct ldlm_lock *lock, * * \retval -EAGAIN lock is being canceled. */ -int ldlm_lock_addref_try(struct lustre_handle *lockh, enum ldlm_mode mode) +int ldlm_lock_addref_try(const struct lustre_handle *lockh, enum ldlm_mode mode) { struct ldlm_lock *lock; int result; @@ -900,7 +900,7 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, enum ldlm_mode mode) /** * Decrease reader/writer refcount for LDLM lock with handle \a lockh */ -void ldlm_lock_decref(struct lustre_handle *lockh, enum ldlm_mode mode) +void ldlm_lock_decref(const struct lustre_handle *lockh, enum ldlm_mode mode) { struct ldlm_lock *lock = __ldlm_handle2lock(lockh, 0); LASSERTF(lock != NULL, "Non-existing lock: "LPX64"\n", lockh->cookie); @@ -915,7 +915,7 @@ EXPORT_SYMBOL(ldlm_lock_decref); * drops to zero instead of putting into LRU. * */ -void ldlm_lock_decref_and_cancel(struct lustre_handle *lockh, +void ldlm_lock_decref_and_cancel(const struct lustre_handle *lockh, enum ldlm_mode mode) { struct ldlm_lock *lock = __ldlm_handle2lock(lockh, 0); @@ -1501,7 +1501,7 @@ enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, } EXPORT_SYMBOL(ldlm_lock_match); -enum ldlm_mode ldlm_revalidate_lock_handle(struct lustre_handle *lockh, +enum ldlm_mode ldlm_revalidate_lock_handle(const struct lustre_handle *lockh, __u64 *bits) { struct ldlm_lock *lock; @@ -2290,7 +2290,7 @@ EXPORT_SYMBOL(ldlm_lock_cancel); /** * Set opaque data into the lock that only makes sense to upper layer. */ -int ldlm_lock_set_data(struct lustre_handle *lockh, void *data) +int ldlm_lock_set_data(const struct lustre_handle *lockh, void *data) { struct ldlm_lock *lock = ldlm_handle2lock(lockh); int rc = -EINVAL; @@ -2583,7 +2583,7 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, * * Used when printing all locks on a resource for debug purposes. */ -void ldlm_lock_dump_handle(int level, struct lustre_handle *lockh) +void ldlm_lock_dump_handle(int level, const struct lustre_handle *lockh) { struct ldlm_lock *lock; diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index c86a314..37feb38 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -2136,8 +2136,8 @@ static int ldlm_handle_setinfo(struct ptlrpc_request *req) } static inline void ldlm_callback_errmsg(struct ptlrpc_request *req, - const char *msg, int rc, - struct lustre_handle *handle) + const char *msg, int rc, + const struct lustre_handle *handle) { DEBUG_REQ((req->rq_no_reply || rc) ? D_WARNING : D_DLMTRACE, req, "%s: [nid %s] [rc %d] [lock "LPX64"]", diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index f9faf01..76dd976 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -541,7 +541,8 @@ static void failed_lock_cleanup(struct ldlm_namespace *ns, int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, enum ldlm_type type, __u8 with_policy, enum ldlm_mode mode, __u64 *flags, void *lvb, - __u32 lvb_len, struct lustre_handle *lockh, int rc) + __u32 lvb_len, const struct lustre_handle *lockh, + int rc) { struct ldlm_namespace *ns = exp->exp_obd->obd_namespace; int is_replay = *flags & LDLM_FL_REPLAY; @@ -1025,7 +1026,8 @@ static int ldlm_cli_convert_local(struct ldlm_lock *lock, int new_mode, * conversion of locks which are on the waiting or converting queue */ /* Caller of this code is supposed to take care of lock readers/writers accounting */ -int ldlm_cli_convert(struct lustre_handle *lockh, int new_mode, __u32 *flags) +int ldlm_cli_convert(const struct lustre_handle *lockh, int new_mode, + __u32 *flags) { struct ldlm_request *body; struct ldlm_reply *reply; @@ -1340,7 +1342,7 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req) * * Lock must not have any readers or writers by this time. */ -int ldlm_cli_cancel(struct lustre_handle *lockh, +int ldlm_cli_cancel(const struct lustre_handle *lockh, enum ldlm_cancel_flags cancel_flags) { struct obd_export *exp; -- 1.8.3.1