Skip to content

Commit 2850713

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: "A collection of fixes from the past few weeks that should go into 4.5. This contains: - Overflow fix for sysfs discard show function from Alan. - A stacking limit init fix for max_dev_sectors, so we don't end up artificially capping some use cases. From Keith. - Have blk-mq proper end unstarted requests on a dying queue, instead of pushing that to the driver. From Keith. - NVMe: - Update to Kconfig description for NVME_SCSI, since it was vague and having it on is important for some SUSE distros. From Christoph. - Set of fixes from Keith, around surprise removal. Also kills the no-merge flag, so it supports merging. - Set of fixes for lightnvm from Matias, Javier, and Wenwei. - Fix null_blk oops when asked for lightnvm, but not available. From Matias. - Copy-to-user EINTR fix from Hannes, fixing a case where SG_IO fails if interrupted by a signal. - Two floppy fixes from Jiri, fixing signal handling and blocking open. - A use-after-free fix for O_DIRECT, from Mike Krinkin. - A block module ref count fix from Roman Pen. - An fs IO wait accounting fix for O_DSYNC from Stephane Gasparini. - Smaller reallo fix for xen-blkfront from Bob Liu. - Removal of an unused struct member in the deadline IO scheduler, from Tahsin. - Also from Tahsin, properly initialize inode struct members associated with cgroup writeback, if enabled. - From Tejun, ensure that we keep the superblock pinned during cgroup writeback" * 'for-linus' of git://git.kernel.dk/linux-block: (25 commits) blk: fix overflow in queue_discard_max_hw_show writeback: initialize inode members that track writeback history writeback: keep superblock pinned during cgroup writeback association switches bio: return EINTR if copying to user space got interrupted NVMe: Rate limit nvme IO warnings NVMe: Poll device while still active during remove NVMe: Requeue requests on suspended queues NVMe: Allow request merges NVMe: Fix io incapable return values blk-mq: End unstarted requests on dying queue block: Initialize max_dev_sectors to 0 null_blk: oops when initializing without lightnvm block: fix module reference leak on put_disk() call for cgroups throttle nvme: fix Kconfig description for BLK_DEV_NVME_SCSI kernel/fs: fix I/O wait not accounted for RW O_DSYNC floppy: refactor open() flags handling lightnvm: allow to force mm initialization lightnvm: check overflow and correct mlc pairs lightnvm: fix request intersection locking in rrpc lightnvm: warn if irqs are disabled in lock laddr ...
2 parents c28b947 + 18f922d commit 2850713

File tree

21 files changed

+175
-106
lines changed

21 files changed

+175
-106
lines changed

block/bio.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ int submit_bio_wait(int rw, struct bio *bio)
874874
bio->bi_private = &ret;
875875
bio->bi_end_io = submit_bio_wait_endio;
876876
submit_bio(rw, bio);
877-
wait_for_completion(&ret.event);
877+
wait_for_completion_io(&ret.event);
878878

879879
return ret.error;
880880
}
@@ -1090,9 +1090,12 @@ int bio_uncopy_user(struct bio *bio)
10901090
if (!bio_flagged(bio, BIO_NULL_MAPPED)) {
10911091
/*
10921092
* if we're in a workqueue, the request is orphaned, so
1093-
* don't copy into a random user address space, just free.
1093+
* don't copy into a random user address space, just free
1094+
* and return -EINTR so user space doesn't expect any data.
10941095
*/
1095-
if (current->mm && bio_data_dir(bio) == READ)
1096+
if (!current->mm)
1097+
ret = -EINTR;
1098+
else if (bio_data_dir(bio) == READ)
10961099
ret = bio_copy_to_iter(bio, bmd->iter);
10971100
if (bmd->is_our_pages)
10981101
bio_free_pages(bio);

block/blk-cgroup.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
788788
{
789789
struct gendisk *disk;
790790
struct blkcg_gq *blkg;
791+
struct module *owner;
791792
unsigned int major, minor;
792793
int key_len, part, ret;
793794
char *body;
@@ -804,7 +805,9 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
804805
if (!disk)
805806
return -ENODEV;
806807
if (part) {
808+
owner = disk->fops->owner;
807809
put_disk(disk);
810+
module_put(owner);
808811
return -ENODEV;
809812
}
810813

@@ -820,7 +823,9 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
820823
ret = PTR_ERR(blkg);
821824
rcu_read_unlock();
822825
spin_unlock_irq(disk->queue->queue_lock);
826+
owner = disk->fops->owner;
823827
put_disk(disk);
828+
module_put(owner);
824829
/*
825830
* If queue was bypassing, we should retry. Do so after a
826831
* short msleep(). It isn't strictly necessary but queue
@@ -851,9 +856,13 @@ EXPORT_SYMBOL_GPL(blkg_conf_prep);
851856
void blkg_conf_finish(struct blkg_conf_ctx *ctx)
852857
__releases(ctx->disk->queue->queue_lock) __releases(rcu)
853858
{
859+
struct module *owner;
860+
854861
spin_unlock_irq(ctx->disk->queue->queue_lock);
855862
rcu_read_unlock();
863+
owner = ctx->disk->fops->owner;
856864
put_disk(ctx->disk);
865+
module_put(owner);
857866
}
858867
EXPORT_SYMBOL_GPL(blkg_conf_finish);
859868

block/blk-mq.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,10 @@ static void blk_mq_check_expired(struct blk_mq_hw_ctx *hctx,
599599
* If a request wasn't started before the queue was
600600
* marked dying, kill it here or it'll go unnoticed.
601601
*/
602-
if (unlikely(blk_queue_dying(rq->q)))
603-
blk_mq_complete_request(rq, -EIO);
602+
if (unlikely(blk_queue_dying(rq->q))) {
603+
rq->errors = -EIO;
604+
blk_mq_end_request(rq, rq->errors);
605+
}
604606
return;
605607
}
606608

block/blk-settings.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ void blk_set_default_limits(struct queue_limits *lim)
9191
lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
9292
lim->virt_boundary_mask = 0;
9393
lim->max_segment_size = BLK_MAX_SEGMENT_SIZE;
94-
lim->max_sectors = lim->max_dev_sectors = lim->max_hw_sectors =
95-
BLK_SAFE_MAX_SECTORS;
94+
lim->max_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS;
95+
lim->max_dev_sectors = 0;
9696
lim->chunk_sectors = 0;
9797
lim->max_write_same_sectors = 0;
9898
lim->max_discard_sectors = 0;

block/blk-sysfs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,9 @@ static ssize_t queue_discard_granularity_show(struct request_queue *q, char *pag
147147

148148
static ssize_t queue_discard_max_hw_show(struct request_queue *q, char *page)
149149
{
150-
unsigned long long val;
151150

152-
val = q->limits.max_hw_discard_sectors << 9;
153-
return sprintf(page, "%llu\n", val);
151+
return sprintf(page, "%llu\n",
152+
(unsigned long long)q->limits.max_hw_discard_sectors << 9);
154153
}
155154

156155
static ssize_t queue_discard_max_show(struct request_queue *q, char *page)

block/deadline-iosched.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ struct deadline_data {
3939
*/
4040
struct request *next_rq[2];
4141
unsigned int batching; /* number of sequential requests made */
42-
sector_t last_sector; /* head position */
4342
unsigned int starved; /* times reads have starved writes */
4443

4544
/*
@@ -210,8 +209,6 @@ deadline_move_request(struct deadline_data *dd, struct request *rq)
210209
dd->next_rq[WRITE] = NULL;
211210
dd->next_rq[data_dir] = deadline_latter_request(rq);
212211

213-
dd->last_sector = rq_end_sector(rq);
214-
215212
/*
216213
* take it off the sort and fifo list, move
217214
* to dispatch queue

drivers/block/floppy.c

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ static void set_fdc(int drive)
866866
}
867867

868868
/* locks the driver */
869-
static int lock_fdc(int drive, bool interruptible)
869+
static int lock_fdc(int drive)
870870
{
871871
if (WARN(atomic_read(&usage_count) == 0,
872872
"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)
21732173
{
21742174
int ret;
21752175

2176-
if (lock_fdc(drive, true))
2176+
if (lock_fdc(drive))
21772177
return -EINTR;
21782178

21792179
set_floppy(drive);
@@ -2960,7 +2960,7 @@ static int user_reset_fdc(int drive, int arg, bool interruptible)
29602960
{
29612961
int ret;
29622962

2963-
if (lock_fdc(drive, interruptible))
2963+
if (lock_fdc(drive))
29642964
return -EINTR;
29652965

29662966
if (arg == FD_RESET_ALWAYS)
@@ -3243,7 +3243,7 @@ static int set_geometry(unsigned int cmd, struct floppy_struct *g,
32433243
if (!capable(CAP_SYS_ADMIN))
32443244
return -EPERM;
32453245
mutex_lock(&open_lock);
3246-
if (lock_fdc(drive, true)) {
3246+
if (lock_fdc(drive)) {
32473247
mutex_unlock(&open_lock);
32483248
return -EINTR;
32493249
}
@@ -3263,7 +3263,7 @@ static int set_geometry(unsigned int cmd, struct floppy_struct *g,
32633263
} else {
32643264
int oldStretch;
32653265

3266-
if (lock_fdc(drive, true))
3266+
if (lock_fdc(drive))
32673267
return -EINTR;
32683268
if (cmd != FDDEFPRM) {
32693269
/* notice a disk change immediately, else
@@ -3349,7 +3349,7 @@ static int get_floppy_geometry(int drive, int type, struct floppy_struct **g)
33493349
if (type)
33503350
*g = &floppy_type[type];
33513351
else {
3352-
if (lock_fdc(drive, false))
3352+
if (lock_fdc(drive))
33533353
return -EINTR;
33543354
if (poll_drive(false, 0) == -EINTR)
33553355
return -EINTR;
@@ -3433,7 +3433,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
34333433
if (UDRS->fd_ref != 1)
34343434
/* somebody else has this drive open */
34353435
return -EBUSY;
3436-
if (lock_fdc(drive, true))
3436+
if (lock_fdc(drive))
34373437
return -EINTR;
34383438

34393439
/* do the actual eject. Fails on
@@ -3445,7 +3445,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
34453445
process_fd_request();
34463446
return ret;
34473447
case FDCLRPRM:
3448-
if (lock_fdc(drive, true))
3448+
if (lock_fdc(drive))
34493449
return -EINTR;
34503450
current_type[drive] = NULL;
34513451
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
34673467
UDP->flags &= ~FTD_MSG;
34683468
return 0;
34693469
case FDFMTBEG:
3470-
if (lock_fdc(drive, true))
3470+
if (lock_fdc(drive))
34713471
return -EINTR;
34723472
if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)
34733473
return -EINTR;
@@ -3484,7 +3484,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
34843484
return do_format(drive, &inparam.f);
34853485
case FDFMTEND:
34863486
case FDFLUSH:
3487-
if (lock_fdc(drive, true))
3487+
if (lock_fdc(drive))
34883488
return -EINTR;
34893489
return invalidate_drive(bdev);
34903490
case FDSETEMSGTRESH:
@@ -3507,7 +3507,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
35073507
outparam = UDP;
35083508
break;
35093509
case FDPOLLDRVSTAT:
3510-
if (lock_fdc(drive, true))
3510+
if (lock_fdc(drive))
35113511
return -EINTR;
35123512
if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)
35133513
return -EINTR;
@@ -3530,7 +3530,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
35303530
case FDRAWCMD:
35313531
if (type)
35323532
return -EINVAL;
3533-
if (lock_fdc(drive, true))
3533+
if (lock_fdc(drive))
35343534
return -EINTR;
35353535
set_floppy(drive);
35363536
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
35393539
process_fd_request();
35403540
return i;
35413541
case FDTWADDLE:
3542-
if (lock_fdc(drive, true))
3542+
if (lock_fdc(drive))
35433543
return -EINTR;
35443544
twaddle();
35453545
process_fd_request();
@@ -3663,6 +3663,11 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
36633663

36643664
opened_bdev[drive] = bdev;
36653665

3666+
if (!(mode & (FMODE_READ|FMODE_WRITE))) {
3667+
res = -EINVAL;
3668+
goto out;
3669+
}
3670+
36663671
res = -ENXIO;
36673672

36683673
if (!floppy_track_buffer) {
@@ -3706,21 +3711,20 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
37063711
if (UFDCS->rawcmd == 1)
37073712
UFDCS->rawcmd = 2;
37083713

3709-
if (!(mode & FMODE_NDELAY)) {
3710-
if (mode & (FMODE_READ|FMODE_WRITE)) {
3711-
UDRS->last_checked = 0;
3712-
clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags);
3713-
check_disk_change(bdev);
3714-
if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags))
3715-
goto out;
3716-
if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags))
3717-
goto out;
3718-
}
3719-
res = -EROFS;
3720-
if ((mode & FMODE_WRITE) &&
3721-
!test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags))
3722-
goto out;
3723-
}
3714+
UDRS->last_checked = 0;
3715+
clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags);
3716+
check_disk_change(bdev);
3717+
if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags))
3718+
goto out;
3719+
if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags))
3720+
goto out;
3721+
3722+
res = -EROFS;
3723+
3724+
if ((mode & FMODE_WRITE) &&
3725+
!test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags))
3726+
goto out;
3727+
37243728
mutex_unlock(&open_lock);
37253729
mutex_unlock(&floppy_mutex);
37263730
return 0;
@@ -3748,7 +3752,8 @@ static unsigned int floppy_check_events(struct gendisk *disk,
37483752
return DISK_EVENT_MEDIA_CHANGE;
37493753

37503754
if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) {
3751-
lock_fdc(drive, false);
3755+
if (lock_fdc(drive))
3756+
return -EINTR;
37523757
poll_drive(false, 0);
37533758
process_fd_request();
37543759
}
@@ -3847,7 +3852,9 @@ static int floppy_revalidate(struct gendisk *disk)
38473852
"VFS: revalidate called on non-open device.\n"))
38483853
return -EFAULT;
38493854

3850-
lock_fdc(drive, false);
3855+
res = lock_fdc(drive);
3856+
if (res)
3857+
return res;
38513858
cf = (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags) ||
38523859
test_bit(FD_VERIFY_BIT, &UDRS->flags));
38533860
if (!(cf || test_bit(drive, &fake_change) || drive_no_geom(drive))) {

drivers/block/null_blk.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ static int null_lnvm_id(struct nvm_dev *dev, struct nvm_id *id)
478478
id->ver_id = 0x1;
479479
id->vmnt = 0;
480480
id->cgrps = 1;
481-
id->cap = 0x3;
481+
id->cap = 0x2;
482482
id->dom = 0x1;
483483

484484
id->ppaf.blk_offset = 0;
@@ -707,9 +707,7 @@ static int null_add_dev(void)
707707
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, nullb->q);
708708
queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, nullb->q);
709709

710-
711710
mutex_lock(&lock);
712-
list_add_tail(&nullb->list, &nullb_list);
713711
nullb->index = nullb_indexes++;
714712
mutex_unlock(&lock);
715713

@@ -743,6 +741,10 @@ static int null_add_dev(void)
743741
strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN);
744742

745743
add_disk(disk);
744+
745+
mutex_lock(&lock);
746+
list_add_tail(&nullb->list, &nullb_list);
747+
mutex_unlock(&lock);
746748
done:
747749
return 0;
748750

0 commit comments

Comments
 (0)