#include <obd_class.h>
#include <lustre_osc.h>
+#include <uapi/linux/lustre/lustre_param.h>
#include "mdc_internal.h"
* VFS and page cache already protect us locally, so lots of readers/
* writers can share a single PW lock. */
mode = mdc_dom_lock_match(env, osc_export(obj), resname, LDLM_IBITS,
- policy, LCK_PR | LCK_PW, &flags, obj, &lockh,
+ policy, LCK_PR | LCK_PW | LCK_GROUP, &flags,
+ obj, &lockh,
dap_flags & OSC_DAP_FL_CANCELING);
if (mode != 0) {
lock = ldlm_handle2lock(&lockh);
result = 0;
}
- rc = mdc_lock_discard_pages(env, obj, start, end, discard);
+ /* Avoid lock matching with CLM_WRITE, there can be no other locks */
+ rc = mdc_lock_discard_pages(env, obj, start, end,
+ mode == CLM_WRITE || discard);
if (result == 0 && rc < 0)
result = rc;
*/
static int mdc_dlm_blocking_ast0(const struct lu_env *env,
struct ldlm_lock *dlmlock,
- void *data, int flag)
+ int flag)
{
struct cl_object *obj = NULL;
int result = 0;
break;
}
- rc = mdc_dlm_blocking_ast0(env, dlmlock, data, flag);
+ rc = mdc_dlm_blocking_ast0(env, dlmlock, flag);
cl_env_put(env, &refcheck);
break;
}
}
int mdc_enqueue_interpret(const struct lu_env *env, struct ptlrpc_request *req,
- struct osc_enqueue_args *aa, int rc)
+ void *args, int rc)
{
+ struct osc_enqueue_args *aa = args;
struct ldlm_lock *lock;
struct lustre_handle *lockh = &aa->oa_lockh;
enum ldlm_mode mode = aa->oa_mode;
enum ldlm_mode mode;
bool glimpse = *flags & LDLM_FL_HAS_INTENT;
__u64 match_flags = *flags;
- int rc;
+ struct list_head cancels = LIST_HEAD_INIT(cancels);
+ int rc, count;
ENTRY;
if (einfo->ei_mode == LCK_PR)
mode |= LCK_PW;
- if (!glimpse)
+ if (glimpse)
match_flags |= LDLM_FL_BLOCK_GRANTED;
- mode = ldlm_lock_match(obd->obd_namespace, match_flags, res_id,
- einfo->ei_type, policy, mode, &lockh, 0);
+ /* DOM locking uses LDLM_FL_KMS_IGNORE to mark locks wich have no valid
+ * LVB information, e.g. canceled locks or locks of just pruned object,
+ * such locks should be skipped.
+ */
+ mode = ldlm_lock_match_with_skip(obd->obd_namespace, match_flags,
+ LDLM_FL_KMS_IGNORE, res_id,
+ einfo->ei_type, policy, mode,
+ &lockh, 0);
if (mode) {
struct ldlm_lock *matched;
RETURN(ELDLM_OK);
matched = ldlm_handle2lock(&lockh);
- if (ldlm_is_kms_ignore(matched))
+ /* this shouldn't happen but this check is kept to make
+ * related test fail if problem occurs
+ */
+ if (unlikely(ldlm_is_kms_ignore(matched))) {
+ LDLM_ERROR(matched, "matched lock has KMS ignore flag");
goto no_match;
+ }
+
+ if (OBD_FAIL_CHECK(OBD_FAIL_MDC_GLIMPSE_DDOS))
+ ldlm_set_kms_ignore(matched);
if (mdc_set_dom_lock_data(env, matched, einfo->ei_cbdata)) {
*flags |= LDLM_FL_LVB_READY;
if (req == NULL)
RETURN(-ENOMEM);
- rc = ldlm_prep_enqueue_req(exp, req, NULL, 0);
+ /* For WRITE lock cancel other locks on resource early if any */
+ if (einfo->ei_mode & LCK_PW)
+ count = mdc_resource_get_unused_res(exp, res_id, &cancels,
+ einfo->ei_mode,
+ MDS_INODELOCK_DOM);
+ else
+ count = 0;
+
+ rc = ldlm_prep_enqueue_req(exp, req, &cancels, count);
if (rc < 0) {
ptlrpc_request_free(req);
RETURN(rc);
aa->oa_flags = flags;
aa->oa_lvb = lvb;
- req->rq_interpret_reply =
- (ptlrpc_interpterer_t)mdc_enqueue_interpret;
+ req->rq_interpret_reply = mdc_enqueue_interpret;
ptlrpcd_add_req(req);
} else {
ptlrpc_req_finished(req);
struct obdo *oa = &oio->oi_oa;
struct osc_async_cbargs *cbargs = &oio->oi_cbarg;
__u64 size = io->u.ci_setattr.sa_attr.lvb_size;
- unsigned int ia_valid = io->u.ci_setattr.sa_valid;
+ unsigned int ia_avalid = io->u.ci_setattr.sa_avalid;
+ enum op_xvalid ia_xvalid = io->u.ci_setattr.sa_xvalid;
int rc;
/* silently ignore non-truncate setattr for Data-on-MDT object */
struct ost_lvb *lvb = &io->u.ci_setattr.sa_attr;
unsigned int cl_valid = 0;
- if (ia_valid & ATTR_SIZE) {
- attr->cat_size = attr->cat_kms = size;
+ if (ia_avalid & ATTR_SIZE) {
+ attr->cat_size = size;
+ attr->cat_kms = size;
cl_valid = (CAT_SIZE | CAT_KMS);
}
- if (ia_valid & ATTR_MTIME_SET) {
+ if (ia_avalid & ATTR_MTIME_SET) {
attr->cat_mtime = lvb->lvb_mtime;
cl_valid |= CAT_MTIME;
}
- if (ia_valid & ATTR_ATIME_SET) {
+ if (ia_avalid & ATTR_ATIME_SET) {
attr->cat_atime = lvb->lvb_atime;
cl_valid |= CAT_ATIME;
}
- if (ia_valid & ATTR_CTIME_SET) {
+ if (ia_xvalid & OP_XVALID_CTIME_SET) {
attr->cat_ctime = lvb->lvb_ctime;
cl_valid |= CAT_CTIME;
}
return rc;
}
- if (!(ia_valid & ATTR_SIZE))
+ if (!(ia_avalid & ATTR_SIZE))
return 0;
memset(oa, 0, sizeof(*oa));
static int
mdc_data_version_interpret(const struct lu_env *env, struct ptlrpc_request *req,
- void *arg, int rc)
+ void *args, int rc)
{
- struct mdc_data_version_args *dva = arg;
+ struct mdc_data_version_args *dva = args;
struct osc_io *oio = dva->dva_oio;
const struct mdt_body *body;
{
ENTRY;
- if ((lock->l_ast_data == NULL && !ldlm_is_kms_ignore(lock)) ||
- (lock->l_ast_data == data)) {
+ if (lock->l_ast_data == data)
lock->l_ast_data = NULL;
- ldlm_set_kms_ignore(lock);
- }
+ ldlm_set_kms_ignore(lock);
RETURN(LDLM_ITER_CONTINUE);
}
return 0;
}
+static int mdc_object_flush(const struct lu_env *env, struct cl_object *obj,
+ struct ldlm_lock *lock)
+{
+ RETURN(mdc_dlm_blocking_ast0(env, lock, LDLM_CB_CANCELING));
+}
+
static const struct cl_object_operations mdc_ops = {
.coo_page_init = osc_page_init,
.coo_lock_init = mdc_lock_init,
.coo_glimpse = osc_object_glimpse,
.coo_req_attr_set = mdc_req_attr_set,
.coo_prune = mdc_object_prune,
+ .coo_object_flush = mdc_object_flush
};
static const struct osc_object_operations mdc_object_ops = {
return obj;
}
-static int mdc_cl_process_config(const struct lu_env *env,
- struct lu_device *d, struct lustre_cfg *cfg)
+static int mdc_process_config(const struct lu_env *env, struct lu_device *d,
+ struct lustre_cfg *cfg)
{
- return mdc_process_config(d->ld_obd, 0, cfg);
+ size_t count = class_modify_config(cfg, PARAM_MDC,
+ &d->ld_obd->obd_kset.kobj);
+ return count > 0 ? 0 : count;
}
const struct lu_device_operations mdc_lu_ops = {
.ldo_object_alloc = mdc_object_alloc,
- .ldo_process_config = mdc_cl_process_config,
+ .ldo_process_config = mdc_process_config,
.ldo_recovery_complete = NULL,
};