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:
"A small collection of fixes/changes for the current series. This
contains:

- Removal of dead code from Gu Zheng.

- Revert of two bad fixes that went in earlier in this round, marking
things as __init that were not purely used from init.

- A fix for blk_mq_start_hw_queue() using the __blk_mq_run_hw_queue(),
which could place us wrongly. Make it use the non __ variant,
which handles cases where we are called from the wrong CPU set.
From me.

- A fix for drbd, which allocates discard requests without room for
the SCSI payload. From Lars Ellenberg.

- A fix for user-after-free in the blkcg code from Tejun.

- Addition of limiting gaps in SG lists, if the hardware needs it.
This is the last pre-req patch for blk-mq to enable the full NVMe
conversion. Could wait until 3.17, but it's simple enough so would
be nice to have everything we need for the NVMe port in the 3.17
release. From me"

* 'for-linus' of git://git.kernel.dk/linux-block:
drbd: fix NULL pointer deref in blk_add_request_payload
blk-mq: blk_mq_start_hw_queue() should use blk_mq_run_hw_queue()
block: add support for limiting gaps in SG lists
bio: remove unused macro bip_vec_idx()
Revert "block: add __init to elv_register"
Revert "block: add __init to blkcg_policy_register"
blkcg: fix use-after-free in __blkg_release_rcu() by making blkcg_gq refcnt an atomic_t
floppy: format block0 read error message properly

+48 -27
+8
block/bio.c
··· 746 746 747 747 goto done; 748 748 } 749 + 750 + /* 751 + * If the queue doesn't support SG gaps and adding this 752 + * offset would create a gap, disallow it. 753 + */ 754 + if (q->queue_flags & (1 << QUEUE_FLAG_SG_GAPS) && 755 + bvec_gap_to_prev(prev, offset)) 756 + return 0; 749 757 } 750 758 751 759 if (bio->bi_vcnt >= bio->bi_max_vecs)
+3 -6
block/blk-cgroup.c
··· 80 80 blkg->q = q; 81 81 INIT_LIST_HEAD(&blkg->q_node); 82 82 blkg->blkcg = blkcg; 83 - blkg->refcnt = 1; 83 + atomic_set(&blkg->refcnt, 1); 84 84 85 85 /* root blkg uses @q->root_rl, init rl only for !root blkgs */ 86 86 if (blkcg != &blkcg_root) { ··· 399 399 400 400 /* release the blkcg and parent blkg refs this blkg has been holding */ 401 401 css_put(&blkg->blkcg->css); 402 - if (blkg->parent) { 403 - spin_lock_irq(blkg->q->queue_lock); 402 + if (blkg->parent) 404 403 blkg_put(blkg->parent); 405 - spin_unlock_irq(blkg->q->queue_lock); 406 - } 407 404 408 405 blkg_free(blkg); 409 406 } ··· 1090 1093 * Register @pol with blkcg core. Might sleep and @pol may be modified on 1091 1094 * successful registration. Returns 0 on success and -errno on failure. 1092 1095 */ 1093 - int __init blkcg_policy_register(struct blkcg_policy *pol) 1096 + int blkcg_policy_register(struct blkcg_policy *pol) 1094 1097 { 1095 1098 int i, ret; 1096 1099
+9 -12
block/blk-cgroup.h
··· 18 18 #include <linux/seq_file.h> 19 19 #include <linux/radix-tree.h> 20 20 #include <linux/blkdev.h> 21 + #include <linux/atomic.h> 21 22 22 23 /* Max limits for throttle policy */ 23 24 #define THROTL_IOPS_MAX UINT_MAX ··· 105 104 struct request_list rl; 106 105 107 106 /* reference count */ 108 - int refcnt; 107 + atomic_t refcnt; 109 108 110 109 /* is this blkg online? protected by both blkcg and q locks */ 111 110 bool online; ··· 146 145 void blkcg_exit_queue(struct request_queue *q); 147 146 148 147 /* Blkio controller policy registration */ 149 - int __init blkcg_policy_register(struct blkcg_policy *pol); 148 + int blkcg_policy_register(struct blkcg_policy *pol); 150 149 void blkcg_policy_unregister(struct blkcg_policy *pol); 151 150 int blkcg_activate_policy(struct request_queue *q, 152 151 const struct blkcg_policy *pol); ··· 258 257 * blkg_get - get a blkg reference 259 258 * @blkg: blkg to get 260 259 * 261 - * The caller should be holding queue_lock and an existing reference. 260 + * The caller should be holding an existing reference. 262 261 */ 263 262 static inline void blkg_get(struct blkcg_gq *blkg) 264 263 { 265 - lockdep_assert_held(blkg->q->queue_lock); 266 - WARN_ON_ONCE(!blkg->refcnt); 267 - blkg->refcnt++; 264 + WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0); 265 + atomic_inc(&blkg->refcnt); 268 266 } 269 267 270 268 void __blkg_release_rcu(struct rcu_head *rcu); ··· 271 271 /** 272 272 * blkg_put - put a blkg reference 273 273 * @blkg: blkg to put 274 - * 275 - * The caller should be holding queue_lock. 276 274 */ 277 275 static inline void blkg_put(struct blkcg_gq *blkg) 278 276 { 279 - lockdep_assert_held(blkg->q->queue_lock); 280 - WARN_ON_ONCE(blkg->refcnt <= 0); 281 - if (!--blkg->refcnt) 277 + WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0); 278 + if (atomic_dec_and_test(&blkg->refcnt)) 282 279 call_rcu(&blkg->rcu_head, __blkg_release_rcu); 283 280 } 284 281 ··· 577 580 static inline int blkcg_init_queue(struct request_queue *q) { return 0; } 578 581 static inline void blkcg_drain_queue(struct request_queue *q) { } 579 582 static inline void blkcg_exit_queue(struct request_queue *q) { } 580 - static inline int __init blkcg_policy_register(struct blkcg_policy *pol) { return 0; } 583 + static inline int blkcg_policy_register(struct blkcg_policy *pol) { return 0; } 581 584 static inline void blkcg_policy_unregister(struct blkcg_policy *pol) { } 582 585 static inline int blkcg_activate_policy(struct request_queue *q, 583 586 const struct blkcg_policy *pol) { return 0; }
+10
block/blk-merge.c
··· 568 568 569 569 bool blk_rq_merge_ok(struct request *rq, struct bio *bio) 570 570 { 571 + struct request_queue *q = rq->q; 572 + 571 573 if (!rq_mergeable(rq) || !bio_mergeable(bio)) 572 574 return false; 573 575 ··· 592 590 if (rq->cmd_flags & REQ_WRITE_SAME && 593 591 !blk_write_same_mergeable(rq->bio, bio)) 594 592 return false; 593 + 594 + if (q->queue_flags & (1 << QUEUE_FLAG_SG_GAPS)) { 595 + struct bio_vec *bprev; 596 + 597 + bprev = &rq->biotail->bi_io_vec[bio->bi_vcnt - 1]; 598 + if (bvec_gap_to_prev(bprev, bio->bi_io_vec[0].bv_offset)) 599 + return false; 600 + } 595 601 596 602 return true; 597 603 }
+1 -1
block/blk-mq.c
··· 878 878 clear_bit(BLK_MQ_S_STOPPED, &hctx->state); 879 879 880 880 preempt_disable(); 881 - __blk_mq_run_hw_queue(hctx); 881 + blk_mq_run_hw_queue(hctx, false); 882 882 preempt_enable(); 883 883 } 884 884 EXPORT_SYMBOL(blk_mq_start_hw_queue);
+1 -1
block/elevator.c
··· 825 825 } 826 826 EXPORT_SYMBOL(elv_unregister_queue); 827 827 828 - int __init elv_register(struct elevator_type *e) 828 + int elv_register(struct elevator_type *e) 829 829 { 830 830 char *def = ""; 831 831
+4 -1
drivers/block/drbd/drbd_receiver.c
··· 1337 1337 return 0; 1338 1338 } 1339 1339 1340 + /* Discards don't have any payload. 1341 + * But the scsi layer still expects a bio_vec it can use internally, 1342 + * see sd_setup_discard_cmnd() and blk_add_request_payload(). */ 1340 1343 if (peer_req->flags & EE_IS_TRIM) 1341 - nr_pages = 0; /* discards don't have any payload. */ 1344 + nr_pages = 1; 1342 1345 1343 1346 /* In most cases, we will only need one bio. But in case the lower 1344 1347 * level restrictions happen to be different at this offset on this
+1 -1
drivers/block/floppy.c
··· 3777 3777 int drive = cbdata->drive; 3778 3778 3779 3779 if (err) { 3780 - pr_info("floppy: error %d while reading block 0", err); 3780 + pr_info("floppy: error %d while reading block 0\n", err); 3781 3781 set_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); 3782 3782 } 3783 3783 complete(&cbdata->complete);
+9 -4
include/linux/bio.h
··· 186 186 #define BIOVEC_SEG_BOUNDARY(q, b1, b2) \ 187 187 __BIO_SEG_BOUNDARY(bvec_to_phys((b1)), bvec_to_phys((b2)) + (b2)->bv_len, queue_segment_boundary((q))) 188 188 189 + /* 190 + * Check if adding a bio_vec after bprv with offset would create a gap in 191 + * the SG list. Most drivers don't care about this, but some do. 192 + */ 193 + static inline bool bvec_gap_to_prev(struct bio_vec *bprv, unsigned int offset) 194 + { 195 + return offset || ((bprv->bv_offset + bprv->bv_len) & (PAGE_SIZE - 1)); 196 + } 197 + 189 198 #define bio_io_error(bio) bio_endio((bio), -EIO) 190 199 191 200 /* ··· 652 643 #define BIO_SPLIT_ENTRIES 2 653 644 654 645 #if defined(CONFIG_BLK_DEV_INTEGRITY) 655 - 656 - 657 - 658 - #define bip_vec_idx(bip, idx) (&(bip->bip_vec[(idx)])) 659 646 660 647 #define bip_for_each_vec(bvl, bip, iter) \ 661 648 for_each_bvec(bvl, (bip)->bip_vec, iter, (bip)->bip_iter)
+1
include/linux/blkdev.h
··· 512 512 #define QUEUE_FLAG_DEAD 19 /* queue tear-down finished */ 513 513 #define QUEUE_FLAG_INIT_DONE 20 /* queue is initialized */ 514 514 #define QUEUE_FLAG_NO_SG_MERGE 21 /* don't attempt to merge SG segments*/ 515 + #define QUEUE_FLAG_SG_GAPS 22 /* queue doesn't support SG gaps */ 515 516 516 517 #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ 517 518 (1 << QUEUE_FLAG_STACKABLE) | \
+1 -1
include/linux/elevator.h
··· 143 143 * io scheduler registration 144 144 */ 145 145 extern void __init load_default_elevator_module(void); 146 - extern int __init elv_register(struct elevator_type *); 146 + extern int elv_register(struct elevator_type *); 147 147 extern void elv_unregister(struct elevator_type *); 148 148 149 149 /*