Whamcloud - gitweb
LU-1206: mdt: Fix error handling in mdt_mfd_open
authorOleg Drokin <green@whamcloud.com>
Thu, 15 Mar 2012 00:56:02 +0000 (20:56 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 29 Mar 2012 18:09:04 +0000 (14:09 -0400)
In mdt_mfd_open if the mo_open() call failed or we could not allocate
mfd, we also need to undo write/exec reference count in order to
not mess up with subsequent exec/write accesses.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Oleg Drokin <green@whamcloud.com>
Change-Id: I3bd98bd68368b48f2afaa7bb450d3a9947c992ac
Reviewed-on: http://review.whamcloud.com/2300
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/mdt/mdt_open.c

index b896886..661461b 100644 (file)
@@ -650,7 +650,7 @@ static int mdt_mfd_open(struct mdt_thread_info *info, struct mdt_object *p,
         rc = mo_open(info->mti_env, mdt_object_child(o),
                      created ? flags | MDS_OPEN_CREATED : flags);
         if (rc)
-                RETURN(rc);
+                GOTO(err_out, rc);
 
         mfd = mdt_mfd_new();
         if (mfd != NULL) {
@@ -716,11 +716,19 @@ static int mdt_mfd_open(struct mdt_thread_info *info, struct mdt_object *p,
 
                 mdt_empty_transno(info);
         } else
-                rc = -ENOMEM;
+                GOTO(err_out, rc = -ENOMEM);
 
         RETURN(rc);
-}
 
+err_out:
+        if (flags & FMODE_WRITE)
+                        /* XXX We also need to close io epoch here.
+                         * See LU-1220 - green */
+                mdt_write_put(o);
+        else if (flags & FMODE_EXEC)
+                mdt_write_allow(o);
+        return rc;
+}
 
 static int mdt_finish_open(struct mdt_thread_info *info,
                            struct mdt_object *p, struct mdt_object *o,