Commit 90b90d06 authored by Jens Axboe's avatar Jens Axboe

Merge branch 'for-4.5/for-jens' of...

Merge branch 'for-4.5/for-jens' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/linux-block into for-linus

Locking fix from Jiri
parents ed0ae43c a0c80efe
...@@ -866,7 +866,7 @@ static void set_fdc(int drive) ...@@ -866,7 +866,7 @@ static void set_fdc(int drive)
} }
/* locks the driver */ /* locks the driver */
static int lock_fdc(int drive, bool interruptible) static int lock_fdc(int drive)
{ {
if (WARN(atomic_read(&usage_count) == 0, if (WARN(atomic_read(&usage_count) == 0,
"Trying to lock fdc while usage count=0\n")) "Trying to lock fdc while usage count=0\n"))
...@@ -2173,7 +2173,7 @@ static int do_format(int drive, struct format_descr *tmp_format_req) ...@@ -2173,7 +2173,7 @@ static int do_format(int drive, struct format_descr *tmp_format_req)
{ {
int ret; int ret;
if (lock_fdc(drive, true)) if (lock_fdc(drive))
return -EINTR; return -EINTR;
set_floppy(drive); set_floppy(drive);
...@@ -2960,7 +2960,7 @@ static int user_reset_fdc(int drive, int arg, bool interruptible) ...@@ -2960,7 +2960,7 @@ static int user_reset_fdc(int drive, int arg, bool interruptible)
{ {
int ret; int ret;
if (lock_fdc(drive, interruptible)) if (lock_fdc(drive))
return -EINTR; return -EINTR;
if (arg == FD_RESET_ALWAYS) if (arg == FD_RESET_ALWAYS)
...@@ -3243,7 +3243,7 @@ static int set_geometry(unsigned int cmd, struct floppy_struct *g, ...@@ -3243,7 +3243,7 @@ static int set_geometry(unsigned int cmd, struct floppy_struct *g,
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
mutex_lock(&open_lock); mutex_lock(&open_lock);
if (lock_fdc(drive, true)) { if (lock_fdc(drive)) {
mutex_unlock(&open_lock); mutex_unlock(&open_lock);
return -EINTR; return -EINTR;
} }
...@@ -3263,7 +3263,7 @@ static int set_geometry(unsigned int cmd, struct floppy_struct *g, ...@@ -3263,7 +3263,7 @@ static int set_geometry(unsigned int cmd, struct floppy_struct *g,
} else { } else {
int oldStretch; int oldStretch;
if (lock_fdc(drive, true)) if (lock_fdc(drive))
return -EINTR; return -EINTR;
if (cmd != FDDEFPRM) { if (cmd != FDDEFPRM) {
/* notice a disk change immediately, else /* notice a disk change immediately, else
...@@ -3349,7 +3349,7 @@ static int get_floppy_geometry(int drive, int type, struct floppy_struct **g) ...@@ -3349,7 +3349,7 @@ static int get_floppy_geometry(int drive, int type, struct floppy_struct **g)
if (type) if (type)
*g = &floppy_type[type]; *g = &floppy_type[type];
else { else {
if (lock_fdc(drive, false)) if (lock_fdc(drive))
return -EINTR; return -EINTR;
if (poll_drive(false, 0) == -EINTR) if (poll_drive(false, 0) == -EINTR)
return -EINTR; return -EINTR;
...@@ -3433,7 +3433,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int ...@@ -3433,7 +3433,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
if (UDRS->fd_ref != 1) if (UDRS->fd_ref != 1)
/* somebody else has this drive open */ /* somebody else has this drive open */
return -EBUSY; return -EBUSY;
if (lock_fdc(drive, true)) if (lock_fdc(drive))
return -EINTR; return -EINTR;
/* do the actual eject. Fails on /* do the actual eject. Fails on
...@@ -3445,7 +3445,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int ...@@ -3445,7 +3445,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
process_fd_request(); process_fd_request();
return ret; return ret;
case FDCLRPRM: case FDCLRPRM:
if (lock_fdc(drive, true)) if (lock_fdc(drive))
return -EINTR; return -EINTR;
current_type[drive] = NULL; current_type[drive] = NULL;
floppy_sizes[drive] = MAX_DISK_SIZE << 1; floppy_sizes[drive] = MAX_DISK_SIZE << 1;
...@@ -3467,7 +3467,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int ...@@ -3467,7 +3467,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
UDP->flags &= ~FTD_MSG; UDP->flags &= ~FTD_MSG;
return 0; return 0;
case FDFMTBEG: case FDFMTBEG:
if (lock_fdc(drive, true)) if (lock_fdc(drive))
return -EINTR; return -EINTR;
if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR) if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)
return -EINTR; return -EINTR;
...@@ -3484,7 +3484,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int ...@@ -3484,7 +3484,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
return do_format(drive, &inparam.f); return do_format(drive, &inparam.f);
case FDFMTEND: case FDFMTEND:
case FDFLUSH: case FDFLUSH:
if (lock_fdc(drive, true)) if (lock_fdc(drive))
return -EINTR; return -EINTR;
return invalidate_drive(bdev); return invalidate_drive(bdev);
case FDSETEMSGTRESH: case FDSETEMSGTRESH:
...@@ -3507,7 +3507,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int ...@@ -3507,7 +3507,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
outparam = UDP; outparam = UDP;
break; break;
case FDPOLLDRVSTAT: case FDPOLLDRVSTAT:
if (lock_fdc(drive, true)) if (lock_fdc(drive))
return -EINTR; return -EINTR;
if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR) if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)
return -EINTR; return -EINTR;
...@@ -3530,7 +3530,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int ...@@ -3530,7 +3530,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
case FDRAWCMD: case FDRAWCMD:
if (type) if (type)
return -EINVAL; return -EINVAL;
if (lock_fdc(drive, true)) if (lock_fdc(drive))
return -EINTR; return -EINTR;
set_floppy(drive); set_floppy(drive);
i = raw_cmd_ioctl(cmd, (void __user *)param); i = raw_cmd_ioctl(cmd, (void __user *)param);
...@@ -3539,7 +3539,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int ...@@ -3539,7 +3539,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
process_fd_request(); process_fd_request();
return i; return i;
case FDTWADDLE: case FDTWADDLE:
if (lock_fdc(drive, true)) if (lock_fdc(drive))
return -EINTR; return -EINTR;
twaddle(); twaddle();
process_fd_request(); process_fd_request();
...@@ -3748,7 +3748,8 @@ static unsigned int floppy_check_events(struct gendisk *disk, ...@@ -3748,7 +3748,8 @@ static unsigned int floppy_check_events(struct gendisk *disk,
return DISK_EVENT_MEDIA_CHANGE; return DISK_EVENT_MEDIA_CHANGE;
if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) { if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) {
lock_fdc(drive, false); if (lock_fdc(drive))
return -EINTR;
poll_drive(false, 0); poll_drive(false, 0);
process_fd_request(); process_fd_request();
} }
...@@ -3847,7 +3848,9 @@ static int floppy_revalidate(struct gendisk *disk) ...@@ -3847,7 +3848,9 @@ static int floppy_revalidate(struct gendisk *disk)
"VFS: revalidate called on non-open device.\n")) "VFS: revalidate called on non-open device.\n"))
return -EFAULT; return -EFAULT;
lock_fdc(drive, false); res = lock_fdc(drive);
if (res)
return res;
cf = (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags) || cf = (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags) ||
test_bit(FD_VERIFY_BIT, &UDRS->flags)); test_bit(FD_VERIFY_BIT, &UDRS->flags));
if (!(cf || test_bit(drive, &fake_change) || drive_no_geom(drive))) { if (!(cf || test_bit(drive, &fake_change) || drive_no_geom(drive))) {
......
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