From 2dbe5495763612f7c1b68fc897cd28c9e22079b8 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Wed, 4 Nov 2015 17:13:39 +0100 Subject: brd: Refuse improperly aligned discard requests Currently when improperly aligned discard request is submitted, we just silently discard more / less data which results in filesystem corruption in some cases. Refuse such misaligned requests. Signed-off-by: Jan Kara Signed-off-by: Jens Axboe --- drivers/block/brd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/block/brd.c b/drivers/block/brd.c index c9f9c30d6467..a5880f4ab40e 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -337,6 +337,9 @@ static blk_qc_t brd_make_request(struct request_queue *q, struct bio *bio) goto io_error; if (unlikely(bio->bi_rw & REQ_DISCARD)) { + if (sector & ((PAGE_SIZE >> SECTOR_SHIFT) - 1) || + bio->bi_iter.bi_size & PAGE_MASK) + goto io_error; discard_from_brd(brd, sector, bio->bi_iter.bi_size); goto out; } -- cgit v1.2.3-59-g8ed1b From b12363d0a5da00c422641f3d926fffb713192ea3 Mon Sep 17 00:00:00 2001 From: Sathyavathi M Date: Thu, 5 Nov 2015 12:52:28 -0700 Subject: NVMe: Increase the max transfer size when mdts is 0 This patch address the issue when IO with 128KB from FIO is split into two parts, 124KB and 4KB, due to max transfer size(127KB). This degrades the device performance. Signed-off-by: Sathyavathi M Acked-by: Keith Busch Signed-off-by: Jens Axboe --- drivers/nvme/host/pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 3dfc28875cc3..cb89789df40c 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2622,6 +2622,8 @@ static int nvme_dev_add(struct nvme_dev *dev) memcpy(dev->firmware_rev, ctrl->fr, sizeof(ctrl->fr)); if (ctrl->mdts) dev->max_hw_sectors = 1 << (ctrl->mdts + shift - 9); + else + dev->max_hw_sectors = UINT_MAX; if ((pdev->vendor == PCI_VENDOR_ID_INTEL) && (pdev->device == 0x0953) && ctrl->vs[3]) { unsigned int max_hw_sectors; -- cgit v1.2.3-59-g8ed1b From 82c426e0f1f0b279a04cbafd1d25b504bbf49c22 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 5 Nov 2015 13:29:25 -0700 Subject: MAINTAINERS: add reference to new linux-block list In the past, I've resisted doing a non-lkml related block/storage list. But we have more activity now than we previously did, and ain't nobody got time to track and follow lkml. So now linux-block@vger.kernel.org exists. Please CC your patches related to block/storage here, and we'll have an easier time tracking them. Signed-off-by: Jens Axboe --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 35fe7ae0492e..372ee63c0099 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2210,6 +2210,7 @@ F: drivers/leds/leds-blinkm.c BLOCK LAYER M: Jens Axboe +L: linux-block@vger.kernel.org T: git git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git S: Maintained F: block/ -- cgit v1.2.3-59-g8ed1b From 1fa8cc52f46c14fb1afc20c220855c40a5d28fcd Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 5 Nov 2015 14:32:55 -0700 Subject: blk-mq: mark __blk_mq_complete_request() static It's no longer used outside of blk-mq core. Signed-off-by: Jens Axboe --- block/blk-mq.c | 2 +- block/blk-mq.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 86bd5b25288e..3ae09de62f19 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -358,7 +358,7 @@ static void blk_mq_ipi_complete_request(struct request *rq) put_cpu(); } -void __blk_mq_complete_request(struct request *rq) +static void __blk_mq_complete_request(struct request *rq) { struct request_queue *q = rq->q; diff --git a/block/blk-mq.h b/block/blk-mq.h index b44dce165761..713820b47b31 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -25,7 +25,6 @@ struct blk_mq_ctx { struct kobject kobj; } ____cacheline_aligned_in_smp; -void __blk_mq_complete_request(struct request *rq); void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async); void blk_mq_freeze_queue(struct request_queue *q); void blk_mq_free_queue(struct request_queue *q); -- cgit v1.2.3-59-g8ed1b From a310acd7a7ea53533886c11bb7edd11ffd61a036 Mon Sep 17 00:00:00 2001 From: Stephan Günther Date: Sat, 7 Nov 2015 18:07:02 -0700 Subject: NVMe: use split lo_hi_{read,write}q Some controllers may require ordered split transfers even on 64bit machines, e.g. Apple's NVMe controller as found in the MacBook8,1 and MacBookAir7,1 (256/512GB models). This patch enforces ordered split transfers on 64bit platforms, which works around that issue for all controllers. As pointed out by Christoph [1] there should be no performance impact due to that modification. [1] http://lists.infradead.org/pipermail/linux-nvme/2015-November/002965.html Signed-off-by: Stephan Guenther Signed-off-by: Maurice Leclaire Reviewed-by: Christoph Hellwig Updated by me to explicitly use lo_hi_read/writeq instead of playing define tricks. Signed-off-by: Jens Axboe --- drivers/nvme/host/pci.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index cb89789df40c..3435d79a99ee 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1725,7 +1725,7 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev) { int result; u32 aqa; - u64 cap = readq(&dev->bar->cap); + u64 cap = lo_hi_readq(&dev->bar->cap); struct nvme_queue *nvmeq; unsigned page_shift = PAGE_SHIFT; unsigned dev_page_min = NVME_CAP_MPSMIN(cap) + 12; @@ -1774,8 +1774,8 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev) dev->ctrl_config |= NVME_CC_IOSQES | NVME_CC_IOCQES; writel(aqa, &dev->bar->aqa); - writeq(nvmeq->sq_dma_addr, &dev->bar->asq); - writeq(nvmeq->cq_dma_addr, &dev->bar->acq); + lo_hi_writeq(nvmeq->sq_dma_addr, &dev->bar->asq); + lo_hi_writeq(nvmeq->cq_dma_addr, &dev->bar->acq); result = nvme_enable_ctrl(dev, cap); if (result) @@ -2606,7 +2606,7 @@ static int nvme_dev_add(struct nvme_dev *dev) struct pci_dev *pdev = to_pci_dev(dev->dev); int res; struct nvme_id_ctrl *ctrl; - int shift = NVME_CAP_MPSMIN(readq(&dev->bar->cap)) + 12; + int shift = NVME_CAP_MPSMIN(lo_hi_readq(&dev->bar->cap)) + 12; res = nvme_identify_ctrl(dev, &ctrl); if (res) { @@ -2697,7 +2697,7 @@ static int nvme_dev_map(struct nvme_dev *dev) goto unmap; } - cap = readq(&dev->bar->cap); + cap = lo_hi_readq(&dev->bar->cap); dev->q_depth = min_t(int, NVME_CAP_MQES(cap) + 1, NVME_Q_DEPTH); dev->db_stride = 1 << NVME_CAP_STRIDE(cap); dev->dbs = ((void __iomem *)dev->bar) + 4096; @@ -2760,7 +2760,7 @@ static void nvme_wait_dq(struct nvme_delq_ctx *dq, struct nvme_dev *dev) * queues than admin tags. */ set_current_state(TASK_RUNNING); - nvme_disable_ctrl(dev, readq(&dev->bar->cap)); + nvme_disable_ctrl(dev, lo_hi_readq(&dev->bar->cap)); nvme_clear_queue(dev->queues[0]); flush_kthread_worker(dq->worker); nvme_disable_queue(dev, 0); -- cgit v1.2.3-59-g8ed1b From c74dc7801d515d01847fd5cf2b472489fa5717b1 Mon Sep 17 00:00:00 2001 From: Stephan Günther Date: Wed, 4 Nov 2015 00:49:45 +0100 Subject: NVMe: add support for Apple NVMe controller Add PCI ID of Apple's NVMe controller. Signed-off-by: Stephan Guenther Signed-off-by: Maurice Leclaire Reviewed-by: Christoph Hellwig Signed-off-by: Jens Axboe --- drivers/nvme/host/pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 3435d79a99ee..8187df204695 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -3403,6 +3403,7 @@ static const struct pci_error_handlers nvme_err_handler = { static const struct pci_device_id nvme_id_table[] = { { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2001) }, { 0, } }; MODULE_DEVICE_TABLE(pci, nvme_id_table); -- cgit v1.2.3-59-g8ed1b From dbd3ca50753e70e09cad747dce23b1a7683a3342 Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Mon, 9 Nov 2015 09:23:40 -0700 Subject: fs/block_dev.c: Remove WARN_ON() when inode writeback fails If a block device is hot removed and later last reference to device is put, we try to writeback the dirty inode. But device is gone and that writeback fails. Currently we do a WARN_ON() which does not seem to be the right thing. Convert it to a ratelimited kernel warning. Reported-by: Andi Kleen Signed-off-by: Vivek Goyal Acked-by: Tejun Heo [jmoyer@redhat.com: get rid of unnecessary name initialization, 80 cols] Signed-off-by: Jeff Moyer Signed-off-by: Jens Axboe --- fs/block_dev.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 0a793c7930eb..bb0dfb1c7af1 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -50,12 +50,21 @@ struct block_device *I_BDEV(struct inode *inode) } EXPORT_SYMBOL(I_BDEV); -static void bdev_write_inode(struct inode *inode) +static void bdev_write_inode(struct block_device *bdev) { + struct inode *inode = bdev->bd_inode; + int ret; + spin_lock(&inode->i_lock); while (inode->i_state & I_DIRTY) { spin_unlock(&inode->i_lock); - WARN_ON_ONCE(write_inode_now(inode, true)); + ret = write_inode_now(inode, true); + if (ret) { + char name[BDEVNAME_SIZE]; + pr_warn_ratelimited("VFS: Dirty inode writeback failed " + "for block device %s (err=%d).\n", + bdevname(bdev, name), ret); + } spin_lock(&inode->i_lock); } spin_unlock(&inode->i_lock); @@ -1504,7 +1513,7 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) * ->release can cause the queue to disappear, so flush all * dirty data before. */ - bdev_write_inode(bdev->bd_inode); + bdev_write_inode(bdev); } if (bdev->bd_contains == bdev) { if (disk->fops->release) -- cgit v1.2.3-59-g8ed1b From ccc2600b8a28f3eb0c126cd00312baba1c22cccb Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Fri, 30 Oct 2015 18:36:16 -0700 Subject: block: fix blk-core.c kernel-doc warning Fix kernel-doc warning in blk-core.c: Warning(..//block/blk-core.c:1549): No description found for parameter 'same_queue_rq' Signed-off-by: Randy Dunlap Reviewed-by: Jeff Moyer Signed-off-by: Jens Axboe --- block/blk-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index 2bbf08cd2900..5131993b23a1 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1575,6 +1575,9 @@ bool bio_attempt_front_merge(struct request_queue *q, struct request *req, * @q: request_queue new bio is being queued at * @bio: new bio being queued * @request_count: out parameter for number of traversed plugged requests + * @same_queue_rq: pointer to &struct request that gets filled in when + * another request associated with @q is found on the plug list + * (optional, may be %NULL) * * Determine whether @bio being queued on @q can be merged with a request * on %current's plugged list. Returns %true if merge was successful, -- cgit v1.2.3-59-g8ed1b From cadfbb6ec2e55171479191046142c927a8b12d87 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 10 Nov 2015 19:42:49 -0700 Subject: dax_io(): don't let non-error value escape via retval instead of EFAULT Signed-off-by: Al Viro Reported-by: Sasha Levin Cc: stable@vger.kernel.org # 4.0+ Signed-off-by: Jens Axboe --- fs/dax.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/dax.c b/fs/dax.c index a86d3cc2b389..7b653e9aa8d1 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -169,8 +169,10 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter, else len = iov_iter_zero(max - pos, iter); - if (!len) + if (!len) { + retval = -EFAULT; break; + } pos += len; addr += len; -- cgit v1.2.3-59-g8ed1b From e3a7a3bf362e2a8acc301e5eaec2631e740a8a95 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 11 Nov 2015 09:37:34 -0700 Subject: block: don't hardcode blk_qc_t -> tag mask Use the shift/mask we use elsewhere. Signed-off-by: Jens Axboe --- include/linux/blk_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 641e5a3ed58c..0fb65843ec1e 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -265,7 +265,7 @@ static inline unsigned int blk_qc_t_to_queue_num(blk_qc_t cookie) static inline unsigned int blk_qc_t_to_tag(blk_qc_t cookie) { - return cookie & 0xffff; + return cookie & ((1u << BLK_QC_T_SHIFT) - 1); } #endif /* __LINUX_BLK_TYPES_H */ -- cgit v1.2.3-59-g8ed1b