Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:
"Here's a set of block fixes for the current 4.8-rc release. This
contains:

- a fix for a secure erase regression, from Adrian.

- a fix for an mmc use-after-free bug regression, also from Adrian.

- potential zero pointer deference in bdev freezing, from Andrey.

- a race fix for blk_set_queue_dying() from Bart.

- a set of xen blkfront fixes from Bob Liu.

- three small fixes for bcache, from Eric and Kent.

- a fix for a potential invalid NVMe state transition, from Gabriel.

- blk-mq CPU offline fix, preventing us from issuing and completing a
request on the wrong queue. From me.

- revert two previous floppy changes, since they caused a user
visibile regression. A better fix is in the works.

- ensure that we don't send down bios that have more than 256
elements in them. Fixes a crash with bcache, for example. From
Ming.

- a fix for deferencing an error pointer with cgroup writeback.
Fixes a regression. From Vegard"

* 'for-linus' of git://git.kernel.dk/linux-block:
mmc: fix use-after-free of struct request
Revert "floppy: refactor open() flags handling"
Revert "floppy: fix open(O_ACCMODE) for ioctl-only open"
fs/block_dev: fix potential NULL ptr deref in freeze_bdev()
blk-mq: improve warning for running a queue on the wrong CPU
blk-mq: don't overwrite rq->mq_ctx
block: make sure a big bio is split into at most 256 bvecs
nvme: Fix nvme_get/set_features() with a NULL result pointer
bdev: fix NULL pointer dereference
xen-blkfront: free resources if xlvbd_alloc_gendisk fails
xen-blkfront: introduce blkif_set_queue_limits()
xen-blkfront: fix places not updated after introducing 64KB page granularity
bcache: pr_err: more meaningful error message when nr_stripes is invalid
bcache: RESERVE_PRIO is too small by one when prio_buckets() is a power of two.
bcache: register_bcache(): call blkdev_put() when cache_alloc() fails
block: Fix race triggered by blk_set_queue_dying()
block: Fix secure erase
nvme: Prevent controller state invalid transition

+188 -142
+11 -10
block/bio.c
··· 667 667 bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; 668 668 bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; 669 669 670 - if (bio_op(bio) == REQ_OP_DISCARD) 671 - goto integrity_clone; 672 - 673 - if (bio_op(bio) == REQ_OP_WRITE_SAME) { 670 + switch (bio_op(bio)) { 671 + case REQ_OP_DISCARD: 672 + case REQ_OP_SECURE_ERASE: 673 + break; 674 + case REQ_OP_WRITE_SAME: 674 675 bio->bi_io_vec[bio->bi_vcnt++] = bio_src->bi_io_vec[0]; 675 - goto integrity_clone; 676 + break; 677 + default: 678 + bio_for_each_segment(bv, bio_src, iter) 679 + bio->bi_io_vec[bio->bi_vcnt++] = bv; 680 + break; 676 681 } 677 682 678 - bio_for_each_segment(bv, bio_src, iter) 679 - bio->bi_io_vec[bio->bi_vcnt++] = bv; 680 - 681 - integrity_clone: 682 683 if (bio_integrity(bio_src)) { 683 684 int ret; 684 685 ··· 1789 1788 * Discards need a mutable bio_vec to accommodate the payload 1790 1789 * required by the DSM TRIM and UNMAP commands. 1791 1790 */ 1792 - if (bio_op(bio) == REQ_OP_DISCARD) 1791 + if (bio_op(bio) == REQ_OP_DISCARD || bio_op(bio) == REQ_OP_SECURE_ERASE) 1793 1792 split = bio_clone_bioset(bio, gfp, bs); 1794 1793 else 1795 1794 split = bio_clone_fast(bio, gfp, bs);
+3 -1
block/blk-core.c
··· 515 515 516 516 void blk_set_queue_dying(struct request_queue *q) 517 517 { 518 - queue_flag_set_unlocked(QUEUE_FLAG_DYING, q); 518 + spin_lock_irq(q->queue_lock); 519 + queue_flag_set(QUEUE_FLAG_DYING, q); 520 + spin_unlock_irq(q->queue_lock); 519 521 520 522 if (q->mq_ops) 521 523 blk_mq_wake_waiters(q);
+41 -14
block/blk-merge.c
··· 94 94 bool do_split = true; 95 95 struct bio *new = NULL; 96 96 const unsigned max_sectors = get_max_io_size(q, bio); 97 + unsigned bvecs = 0; 97 98 98 99 bio_for_each_segment(bv, bio, iter) { 100 + /* 101 + * With arbitrary bio size, the incoming bio may be very 102 + * big. We have to split the bio into small bios so that 103 + * each holds at most BIO_MAX_PAGES bvecs because 104 + * bio_clone() can fail to allocate big bvecs. 105 + * 106 + * It should have been better to apply the limit per 107 + * request queue in which bio_clone() is involved, 108 + * instead of globally. The biggest blocker is the 109 + * bio_clone() in bio bounce. 110 + * 111 + * If bio is splitted by this reason, we should have 112 + * allowed to continue bios merging, but don't do 113 + * that now for making the change simple. 114 + * 115 + * TODO: deal with bio bounce's bio_clone() gracefully 116 + * and convert the global limit into per-queue limit. 117 + */ 118 + if (bvecs++ >= BIO_MAX_PAGES) 119 + goto split; 120 + 99 121 /* 100 122 * If the queue doesn't support SG gaps and adding this 101 123 * offset would create a gap, disallow it. ··· 194 172 struct bio *split, *res; 195 173 unsigned nsegs; 196 174 197 - if (bio_op(*bio) == REQ_OP_DISCARD) 175 + switch (bio_op(*bio)) { 176 + case REQ_OP_DISCARD: 177 + case REQ_OP_SECURE_ERASE: 198 178 split = blk_bio_discard_split(q, *bio, bs, &nsegs); 199 - else if (bio_op(*bio) == REQ_OP_WRITE_SAME) 179 + break; 180 + case REQ_OP_WRITE_SAME: 200 181 split = blk_bio_write_same_split(q, *bio, bs, &nsegs); 201 - else 182 + break; 183 + default: 202 184 split = blk_bio_segment_split(q, *bio, q->bio_split, &nsegs); 185 + break; 186 + } 203 187 204 188 /* physical segments can be figured out during splitting */ 205 189 res = split ? split : *bio; ··· 241 213 * This should probably be returning 0, but blk_add_request_payload() 242 214 * (Christoph!!!!) 243 215 */ 244 - if (bio_op(bio) == REQ_OP_DISCARD) 216 + if (bio_op(bio) == REQ_OP_DISCARD || bio_op(bio) == REQ_OP_SECURE_ERASE) 245 217 return 1; 246 218 247 219 if (bio_op(bio) == REQ_OP_WRITE_SAME) ··· 413 385 nsegs = 0; 414 386 cluster = blk_queue_cluster(q); 415 387 416 - if (bio_op(bio) == REQ_OP_DISCARD) { 388 + switch (bio_op(bio)) { 389 + case REQ_OP_DISCARD: 390 + case REQ_OP_SECURE_ERASE: 417 391 /* 418 392 * This is a hack - drivers should be neither modifying the 419 393 * biovec, nor relying on bi_vcnt - but because of ··· 423 393 * a payload we need to set up here (thank you Christoph) and 424 394 * bi_vcnt is really the only way of telling if we need to. 425 395 */ 426 - 427 - if (bio->bi_vcnt) 428 - goto single_segment; 429 - 430 - return 0; 431 - } 432 - 433 - if (bio_op(bio) == REQ_OP_WRITE_SAME) { 434 - single_segment: 396 + if (!bio->bi_vcnt) 397 + return 0; 398 + /* Fall through */ 399 + case REQ_OP_WRITE_SAME: 435 400 *sg = sglist; 436 401 bvec = bio_iovec(bio); 437 402 sg_set_page(*sg, bvec.bv_page, bvec.bv_len, bvec.bv_offset); 438 403 return 1; 404 + default: 405 + break; 439 406 } 440 407 441 408 for_each_bio(bio)
+19 -41
block/blk-mq.c
··· 793 793 struct list_head *dptr; 794 794 int queued; 795 795 796 - WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask)); 797 - 798 796 if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state))) 799 797 return; 798 + 799 + WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask) && 800 + cpu_online(hctx->next_cpu)); 800 801 801 802 hctx->run++; 802 803 ··· 1037 1036 EXPORT_SYMBOL(blk_mq_delay_queue); 1038 1037 1039 1038 static inline void __blk_mq_insert_req_list(struct blk_mq_hw_ctx *hctx, 1040 - struct blk_mq_ctx *ctx, 1041 1039 struct request *rq, 1042 1040 bool at_head) 1043 1041 { 1042 + struct blk_mq_ctx *ctx = rq->mq_ctx; 1043 + 1044 1044 trace_block_rq_insert(hctx->queue, rq); 1045 1045 1046 1046 if (at_head) ··· 1055 1053 { 1056 1054 struct blk_mq_ctx *ctx = rq->mq_ctx; 1057 1055 1058 - __blk_mq_insert_req_list(hctx, ctx, rq, at_head); 1056 + __blk_mq_insert_req_list(hctx, rq, at_head); 1059 1057 blk_mq_hctx_mark_pending(hctx, ctx); 1060 1058 } 1061 1059 1062 1060 void blk_mq_insert_request(struct request *rq, bool at_head, bool run_queue, 1063 - bool async) 1061 + bool async) 1064 1062 { 1063 + struct blk_mq_ctx *ctx = rq->mq_ctx; 1065 1064 struct request_queue *q = rq->q; 1066 1065 struct blk_mq_hw_ctx *hctx; 1067 - struct blk_mq_ctx *ctx = rq->mq_ctx, *current_ctx; 1068 - 1069 - current_ctx = blk_mq_get_ctx(q); 1070 - if (!cpu_online(ctx->cpu)) 1071 - rq->mq_ctx = ctx = current_ctx; 1072 1066 1073 1067 hctx = q->mq_ops->map_queue(q, ctx->cpu); 1074 1068 ··· 1074 1076 1075 1077 if (run_queue) 1076 1078 blk_mq_run_hw_queue(hctx, async); 1077 - 1078 - blk_mq_put_ctx(current_ctx); 1079 1079 } 1080 1080 1081 1081 static void blk_mq_insert_requests(struct request_queue *q, ··· 1084 1088 1085 1089 { 1086 1090 struct blk_mq_hw_ctx *hctx; 1087 - struct blk_mq_ctx *current_ctx; 1088 1091 1089 1092 trace_block_unplug(q, depth, !from_schedule); 1090 1093 1091 - current_ctx = blk_mq_get_ctx(q); 1092 - 1093 - if (!cpu_online(ctx->cpu)) 1094 - ctx = current_ctx; 1095 1094 hctx = q->mq_ops->map_queue(q, ctx->cpu); 1096 1095 1097 1096 /* ··· 1098 1107 struct request *rq; 1099 1108 1100 1109 rq = list_first_entry(list, struct request, queuelist); 1110 + BUG_ON(rq->mq_ctx != ctx); 1101 1111 list_del_init(&rq->queuelist); 1102 - rq->mq_ctx = ctx; 1103 - __blk_mq_insert_req_list(hctx, ctx, rq, false); 1112 + __blk_mq_insert_req_list(hctx, rq, false); 1104 1113 } 1105 1114 blk_mq_hctx_mark_pending(hctx, ctx); 1106 1115 spin_unlock(&ctx->lock); 1107 1116 1108 1117 blk_mq_run_hw_queue(hctx, from_schedule); 1109 - blk_mq_put_ctx(current_ctx); 1110 1118 } 1111 1119 1112 1120 static int plug_ctx_cmp(void *priv, struct list_head *a, struct list_head *b) ··· 1620 1630 return 0; 1621 1631 } 1622 1632 1633 + /* 1634 + * 'cpu' is going away. splice any existing rq_list entries from this 1635 + * software queue to the hw queue dispatch list, and ensure that it 1636 + * gets run. 1637 + */ 1623 1638 static int blk_mq_hctx_cpu_offline(struct blk_mq_hw_ctx *hctx, int cpu) 1624 1639 { 1625 - struct request_queue *q = hctx->queue; 1626 1640 struct blk_mq_ctx *ctx; 1627 1641 LIST_HEAD(tmp); 1628 1642 1629 - /* 1630 - * Move ctx entries to new CPU, if this one is going away. 1631 - */ 1632 - ctx = __blk_mq_get_ctx(q, cpu); 1643 + ctx = __blk_mq_get_ctx(hctx->queue, cpu); 1633 1644 1634 1645 spin_lock(&ctx->lock); 1635 1646 if (!list_empty(&ctx->rq_list)) { ··· 1642 1651 if (list_empty(&tmp)) 1643 1652 return NOTIFY_OK; 1644 1653 1645 - ctx = blk_mq_get_ctx(q); 1646 - spin_lock(&ctx->lock); 1647 - 1648 - while (!list_empty(&tmp)) { 1649 - struct request *rq; 1650 - 1651 - rq = list_first_entry(&tmp, struct request, queuelist); 1652 - rq->mq_ctx = ctx; 1653 - list_move_tail(&rq->queuelist, &ctx->rq_list); 1654 - } 1655 - 1656 - hctx = q->mq_ops->map_queue(q, ctx->cpu); 1657 - blk_mq_hctx_mark_pending(hctx, ctx); 1658 - 1659 - spin_unlock(&ctx->lock); 1654 + spin_lock(&hctx->lock); 1655 + list_splice_tail_init(&tmp, &hctx->dispatch); 1656 + spin_unlock(&hctx->lock); 1660 1657 1661 1658 blk_mq_run_hw_queue(hctx, true); 1662 - blk_mq_put_ctx(ctx); 1663 1659 return NOTIFY_OK; 1664 1660 } 1665 1661
+1 -1
block/elevator.c
··· 366 366 list_for_each_prev(entry, &q->queue_head) { 367 367 struct request *pos = list_entry_rq(entry); 368 368 369 - if ((req_op(rq) == REQ_OP_DISCARD) != (req_op(pos) == REQ_OP_DISCARD)) 369 + if (req_op(rq) != req_op(pos)) 370 370 break; 371 371 if (rq_data_dir(rq) != rq_data_dir(pos)) 372 372 break;
+13 -14
drivers/block/floppy.c
··· 3706 3706 if (UFDCS->rawcmd == 1) 3707 3707 UFDCS->rawcmd = 2; 3708 3708 3709 - if (mode & (FMODE_READ|FMODE_WRITE)) { 3710 - UDRS->last_checked = 0; 3711 - clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); 3712 - check_disk_change(bdev); 3713 - if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) 3714 - goto out; 3715 - if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags)) 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)) 3716 3722 goto out; 3717 3723 } 3718 - 3719 - res = -EROFS; 3720 - 3721 - if ((mode & FMODE_WRITE) && 3722 - !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags)) 3723 - goto out; 3724 - 3725 3724 mutex_unlock(&open_lock); 3726 3725 mutex_unlock(&floppy_mutex); 3727 3726 return 0;
+56 -41
drivers/block/xen-blkfront.c
··· 189 189 struct mutex mutex; 190 190 struct xenbus_device *xbdev; 191 191 struct gendisk *gd; 192 + u16 sector_size; 193 + unsigned int physical_sector_size; 192 194 int vdevice; 193 195 blkif_vdev_t handle; 194 196 enum blkif_state connected; ··· 912 910 .map_queue = blk_mq_map_queue, 913 911 }; 914 912 913 + static void blkif_set_queue_limits(struct blkfront_info *info) 914 + { 915 + struct request_queue *rq = info->rq; 916 + struct gendisk *gd = info->gd; 917 + unsigned int segments = info->max_indirect_segments ? : 918 + BLKIF_MAX_SEGMENTS_PER_REQUEST; 919 + 920 + queue_flag_set_unlocked(QUEUE_FLAG_VIRT, rq); 921 + 922 + if (info->feature_discard) { 923 + queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, rq); 924 + blk_queue_max_discard_sectors(rq, get_capacity(gd)); 925 + rq->limits.discard_granularity = info->discard_granularity; 926 + rq->limits.discard_alignment = info->discard_alignment; 927 + if (info->feature_secdiscard) 928 + queue_flag_set_unlocked(QUEUE_FLAG_SECERASE, rq); 929 + } 930 + 931 + /* Hard sector size and max sectors impersonate the equiv. hardware. */ 932 + blk_queue_logical_block_size(rq, info->sector_size); 933 + blk_queue_physical_block_size(rq, info->physical_sector_size); 934 + blk_queue_max_hw_sectors(rq, (segments * XEN_PAGE_SIZE) / 512); 935 + 936 + /* Each segment in a request is up to an aligned page in size. */ 937 + blk_queue_segment_boundary(rq, PAGE_SIZE - 1); 938 + blk_queue_max_segment_size(rq, PAGE_SIZE); 939 + 940 + /* Ensure a merged request will fit in a single I/O ring slot. */ 941 + blk_queue_max_segments(rq, segments / GRANTS_PER_PSEG); 942 + 943 + /* Make sure buffer addresses are sector-aligned. */ 944 + blk_queue_dma_alignment(rq, 511); 945 + 946 + /* Make sure we don't use bounce buffers. */ 947 + blk_queue_bounce_limit(rq, BLK_BOUNCE_ANY); 948 + } 949 + 915 950 static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size, 916 - unsigned int physical_sector_size, 917 - unsigned int segments) 951 + unsigned int physical_sector_size) 918 952 { 919 953 struct request_queue *rq; 920 954 struct blkfront_info *info = gd->private_data; ··· 982 944 } 983 945 984 946 rq->queuedata = info; 985 - queue_flag_set_unlocked(QUEUE_FLAG_VIRT, rq); 986 - 987 - if (info->feature_discard) { 988 - queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, rq); 989 - blk_queue_max_discard_sectors(rq, get_capacity(gd)); 990 - rq->limits.discard_granularity = info->discard_granularity; 991 - rq->limits.discard_alignment = info->discard_alignment; 992 - if (info->feature_secdiscard) 993 - queue_flag_set_unlocked(QUEUE_FLAG_SECERASE, rq); 994 - } 995 - 996 - /* Hard sector size and max sectors impersonate the equiv. hardware. */ 997 - blk_queue_logical_block_size(rq, sector_size); 998 - blk_queue_physical_block_size(rq, physical_sector_size); 999 - blk_queue_max_hw_sectors(rq, (segments * XEN_PAGE_SIZE) / 512); 1000 - 1001 - /* Each segment in a request is up to an aligned page in size. */ 1002 - blk_queue_segment_boundary(rq, PAGE_SIZE - 1); 1003 - blk_queue_max_segment_size(rq, PAGE_SIZE); 1004 - 1005 - /* Ensure a merged request will fit in a single I/O ring slot. */ 1006 - blk_queue_max_segments(rq, segments / GRANTS_PER_PSEG); 1007 - 1008 - /* Make sure buffer addresses are sector-aligned. */ 1009 - blk_queue_dma_alignment(rq, 511); 1010 - 1011 - /* Make sure we don't use bounce buffers. */ 1012 - blk_queue_bounce_limit(rq, BLK_BOUNCE_ANY); 1013 - 1014 - gd->queue = rq; 947 + info->rq = gd->queue = rq; 948 + info->gd = gd; 949 + info->sector_size = sector_size; 950 + info->physical_sector_size = physical_sector_size; 951 + blkif_set_queue_limits(info); 1015 952 1016 953 return 0; 1017 954 } ··· 1149 1136 gd->private_data = info; 1150 1137 set_capacity(gd, capacity); 1151 1138 1152 - if (xlvbd_init_blk_queue(gd, sector_size, physical_sector_size, 1153 - info->max_indirect_segments ? : 1154 - BLKIF_MAX_SEGMENTS_PER_REQUEST)) { 1139 + if (xlvbd_init_blk_queue(gd, sector_size, physical_sector_size)) { 1155 1140 del_gendisk(gd); 1156 1141 goto release; 1157 1142 } 1158 - 1159 - info->rq = gd->queue; 1160 - info->gd = gd; 1161 1143 1162 1144 xlvbd_flush(info); 1163 1145 ··· 1323 1315 rinfo->ring_ref[i] = GRANT_INVALID_REF; 1324 1316 } 1325 1317 } 1326 - free_pages((unsigned long)rinfo->ring.sring, get_order(info->nr_ring_pages * PAGE_SIZE)); 1318 + free_pages((unsigned long)rinfo->ring.sring, get_order(info->nr_ring_pages * XEN_PAGE_SIZE)); 1327 1319 rinfo->ring.sring = NULL; 1328 1320 1329 1321 if (rinfo->irq) ··· 2015 2007 struct split_bio *split_bio; 2016 2008 2017 2009 blkfront_gather_backend_features(info); 2010 + /* Reset limits changed by blk_mq_update_nr_hw_queues(). */ 2011 + blkif_set_queue_limits(info); 2018 2012 segs = info->max_indirect_segments ? : BLKIF_MAX_SEGMENTS_PER_REQUEST; 2019 - blk_queue_max_segments(info->rq, segs); 2013 + blk_queue_max_segments(info->rq, segs / GRANTS_PER_PSEG); 2020 2014 2021 2015 for (r_index = 0; r_index < info->nr_rings; r_index++) { 2022 2016 struct blkfront_ring_info *rinfo = &info->rinfo[r_index]; ··· 2442 2432 if (err) { 2443 2433 xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s", 2444 2434 info->xbdev->otherend); 2445 - return; 2435 + goto fail; 2446 2436 } 2447 2437 2448 2438 xenbus_switch_state(info->xbdev, XenbusStateConnected); ··· 2455 2445 device_add_disk(&info->xbdev->dev, info->gd); 2456 2446 2457 2447 info->is_ready = 1; 2448 + return; 2449 + 2450 + fail: 2451 + blkif_free(info, 0); 2452 + return; 2458 2453 } 2459 2454 2460 2455 /**
+10 -4
drivers/md/bcache/super.c
··· 760 760 if (!d->nr_stripes || 761 761 d->nr_stripes > INT_MAX || 762 762 d->nr_stripes > SIZE_MAX / sizeof(atomic_t)) { 763 - pr_err("nr_stripes too large"); 763 + pr_err("nr_stripes too large or invalid: %u (start sector beyond end of disk?)", 764 + (unsigned)d->nr_stripes); 764 765 return -ENOMEM; 765 766 } 766 767 ··· 1821 1820 free = roundup_pow_of_two(ca->sb.nbuckets) >> 10; 1822 1821 1823 1822 if (!init_fifo(&ca->free[RESERVE_BTREE], 8, GFP_KERNEL) || 1824 - !init_fifo(&ca->free[RESERVE_PRIO], prio_buckets(ca), GFP_KERNEL) || 1823 + !init_fifo_exact(&ca->free[RESERVE_PRIO], prio_buckets(ca), GFP_KERNEL) || 1825 1824 !init_fifo(&ca->free[RESERVE_MOVINGGC], free, GFP_KERNEL) || 1826 1825 !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) || 1827 1826 !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) || ··· 1845 1844 struct block_device *bdev, struct cache *ca) 1846 1845 { 1847 1846 char name[BDEVNAME_SIZE]; 1848 - const char *err = NULL; 1847 + const char *err = NULL; /* must be set for any error case */ 1849 1848 int ret = 0; 1850 1849 1851 1850 memcpy(&ca->sb, sb, sizeof(struct cache_sb)); ··· 1862 1861 ca->discard = CACHE_DISCARD(&ca->sb); 1863 1862 1864 1863 ret = cache_alloc(ca); 1865 - if (ret != 0) 1864 + if (ret != 0) { 1865 + if (ret == -ENOMEM) 1866 + err = "cache_alloc(): -ENOMEM"; 1867 + else 1868 + err = "cache_alloc(): unknown error"; 1866 1869 goto err; 1870 + } 1867 1871 1868 1872 if (kobject_add(&ca->kobj, &part_to_dev(bdev->bd_part)->kobj, "bcache")) { 1869 1873 err = "error calling kobject_add";
+3 -2
drivers/mmc/card/block.c
··· 1726 1726 break; 1727 1727 1728 1728 if (req_op(next) == REQ_OP_DISCARD || 1729 + req_op(next) == REQ_OP_SECURE_ERASE || 1729 1730 req_op(next) == REQ_OP_FLUSH) 1730 1731 break; 1731 1732 ··· 2151 2150 struct mmc_card *card = md->queue.card; 2152 2151 struct mmc_host *host = card->host; 2153 2152 unsigned long flags; 2153 + bool req_is_special = mmc_req_is_special(req); 2154 2154 2155 2155 if (req && !mq->mqrq_prev->req) 2156 2156 /* claim host only for the first request */ ··· 2192 2190 } 2193 2191 2194 2192 out: 2195 - if ((!req && !(mq->flags & MMC_QUEUE_NEW_REQUEST)) || 2196 - mmc_req_is_special(req)) 2193 + if ((!req && !(mq->flags & MMC_QUEUE_NEW_REQUEST)) || req_is_special) 2197 2194 /* 2198 2195 * Release host when there are no more requests 2199 2196 * and after special request(discard, flush) is done.
+5 -2
drivers/mmc/card/queue.c
··· 33 33 /* 34 34 * We only like normal block requests and discards. 35 35 */ 36 - if (req->cmd_type != REQ_TYPE_FS && req_op(req) != REQ_OP_DISCARD) { 36 + if (req->cmd_type != REQ_TYPE_FS && req_op(req) != REQ_OP_DISCARD && 37 + req_op(req) != REQ_OP_SECURE_ERASE) { 37 38 blk_dump_rq_flags(req, "MMC bad request"); 38 39 return BLKPREP_KILL; 39 40 } ··· 65 64 spin_unlock_irq(q->queue_lock); 66 65 67 66 if (req || mq->mqrq_prev->req) { 67 + bool req_is_special = mmc_req_is_special(req); 68 + 68 69 set_current_state(TASK_RUNNING); 69 70 mq->issue_fn(mq, req); 70 71 cond_resched(); ··· 82 79 * has been finished. Do not assign it to previous 83 80 * request. 84 81 */ 85 - if (mmc_req_is_special(req)) 82 + if (req_is_special) 86 83 mq->mqrq_cur->req = NULL; 87 84 88 85 mq->mqrq_prev->brq.mrq.data = NULL;
+3 -1
drivers/mmc/card/queue.h
··· 4 4 static inline bool mmc_req_is_special(struct request *req) 5 5 { 6 6 return req && 7 - (req_op(req) == REQ_OP_FLUSH || req_op(req) == REQ_OP_DISCARD); 7 + (req_op(req) == REQ_OP_FLUSH || 8 + req_op(req) == REQ_OP_DISCARD || 9 + req_op(req) == REQ_OP_SECURE_ERASE); 8 10 } 9 11 10 12 struct request;
+7 -4
drivers/nvme/host/core.c
··· 81 81 bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, 82 82 enum nvme_ctrl_state new_state) 83 83 { 84 - enum nvme_ctrl_state old_state = ctrl->state; 84 + enum nvme_ctrl_state old_state; 85 85 bool changed = false; 86 86 87 87 spin_lock_irq(&ctrl->lock); 88 + 89 + old_state = ctrl->state; 88 90 switch (new_state) { 89 91 case NVME_CTRL_LIVE: 90 92 switch (old_state) { ··· 142 140 default: 143 141 break; 144 142 } 145 - spin_unlock_irq(&ctrl->lock); 146 143 147 144 if (changed) 148 145 ctrl->state = new_state; 146 + 147 + spin_unlock_irq(&ctrl->lock); 149 148 150 149 return changed; 151 150 } ··· 611 608 612 609 ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0, 613 610 NVME_QID_ANY, 0, 0); 614 - if (ret >= 0) 611 + if (ret >= 0 && result) 615 612 *result = le32_to_cpu(cqe.result); 616 613 return ret; 617 614 } ··· 631 628 632 629 ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0, 633 630 NVME_QID_ANY, 0, 0); 634 - if (ret >= 0) 631 + if (ret >= 0 && result) 635 632 *result = le32_to_cpu(cqe.result); 636 633 return ret; 637 634 }
+3 -2
fs/block_dev.c
··· 249 249 * thaw_bdev drops it. 250 250 */ 251 251 sb = get_super(bdev); 252 - drop_super(sb); 252 + if (sb) 253 + drop_super(sb); 253 254 mutex_unlock(&bdev->bd_fsfreeze_mutex); 254 255 return sb; 255 256 } ··· 647 646 { 648 647 struct dentry *dent; 649 648 dent = mount_pseudo(fs_type, "bdev:", &bdev_sops, NULL, BDEVFS_MAGIC); 650 - if (dent) 649 + if (!IS_ERR(dent)) 651 650 dent->d_sb->s_iflags |= SB_I_CGROUPWB; 652 651 return dent; 653 652 }
+8 -2
include/linux/bio.h
··· 71 71 { 72 72 if (bio && 73 73 bio->bi_iter.bi_size && 74 - bio_op(bio) != REQ_OP_DISCARD) 74 + bio_op(bio) != REQ_OP_DISCARD && 75 + bio_op(bio) != REQ_OP_SECURE_ERASE) 75 76 return true; 76 77 77 78 return false; ··· 80 79 81 80 static inline bool bio_no_advance_iter(struct bio *bio) 82 81 { 83 - return bio_op(bio) == REQ_OP_DISCARD || bio_op(bio) == REQ_OP_WRITE_SAME; 82 + return bio_op(bio) == REQ_OP_DISCARD || 83 + bio_op(bio) == REQ_OP_SECURE_ERASE || 84 + bio_op(bio) == REQ_OP_WRITE_SAME; 84 85 } 85 86 86 87 static inline bool bio_is_rw(struct bio *bio) ··· 200 197 */ 201 198 202 199 if (bio_op(bio) == REQ_OP_DISCARD) 200 + return 1; 201 + 202 + if (bio_op(bio) == REQ_OP_SECURE_ERASE) 203 203 return 1; 204 204 205 205 if (bio_op(bio) == REQ_OP_WRITE_SAME)
+4 -2
include/linux/blkdev.h
··· 882 882 static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, 883 883 int op) 884 884 { 885 - if (unlikely(op == REQ_OP_DISCARD)) 885 + if (unlikely(op == REQ_OP_DISCARD || op == REQ_OP_SECURE_ERASE)) 886 886 return min(q->limits.max_discard_sectors, UINT_MAX >> 9); 887 887 888 888 if (unlikely(op == REQ_OP_WRITE_SAME)) ··· 913 913 if (unlikely(rq->cmd_type != REQ_TYPE_FS)) 914 914 return q->limits.max_hw_sectors; 915 915 916 - if (!q->limits.chunk_sectors || (req_op(rq) == REQ_OP_DISCARD)) 916 + if (!q->limits.chunk_sectors || 917 + req_op(rq) == REQ_OP_DISCARD || 918 + req_op(rq) == REQ_OP_SECURE_ERASE) 917 919 return blk_queue_get_max_sectors(q, req_op(rq)); 918 920 919 921 return min(blk_max_size_offset(q, offset),
+1 -1
kernel/trace/blktrace.c
··· 223 223 what |= MASK_TC_BIT(op_flags, META); 224 224 what |= MASK_TC_BIT(op_flags, PREFLUSH); 225 225 what |= MASK_TC_BIT(op_flags, FUA); 226 - if (op == REQ_OP_DISCARD) 226 + if (op == REQ_OP_DISCARD || op == REQ_OP_SECURE_ERASE) 227 227 what |= BLK_TC_ACT(BLK_TC_DISCARD); 228 228 if (op == REQ_OP_FLUSH) 229 229 what |= BLK_TC_ACT(BLK_TC_FLUSH);