CDEBUG(D_HA, "cancelling %d cookies\n",
(int)(mlcd->mlcd_cookielen / sizeof(*mlcd->mlcd_cookies)));
- rc = obd_unpackmd(obd->u.mds.mds_osc_exp, &lsm, mlcd->mlcd_lmm,
+ rc = obd_unpackmd(obd->u.mds.mds_osc_exp, &lsm, mlcd->mlcd_lmm,
mlcd->mlcd_eadatalen);
if (rc < 0) {
CERROR("bad LSM cancelling %d log cookies: rc %d\n",
/* Assumes caller has already pushed us into the kernel context. */
int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
- struct ptlrpc_request *req, int rc, __u32 op_data)
+ struct ptlrpc_request *req, int rc, __u32 op_data,
+ int force_sync)
{
struct mds_export_data *med = &req->rq_export->exp_mds_data;
struct mds_client_data *mcd = med->med_mcd;
struct obd_device *obd = req->rq_export->exp_obd;
- __u64 transno, prev_transno;
int err;
+ __u64 transno, prev_transno;
loff_t off;
int log_pri = D_HA;
ENTRY;
}
/* if the export has already been failed, we have no last_rcvd slot */
- if (req->rq_export->exp_failed) {
+ if (req->rq_export->exp_failed || obd->obd_fail) {
CWARN("commit transaction for disconnected client %s: rc %d\n",
req->rq_export->exp_client_uuid.uuid, rc);
if (rc == 0)
CERROR("client idx %d has offset %lld\n", med->med_lr_idx, off);
err = -EINVAL;
} else {
- fsfilt_add_journal_cb(req->rq_export->exp_obd, transno, handle,
- mds_commit_cb, NULL);
+ struct obd_export *exp = req->rq_export;
+
+ if (!force_sync)
+ force_sync = fsfilt_add_journal_cb(exp->exp_obd,transno,
+ handle, mds_commit_cb,
+ NULL);
+
err = fsfilt_write_record(obd, mds->mds_rcvd_filp, mcd,
sizeof(*mcd), &off,
- req->rq_export->exp_need_sync);
+ force_sync | exp->exp_need_sync);
+ if (force_sync)
+ mds_commit_cb(obd, transno, NULL, err);
}
if (err) {
DEBUG_REQ(log_pri, req,
"wrote trans #"LPU64" rc %d client %s at idx %u: err = %d",
- transno, rc, mcd->mcd_uuid, med->med_lr_idx, err);
+ transno, rc, mcd->mcd_uuid, med->med_lr_idx, err);
err = mds_lov_write_objids(obd);
if (err) {
}
spin_unlock(&exp->exp_lock);
}
-
+EXPORT_SYMBOL(mds_steal_ack_locks);
void mds_req_from_mcd(struct ptlrpc_request *req, struct mds_client_data *mcd)
{
if (lustre_msg_get_opc(req->rq_reqmsg) == MDS_CLOSE) {
l_dput(de);
}
-int mds_osc_setattr_async(struct obd_device *obd, struct inode *inode,
+int mds_osc_setattr_async(struct obd_device *obd, __u32 uid, __u32 gid,
struct lov_mds_md *lmm, int lmm_size,
- struct llog_cookie *logcookies, struct ll_fid *fid)
+ struct llog_cookie *logcookies, __u64 id, __u32 gen,
+ struct obd_capa *oc)
{
struct mds_obd *mds = &obd->u.mds;
struct obd_trans_info oti = { 0 };
RETURN(0);
/* first get memory EA */
- oinfo.oi_oa = obdo_alloc();
+ OBDO_ALLOC(oinfo.oi_oa);
if (!oinfo.oi_oa)
RETURN(-ENOMEM);
rc = obd_unpackmd(mds->mds_osc_exp, &oinfo.oi_md, lmm, lmm_size);
if (rc < 0) {
- CERROR("Error unpack md %p for inode %lu\n", lmm, inode->i_ino);
+ CERROR("Error unpack md %p for inode "LPU64"\n", lmm, id);
GOTO(out, rc);
}
}
/* then fill oa */
- obdo_from_inode(oinfo.oi_oa, inode, OBD_MD_FLUID | OBD_MD_FLGID);
- oinfo.oi_oa->o_valid |= OBD_MD_FLID;
+ oinfo.oi_oa->o_uid = uid;
+ oinfo.oi_oa->o_gid = gid;
oinfo.oi_oa->o_id = oinfo.oi_md->lsm_object_id;
+ oinfo.oi_oa->o_gr = oinfo.oi_md->lsm_object_gr;
+ oinfo.oi_oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP |
+ OBD_MD_FLUID | OBD_MD_FLGID;
if (logcookies) {
oinfo.oi_oa->o_valid |= OBD_MD_FLCOOKIE;
oti.oti_logcookies = logcookies;
}
- LASSERT(fid != NULL);
- oinfo.oi_oa->o_fid = fid->id;
- oinfo.oi_oa->o_generation = fid->generation;
+ oinfo.oi_oa->o_fid = id;
+ oinfo.oi_oa->o_generation = gen;
oinfo.oi_oa->o_valid |= OBD_MD_FLFID | OBD_MD_FLGENER;
+ oinfo.oi_capa = oc;
/* do async setattr from mds to ost not waiting for responses. */
rc = obd_setattr_async(mds->mds_osc_exp, &oinfo, &oti, NULL);
out:
if (oinfo.oi_md)
obd_free_memmd(mds->mds_osc_exp, &oinfo.oi_md);
- obdo_free(oinfo.oi_oa);
+ OBDO_FREE(oinfo.oi_oa);
RETURN(rc);
}
+EXPORT_SYMBOL(mds_osc_setattr_async);
/* In the raw-setattr case, we lock the child inode.
* In the write-back case or if being called from open, the client holds a lock
struct lov_mds_md *lmm = NULL;
struct llog_cookie *logcookies = NULL;
int lmm_size = 0, need_lock = 1, cookie_size = 0;
- int rc = 0, cleanup_phase = 0, err, locked = 0;
+ int rc = 0, cleanup_phase = 0, err, locked = 0, sync = 0;
unsigned int qcids[MAXQUOTAS] = { 0, 0 };
- unsigned int qpids[MAXQUOTAS] = { rec->ur_iattr.ia_uid,
+ unsigned int qpids[MAXQUOTAS] = { rec->ur_iattr.ia_uid,
rec->ur_iattr.ia_gid };
ENTRY;
lockpart |= MDS_INODELOCK_LOOKUP;
de = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, LCK_EX,
- &lockh, NULL, 0, lockpart);
+ &lockh, lockpart);
if (IS_ERR(de))
GOTO(cleanup, rc = PTR_ERR(de));
locked = 1;
need_lock = 0;
}
- OBD_FAIL_WRITE(obd, OBD_FAIL_MDS_REINT_SETATTR_WRITE, inode->i_sb);
+ OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_SETATTR_WRITE, inode->i_sb);
/* start a log jounal handle if needed */
if (S_ISREG(inode->i_mode) &&
if (logcookies == NULL)
GOTO(cleanup, rc = -ENOMEM);
- if (mds_log_op_setattr(obd, inode, lmm, lmm_size,
+ if (mds_log_op_setattr(obd, inode->i_uid, inode->i_gid,
+ lmm, lmm_size,
logcookies, cookie_size) <= 0) {
OBD_FREE(logcookies, cookie_size);
logcookies = NULL;
EXIT;
cleanup:
if (mlcd != NULL)
- fsfilt_add_journal_cb(req->rq_export->exp_obd, 0, handle,
- mds_cancel_cookies_cb, mlcd);
- err = mds_finish_transno(mds, inode, handle, req, rc, 0);
+ sync = fsfilt_add_journal_cb(req->rq_export->exp_obd, 0, handle,
+ mds_cancel_cookies_cb, mlcd);
+ err = mds_finish_transno(mds, inode, handle, req, rc, 0, sync);
/* do mds to ost setattr if needed */
if (!rc && !err && lmm_size)
- mds_osc_setattr_async(obd, inode, lmm, lmm_size,
- logcookies, rec->ur_fid1);
+ mds_osc_setattr_async(obd, inode->i_ino, inode->i_generation, lmm,
+ lmm_size, logcookies, rec->ur_fid1->id,
+ rec->ur_fid1->generation, NULL);
switch (cleanup_phase) {
case 2:
GOTO(cleanup, rc = -ESTALE);
dparent = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, LCK_EX, &lockh,
- rec->ur_name, rec->ur_namelen - 1,
MDS_INODELOCK_UPDATE);
if (IS_ERR(dparent)) {
rc = PTR_ERR(dparent);
cleanup_phase = 2; /* child dentry */
- OBD_FAIL_WRITE(obd, OBD_FAIL_MDS_REINT_CREATE_WRITE, dir->i_sb);
+ OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_CREATE_WRITE, dir->i_sb);
if (req->rq_export->exp_connect_flags & OBD_CONNECT_RDONLY) {
if (dchild->d_inode)
EXIT;
cleanup:
- err = mds_finish_transno(mds, dir, handle, req, rc, 0);
+ err = mds_finish_transno(mds, dir, handle, req, rc, 0, 0);
if (rc && created) {
/* Destroy the file we just created. This should not need
return 0;
}
-int res_gt(struct ldlm_res_id *res1, struct ldlm_res_id *res2,
+int res_gt(const struct ldlm_res_id *res1, const struct ldlm_res_id *res2,
ldlm_policy_data_t *p1, ldlm_policy_data_t *p2)
{
int i;
*
* One or two locks are taken in numerical order. A res_id->name[0] of 0 means
* no lock is taken for that res_id. Must be at least one non-zero res_id. */
-int enqueue_ordered_locks(struct obd_device *obd, struct ldlm_res_id *p1_res_id,
+int enqueue_ordered_locks(struct obd_device *obd,
+ const struct ldlm_res_id *p1_res_id,
struct lustre_handle *p1_lockh, int p1_lock_mode,
ldlm_policy_data_t *p1_policy,
- struct ldlm_res_id *p2_res_id,
+ const struct ldlm_res_id *p2_res_id,
struct lustre_handle *p2_lockh, int p2_lock_mode,
ldlm_policy_data_t *p2_policy)
{
- struct ldlm_res_id *res_id[2] = { p1_res_id, p2_res_id };
+ const struct ldlm_res_id *res_id[2] = { p1_res_id, p2_res_id };
struct lustre_handle *handles[2] = { p1_lockh, p2_lockh };
int lock_modes[2] = { p1_lock_mode, p2_lock_mode };
ldlm_policy_data_t *policies[2] = {p1_policy, p2_policy};
res_id[0]->name[0], res_id[1]->name[0]);
flags = LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB;
- rc = ldlm_cli_enqueue_local(obd->obd_namespace, *res_id[0],
+ rc = ldlm_cli_enqueue_local(obd->obd_namespace, res_id[0],
LDLM_IBITS, policies[0], lock_modes[0],
- &flags, ldlm_blocking_ast,
- ldlm_completion_ast, NULL, NULL, 0,
+ &flags, ldlm_blocking_ast,
+ ldlm_completion_ast, NULL, NULL, 0,
NULL, handles[0]);
if (rc != ELDLM_OK)
RETURN(-EIO);
ldlm_lock_addref(handles[1], lock_modes[1]);
} else if (res_id[1]->name[0] != 0) {
flags = LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB;
- rc = ldlm_cli_enqueue_local(obd->obd_namespace, *res_id[1],
+ rc = ldlm_cli_enqueue_local(obd->obd_namespace, res_id[1],
LDLM_IBITS, policies[1],
- lock_modes[1], &flags,
+ lock_modes[1], &flags,
ldlm_blocking_ast,
ldlm_completion_ast, NULL, NULL,
0, NULL, handles[1]);
RETURN(0);
}
-static inline int res_eq(struct ldlm_res_id *res1, struct ldlm_res_id *res2)
+static inline int res_eq(const struct ldlm_res_id *res1,
+ const struct ldlm_res_id *res2)
{
return !memcmp(res1, res2, sizeof(*res1));
}
static inline void
-try_to_aggregate_locks(struct ldlm_res_id *res1, ldlm_policy_data_t *p1,
- struct ldlm_res_id *res2, ldlm_policy_data_t *p2)
+try_to_aggregate_locks(const struct ldlm_res_id *res1, ldlm_policy_data_t *p1,
+ const struct ldlm_res_id *res2, ldlm_policy_data_t *p2)
{
if (!res_eq(res1, res2))
return;
p1->l_inodebits.bits |= p2->l_inodebits.bits;
}
-int enqueue_4ordered_locks(struct obd_device *obd,struct ldlm_res_id *p1_res_id,
+int enqueue_4ordered_locks(struct obd_device *obd,
+ const struct ldlm_res_id *p1_res_id,
struct lustre_handle *p1_lockh, int p1_lock_mode,
- ldlm_policy_data_t *p1_policy,
- struct ldlm_res_id *p2_res_id,
+ ldlm_policy_data_t *p1_policy,
+ const struct ldlm_res_id *p2_res_id,
struct lustre_handle *p2_lockh, int p2_lock_mode,
- ldlm_policy_data_t *p2_policy,
- struct ldlm_res_id *c1_res_id,
+ ldlm_policy_data_t *p2_policy,
+ const struct ldlm_res_id *c1_res_id,
struct lustre_handle *c1_lockh, int c1_lock_mode,
- ldlm_policy_data_t *c1_policy,
- struct ldlm_res_id *c2_res_id,
+ ldlm_policy_data_t *c1_policy,
+ const struct ldlm_res_id *c2_res_id,
struct lustre_handle *c2_lockh, int c2_lock_mode,
ldlm_policy_data_t *c2_policy)
{
- struct ldlm_res_id *res_id[5] = { p1_res_id, p2_res_id,
- c1_res_id, c2_res_id };
+ const struct ldlm_res_id *res_id[5] = { p1_res_id, p2_res_id,
+ c1_res_id, c2_res_id };
struct lustre_handle *dlm_handles[5] = { p1_lockh, p2_lockh,
c1_lockh, c2_lockh };
int lock_modes[5] = { p1_lock_mode, p2_lock_mode,
try_to_aggregate_locks(res_id[i], policies[i],
res_id[i+1], policies[i+1]);
rc = ldlm_cli_enqueue_local(obd->obd_namespace,
- *res_id[i], LDLM_IBITS,
+ res_id[i], LDLM_IBITS,
policies[i], lock_modes[i],
&flags, ldlm_blocking_ast,
- ldlm_completion_ast, NULL,
- NULL, 0, NULL,
+ ldlm_completion_ast, NULL,
+ NULL, 0, NULL,
dlm_handles[i]);
if (rc != ELDLM_OK)
GOTO(out_err, rc = -EIO);
* Returns 1 if the child changed and we need to re-lock (no locks held).
* Returns -ve error with a valid dchild (no locks held). */
static int mds_verify_child(struct obd_device *obd,
- struct ldlm_res_id *parent_res_id,
+ const struct ldlm_res_id *parent_res_id,
struct lustre_handle *parent_lockh,
struct dentry *dparent, int parent_mode,
struct ldlm_res_id *child_res_id,
struct dentry **dchildp, int child_mode,
ldlm_policy_data_t *child_policy,
const char *name, int namelen,
- struct ldlm_res_id *maxres)
+ const struct ldlm_res_id *maxres)
{
struct dentry *vchild, *dchild = *dchildp;
int rc = 0, cleanup_phase = 2; /* parent, child locks */
GOTO(cleanup, rc = 1);
}
- rc = ldlm_cli_enqueue_local(obd->obd_namespace, *child_res_id,
- LDLM_IBITS, child_policy,
- child_mode, &flags,
- ldlm_blocking_ast,
- ldlm_completion_ast, NULL,
+ rc = ldlm_cli_enqueue_local(obd->obd_namespace, child_res_id,
+ LDLM_IBITS, child_policy,
+ child_mode, &flags,
+ ldlm_blocking_ast,
+ ldlm_completion_ast, NULL,
NULL, 0, NULL, child_lockh);
if (rc != ELDLM_OK)
GOTO(cleanup, rc = -EIO);
child_res_id.name[1] = inode->i_generation;
/* If we want a LCK_CR for a directory, and this directory has not been
- changed for some time, we return not only a LOOKUP lock, but also an
+ changed for some time, we return not only a LOOKUP lock, but also an
UPDATE lock to have negative dentry starts working for this dir.
Also we apply same logic to non-directories. If the file is rarely
changed - we return both locks and this might save us RPC on
int mds_get_cookie_size(struct obd_device *obd, struct lov_mds_md *lmm)
{
int count = le32_to_cpu(lmm->lmm_stripe_count);
- int real_csize = count * sizeof(struct llog_cookie);
+ int real_csize = count * sizeof(struct llog_cookie);
return real_csize;
}
CDEBUG(D_INFO, "Shrink to md_size %d cookie_size %d \n", md_size,
cookie_size);
-
+
lustre_shrink_reply(req, md_off, md_size, 1);
-
- lustre_shrink_reply(req, md_off + (md_size > 0), cookie_size, 0);
+
+ lustre_shrink_reply(req, md_off + (md_size > 0), cookie_size, 0);
}
static int mds_reint_unlink(struct mds_update_record *rec, int offset,
rc = mds_get_parent_child_locked(obd, mds, rec->ur_fid1,
&parent_lockh, &dparent, LCK_EX,
- MDS_INODELOCK_UPDATE,
+ MDS_INODELOCK_UPDATE,
rec->ur_name, rec->ur_namelen,
- &child_lockh, &dchild, LCK_EX,
+ &child_lockh, &dchild, LCK_EX,
MDS_INODELOCK_FULL);
if (rc)
GOTO(cleanup, rc);
cleanup_phase = 3; /* child inum lock */
- OBD_FAIL_WRITE(obd, OBD_FAIL_MDS_REINT_UNLINK_WRITE, dparent->d_inode->i_sb);
+ OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_UNLINK_WRITE, dparent->d_inode->i_sb);
/* ldlm_reply in buf[0] if called via intent */
if (offset == DLM_INTENT_REC_OFF)
}
rc = mds_finish_transno(mds, dparent ? dparent->d_inode : NULL,
- handle, req, rc, 0);
+ handle, req, rc, 0, 0);
if (!rc)
(void)obd_set_info_async(mds->mds_osc_exp, strlen("unlinked"),
"unlinked", 0, NULL, NULL);
mds_shrink_reply(obd, req, body, REPLY_REC_OFF + 1);
/* trigger dqrel on the owner of child and parent */
- lquota_adjust(mds_quota_interface_ref, obd, qcids, qpids, rc,
- FSFILT_OP_UNLINK);
+ lquota_adjust(mds_quota_interface_ref, obd, qcids, qpids, rc, FSFILT_OP_UNLINK);
return 0;
}
DEBUG_REQ(D_INODE, req, "original "LPU64"/%u to "LPU64"/%u %s",
rec->ur_fid1->id, rec->ur_fid1->generation,
rec->ur_fid2->id, rec->ur_fid2->generation, rec->ur_name);
-
mds_counter_incr(req->rq_export, LPROC_MDS_LINK);
MDS_CHECK_RESENT(req, mds_reconstruct_generic(req));
}
/* Step 4: Do it. */
- OBD_FAIL_WRITE(obd, OBD_FAIL_MDS_REINT_LINK_WRITE, de_src->d_inode->i_sb);
+ OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_LINK_WRITE, de_src->d_inode->i_sb);
if (req->rq_export->exp_connect_flags & OBD_CONNECT_RDONLY)
GOTO(cleanup, rc = -EROFS);
CERROR("vfs_link error %d\n", rc);
cleanup:
rc = mds_finish_transno(mds, de_tgt_dir ? de_tgt_dir->d_inode : NULL,
- handle, req, rc, 0);
+ handle, req, rc, 0, 0);
EXIT;
switch (cleanup_phase) {
*de_oldp = ll_lookup_one_len(old_name, *de_srcdirp, old_len - 1);
if (IS_ERR(*de_oldp)) {
rc = PTR_ERR(*de_oldp);
- CERROR("old child lookup error (%.*s): %d\n",
+ CDEBUG(D_INODE, "old child lookup error (%.*s): %d\n",
old_len - 1, old_name, rc);
GOTO(cleanup, rc);
}
DEBUG_REQ(D_INODE, req, "parent "LPU64"/%u %s to "LPU64"/%u %s",
rec->ur_fid1->id, rec->ur_fid1->generation, rec->ur_name,
rec->ur_fid2->id, rec->ur_fid2->generation, rec->ur_tgt);
-
mds_counter_incr(req->rq_export, LPROC_MDS_RENAME);
-
+
MDS_CHECK_RESENT(req, mds_reconstruct_generic(req));
rc = mds_get_parents_children_locked(obd, mds, rec->ur_fid1, &de_srcdir,
}
no_unlink:
- OBD_FAIL_WRITE(obd, OBD_FAIL_MDS_REINT_RENAME_WRITE,
+ OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_RENAME_WRITE,
de_srcdir->d_inode->i_sb);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
GOTO(cleanup, rc);
cleanup:
rc = mds_finish_transno(mds, de_tgtdir ? de_tgtdir->d_inode : NULL,
- handle, req, rc, 0);
+ handle, req, rc, 0, 0);
switch (cleanup_phase) {
case 4:
req->rq_status = rc;
/* acquire/release qunit */
- lquota_adjust(mds_quota_interface_ref, obd, qcids, qpids, rc,
- FSFILT_OP_RENAME);
+ lquota_adjust(mds_quota_interface_ref, obd, qcids, qpids, rc, FSFILT_OP_RENAME);
return 0;
}
struct ptlrpc_request *req, struct lustre_handle *lockh)
{
struct obd_device *obd = req->rq_export->exp_obd;
+#if 0
struct mds_obd *mds = &obd->u.mds;
+#endif
struct lvfs_run_ctxt saved;
int rc;
ENTRY;
}
#endif
+#if 0
/* get group info of this user */
rec->ur_uc.luc_uce = upcall_cache_get_entry(mds->mds_group_hash,
rec->ur_uc.luc_fsuid,
if (rec->ur_uc.luc_uce)
rec->ur_uc.luc_fsgid = rec->ur_uc.luc_uce->ue_primary;
#endif
+#endif
push_ctxt(&saved, &obd->obd_lvfs_ctxt, &rec->ur_uc);
rc = reinters[rec->ur_opcode] (rec, offset, req, lockh);
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, &rec->ur_uc);
+#if 0
upcall_cache_put_entry(mds->mds_group_hash, rec->ur_uc.luc_uce);
+#endif
RETURN(rc);
}