Whamcloud - gitweb
b=22731 server should not fall into LBUG if client send invalid parameter
[fs/lustre-release.git] / libsysio / src / rename.c
index bf8724c..05606ca 100644 (file)
@@ -127,7 +127,7 @@ SYSIO_INTERFACE_NAME(rename)(const char *oldpath, const char *newpath)
         * If old == new, we're done.
         */
        if (old->p_base->pb_ino == new->p_base->pb_ino)
-               goto out;
+               goto short_out;
 
        if (new->p_base->pb_ino) {
                /*
@@ -161,7 +161,12 @@ SYSIO_INTERFACE_NAME(rename)(const char *oldpath, const char *newpath)
                err = -EBUSY;
                goto error1;
        }
-       err = old->p_base->pb_ino->i_ops.inop_rename(old, new);
+       /*
+        * Use the parent node operations to request the task in case the
+        * driver is implemented using differentiated inode operations based
+        * on file type, such as incore does.
+        */
+       err = old->p_parent->p_base->pb_ino->i_ops.inop_rename(old, new);
        if (err)
                goto error1;
        /*
@@ -170,8 +175,9 @@ SYSIO_INTERFACE_NAME(rename)(const char *oldpath, const char *newpath)
        if (new->p_base->pb_ino)
                I_GONE(new->p_base->pb_ino);
        new->p_base->pb_ino = old->p_base->pb_ino;
-       I_REF(new->p_base->pb_ino);
+       old->p_base->pb_ino = NULL;
 
+short_out:
 error1:
        P_RELE(new);
 error2:
@@ -179,7 +185,6 @@ error2:
 error3:
        if (err)
                goto out;
-       _sysio_p_gone(old);                                     /* kill it! */
 out:
        SYSIO_INTERFACE_RETURN(err ? -1 : 0, err);
 }