staging/lustre: fix LBUG and inode refcount bug
authorPeng Tao <bergwolf@gmail.com>
Wed, 29 May 2013 13:40:56 +0000 (21:40 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 May 2013 11:49:45 +0000 (20:49 +0900)
ldlm_proc_setup and ldlm_proc_cleanup should reset global
pde pointers otherwise remount may hit
LASSERT(ldlm_ns_proc_dir == NULL);

Also in libcfs_sock_ioctl, fput() includes itself sock_release.
So don't call sock_release twice otherwise kernel may oops
due to incorrect inode ref counting.

Signed-off-by: Peng Tao <tao.peng@emc.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c

index f4d5b50b46ae9a32f7d1825ee406a03d87e2307e..9052dc5e7ad24e577294ec079708dbb8da598c27 100644 (file)
@@ -130,6 +130,8 @@ err_type:
        lprocfs_remove(&ldlm_type_proc_dir);
 err:
        ldlm_svc_proc_dir = NULL;
+       ldlm_type_proc_dir = NULL;
+       ldlm_ns_proc_dir = NULL;
        RETURN(rc);
 }
 
@@ -143,6 +145,10 @@ void ldlm_proc_cleanup(void)
 
        if (ldlm_type_proc_dir)
                lprocfs_remove(&ldlm_type_proc_dir);
+
+       ldlm_svc_proc_dir = NULL;
+       ldlm_type_proc_dir = NULL;
+       ldlm_ns_proc_dir = NULL;
 }
 
 static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v)
index 4a018167cb033f552463a7767cf1d0e425dd5be1..6f1f047d65555116d6e4c47d95133976f9811fc9 100644 (file)
@@ -49,7 +49,6 @@ libcfs_sock_ioctl(int cmd, unsigned long arg)
 {
        mm_segment_t    oldmm = get_fs();
        struct socket  *sock;
-       int          fd = -1;
        int          rc;
        struct file    *sock_filp;
 
@@ -61,6 +60,7 @@ libcfs_sock_ioctl(int cmd, unsigned long arg)
 
        sock_filp = sock_alloc_file(sock, 0, NULL);
        if (!sock_filp) {
+               sock_release(sock);
                rc = -ENOMEM;
                goto out;
        }
@@ -71,12 +71,7 @@ libcfs_sock_ioctl(int cmd, unsigned long arg)
        set_fs(oldmm);
 
        fput(sock_filp);
-
- out:
-       if (fd >= 0)
-               sys_close(fd);
-       else
-               sock_release(sock);
+out:
        return rc;
 }