#include <linux/module.h>
#include <linux/init.h>
#include <linux/version.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
-# include <linux/buffer_head.h>
-# include <linux/workqueue.h>
-#else
-# include <linux/locks.h>
-#endif
+#include <linux/buffer_head.h>
+#include <linux/workqueue.h>
#include <obd_class.h>
#include <obd_lov.h>
atomic_set(&mfd->mfd_refcount, 2);
- INIT_LIST_HEAD(&mfd->mfd_handle.h_link);
- INIT_LIST_HEAD(&mfd->mfd_list);
+ CFS_INIT_LIST_HEAD(&mfd->mfd_handle.h_link);
+ CFS_INIT_LIST_HEAD(&mfd->mfd_list);
class_handle_hash(&mfd->mfd_handle, mds_mfd_addref);
return mfd;
struct mds_update_record *rec,
struct mds_obd *mds, struct obd_device *obd,
struct dentry *dchild, void **handle,
- obd_id **ids)
+ struct lov_mds_md **objid)
{
struct inode *inode = dchild->d_inode;
struct obd_trans_info oti = { 0 };
if (body->valid & OBD_MD_FLEASIZE)
RETURN(0);
- OBD_ALLOC(*ids, mds->mds_lov_desc.ld_tgt_count * sizeof(**ids));
- if (*ids == NULL)
- RETURN(-ENOMEM);
oti_init(&oti, req);
- oti.oti_objid = *ids;
/* replay case */
if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
GOTO(out_ids, rc);
}
- mds_objids_from_lmm(*ids, lmm, &mds->mds_lov_desc);
-
rc = fsfilt_set_md(obd, inode, *handle, lmm, lmm_size, "lov");
if (rc)
CERROR("open replay failed to set md:%d\n", rc);
LASSERT(lmm_buf);
memcpy(lmm_buf, lmm, lmm_size);
+ *objid = lmm_buf;
RETURN(rc);
}
- if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_MDS_ALLOC_OBDO))
+ if (OBD_FAIL_CHECK(OBD_FAIL_MDS_ALLOC_OBDO))
GOTO(out_ids, rc = -ENOMEM);
OBDO_ALLOC(oinfo.oi_oa);
lmm_buf = lustre_msg_buf(req->rq_repmsg, offset, lmm_size);
LASSERT(lmm_buf);
memcpy(lmm_buf, lmm, lmm_size);
+
+ *objid = lmm_buf; // save for mds_lov_update_objid
+
free_diskmd:
obd_free_diskmd(mds->mds_osc_exp, &lmm);
out_oa:
oti_free_cookies(&oti);
OBDO_FREE(oinfo.oi_oa);
out_ids:
- if (rc) {
- OBD_FREE(*ids, mds->mds_lov_desc.ld_tgt_count * sizeof(**ids));
- *ids = NULL;
- }
if (oinfo.oi_md)
obd_free_memmd(mds->mds_osc_exp, &oinfo.oi_md);
RETURN(rc);
struct mds_obd *mds = mds_req2mds(req);
struct obd_device *obd = req->rq_export->exp_obd;
struct mds_file_data *mfd = NULL;
- obd_id *ids = NULL; /* object IDs created */
+ struct lov_mds_md *lmm = NULL; /* object IDs created */
int rc = 0;
ENTRY;
!(body->valid & OBD_MD_FLMODEASIZE)) {
/* no EA: create objects */
rc = mds_create_objects(req, DLM_REPLY_REC_OFF + 1, rec,
- mds, obd, dchild, handle, &ids);
+ mds, obd, dchild, handle, &lmm);
if (rc) {
CERROR("mds_create_objects: rc = %d\n", rc);
UNLOCK_INODE_MUTEX(dchild->d_inode);
CDEBUG(D_INODE, "mfd %p, cookie "LPX64"\n", mfd,
mfd->mfd_handle.h_cookie);
- if (ids != NULL) {
- mds_lov_update_objids(obd, ids);
- OBD_FREE(ids, sizeof(*ids) * mds->mds_lov_desc.ld_tgt_count);
- }
+ if (lmm != NULL)
+ mds_lov_update_objids(obd, lmm);
+
if (rc) /* coverity[deadcode] */
mds_mfd_unlink(mfd, 1);
rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
RETURN(rc);
+
repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
sizeof(*repbody));
mds_counter_incr(req->rq_export, LPROC_MDS_OPEN);
- OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_PAUSE_OPEN | OBD_FAIL_ONCE,
- (obd_timeout + 1) / 4);
+ OBD_FAIL_TIMEOUT_ORSET(OBD_FAIL_MDS_PAUSE_OPEN, OBD_FAIL_ONCE,
+ (obd_timeout + 1) / 4);
CLASSERT(MAXQUOTAS < 4);
if (offset == DLM_INTENT_REC_OFF) { /* intent */
}
/* Step 2: Lookup the child */
-
+
if (!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) &&
(rec->ur_flags & MDS_OPEN_LOCK) && (rec->ur_namelen == 1)) {
/* hack for nfsd with no_subtree_check, it will use anon
* dentry w/o filename to open the file. the anon dentry's
* parent was set to itself, so rec->ur_fid1 is the file.
* And in MDC it cannot derive the dentry's parent dentry,
- * hence the file's name, so we hack here in MDS,
+ * hence the file's name, so we hack here in MDS,
* refer to bug 13030. */
dchild = mds_fid2dentry(mds, rec->ur_fid1, NULL);
} else {
GOTO(cleanup, rc = -ENOTDIR);
}
- if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OPEN_CREATE)) {
- obd_fail_loc = OBD_FAIL_LDLM_REPLY | OBD_FAIL_ONCE;
+ if (OBD_FAIL_CHECK_RESET(OBD_FAIL_MDS_OPEN_CREATE,
+ OBD_FAIL_LDLM_REPLY | OBD_FAIL_ONCE)) {
GOTO(cleanup, rc = -EAGAIN);
}
inode->i_nlink, mds_orphan_open_count(inode));
last_orphan = mds_orphan_open_dec_test(inode) &&
- mds_inode_is_orphan(inode);
- MDS_UP_WRITE_ORPHAN_SEM(inode);
+ mds_inode_is_orphan(inode);
/* this is half of the actual "close" */
if (mfd->mfd_mode & FMODE_WRITE) {
} else if (mfd->mfd_mode & MDS_FMODE_EXEC) {
mds_allow_write_access(inode);
}
+ /* here writecount change also needs protection from orphan write sem.
+ * so drop orphan write sem after mds_put_write_access, bz 12888. */
+ MDS_UP_WRITE_ORPHAN_SEM(inode);
if (last_orphan && unlink_orphan) {
int stripe_count = 0;
LASSERT(rc == 0); /* mds_put_write_access must have succeeded */
- CDEBUG(D_HA, "destroying orphan object %s\n", fidname);
+ CDEBUG(D_INODE, "destroying orphan object %s\n", fidname);
if ((S_ISREG(inode->i_mode) && inode->i_nlink != 1) ||
(S_ISDIR(inode->i_mode) && inode->i_nlink != 2))
ENTRY;
rc = lustre_pack_reply(req, 4, repsize, NULL);
- if (rc) {
- CERROR("lustre_pack_reply: rc = %d\n", rc);
+ if (rc)
req->rq_status = rc;
/* continue on to drop local open even if we can't send reply */
- } else {
+ else
MDS_CHECK_RESENT(req, mds_reconstruct_generic(req));
- }
- CDEBUG(D_HA, "close req->rep_len %d mdsize %d cookiesize %d\n",
+ CDEBUG(D_INODE, "close req->rep_len %d mdsize %d cookiesize %d\n",
req->rq_replen,
obd->u.mds.mds_max_mdsize, obd->u.mds.mds_max_cookiesize);
mds_counter_incr(req->rq_export, LPROC_MDS_CLOSE);
}
rc = lustre_pack_reply(req, 2, size, NULL);
- if (rc) {
- CERROR("lustre_pack_reply: rc = %d\n", rc);
+ if (rc)
req->rq_status = rc;
- }
RETURN(0);
}