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. */
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,
}
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);
}
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);
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));
}
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);
}
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;
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,
}
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)