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 tag 'for-linus-20190125' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:
"A collection of fixes for this release. This contains:

- Silence sparse rightfully complaining about non-static wbt
functions (Bart)

- Fixes for the zoned comments/ioctl documentation (Damien)

- direct-io fix that's been lingering for a while (Ernesto)

- cgroup writeback fix (Tejun)

- Set of NVMe patches for nvme-rdma/tcp (Sagi, Hannes, Raju)

- Block recursion tracking fix (Ming)

- Fix debugfs command flag naming for a few flags (Jianchao)"

* tag 'for-linus-20190125' of git://git.kernel.dk/linux-block:
block: Fix comment typo
uapi: fix ioctl documentation
blk-wbt: Declare local functions static
blk-mq: fix the cmd_flag_name array
nvme-multipath: drop optimization for static ANA group IDs
nvmet-rdma: fix null dereference under heavy load
nvme-rdma: rework queue maps handling
nvme-tcp: fix timeout handler
nvme-rdma: fix timeout handler
writeback: synchronize sync(2) against cgroup writeback membership switches
block: cover another queue enter recursion via BIO_QUEUE_ENTERED
direct-io: allow direct writes to empty inodes

+129 -50
+11
block/blk-core.c
··· 1083 1083 /* Create a fresh bio_list for all subordinate requests */ 1084 1084 bio_list_on_stack[1] = bio_list_on_stack[0]; 1085 1085 bio_list_init(&bio_list_on_stack[0]); 1086 + 1087 + /* 1088 + * Since we're recursing into make_request here, ensure 1089 + * that we mark this bio as already having entered the queue. 1090 + * If not, and the queue is going away, we can get stuck 1091 + * forever on waiting for the queue reference to drop. But 1092 + * that will never happen, as we're already holding a 1093 + * reference to it. 1094 + */ 1095 + bio_set_flag(bio, BIO_QUEUE_ENTERED); 1086 1096 ret = q->make_request_fn(q, bio); 1097 + bio_clear_flag(bio, BIO_QUEUE_ENTERED); 1087 1098 1088 1099 /* sort new bios into those for a lower level 1089 1100 * and those for the same level
-10
block/blk-merge.c
··· 272 272 /* there isn't chance to merge the splitted bio */ 273 273 split->bi_opf |= REQ_NOMERGE; 274 274 275 - /* 276 - * Since we're recursing into make_request here, ensure 277 - * that we mark this bio as already having entered the queue. 278 - * If not, and the queue is going away, we can get stuck 279 - * forever on waiting for the queue reference to drop. But 280 - * that will never happen, as we're already holding a 281 - * reference to it. 282 - */ 283 - bio_set_flag(*bio, BIO_QUEUE_ENTERED); 284 - 285 275 bio_chain(split, *bio); 286 276 trace_block_split(q, split, (*bio)->bi_iter.bi_sector); 287 277 generic_make_request(*bio);
+2 -1
block/blk-mq-debugfs.c
··· 308 308 CMD_FLAG_NAME(PREFLUSH), 309 309 CMD_FLAG_NAME(RAHEAD), 310 310 CMD_FLAG_NAME(BACKGROUND), 311 - CMD_FLAG_NAME(NOUNMAP), 312 311 CMD_FLAG_NAME(NOWAIT), 312 + CMD_FLAG_NAME(NOUNMAP), 313 + CMD_FLAG_NAME(HIPRI), 313 314 }; 314 315 #undef CMD_FLAG_NAME 315 316
+2 -2
block/blk-wbt.c
··· 597 597 rq->wbt_flags |= bio_to_wbt_flags(rwb, bio); 598 598 } 599 599 600 - void wbt_issue(struct rq_qos *rqos, struct request *rq) 600 + static void wbt_issue(struct rq_qos *rqos, struct request *rq) 601 601 { 602 602 struct rq_wb *rwb = RQWB(rqos); 603 603 ··· 617 617 } 618 618 } 619 619 620 - void wbt_requeue(struct rq_qos *rqos, struct request *rq) 620 + static void wbt_requeue(struct rq_qos *rqos, struct request *rq) 621 621 { 622 622 struct rq_wb *rwb = RQWB(rqos); 623 623 if (!rwb_enabled(rwb))
+1 -2
drivers/nvme/host/multipath.c
··· 545 545 timer_setup(&ctrl->anatt_timer, nvme_anatt_timeout, 0); 546 546 ctrl->ana_log_size = sizeof(struct nvme_ana_rsp_hdr) + 547 547 ctrl->nanagrpid * sizeof(struct nvme_ana_group_desc); 548 - if (!(ctrl->anacap & (1 << 6))) 549 - ctrl->ana_log_size += ctrl->max_namespaces * sizeof(__le32); 548 + ctrl->ana_log_size += ctrl->max_namespaces * sizeof(__le32); 550 549 551 550 if (ctrl->ana_log_size > ctrl->max_hw_sectors << SECTOR_SHIFT) { 552 551 dev_err(ctrl->device,
+43 -21
drivers/nvme/host/rdma.c
··· 119 119 120 120 struct nvme_ctrl ctrl; 121 121 bool use_inline_data; 122 + u32 io_queues[HCTX_MAX_TYPES]; 122 123 }; 123 124 124 125 static inline struct nvme_rdma_ctrl *to_rdma_ctrl(struct nvme_ctrl *ctrl) ··· 166 165 static bool nvme_rdma_poll_queue(struct nvme_rdma_queue *queue) 167 166 { 168 167 return nvme_rdma_queue_idx(queue) > 169 - queue->ctrl->ctrl.opts->nr_io_queues + 170 - queue->ctrl->ctrl.opts->nr_write_queues; 168 + queue->ctrl->io_queues[HCTX_TYPE_DEFAULT] + 169 + queue->ctrl->io_queues[HCTX_TYPE_READ]; 171 170 } 172 171 173 172 static inline size_t nvme_rdma_inline_data_size(struct nvme_rdma_queue *queue) ··· 662 661 nr_io_queues = min_t(unsigned int, nr_io_queues, 663 662 ibdev->num_comp_vectors); 664 663 665 - nr_io_queues += min(opts->nr_write_queues, num_online_cpus()); 666 - nr_io_queues += min(opts->nr_poll_queues, num_online_cpus()); 664 + if (opts->nr_write_queues) { 665 + ctrl->io_queues[HCTX_TYPE_DEFAULT] = 666 + min(opts->nr_write_queues, nr_io_queues); 667 + nr_io_queues += ctrl->io_queues[HCTX_TYPE_DEFAULT]; 668 + } else { 669 + ctrl->io_queues[HCTX_TYPE_DEFAULT] = nr_io_queues; 670 + } 671 + 672 + ctrl->io_queues[HCTX_TYPE_READ] = nr_io_queues; 673 + 674 + if (opts->nr_poll_queues) { 675 + ctrl->io_queues[HCTX_TYPE_POLL] = 676 + min(opts->nr_poll_queues, num_online_cpus()); 677 + nr_io_queues += ctrl->io_queues[HCTX_TYPE_POLL]; 678 + } 667 679 668 680 ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); 669 681 if (ret) ··· 1703 1689 nvme_rdma_timeout(struct request *rq, bool reserved) 1704 1690 { 1705 1691 struct nvme_rdma_request *req = blk_mq_rq_to_pdu(rq); 1692 + struct nvme_rdma_queue *queue = req->queue; 1693 + struct nvme_rdma_ctrl *ctrl = queue->ctrl; 1706 1694 1707 - dev_warn(req->queue->ctrl->ctrl.device, 1708 - "I/O %d QID %d timeout, reset controller\n", 1709 - rq->tag, nvme_rdma_queue_idx(req->queue)); 1695 + dev_warn(ctrl->ctrl.device, "I/O %d QID %d timeout\n", 1696 + rq->tag, nvme_rdma_queue_idx(queue)); 1710 1697 1711 - /* queue error recovery */ 1712 - nvme_rdma_error_recovery(req->queue->ctrl); 1698 + if (ctrl->ctrl.state != NVME_CTRL_LIVE) { 1699 + /* 1700 + * Teardown immediately if controller times out while starting 1701 + * or we are already started error recovery. all outstanding 1702 + * requests are completed on shutdown, so we return BLK_EH_DONE. 1703 + */ 1704 + flush_work(&ctrl->err_work); 1705 + nvme_rdma_teardown_io_queues(ctrl, false); 1706 + nvme_rdma_teardown_admin_queue(ctrl, false); 1707 + return BLK_EH_DONE; 1708 + } 1713 1709 1714 - /* fail with DNR on cmd timeout */ 1715 - nvme_req(rq)->status = NVME_SC_ABORT_REQ | NVME_SC_DNR; 1710 + dev_warn(ctrl->ctrl.device, "starting error recovery\n"); 1711 + nvme_rdma_error_recovery(ctrl); 1716 1712 1717 - return BLK_EH_DONE; 1713 + return BLK_EH_RESET_TIMER; 1718 1714 } 1719 1715 1720 1716 static blk_status_t nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx, ··· 1803 1779 struct nvme_rdma_ctrl *ctrl = set->driver_data; 1804 1780 1805 1781 set->map[HCTX_TYPE_DEFAULT].queue_offset = 0; 1806 - set->map[HCTX_TYPE_READ].nr_queues = ctrl->ctrl.opts->nr_io_queues; 1782 + set->map[HCTX_TYPE_DEFAULT].nr_queues = 1783 + ctrl->io_queues[HCTX_TYPE_DEFAULT]; 1784 + set->map[HCTX_TYPE_READ].nr_queues = ctrl->io_queues[HCTX_TYPE_READ]; 1807 1785 if (ctrl->ctrl.opts->nr_write_queues) { 1808 1786 /* separate read/write queues */ 1809 - set->map[HCTX_TYPE_DEFAULT].nr_queues = 1810 - ctrl->ctrl.opts->nr_write_queues; 1811 1787 set->map[HCTX_TYPE_READ].queue_offset = 1812 - ctrl->ctrl.opts->nr_write_queues; 1788 + ctrl->io_queues[HCTX_TYPE_DEFAULT]; 1813 1789 } else { 1814 1790 /* mixed read/write queues */ 1815 - set->map[HCTX_TYPE_DEFAULT].nr_queues = 1816 - ctrl->ctrl.opts->nr_io_queues; 1817 1791 set->map[HCTX_TYPE_READ].queue_offset = 0; 1818 1792 } 1819 1793 blk_mq_rdma_map_queues(&set->map[HCTX_TYPE_DEFAULT], ··· 1821 1799 1822 1800 if (ctrl->ctrl.opts->nr_poll_queues) { 1823 1801 set->map[HCTX_TYPE_POLL].nr_queues = 1824 - ctrl->ctrl.opts->nr_poll_queues; 1802 + ctrl->io_queues[HCTX_TYPE_POLL]; 1825 1803 set->map[HCTX_TYPE_POLL].queue_offset = 1826 - ctrl->ctrl.opts->nr_io_queues; 1804 + ctrl->io_queues[HCTX_TYPE_DEFAULT]; 1827 1805 if (ctrl->ctrl.opts->nr_write_queues) 1828 1806 set->map[HCTX_TYPE_POLL].queue_offset += 1829 - ctrl->ctrl.opts->nr_write_queues; 1807 + ctrl->io_queues[HCTX_TYPE_READ]; 1830 1808 blk_mq_map_queues(&set->map[HCTX_TYPE_POLL]); 1831 1809 } 1832 1810 return 0;
+11 -8
drivers/nvme/host/tcp.c
··· 1948 1948 struct nvme_tcp_ctrl *ctrl = req->queue->ctrl; 1949 1949 struct nvme_tcp_cmd_pdu *pdu = req->pdu; 1950 1950 1951 - dev_dbg(ctrl->ctrl.device, 1951 + dev_warn(ctrl->ctrl.device, 1952 1952 "queue %d: timeout request %#x type %d\n", 1953 - nvme_tcp_queue_id(req->queue), rq->tag, 1954 - pdu->hdr.type); 1953 + nvme_tcp_queue_id(req->queue), rq->tag, pdu->hdr.type); 1955 1954 1956 1955 if (ctrl->ctrl.state != NVME_CTRL_LIVE) { 1957 - union nvme_result res = {}; 1958 - 1959 - nvme_req(rq)->flags |= NVME_REQ_CANCELLED; 1960 - nvme_end_request(rq, cpu_to_le16(NVME_SC_ABORT_REQ), res); 1956 + /* 1957 + * Teardown immediately if controller times out while starting 1958 + * or we are already started error recovery. all outstanding 1959 + * requests are completed on shutdown, so we return BLK_EH_DONE. 1960 + */ 1961 + flush_work(&ctrl->err_work); 1962 + nvme_tcp_teardown_io_queues(&ctrl->ctrl, false); 1963 + nvme_tcp_teardown_admin_queue(&ctrl->ctrl, false); 1961 1964 return BLK_EH_DONE; 1962 1965 } 1963 1966 1964 - /* queue error recovery */ 1967 + dev_warn(ctrl->ctrl.device, "starting error recovery\n"); 1965 1968 nvme_tcp_error_recovery(&ctrl->ctrl); 1966 1969 1967 1970 return BLK_EH_RESET_TIMER;
+14 -1
drivers/nvme/target/rdma.c
··· 139 139 static void nvmet_rdma_read_data_done(struct ib_cq *cq, struct ib_wc *wc); 140 140 static void nvmet_rdma_qp_event(struct ib_event *event, void *priv); 141 141 static void nvmet_rdma_queue_disconnect(struct nvmet_rdma_queue *queue); 142 + static void nvmet_rdma_free_rsp(struct nvmet_rdma_device *ndev, 143 + struct nvmet_rdma_rsp *r); 144 + static int nvmet_rdma_alloc_rsp(struct nvmet_rdma_device *ndev, 145 + struct nvmet_rdma_rsp *r); 142 146 143 147 static const struct nvmet_fabrics_ops nvmet_rdma_ops; 144 148 ··· 186 182 spin_unlock_irqrestore(&queue->rsps_lock, flags); 187 183 188 184 if (unlikely(!rsp)) { 189 - rsp = kmalloc(sizeof(*rsp), GFP_KERNEL); 185 + int ret; 186 + 187 + rsp = kzalloc(sizeof(*rsp), GFP_KERNEL); 190 188 if (unlikely(!rsp)) 191 189 return NULL; 190 + ret = nvmet_rdma_alloc_rsp(queue->dev, rsp); 191 + if (unlikely(ret)) { 192 + kfree(rsp); 193 + return NULL; 194 + } 195 + 192 196 rsp->allocated = true; 193 197 } 194 198 ··· 209 197 unsigned long flags; 210 198 211 199 if (unlikely(rsp->allocated)) { 200 + nvmet_rdma_free_rsp(rsp->queue->dev, rsp); 212 201 kfree(rsp); 213 202 return; 214 203 }
+3 -2
fs/direct-io.c
··· 679 679 unsigned long fs_count; /* Number of filesystem-sized blocks */ 680 680 int create; 681 681 unsigned int i_blkbits = sdio->blkbits + sdio->blkfactor; 682 + loff_t i_size; 682 683 683 684 /* 684 685 * If there was a memory error and we've overwritten all the ··· 709 708 */ 710 709 create = dio->op == REQ_OP_WRITE; 711 710 if (dio->flags & DIO_SKIP_HOLES) { 712 - if (fs_startblk <= ((i_size_read(dio->inode) - 1) >> 713 - i_blkbits)) 711 + i_size = i_size_read(dio->inode); 712 + if (i_size && fs_startblk <= (i_size - 1) >> i_blkbits) 714 713 create = 0; 715 714 } 716 715
+38 -2
fs/fs-writeback.c
··· 331 331 struct work_struct work; 332 332 }; 333 333 334 + static void bdi_down_write_wb_switch_rwsem(struct backing_dev_info *bdi) 335 + { 336 + down_write(&bdi->wb_switch_rwsem); 337 + } 338 + 339 + static void bdi_up_write_wb_switch_rwsem(struct backing_dev_info *bdi) 340 + { 341 + up_write(&bdi->wb_switch_rwsem); 342 + } 343 + 334 344 static void inode_switch_wbs_work_fn(struct work_struct *work) 335 345 { 336 346 struct inode_switch_wbs_context *isw = 337 347 container_of(work, struct inode_switch_wbs_context, work); 338 348 struct inode *inode = isw->inode; 349 + struct backing_dev_info *bdi = inode_to_bdi(inode); 339 350 struct address_space *mapping = inode->i_mapping; 340 351 struct bdi_writeback *old_wb = inode->i_wb; 341 352 struct bdi_writeback *new_wb = isw->new_wb; 342 353 XA_STATE(xas, &mapping->i_pages, 0); 343 354 struct page *page; 344 355 bool switched = false; 356 + 357 + /* 358 + * If @inode switches cgwb membership while sync_inodes_sb() is 359 + * being issued, sync_inodes_sb() might miss it. Synchronize. 360 + */ 361 + down_read(&bdi->wb_switch_rwsem); 345 362 346 363 /* 347 364 * By the time control reaches here, RCU grace period has passed ··· 445 428 spin_unlock(&new_wb->list_lock); 446 429 spin_unlock(&old_wb->list_lock); 447 430 431 + up_read(&bdi->wb_switch_rwsem); 432 + 448 433 if (switched) { 449 434 wb_wakeup(new_wb); 450 435 wb_put(old_wb); ··· 487 468 if (inode->i_state & I_WB_SWITCH) 488 469 return; 489 470 471 + /* 472 + * Avoid starting new switches while sync_inodes_sb() is in 473 + * progress. Otherwise, if the down_write protected issue path 474 + * blocks heavily, we might end up starting a large number of 475 + * switches which will block on the rwsem. 476 + */ 477 + if (!down_read_trylock(&bdi->wb_switch_rwsem)) 478 + return; 479 + 490 480 isw = kzalloc(sizeof(*isw), GFP_ATOMIC); 491 481 if (!isw) 492 - return; 482 + goto out_unlock; 493 483 494 484 /* find and pin the new wb */ 495 485 rcu_read_lock(); ··· 532 504 * Let's continue after I_WB_SWITCH is guaranteed to be visible. 533 505 */ 534 506 call_rcu(&isw->rcu_head, inode_switch_wbs_rcu_fn); 535 - return; 507 + goto out_unlock; 536 508 537 509 out_free: 538 510 if (isw->new_wb) 539 511 wb_put(isw->new_wb); 540 512 kfree(isw); 513 + out_unlock: 514 + up_read(&bdi->wb_switch_rwsem); 541 515 } 542 516 543 517 /** ··· 916 886 fs_initcall(cgroup_writeback_init); 917 887 918 888 #else /* CONFIG_CGROUP_WRITEBACK */ 889 + 890 + static void bdi_down_write_wb_switch_rwsem(struct backing_dev_info *bdi) { } 891 + static void bdi_up_write_wb_switch_rwsem(struct backing_dev_info *bdi) { } 919 892 920 893 static struct bdi_writeback * 921 894 locked_inode_to_wb_and_lock_list(struct inode *inode) ··· 2446 2413 return; 2447 2414 WARN_ON(!rwsem_is_locked(&sb->s_umount)); 2448 2415 2416 + /* protect against inode wb switch, see inode_switch_wbs_work_fn() */ 2417 + bdi_down_write_wb_switch_rwsem(bdi); 2449 2418 bdi_split_work_to_wbs(bdi, &work, false); 2450 2419 wb_wait_for_completion(bdi, &done); 2420 + bdi_up_write_wb_switch_rwsem(bdi); 2451 2421 2452 2422 wait_sb_inodes(sb); 2453 2423 }
+1
include/linux/backing-dev-defs.h
··· 190 190 struct radix_tree_root cgwb_tree; /* radix tree of active cgroup wbs */ 191 191 struct rb_root cgwb_congested_tree; /* their congested states */ 192 192 struct mutex cgwb_release_mutex; /* protect shutdown of wb structs */ 193 + struct rw_semaphore wb_switch_rwsem; /* no cgwb switch while syncing */ 193 194 #else 194 195 struct bdi_writeback_congested *wb_congested; 195 196 #endif
+1 -1
include/linux/blk_types.h
··· 287 287 REQ_OP_DISCARD = 3, 288 288 /* securely erase sectors */ 289 289 REQ_OP_SECURE_ERASE = 5, 290 - /* seset a zone write pointer */ 290 + /* reset a zone write pointer */ 291 291 REQ_OP_ZONE_RESET = 6, 292 292 /* write the same sector many times */ 293 293 REQ_OP_WRITE_SAME = 7,
+1
include/uapi/linux/blkzoned.h
··· 138 138 * @BLKRESETZONE: Reset the write pointer of the zones in the specified 139 139 * sector range. The sector range must be zone aligned. 140 140 * @BLKGETZONESZ: Get the device zone size in number of 512 B sectors. 141 + * @BLKGETNRZONES: Get the total number of zones of the device. 141 142 */ 142 143 #define BLKREPORTZONE _IOWR(0x12, 130, struct blk_zone_report) 143 144 #define BLKRESETZONE _IOW(0x12, 131, struct blk_zone_range)
+1
mm/backing-dev.c
··· 689 689 INIT_RADIX_TREE(&bdi->cgwb_tree, GFP_ATOMIC); 690 690 bdi->cgwb_congested_tree = RB_ROOT; 691 691 mutex_init(&bdi->cgwb_release_mutex); 692 + init_rwsem(&bdi->wb_switch_rwsem); 692 693 693 694 ret = wb_init(&bdi->wb, bdi, 1, GFP_KERNEL); 694 695 if (!ret) {