ChangeSet 1.738.5.17, 2002/10/11 15:02:59-07:00, ddstreet@ieee.org [PATCH] fix usbfs mount count Hi, this patch fixes usbfs. You can't use a single mount_count for 2 different mounts. diff -Nru a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c --- a/drivers/usb/core/inode.c Sun Oct 13 17:09:22 2002 +++ b/drivers/usb/core/inode.c Sun Oct 13 17:09:22 2002 @@ -45,7 +45,8 @@ 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 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 @@ 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 @@ 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 @@ 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 @@ 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)