Whamcloud - gitweb
- additional debug to catch the case when client gets openhandle w/o capa
[fs/lustre-release.git] / lustre / mds / mds_open.c
index f96835e..f00cac4 100644 (file)
@@ -94,7 +94,7 @@ struct mds_file_data *mds_handle2mfd(struct lustre_handle *handle)
         RETURN(class_handle2object(handle->cookie));
 }
 
-static void mds_mfd_put(struct mds_file_data *mfd)
+void mds_mfd_put(struct mds_file_data *mfd)
 {
         CDEBUG(D_INFO, "PUTting mfd %p : new refcount %d\n", mfd,
                atomic_read(&mfd->mfd_refcount) - 1);
@@ -632,6 +632,7 @@ static void reconstruct_open(struct mds_update_record *rec, int offset,
                 if (!(body->valid & OBD_MD_FLEASIZE))
                         body->valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
                                         OBD_MD_FLATIME | OBD_MD_FLMTIME);
+                DEBUG_REQ(D_ERROR, req, "no capa for "DLID4, OLID4(&body->id1));
         }
         
         /* If we have -EEXIST as the status, and we were asked to create
@@ -788,6 +789,7 @@ static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild,
                         .lc_uid   = rec->ur_uc.luc_uid,
                         .lc_op    = capa_op(rec->ur_flags),
                         .lc_ino   = dchild->d_inode->i_ino,
+                        .lc_igen  = dchild->d_inode->i_generation,
                         .lc_mdsid = mds->mds_num,
                 };
 
@@ -1272,13 +1274,8 @@ got_child:
                         }
                 }
 
-                if (!(rec->ur_flags & O_EXCL)) { /* bug 3313 */
-                        rc = fsfilt_commit(obd, dchild->d_inode->i_sb,
-                                           dchild->d_inode, handle, 
-                                           req->rq_export->exp_sync);
-                        handle = NULL;
-                }
-
+                rc = fsfilt_commit(obd, dchild->d_inode->i_sb, dchild->d_inode, handle, 0);
+                handle = NULL;
                 acc_mode = 0;           /* Don't check for permissions */
         }
         mds_pack_inode2body(obd, body, dchild->d_inode, 1);
@@ -1389,7 +1386,6 @@ got_child:
         }
 #else
 /* re-enable test 24n in sanity.sh: it needs LOOKUP lock on open */
-#warning "disable opencache lock for CMD2"
 #endif
 
         /* Step 5: mds_open it */
@@ -1459,24 +1455,9 @@ cleanup_no_trans:
                         mds_lock_new_child(obd, dchild->d_inode, NULL);
                 }
                 /* audit stuff for OPEN */
-                if (offset == 3 && (dchild->d_inode || dparent)) {
-                        struct lustre_id au_id;
-                        struct inode * au_inode = dchild->d_inode;
-
-                        if (au_inode == NULL) {
-                                au_inode = dparent->d_inode;
-                                au_id = *(rec->ur_id1);
-                                mds_audit_open(req, &au_id, au_inode, 
-                                               rec->ur_name, rec->ur_namelen - 1,
-                                               rc);
-                        } else {
-                                if (fid == 0)
-                                        mds_read_inode_sid(obd, au_inode, &au_id);
-                                else
-                                        mds_inode2id(obd, &au_id, au_inode, fid);
-                                mds_audit_open(req, &au_id, au_inode, 
-                                               NULL, 0, rc);
-                        }
+                if (offset == 3) {
+                        mds_audit(req, dchild, rec->ur_name,
+                                  rec->ur_namelen - 1, AUDIT_OPEN, rc);
                 }
 
                 l_dput(dchild);
@@ -1561,8 +1542,11 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset,
                                request_body->io_epoch);
                 i_size_write(inode, request_body->size);
                 inode->i_blocks = request_body->blocks;
+                LTIME_S(inode->i_mtime) = (request_body->mtime);
+
+                LTIME_S(iattr.ia_mtime) = request_body->mtime;
                 iattr.ia_size = inode->i_size;
-                iattr.ia_valid |= ATTR_SIZE;
+                iattr.ia_valid |= ATTR_SIZE|ATTR_MTIME;
                 mds_inode_unset_attrs_old(inode);
         }
 
@@ -1786,6 +1770,7 @@ static int mds_extent_lock_callback(struct ldlm_lock *lock,
 }
 __u64 lov_merge_size(struct lov_stripe_md *lsm, int kms);
 __u64 lov_merge_blocks(struct lov_stripe_md *lsm);
+__u64 lov_merge_mtime(struct lov_stripe_md *lsm, __u64 current_time);
 
 int mds_validate_size(struct obd_device *obd, struct inode *inode,
                       struct mds_body *body, struct iattr *iattr)
@@ -1874,8 +1859,11 @@ int mds_validate_size(struct obd_device *obd, struct inode *inode,
 
         i_size_write(inode, lov_merge_size(lsm, 0));
         inode->i_blocks = lov_merge_blocks(lsm);
+        LTIME_S(inode->i_mtime) = lov_merge_mtime(lsm, LTIME_S(inode->i_mtime));
         iattr->ia_size = inode->i_size;
-        iattr->ia_valid |= ATTR_SIZE;
+        LTIME_S(iattr->ia_mtime) = LTIME_S(inode->i_mtime);
+        iattr->ia_valid |= ATTR_SIZE | ATTR_MTIME;
+        
         DOWN_WRITE_I_ALLOC_SEM(inode);
         mds_inode_unset_attrs_old(inode);
         UP_WRITE_I_ALLOC_SEM(inode);