Whamcloud - gitweb
Don't copy lvb into reply message on error, since that message might not have
[fs/lustre-release.git] / lustre / mds / mds_open.c
index 8d49420..0ed7c66 100644 (file)
@@ -28,6 +28,7 @@
 #endif
 #define DEBUG_SUBSYSTEM S_MDS
 
+#include <linux/version.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/version.h>
@@ -303,13 +304,15 @@ static void mds_objids_from_lmm(obd_id *ids, struct lov_mds_md *lmm,
 static int mds_create_objects(struct ptlrpc_request *req, int offset,
                               struct mds_update_record *rec,
                               struct mds_obd *mds, struct obd_device *obd,
-                              struct inode *inode, void **handle, obd_id **ids)
+                              struct dentry *dchild, void **handle, 
+                              obd_id **ids)
 {
         struct obdo *oa;
         struct obd_trans_info oti = { 0 };
         struct mds_body *body;
         struct lov_stripe_md *lsm = NULL;
         struct lov_mds_md *lmm = NULL;
+        struct inode *inode = dchild->d_inode;
         void *lmm_buf;
         int rc, lmm_bufsize, lmm_size;
         ENTRY;
@@ -386,6 +389,21 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset,
                                            0, &lsm, rec->ur_eadata);
                         if (rc)
                                 GOTO(out_oa, rc);
+                } else {
+                        OBD_ALLOC(lmm, mds->mds_max_mdsize);
+                        if (lmm == NULL)
+                                GOTO(out_oa, rc = -ENOMEM);
+
+                        lmm_size = mds->mds_max_mdsize;
+                        rc = mds_get_md(obd, dchild->d_parent->d_inode,
+                                        lmm, &lmm_size, 1);
+                        if (rc > 0)
+                                rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE,
+                                                   mds->mds_osc_exp, 
+                                                   0, &lsm, lmm);
+                        OBD_FREE(lmm, mds->mds_max_mdsize);
+                        if (rc)
+                                GOTO(out_oa, rc);
                 }
                 rc = obd_create(mds->mds_osc_exp, oa, &lsm, &oti);
                 if (rc) {
@@ -557,7 +575,7 @@ static void reconstruct_open(struct mds_update_record *rec, int offset,
                 mfd = NULL;
         }
 
-#warning "XXX fixme"
+        /* #warning "XXX fixme" bug 2991 */
         /* Here it used to LASSERT(mfd) if exp_outstanding_reply != NULL.
          * Now that exp_outstanding_reply is a list, it's just using mfd != NULL
          * to detect a re-open */
@@ -620,7 +638,7 @@ static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild,
         if (rec != NULL) {
                 /* no EA: create objects */
                 rc = mds_create_objects(req, 2, rec, mds, obd,
-                                        dchild->d_inode, handle, &ids);
+                                        dchild, handle, &ids);
                 if (rc) {
                         CERROR("mds_create_objects: rc = %d\n", rc);
                         up(&dchild->d_inode->i_sem);
@@ -790,14 +808,14 @@ int mds_open(struct mds_update_record *rec, int offset,
          * opened this file and is only replaying the RPC, so we open the
          * inode by fid (at some large expense in security). */
         if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
-                DEBUG_REQ(D_HA, req, "open replay, disp: "LPX64"\n", 
+                DEBUG_REQ(D_HA, req, "open replay, disp: "LPX64"\n",
                           rep->lock_policy_res1);
 
                 LASSERT(rec->ur_fid2->id);
-                
+
                 rc = mds_open_by_fid(req, rec->ur_fid2, body, rec->ur_flags,
                                      rec, rep);
-                if (rc != -ENOENT) 
+                if (rc != -ENOENT)
                         RETURN(rc);
                 /* We didn't find the correct inode on disk either, so we
                  * need to re-create it via a regular replay. */
@@ -1043,6 +1061,8 @@ int mds_mfd_close(struct ptlrpc_request *req, struct obd_device *obd,
         }
 
         if (last_orphan && unlink_orphan) {
+                int stripe_count = 0;
+                struct lov_mds_md *lmm = NULL;
                 LASSERT(rc == 0); /* mds_put_write_access must have succeeded */
 
                 CDEBUG(D_HA, "destroying orphan object %s\n", fidname);
@@ -1060,21 +1080,24 @@ int mds_mfd_close(struct ptlrpc_request *req, struct obd_device *obd,
                 LASSERT(pending_child->d_inode != NULL);
 
                 cleanup_phase = 2; /* dput(pending_child) when finished */
-                handle = fsfilt_start(obd, pending_dir, FSFILT_OP_UNLINK_LOG,
-                                      NULL);
+                if (req != NULL) {
+                        lmm = lustre_msg_buf(req->rq_repmsg, 1, 0);
+                        stripe_count = le32_to_cpu(lmm->lmm_stripe_count);
+                }
+
+                handle = fsfilt_start_log(obd, pending_dir, FSFILT_OP_UNLINK,
+                                          NULL, stripe_count);
                 if (IS_ERR(handle)) {
                         rc = PTR_ERR(handle);
                         handle = NULL;
                         GOTO(cleanup, rc);
                 }
 
-                if (req != NULL &&
-                    (reply_body->valid & OBD_MD_FLEASIZE) &&
-                    mds_log_op_unlink(obd, pending_child->d_inode,
-                                lustre_msg_buf(req->rq_repmsg, 1, 0),
-                                req->rq_repmsg->buflens[1],
-                                lustre_msg_buf(req->rq_repmsg, 2, 0),
-                                req->rq_repmsg->buflens[2]) > 0) {
+                if (req != NULL && (reply_body->valid & OBD_MD_FLEASIZE) &&
+                    mds_log_op_unlink(obd, pending_child->d_inode, lmm,
+                                      req->rq_repmsg->buflens[1],
+                                      lustre_msg_buf(req->rq_repmsg, 2, 0),
+                                      req->rq_repmsg->buflens[2]) > 0) {
                         reply_body->valid |= OBD_MD_FLCOOKIE;
                 }