Whamcloud - gitweb
patches related to bug 13377 (CMD small fixes), 2+4 patch and fid_unpack patch
[fs/lustre-release.git] / lustre / mds / mds_open.c
index 58e4bce..5136883 100644 (file)
@@ -320,8 +320,7 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset,
 
         if (!S_ISREG(inode->i_mode))
                 RETURN(0);
-        if (rec->ur_flags & MDS_OPEN_DELAY_CREATE ||
-            !(rec->ur_flags & FMODE_WRITE))
+        if (!md_should_create(rec->ur_flags))
                 RETURN(0);
 
         body = lustre_msg_buf(req->rq_repmsg, DLM_REPLY_REC_OFF, sizeof(*body));
@@ -433,8 +432,8 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset,
                 oinfo.oi_md->lsm_object_id = oinfo.oi_oa->o_id;
                 oinfo.oi_md->lsm_object_gr = oinfo.oi_oa->o_gr;
         }
-        if (inode->i_size) {
-                oinfo.oi_oa->o_size = inode->i_size;
+        if (i_size_read(inode)) {
+                oinfo.oi_oa->o_size = i_size_read(inode);
                 obdo_from_inode(oinfo.oi_oa, inode, OBD_MD_FLTYPE |
                                 OBD_MD_FLATIME | OBD_MD_FLMTIME |
                                 OBD_MD_FLCTIME | OBD_MD_FLSIZE);
@@ -981,7 +980,20 @@ int mds_open(struct mds_update_record *rec, int offset,
         }
 
         /* Step 2: Lookup the child */
-        dchild = ll_lookup_one_len(rec->ur_name, dparent, rec->ur_namelen - 1);
+      
+        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, 
+                 * refer to bug 13030. */
+                dchild = mds_fid2dentry(mds, rec->ur_fid1, NULL);
+        } else {
+                dchild = ll_lookup_one_len(rec->ur_name, dparent,
+                                           rec->ur_namelen - 1);
+        }
         if (IS_ERR(dchild)) {
                 rc = PTR_ERR(dchild);
                 dchild = NULL; /* don't confuse mds_finish_transno() below */