Commit b41cd6f0 authored by Dan Streetman's avatar Dan Streetman Committed by Linus Torvalds

[PATCH] fix usbfs mount count

Hi, this patch fixes usbfs.  You can't use a single mount_count for 2
different mounts.
parent af358dcd
......@@ -45,7 +45,8 @@ static struct inode_operations usbfs_dir_inode_operations;
static struct vfsmount *usbdevfs_mount;
static struct vfsmount *usbfs_mount;
static spinlock_t mount_lock = SPIN_LOCK_UNLOCKED;
static int mount_count; /* = 0 */
static int usbdevfs_mount_count; /* = 0 */
static int usbfs_mount_count; /* = 0 */
static struct dentry *devices_usbdevfs_dentry;
static struct dentry *devices_usbfs_dentry;
......@@ -507,14 +508,14 @@ static struct file_system_type usb_fs_type = {
};
/* --------------------------------------------------------------------- */
static int get_mount (struct file_system_type *fs_type, struct vfsmount **mount)
static int get_mount (struct file_system_type *fs_type, struct vfsmount **mount, int *mount_count)
{
struct vfsmount *mnt;
spin_lock (&mount_lock);
if (*mount) {
mntget(*mount);
++mount_count;
++(*mount_count);
spin_unlock (&mount_lock);
goto go_ahead;
}
......@@ -528,33 +529,33 @@ static int get_mount (struct file_system_type *fs_type, struct vfsmount **mount)
spin_lock (&mount_lock);
if (!*mount) {
*mount = mnt;
++mount_count;
++(*mount_count);
spin_unlock (&mount_lock);
goto go_ahead;
}
mntget(*mount);
++mount_count;
++(*mount_count);
spin_unlock (&mount_lock);
mntput(mnt);
go_ahead:
dbg("mount_count = %d", mount_count);
dbg("mount_count = %d", *mount_count);
return 0;
}
static void put_mount (struct vfsmount **mount)
static void put_mount (struct vfsmount **mount, int *mount_count)
{
struct vfsmount *mnt;
spin_lock (&mount_lock);
mnt = *mount;
--mount_count;
if (!mount_count)
--(*mount_count);
if (!(*mount_count))
*mount = NULL;
spin_unlock (&mount_lock);
mntput(mnt);
dbg("mount_count = %d", mount_count);
dbg("mount_count = %d", *mount_count);
}
static int create_special_files (void)
......@@ -563,13 +564,13 @@ static int create_special_files (void)
int retval = 0;
/* create the devices special file */
retval = get_mount (&usbdevice_fs_type, &usbdevfs_mount);
retval = get_mount (&usbdevice_fs_type, &usbdevfs_mount, &usbdevfs_mount_count);
if (retval) {
err ("Unable to get usbdevfs mount");
goto exit;
}
retval = get_mount (&usb_fs_type, &usbfs_mount);
retval = get_mount (&usb_fs_type, &usbfs_mount, &usbfs_mount_count);
if (retval) {
err ("Unable to get usbfs mount");
goto error_clean_usbdevfs_mount;
......@@ -604,10 +605,10 @@ static int create_special_files (void)
devices_usbfs_dentry = NULL;
error_clean_mounts:
put_mount (&usbfs_mount);
put_mount (&usbfs_mount, &usbfs_mount_count);
error_clean_usbdevfs_mount:
put_mount (&usbdevfs_mount);
put_mount (&usbdevfs_mount, &usbdevfs_mount_count);
exit:
return retval;
......@@ -621,8 +622,8 @@ static void remove_special_files (void)
fs_remove_file (devices_usbfs_dentry);
devices_usbdevfs_dentry = NULL;
devices_usbfs_dentry = NULL;
put_mount (&usbdevfs_mount);
put_mount (&usbfs_mount);
put_mount (&usbdevfs_mount, &usbdevfs_mount_count);
put_mount (&usbfs_mount, &usbfs_mount_count);
}
void usbfs_update_special (void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment