Whamcloud - gitweb
b=14230
[fs/lustre-release.git] / lustre / mds / mds_open.c
index bb6607b..61dc455 100644 (file)
@@ -82,8 +82,8 @@ struct mds_file_data *mds_mfd_new(void)
 
         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;
@@ -663,7 +663,7 @@ static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild,
         struct mds_obd *mds = mds_req2mds(req);
         struct obd_device *obd = req->rq_export->exp_obd;
         struct mds_file_data *mfd = NULL;
-        struct lov_mds_md *lmm; /* object IDs created */
+        struct lov_mds_md *lmm = NULL; /* object IDs created */
         int rc = 0;
         ENTRY;
 
@@ -970,14 +970,14 @@ int mds_open(struct mds_update_record *rec, int offset,
         }
 
         /* 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 {
@@ -1267,8 +1267,7 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset,struct obd_device *obd,
                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) {
@@ -1277,6 +1276,9 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset,struct obd_device *obd,
         } 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;