From 823795993036853dfb9e954c330cabfe376c3c57 Mon Sep 17 00:00:00 2001 From: pschwan Date: Tue, 24 Sep 2002 16:24:45 +0000 Subject: [PATCH] - Adds an int 'local_only' to the cancel_unused function and methods. Pass in a non-zero value to cancel the locks locally without notifying the server. Used in recovery. - Documentation update for the same. --- lustre/include/linux/lustre_dlm.h | 2 +- lustre/include/linux/obd.h | 3 ++- lustre/include/linux/obd_class.h | 4 ++-- lustre/ldlm/ldlm_request.c | 21 ++++++++++++++------- lustre/llite/file.c | 2 +- lustre/lov/lov_obd.c | 4 ++-- lustre/osc/osc_request.c | 4 ++-- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/lustre/include/linux/lustre_dlm.h b/lustre/include/linux/lustre_dlm.h index ad6a93c..41116b4 100644 --- a/lustre/include/linux/lustre_dlm.h +++ b/lustre/include/linux/lustre_dlm.h @@ -368,7 +368,7 @@ 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, int *flags); int ldlm_cli_cancel(struct lustre_handle *lockh); -int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, __u64 *res_id); +int ldlm_cli_cancel_unused(struct ldlm_namespace *, __u64 *, int local_only); /* mds/handler.c */ /* This has to be here because recurisve inclusion sucks. */ diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index 7547394..25fb414 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -300,7 +300,8 @@ struct obd_ops { struct lustre_handle *lockh); int (*o_cancel)(struct lustre_handle *, struct lov_stripe_md *md, __u32 mode, struct lustre_handle *); - int (*o_cancel_unused)(struct lustre_handle *, struct lov_stripe_md *); + int (*o_cancel_unused)(struct lustre_handle *, struct lov_stripe_md *, + int local_only); }; static inline void *mds_fs_start(struct mds_obd *mds, struct inode *inode, diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index fa4fc4b..dc2f71c 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -408,14 +408,14 @@ static inline int obd_cancel(struct lustre_handle *conn, } static inline int obd_cancel_unused(struct lustre_handle *conn, - struct lov_stripe_md *lsm) + struct lov_stripe_md *lsm, int local) { int rc; struct obd_export *export; OBD_CHECK_SETUP(conn, export); OBD_CHECK_OP(export->exp_obd, cancel_unused); - rc = OBP(export->exp_obd, cancel_unused)(conn, lsm); + rc = OBP(export->exp_obd, cancel_unused)(conn, lsm, local); RETURN(rc); } diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index e273834..bdde5c4 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -400,8 +400,12 @@ int ldlm_cli_cancel(struct lustre_handle *lockh) return rc; } -/* Cancel all locks on a given resource that have 0 readers/writers */ -int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, __u64 *res_id) +/* Cancel all locks on a given resource that have 0 readers/writers. + * + * If 'local_only' is true, throw the locks away without trying to notify the + * server. */ +int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, __u64 *res_id, + int local_only) { struct ldlm_resource *res; struct list_head *tmp, *next, list = LIST_HEAD_INIT(list); @@ -440,11 +444,14 @@ int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, __u64 *res_id) int rc; w = list_entry(tmp, struct ldlm_ast_work, w_list); - ldlm_lock2handle(w->w_lock, &lockh); - rc = ldlm_cli_cancel(&lockh); - if (rc != ELDLM_OK) - CERROR("ldlm_cli_cancel: %d\n", rc); - + if (local_only) + ldlm_lock_cancel(w->w_lock); + else { + ldlm_lock2handle(w->w_lock, &lockh); + rc = ldlm_cli_cancel(&lockh); + if (rc != ELDLM_OK) + CERROR("ldlm_cli_cancel: %d\n", rc); + } LDLM_LOCK_PUT(w->w_lock); list_del(&w->w_list); OBD_FREE(w, sizeof(*w)); diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 44ac03f..d86b313 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -294,7 +294,7 @@ static int ll_file_release(struct inode *inode, struct file *file) } ptlrpc_req_finished(fd->fd_req); - rc = obd_cancel_unused(ll_i2obdconn(inode), lli->lli_smd); + rc = obd_cancel_unused(ll_i2obdconn(inode), lli->lli_smd, 0); if (rc) CERROR("obd_cancel_unused: %d\n", rc); diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index f7b9248..aa8bdb3 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -868,7 +868,7 @@ static int lov_cancel(struct lustre_handle *conn, struct lov_stripe_md *lsm, } static int lov_cancel_unused(struct lustre_handle *conn, - struct lov_stripe_md *lsm) + struct lov_stripe_md *lsm, int local_only) { struct obd_export *export = class_conn2export(conn); struct lov_obd *lov; @@ -892,7 +892,7 @@ static int lov_cancel_unused(struct lustre_handle *conn, submd.lsm_mds_easize = lov_mds_md_size(lsm->lsm_ost_count); submd.lsm_stripe_count = 0; rc = obd_cancel_unused(&lov->tgts[loi->loi_ost_idx].conn, - &submd); + &submd, local_only); if (rc) CERROR("Error cancel unused objid "LPX64" subobj "LPX64 " on OST idx %d: rc = %d\n", lsm->lsm_object_id, diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index a4e1a18..ef67119 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -682,12 +682,12 @@ static int osc_cancel(struct lustre_handle *oconn, struct lov_stripe_md *md, } static int osc_cancel_unused(struct lustre_handle *connh, - struct lov_stripe_md *lsm) + struct lov_stripe_md *lsm, int local) { struct obd_device *obddev = class_conn2obd(connh); __u64 res_id[RES_NAME_SIZE] = { lsm->lsm_object_id }; - return ldlm_cli_cancel_unused(obddev->obd_namespace, res_id); + return ldlm_cli_cancel_unused(obddev->obd_namespace, res_id, local); } static int osc_statfs(struct lustre_handle *conn, struct obd_statfs *osfs) -- 1.8.3.1