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

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

Pull block bits from Jens Axboe:
"As vacation is coming up, thought I'd better get rid of my pending
changes in my for-linus branch for this iteration. It contains:

- Two patches for mtip32xx. Killing a non-compliant sysfs interface
and moving it to debugfs, where it belongs.

- A few patches from Asias. Two legit bug fixes, and one killing an
interface that is no longer in use.

- A patch from Jan, making the annoying partition ioctl warning a bit
less annoying, by restricting it to !CAP_SYS_RAWIO only.

- Three bug fixes for drbd from Lars Ellenberg.

- A fix for an old regression for umem, it hasn't really worked since
the plugging scheme was changed in 3.0.

- A few fixes from Tejun.

- A splice fix from Eric Dumazet, fixing an issue with pipe
resizing."

* 'for-linus' of git://git.kernel.dk/linux-block:
scsi: Silence unnecessary warnings about ioctl to partition
block: Drop dead function blk_abort_queue()
block: Mitigate lock unbalance caused by lock switching
block: Avoid missed wakeup in request waitqueue
umem: fix up unplugging
splice: fix racy pipe->buffers uses
drbd: fix null pointer dereference with on-congestion policy when diskless
drbd: fix list corruption by failing but already aborted reads
drbd: fix access of unallocated pages and kernel panic
xen/blkfront: Add WARN to deal with misbehaving backends.
blkcg: drop local variable @q from blkg_destroy()
mtip32xx: Create debugfs entries for troubleshooting
mtip32xx: Remove 'registers' and 'flags' from sysfs
blkcg: fix blkg_alloc() failure path
block: blkcg_policy_cfq shouldn't be used if !CONFIG_CFQ_GROUP_IOSCHED
block: fix return value on cfq_init() failure
mtip32xx: Remove version.h header file inclusion
xen/blkback: Copy id field when doing BLKIF_DISCARD.

+378 -240
-21
Documentation/ABI/testing/sysfs-block-rssd
··· 1 - What: /sys/block/rssd*/registers 2 - Date: March 2012 3 - KernelVersion: 3.3 4 - Contact: Asai Thambi S P <asamymuthupa@micron.com> 5 - Description: This is a read-only file. Dumps below driver information and 6 - hardware registers. 7 - - S ACTive 8 - - Command Issue 9 - - Completed 10 - - PORT IRQ STAT 11 - - HOST IRQ STAT 12 - - Allocated 13 - - Commands in Q 14 - 15 1 What: /sys/block/rssd*/status 16 2 Date: April 2012 17 3 KernelVersion: 3.4 18 4 Contact: Asai Thambi S P <asamymuthupa@micron.com> 19 5 Description: This is a read-only file. Indicates the status of the device. 20 - 21 - What: /sys/block/rssd*/flags 22 - Date: May 2012 23 - KernelVersion: 3.5 24 - Contact: Asai Thambi S P <asamymuthupa@micron.com> 25 - Description: This is a read-only file. Dumps the flags in port and driver 26 - data structure
+2 -7
block/blk-cgroup.c
··· 125 125 126 126 blkg->pd[i] = pd; 127 127 pd->blkg = blkg; 128 - } 129 128 130 - /* invoke per-policy init */ 131 - for (i = 0; i < BLKCG_MAX_POLS; i++) { 132 - struct blkcg_policy *pol = blkcg_policy[i]; 133 - 129 + /* invoke per-policy init */ 134 130 if (blkcg_policy_enabled(blkg->q, pol)) 135 131 pol->pd_init_fn(blkg); 136 132 } ··· 241 245 242 246 static void blkg_destroy(struct blkcg_gq *blkg) 243 247 { 244 - struct request_queue *q = blkg->q; 245 248 struct blkcg *blkcg = blkg->blkcg; 246 249 247 - lockdep_assert_held(q->queue_lock); 250 + lockdep_assert_held(blkg->q->queue_lock); 248 251 lockdep_assert_held(&blkcg->lock); 249 252 250 253 /* Something wrong if we are trying to remove same group twice */
+19 -6
block/blk-core.c
··· 361 361 */ 362 362 void blk_drain_queue(struct request_queue *q, bool drain_all) 363 363 { 364 + int i; 365 + 364 366 while (true) { 365 367 bool drain = false; 366 - int i; 367 368 368 369 spin_lock_irq(q->queue_lock); 369 370 ··· 408 407 if (!drain) 409 408 break; 410 409 msleep(10); 410 + } 411 + 412 + /* 413 + * With queue marked dead, any woken up waiter will fail the 414 + * allocation path, so the wakeup chaining is lost and we're 415 + * left with hung waiters. We need to wake up those waiters. 416 + */ 417 + if (q->request_fn) { 418 + spin_lock_irq(q->queue_lock); 419 + for (i = 0; i < ARRAY_SIZE(q->rq.wait); i++) 420 + wake_up_all(&q->rq.wait[i]); 421 + spin_unlock_irq(q->queue_lock); 411 422 } 412 423 } 413 424 ··· 480 467 /* mark @q DEAD, no new request or merges will be allowed afterwards */ 481 468 mutex_lock(&q->sysfs_lock); 482 469 queue_flag_set_unlocked(QUEUE_FLAG_DEAD, q); 483 - 484 470 spin_lock_irq(lock); 485 471 486 472 /* ··· 497 485 queue_flag_set(QUEUE_FLAG_NOMERGES, q); 498 486 queue_flag_set(QUEUE_FLAG_NOXMERGES, q); 499 487 queue_flag_set(QUEUE_FLAG_DEAD, q); 500 - 501 - if (q->queue_lock != &q->__queue_lock) 502 - q->queue_lock = &q->__queue_lock; 503 - 504 488 spin_unlock_irq(lock); 505 489 mutex_unlock(&q->sysfs_lock); 506 490 ··· 506 498 /* @q won't process any more request, flush async actions */ 507 499 del_timer_sync(&q->backing_dev_info.laptop_mode_wb_timer); 508 500 blk_sync_queue(q); 501 + 502 + spin_lock_irq(lock); 503 + if (q->queue_lock != &q->__queue_lock) 504 + q->queue_lock = &q->__queue_lock; 505 + spin_unlock_irq(lock); 509 506 510 507 /* @q is and will stay empty, shutdown and put */ 511 508 blk_put_queue(q);
-41
block/blk-timeout.c
··· 197 197 mod_timer(&q->timeout, expiry); 198 198 } 199 199 200 - /** 201 - * blk_abort_queue -- Abort all request on given queue 202 - * @queue: pointer to queue 203 - * 204 - */ 205 - void blk_abort_queue(struct request_queue *q) 206 - { 207 - unsigned long flags; 208 - struct request *rq, *tmp; 209 - LIST_HEAD(list); 210 - 211 - /* 212 - * Not a request based block device, nothing to abort 213 - */ 214 - if (!q->request_fn) 215 - return; 216 - 217 - spin_lock_irqsave(q->queue_lock, flags); 218 - 219 - elv_abort_queue(q); 220 - 221 - /* 222 - * Splice entries to local list, to avoid deadlocking if entries 223 - * get readded to the timeout list by error handling 224 - */ 225 - list_splice_init(&q->timeout_list, &list); 226 - 227 - list_for_each_entry_safe(rq, tmp, &list, timeout_list) 228 - blk_abort_request(rq); 229 - 230 - /* 231 - * Occasionally, blk_abort_request() will return without 232 - * deleting the element from the list. Make sure we add those back 233 - * instead of leaving them on the local stack list. 234 - */ 235 - list_splice(&list, &q->timeout_list); 236 - 237 - spin_unlock_irqrestore(q->queue_lock, flags); 238 - 239 - } 240 - EXPORT_SYMBOL_GPL(blk_abort_queue);
+18 -12
block/cfq-iosched.c
··· 17 17 #include "blk.h" 18 18 #include "blk-cgroup.h" 19 19 20 - static struct blkcg_policy blkcg_policy_cfq __maybe_unused; 21 - 22 20 /* 23 21 * tunables 24 22 */ ··· 416 418 return pd ? container_of(pd, struct cfq_group, pd) : NULL; 417 419 } 418 420 419 - static inline struct cfq_group *blkg_to_cfqg(struct blkcg_gq *blkg) 420 - { 421 - return pd_to_cfqg(blkg_to_pd(blkg, &blkcg_policy_cfq)); 422 - } 423 - 424 421 static inline struct blkcg_gq *cfqg_to_blkg(struct cfq_group *cfqg) 425 422 { 426 423 return pd_to_blkg(&cfqg->pd); ··· 564 571 #endif /* CONFIG_CFQ_GROUP_IOSCHED && CONFIG_DEBUG_BLK_CGROUP */ 565 572 566 573 #ifdef CONFIG_CFQ_GROUP_IOSCHED 574 + 575 + static struct blkcg_policy blkcg_policy_cfq; 576 + 577 + static inline struct cfq_group *blkg_to_cfqg(struct blkcg_gq *blkg) 578 + { 579 + return pd_to_cfqg(blkg_to_pd(blkg, &blkcg_policy_cfq)); 580 + } 567 581 568 582 static inline void cfqg_get(struct cfq_group *cfqg) 569 583 { ··· 3951 3951 3952 3952 cfq_shutdown_timer_wq(cfqd); 3953 3953 3954 - #ifndef CONFIG_CFQ_GROUP_IOSCHED 3954 + #ifdef CONFIG_CFQ_GROUP_IOSCHED 3955 + blkcg_deactivate_policy(q, &blkcg_policy_cfq); 3956 + #else 3955 3957 kfree(cfqd->root_group); 3956 3958 #endif 3957 - blkcg_deactivate_policy(q, &blkcg_policy_cfq); 3958 3959 kfree(cfqd); 3959 3960 } 3960 3961 ··· 4195 4194 #ifdef CONFIG_CFQ_GROUP_IOSCHED 4196 4195 if (!cfq_group_idle) 4197 4196 cfq_group_idle = 1; 4198 - #else 4199 - cfq_group_idle = 0; 4200 - #endif 4201 4197 4202 4198 ret = blkcg_policy_register(&blkcg_policy_cfq); 4203 4199 if (ret) 4204 4200 return ret; 4201 + #else 4202 + cfq_group_idle = 0; 4203 + #endif 4205 4204 4205 + ret = -ENOMEM; 4206 4206 cfq_pool = KMEM_CACHE(cfq_queue, 0); 4207 4207 if (!cfq_pool) 4208 4208 goto err_pol_unreg; ··· 4217 4215 err_free_pool: 4218 4216 kmem_cache_destroy(cfq_pool); 4219 4217 err_pol_unreg: 4218 + #ifdef CONFIG_CFQ_GROUP_IOSCHED 4220 4219 blkcg_policy_unregister(&blkcg_policy_cfq); 4220 + #endif 4221 4221 return ret; 4222 4222 } 4223 4223 4224 4224 static void __exit cfq_exit(void) 4225 4225 { 4226 + #ifdef CONFIG_CFQ_GROUP_IOSCHED 4226 4227 blkcg_policy_unregister(&blkcg_policy_cfq); 4228 + #endif 4227 4229 elv_unregister(&iosched_cfq); 4228 4230 kmem_cache_destroy(cfq_pool); 4229 4231 }
+4 -1
block/scsi_ioctl.c
··· 721 721 break; 722 722 } 723 723 724 + if (capable(CAP_SYS_RAWIO)) 725 + return 0; 726 + 724 727 /* In particular, rule out all resets and host-specific ioctls. */ 725 728 printk_ratelimited(KERN_WARNING 726 729 "%s: sending ioctl %x to a partition!\n", current->comm, cmd); 727 730 728 - return capable(CAP_SYS_RAWIO) ? 0 : -ENOIOCTLCMD; 731 + return -ENOIOCTLCMD; 729 732 } 730 733 EXPORT_SYMBOL(scsi_verify_blk_ioctl); 731 734
+9 -2
drivers/block/drbd/drbd_bitmap.c
··· 1475 1475 first_word = 0; 1476 1476 spin_lock_irq(&b->bm_lock); 1477 1477 } 1478 - 1479 1478 /* last page (respectively only page, for first page == last page) */ 1480 1479 last_word = MLPP(el >> LN2_BPL); 1481 - bm_set_full_words_within_one_page(mdev->bitmap, last_page, first_word, last_word); 1480 + 1481 + /* consider bitmap->bm_bits = 32768, bitmap->bm_number_of_pages = 1. (or multiples). 1482 + * ==> e = 32767, el = 32768, last_page = 2, 1483 + * and now last_word = 0. 1484 + * We do not want to touch last_page in this case, 1485 + * as we did not allocate it, it is not present in bitmap->bm_pages. 1486 + */ 1487 + if (last_word) 1488 + bm_set_full_words_within_one_page(mdev->bitmap, last_page, first_word, last_word); 1482 1489 1483 1490 /* possibly trailing bits. 1484 1491 * example: (e & 63) == 63, el will be e+1.
+42 -24
drivers/block/drbd/drbd_req.c
··· 472 472 req->rq_state |= RQ_LOCAL_COMPLETED; 473 473 req->rq_state &= ~RQ_LOCAL_PENDING; 474 474 475 - D_ASSERT(!(req->rq_state & RQ_NET_MASK)); 475 + if (req->rq_state & RQ_LOCAL_ABORTED) { 476 + _req_may_be_done(req, m); 477 + break; 478 + } 476 479 477 480 __drbd_chk_io_error(mdev, false); 478 481 479 482 goto_queue_for_net_read: 483 + 484 + D_ASSERT(!(req->rq_state & RQ_NET_MASK)); 480 485 481 486 /* no point in retrying if there is no good remote data, 482 487 * or we have no connection. */ ··· 770 765 return 0 == drbd_bm_count_bits(mdev, sbnr, ebnr); 771 766 } 772 767 768 + static void maybe_pull_ahead(struct drbd_conf *mdev) 769 + { 770 + int congested = 0; 771 + 772 + /* If I don't even have good local storage, we can not reasonably try 773 + * to pull ahead of the peer. We also need the local reference to make 774 + * sure mdev->act_log is there. 775 + * Note: caller has to make sure that net_conf is there. 776 + */ 777 + if (!get_ldev_if_state(mdev, D_UP_TO_DATE)) 778 + return; 779 + 780 + if (mdev->net_conf->cong_fill && 781 + atomic_read(&mdev->ap_in_flight) >= mdev->net_conf->cong_fill) { 782 + dev_info(DEV, "Congestion-fill threshold reached\n"); 783 + congested = 1; 784 + } 785 + 786 + if (mdev->act_log->used >= mdev->net_conf->cong_extents) { 787 + dev_info(DEV, "Congestion-extents threshold reached\n"); 788 + congested = 1; 789 + } 790 + 791 + if (congested) { 792 + queue_barrier(mdev); /* last barrier, after mirrored writes */ 793 + 794 + if (mdev->net_conf->on_congestion == OC_PULL_AHEAD) 795 + _drbd_set_state(_NS(mdev, conn, C_AHEAD), 0, NULL); 796 + else /*mdev->net_conf->on_congestion == OC_DISCONNECT */ 797 + _drbd_set_state(_NS(mdev, conn, C_DISCONNECTING), 0, NULL); 798 + } 799 + put_ldev(mdev); 800 + } 801 + 773 802 static int drbd_make_request_common(struct drbd_conf *mdev, struct bio *bio, unsigned long start_time) 774 803 { 775 804 const int rw = bio_rw(bio); ··· 1011 972 _req_mod(req, queue_for_send_oos); 1012 973 1013 974 if (remote && 1014 - mdev->net_conf->on_congestion != OC_BLOCK && mdev->agreed_pro_version >= 96) { 1015 - int congested = 0; 1016 - 1017 - if (mdev->net_conf->cong_fill && 1018 - atomic_read(&mdev->ap_in_flight) >= mdev->net_conf->cong_fill) { 1019 - dev_info(DEV, "Congestion-fill threshold reached\n"); 1020 - congested = 1; 1021 - } 1022 - 1023 - if (mdev->act_log->used >= mdev->net_conf->cong_extents) { 1024 - dev_info(DEV, "Congestion-extents threshold reached\n"); 1025 - congested = 1; 1026 - } 1027 - 1028 - if (congested) { 1029 - queue_barrier(mdev); /* last barrier, after mirrored writes */ 1030 - 1031 - if (mdev->net_conf->on_congestion == OC_PULL_AHEAD) 1032 - _drbd_set_state(_NS(mdev, conn, C_AHEAD), 0, NULL); 1033 - else /*mdev->net_conf->on_congestion == OC_DISCONNECT */ 1034 - _drbd_set_state(_NS(mdev, conn, C_DISCONNECTING), 0, NULL); 1035 - } 1036 - } 975 + mdev->net_conf->on_congestion != OC_BLOCK && mdev->agreed_pro_version >= 96) 976 + maybe_pull_ahead(mdev); 1037 977 1038 978 spin_unlock_irq(&mdev->req_lock); 1039 979 kfree(b); /* if someone else has beaten us to it... */
+158 -88
drivers/block/mtip32xx/mtip32xx.c
··· 37 37 #include <linux/kthread.h> 38 38 #include <../drivers/ata/ahci.h> 39 39 #include <linux/export.h> 40 + #include <linux/debugfs.h> 40 41 #include "mtip32xx.h" 41 42 42 43 #define HW_CMD_SLOT_SZ (MTIP_MAX_COMMAND_SLOTS * 32) ··· 86 85 * allocated in mtip_init(). 87 86 */ 88 87 static int mtip_major; 88 + static struct dentry *dfs_parent; 89 89 90 90 static DEFINE_SPINLOCK(rssd_index_lock); 91 91 static DEFINE_IDA(rssd_index_ida); ··· 2548 2546 } 2549 2547 2550 2548 /* 2551 - * Sysfs register/status dump. 2549 + * Sysfs status dump. 2552 2550 * 2553 2551 * @dev Pointer to the device structure, passed by the kernrel. 2554 2552 * @attr Pointer to the device_attribute structure passed by the kernel. ··· 2557 2555 * return value 2558 2556 * The size, in bytes, of the data copied into buf. 2559 2557 */ 2560 - static ssize_t mtip_hw_show_registers(struct device *dev, 2561 - struct device_attribute *attr, 2562 - char *buf) 2563 - { 2564 - u32 group_allocated; 2565 - struct driver_data *dd = dev_to_disk(dev)->private_data; 2566 - int size = 0; 2567 - int n; 2568 - 2569 - size += sprintf(&buf[size], "Hardware\n--------\n"); 2570 - size += sprintf(&buf[size], "S ACTive : [ 0x"); 2571 - 2572 - for (n = dd->slot_groups-1; n >= 0; n--) 2573 - size += sprintf(&buf[size], "%08X ", 2574 - readl(dd->port->s_active[n])); 2575 - 2576 - size += sprintf(&buf[size], "]\n"); 2577 - size += sprintf(&buf[size], "Command Issue : [ 0x"); 2578 - 2579 - for (n = dd->slot_groups-1; n >= 0; n--) 2580 - size += sprintf(&buf[size], "%08X ", 2581 - readl(dd->port->cmd_issue[n])); 2582 - 2583 - size += sprintf(&buf[size], "]\n"); 2584 - size += sprintf(&buf[size], "Completed : [ 0x"); 2585 - 2586 - for (n = dd->slot_groups-1; n >= 0; n--) 2587 - size += sprintf(&buf[size], "%08X ", 2588 - readl(dd->port->completed[n])); 2589 - 2590 - size += sprintf(&buf[size], "]\n"); 2591 - size += sprintf(&buf[size], "PORT IRQ STAT : [ 0x%08X ]\n", 2592 - readl(dd->port->mmio + PORT_IRQ_STAT)); 2593 - size += sprintf(&buf[size], "HOST IRQ STAT : [ 0x%08X ]\n", 2594 - readl(dd->mmio + HOST_IRQ_STAT)); 2595 - size += sprintf(&buf[size], "\n"); 2596 - 2597 - size += sprintf(&buf[size], "Local\n-----\n"); 2598 - size += sprintf(&buf[size], "Allocated : [ 0x"); 2599 - 2600 - for (n = dd->slot_groups-1; n >= 0; n--) { 2601 - if (sizeof(long) > sizeof(u32)) 2602 - group_allocated = 2603 - dd->port->allocated[n/2] >> (32*(n&1)); 2604 - else 2605 - group_allocated = dd->port->allocated[n]; 2606 - size += sprintf(&buf[size], "%08X ", group_allocated); 2607 - } 2608 - size += sprintf(&buf[size], "]\n"); 2609 - 2610 - size += sprintf(&buf[size], "Commands in Q: [ 0x"); 2611 - 2612 - for (n = dd->slot_groups-1; n >= 0; n--) { 2613 - if (sizeof(long) > sizeof(u32)) 2614 - group_allocated = 2615 - dd->port->cmds_to_issue[n/2] >> (32*(n&1)); 2616 - else 2617 - group_allocated = dd->port->cmds_to_issue[n]; 2618 - size += sprintf(&buf[size], "%08X ", group_allocated); 2619 - } 2620 - size += sprintf(&buf[size], "]\n"); 2621 - 2622 - return size; 2623 - } 2624 - 2625 2558 static ssize_t mtip_hw_show_status(struct device *dev, 2626 2559 struct device_attribute *attr, 2627 2560 char *buf) ··· 2574 2637 return size; 2575 2638 } 2576 2639 2577 - static ssize_t mtip_hw_show_flags(struct device *dev, 2578 - struct device_attribute *attr, 2579 - char *buf) 2640 + static DEVICE_ATTR(status, S_IRUGO, mtip_hw_show_status, NULL); 2641 + 2642 + static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf, 2643 + size_t len, loff_t *offset) 2580 2644 { 2581 - struct driver_data *dd = dev_to_disk(dev)->private_data; 2582 - int size = 0; 2645 + struct driver_data *dd = (struct driver_data *)f->private_data; 2646 + char buf[MTIP_DFS_MAX_BUF_SIZE]; 2647 + u32 group_allocated; 2648 + int size = *offset; 2649 + int n; 2583 2650 2584 - size += sprintf(&buf[size], "Flag in port struct : [ %08lX ]\n", 2585 - dd->port->flags); 2586 - size += sprintf(&buf[size], "Flag in dd struct : [ %08lX ]\n", 2587 - dd->dd_flag); 2651 + if (!len || size) 2652 + return 0; 2588 2653 2589 - return size; 2654 + if (size < 0) 2655 + return -EINVAL; 2656 + 2657 + size += sprintf(&buf[size], "H/ S ACTive : [ 0x"); 2658 + 2659 + for (n = dd->slot_groups-1; n >= 0; n--) 2660 + size += sprintf(&buf[size], "%08X ", 2661 + readl(dd->port->s_active[n])); 2662 + 2663 + size += sprintf(&buf[size], "]\n"); 2664 + size += sprintf(&buf[size], "H/ Command Issue : [ 0x"); 2665 + 2666 + for (n = dd->slot_groups-1; n >= 0; n--) 2667 + size += sprintf(&buf[size], "%08X ", 2668 + readl(dd->port->cmd_issue[n])); 2669 + 2670 + size += sprintf(&buf[size], "]\n"); 2671 + size += sprintf(&buf[size], "H/ Completed : [ 0x"); 2672 + 2673 + for (n = dd->slot_groups-1; n >= 0; n--) 2674 + size += sprintf(&buf[size], "%08X ", 2675 + readl(dd->port->completed[n])); 2676 + 2677 + size += sprintf(&buf[size], "]\n"); 2678 + size += sprintf(&buf[size], "H/ PORT IRQ STAT : [ 0x%08X ]\n", 2679 + readl(dd->port->mmio + PORT_IRQ_STAT)); 2680 + size += sprintf(&buf[size], "H/ HOST IRQ STAT : [ 0x%08X ]\n", 2681 + readl(dd->mmio + HOST_IRQ_STAT)); 2682 + size += sprintf(&buf[size], "\n"); 2683 + 2684 + size += sprintf(&buf[size], "L/ Allocated : [ 0x"); 2685 + 2686 + for (n = dd->slot_groups-1; n >= 0; n--) { 2687 + if (sizeof(long) > sizeof(u32)) 2688 + group_allocated = 2689 + dd->port->allocated[n/2] >> (32*(n&1)); 2690 + else 2691 + group_allocated = dd->port->allocated[n]; 2692 + size += sprintf(&buf[size], "%08X ", group_allocated); 2693 + } 2694 + size += sprintf(&buf[size], "]\n"); 2695 + 2696 + size += sprintf(&buf[size], "L/ Commands in Q : [ 0x"); 2697 + 2698 + for (n = dd->slot_groups-1; n >= 0; n--) { 2699 + if (sizeof(long) > sizeof(u32)) 2700 + group_allocated = 2701 + dd->port->cmds_to_issue[n/2] >> (32*(n&1)); 2702 + else 2703 + group_allocated = dd->port->cmds_to_issue[n]; 2704 + size += sprintf(&buf[size], "%08X ", group_allocated); 2705 + } 2706 + size += sprintf(&buf[size], "]\n"); 2707 + 2708 + *offset = size <= len ? size : len; 2709 + size = copy_to_user(ubuf, buf, *offset); 2710 + if (size) 2711 + return -EFAULT; 2712 + 2713 + return *offset; 2590 2714 } 2591 2715 2592 - static DEVICE_ATTR(registers, S_IRUGO, mtip_hw_show_registers, NULL); 2593 - static DEVICE_ATTR(status, S_IRUGO, mtip_hw_show_status, NULL); 2594 - static DEVICE_ATTR(flags, S_IRUGO, mtip_hw_show_flags, NULL); 2716 + static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf, 2717 + size_t len, loff_t *offset) 2718 + { 2719 + struct driver_data *dd = (struct driver_data *)f->private_data; 2720 + char buf[MTIP_DFS_MAX_BUF_SIZE]; 2721 + int size = *offset; 2722 + 2723 + if (!len || size) 2724 + return 0; 2725 + 2726 + if (size < 0) 2727 + return -EINVAL; 2728 + 2729 + size += sprintf(&buf[size], "Flag-port : [ %08lX ]\n", 2730 + dd->port->flags); 2731 + size += sprintf(&buf[size], "Flag-dd : [ %08lX ]\n", 2732 + dd->dd_flag); 2733 + 2734 + *offset = size <= len ? size : len; 2735 + size = copy_to_user(ubuf, buf, *offset); 2736 + if (size) 2737 + return -EFAULT; 2738 + 2739 + return *offset; 2740 + } 2741 + 2742 + static const struct file_operations mtip_regs_fops = { 2743 + .owner = THIS_MODULE, 2744 + .open = simple_open, 2745 + .read = mtip_hw_read_registers, 2746 + .llseek = no_llseek, 2747 + }; 2748 + 2749 + static const struct file_operations mtip_flags_fops = { 2750 + .owner = THIS_MODULE, 2751 + .open = simple_open, 2752 + .read = mtip_hw_read_flags, 2753 + .llseek = no_llseek, 2754 + }; 2595 2755 2596 2756 /* 2597 2757 * Create the sysfs related attributes. ··· 2705 2671 if (!kobj || !dd) 2706 2672 return -EINVAL; 2707 2673 2708 - if (sysfs_create_file(kobj, &dev_attr_registers.attr)) 2709 - dev_warn(&dd->pdev->dev, 2710 - "Error creating 'registers' sysfs entry\n"); 2711 2674 if (sysfs_create_file(kobj, &dev_attr_status.attr)) 2712 2675 dev_warn(&dd->pdev->dev, 2713 2676 "Error creating 'status' sysfs entry\n"); 2714 - if (sysfs_create_file(kobj, &dev_attr_flags.attr)) 2715 - dev_warn(&dd->pdev->dev, 2716 - "Error creating 'flags' sysfs entry\n"); 2717 2677 return 0; 2718 2678 } 2719 2679 ··· 2726 2698 if (!kobj || !dd) 2727 2699 return -EINVAL; 2728 2700 2729 - sysfs_remove_file(kobj, &dev_attr_registers.attr); 2730 2701 sysfs_remove_file(kobj, &dev_attr_status.attr); 2731 - sysfs_remove_file(kobj, &dev_attr_flags.attr); 2732 2702 2733 2703 return 0; 2734 2704 } 2705 + 2706 + static int mtip_hw_debugfs_init(struct driver_data *dd) 2707 + { 2708 + if (!dfs_parent) 2709 + return -1; 2710 + 2711 + dd->dfs_node = debugfs_create_dir(dd->disk->disk_name, dfs_parent); 2712 + if (IS_ERR_OR_NULL(dd->dfs_node)) { 2713 + dev_warn(&dd->pdev->dev, 2714 + "Error creating node %s under debugfs\n", 2715 + dd->disk->disk_name); 2716 + dd->dfs_node = NULL; 2717 + return -1; 2718 + } 2719 + 2720 + debugfs_create_file("flags", S_IRUGO, dd->dfs_node, dd, 2721 + &mtip_flags_fops); 2722 + debugfs_create_file("registers", S_IRUGO, dd->dfs_node, dd, 2723 + &mtip_regs_fops); 2724 + 2725 + return 0; 2726 + } 2727 + 2728 + static void mtip_hw_debugfs_exit(struct driver_data *dd) 2729 + { 2730 + debugfs_remove_recursive(dd->dfs_node); 2731 + } 2732 + 2735 2733 2736 2734 /* 2737 2735 * Perform any init/resume time hardware setup ··· 3784 3730 mtip_hw_sysfs_init(dd, kobj); 3785 3731 kobject_put(kobj); 3786 3732 } 3733 + mtip_hw_debugfs_init(dd); 3787 3734 3788 3735 if (dd->mtip_svc_handler) { 3789 3736 set_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag); ··· 3810 3755 return rv; 3811 3756 3812 3757 kthread_run_error: 3758 + mtip_hw_debugfs_exit(dd); 3759 + 3813 3760 /* Delete our gendisk. This also removes the device from /dev */ 3814 3761 del_gendisk(dd->disk); 3815 3762 ··· 3862 3805 kobject_put(kobj); 3863 3806 } 3864 3807 } 3808 + mtip_hw_debugfs_exit(dd); 3865 3809 3866 3810 /* 3867 3811 * Delete our gendisk structure. This also removes the device ··· 4210 4152 } 4211 4153 mtip_major = error; 4212 4154 4155 + if (!dfs_parent) { 4156 + dfs_parent = debugfs_create_dir("rssd", NULL); 4157 + if (IS_ERR_OR_NULL(dfs_parent)) { 4158 + printk(KERN_WARNING "Error creating debugfs parent\n"); 4159 + dfs_parent = NULL; 4160 + } 4161 + } 4162 + 4213 4163 /* Register our PCI operations. */ 4214 4164 error = pci_register_driver(&mtip_pci_driver); 4215 - if (error) 4165 + if (error) { 4166 + debugfs_remove(dfs_parent); 4216 4167 unregister_blkdev(mtip_major, MTIP_DRV_NAME); 4168 + } 4217 4169 4218 4170 return error; 4219 4171 } ··· 4240 4172 */ 4241 4173 static void __exit mtip_exit(void) 4242 4174 { 4175 + debugfs_remove_recursive(dfs_parent); 4176 + 4243 4177 /* Release the allocated major block device number. */ 4244 4178 unregister_blkdev(mtip_major, MTIP_DRV_NAME); 4245 4179
+4 -1
drivers/block/mtip32xx/mtip32xx.h
··· 26 26 #include <linux/ata.h> 27 27 #include <linux/interrupt.h> 28 28 #include <linux/genhd.h> 29 - #include <linux/version.h> 30 29 31 30 /* Offset of Subsystem Device ID in pci confoguration space */ 32 31 #define PCI_SUBSYSTEM_DEVICEID 0x2E ··· 109 110 #else 110 111 #define dbg_printk(format, arg...) 111 112 #endif 113 + 114 + #define MTIP_DFS_MAX_BUF_SIZE 1024 112 115 113 116 #define __force_bit2int (unsigned int __force) 114 117 ··· 448 447 unsigned long dd_flag; /* NOTE: use atomic bit operations on this */ 449 448 450 449 struct task_struct *mtip_svc_handler; /* task_struct of svc thd */ 450 + 451 + struct dentry *dfs_node; 451 452 }; 452 453 453 454 #endif
+40
drivers/block/umem.c
··· 513 513 } 514 514 } 515 515 516 + struct mm_plug_cb { 517 + struct blk_plug_cb cb; 518 + struct cardinfo *card; 519 + }; 520 + 521 + static void mm_unplug(struct blk_plug_cb *cb) 522 + { 523 + struct mm_plug_cb *mmcb = container_of(cb, struct mm_plug_cb, cb); 524 + 525 + spin_lock_irq(&mmcb->card->lock); 526 + activate(mmcb->card); 527 + spin_unlock_irq(&mmcb->card->lock); 528 + kfree(mmcb); 529 + } 530 + 531 + static int mm_check_plugged(struct cardinfo *card) 532 + { 533 + struct blk_plug *plug = current->plug; 534 + struct mm_plug_cb *mmcb; 535 + 536 + if (!plug) 537 + return 0; 538 + 539 + list_for_each_entry(mmcb, &plug->cb_list, cb.list) { 540 + if (mmcb->cb.callback == mm_unplug && mmcb->card == card) 541 + return 1; 542 + } 543 + /* Not currently on the callback list */ 544 + mmcb = kmalloc(sizeof(*mmcb), GFP_ATOMIC); 545 + if (!mmcb) 546 + return 0; 547 + 548 + mmcb->card = card; 549 + mmcb->cb.callback = mm_unplug; 550 + list_add(&mmcb->cb.list, &plug->cb_list); 551 + return 1; 552 + } 553 + 516 554 static void mm_make_request(struct request_queue *q, struct bio *bio) 517 555 { 518 556 struct cardinfo *card = q->queuedata; ··· 561 523 *card->biotail = bio; 562 524 bio->bi_next = NULL; 563 525 card->biotail = &bio->bi_next; 526 + if (bio->bi_rw & REQ_SYNC || !mm_check_plugged(card)) 527 + activate(card); 564 528 spin_unlock_irq(&card->lock); 565 529 566 530 return;
+2
drivers/block/xen-blkback/common.h
··· 257 257 break; 258 258 case BLKIF_OP_DISCARD: 259 259 dst->u.discard.flag = src->u.discard.flag; 260 + dst->u.discard.id = src->u.discard.id; 260 261 dst->u.discard.sector_number = src->u.discard.sector_number; 261 262 dst->u.discard.nr_sectors = src->u.discard.nr_sectors; 262 263 break; ··· 288 287 break; 289 288 case BLKIF_OP_DISCARD: 290 289 dst->u.discard.flag = src->u.discard.flag; 290 + dst->u.discard.id = src->u.discard.id; 291 291 dst->u.discard.sector_number = src->u.discard.sector_number; 292 292 dst->u.discard.nr_sectors = src->u.discard.nr_sectors; 293 293 break;
+46 -12
drivers/block/xen-blkfront.c
··· 141 141 return free; 142 142 } 143 143 144 - static void add_id_to_freelist(struct blkfront_info *info, 144 + static int add_id_to_freelist(struct blkfront_info *info, 145 145 unsigned long id) 146 146 { 147 + if (info->shadow[id].req.u.rw.id != id) 148 + return -EINVAL; 149 + if (info->shadow[id].request == NULL) 150 + return -EINVAL; 147 151 info->shadow[id].req.u.rw.id = info->shadow_free; 148 152 info->shadow[id].request = NULL; 149 153 info->shadow_free = id; 154 + return 0; 150 155 } 151 156 157 + static const char *op_name(int op) 158 + { 159 + static const char *const names[] = { 160 + [BLKIF_OP_READ] = "read", 161 + [BLKIF_OP_WRITE] = "write", 162 + [BLKIF_OP_WRITE_BARRIER] = "barrier", 163 + [BLKIF_OP_FLUSH_DISKCACHE] = "flush", 164 + [BLKIF_OP_DISCARD] = "discard" }; 165 + 166 + if (op < 0 || op >= ARRAY_SIZE(names)) 167 + return "unknown"; 168 + 169 + if (!names[op]) 170 + return "reserved"; 171 + 172 + return names[op]; 173 + } 152 174 static int xlbd_reserve_minors(unsigned int minor, unsigned int nr) 153 175 { 154 176 unsigned int end = minor + nr; ··· 768 746 769 747 bret = RING_GET_RESPONSE(&info->ring, i); 770 748 id = bret->id; 749 + /* 750 + * The backend has messed up and given us an id that we would 751 + * never have given to it (we stamp it up to BLK_RING_SIZE - 752 + * look in get_id_from_freelist. 753 + */ 754 + if (id >= BLK_RING_SIZE) { 755 + WARN(1, "%s: response to %s has incorrect id (%ld)\n", 756 + info->gd->disk_name, op_name(bret->operation), id); 757 + /* We can't safely get the 'struct request' as 758 + * the id is busted. */ 759 + continue; 760 + } 771 761 req = info->shadow[id].request; 772 762 773 763 if (bret->operation != BLKIF_OP_DISCARD) 774 764 blkif_completion(&info->shadow[id]); 775 765 776 - add_id_to_freelist(info, id); 766 + if (add_id_to_freelist(info, id)) { 767 + WARN(1, "%s: response to %s (id %ld) couldn't be recycled!\n", 768 + info->gd->disk_name, op_name(bret->operation), id); 769 + continue; 770 + } 777 771 778 772 error = (bret->status == BLKIF_RSP_OKAY) ? 0 : -EIO; 779 773 switch (bret->operation) { 780 774 case BLKIF_OP_DISCARD: 781 775 if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) { 782 776 struct request_queue *rq = info->rq; 783 - printk(KERN_WARNING "blkfront: %s: discard op failed\n", 784 - info->gd->disk_name); 777 + printk(KERN_WARNING "blkfront: %s: %s op failed\n", 778 + info->gd->disk_name, op_name(bret->operation)); 785 779 error = -EOPNOTSUPP; 786 780 info->feature_discard = 0; 787 781 info->feature_secdiscard = 0; ··· 809 771 case BLKIF_OP_FLUSH_DISKCACHE: 810 772 case BLKIF_OP_WRITE_BARRIER: 811 773 if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) { 812 - printk(KERN_WARNING "blkfront: %s: write %s op failed\n", 813 - info->flush_op == BLKIF_OP_WRITE_BARRIER ? 814 - "barrier" : "flush disk cache", 815 - info->gd->disk_name); 774 + printk(KERN_WARNING "blkfront: %s: %s op failed\n", 775 + info->gd->disk_name, op_name(bret->operation)); 816 776 error = -EOPNOTSUPP; 817 777 } 818 778 if (unlikely(bret->status == BLKIF_RSP_ERROR && 819 779 info->shadow[id].req.u.rw.nr_segments == 0)) { 820 - printk(KERN_WARNING "blkfront: %s: empty write %s op failed\n", 821 - info->flush_op == BLKIF_OP_WRITE_BARRIER ? 822 - "barrier" : "flush disk cache", 823 - info->gd->disk_name); 780 + printk(KERN_WARNING "blkfront: %s: empty %s op failed\n", 781 + info->gd->disk_name, op_name(bret->operation)); 824 782 error = -EOPNOTSUPP; 825 783 } 826 784 if (unlikely(error)) {
+20 -15
fs/splice.c
··· 273 273 * Check if we need to grow the arrays holding pages and partial page 274 274 * descriptions. 275 275 */ 276 - int splice_grow_spd(struct pipe_inode_info *pipe, struct splice_pipe_desc *spd) 276 + int splice_grow_spd(const struct pipe_inode_info *pipe, struct splice_pipe_desc *spd) 277 277 { 278 - if (pipe->buffers <= PIPE_DEF_BUFFERS) 278 + unsigned int buffers = ACCESS_ONCE(pipe->buffers); 279 + 280 + spd->nr_pages_max = buffers; 281 + if (buffers <= PIPE_DEF_BUFFERS) 279 282 return 0; 280 283 281 - spd->pages = kmalloc(pipe->buffers * sizeof(struct page *), GFP_KERNEL); 282 - spd->partial = kmalloc(pipe->buffers * sizeof(struct partial_page), GFP_KERNEL); 284 + spd->pages = kmalloc(buffers * sizeof(struct page *), GFP_KERNEL); 285 + spd->partial = kmalloc(buffers * sizeof(struct partial_page), GFP_KERNEL); 283 286 284 287 if (spd->pages && spd->partial) 285 288 return 0; ··· 292 289 return -ENOMEM; 293 290 } 294 291 295 - void splice_shrink_spd(struct pipe_inode_info *pipe, 296 - struct splice_pipe_desc *spd) 292 + void splice_shrink_spd(struct splice_pipe_desc *spd) 297 293 { 298 - if (pipe->buffers <= PIPE_DEF_BUFFERS) 294 + if (spd->nr_pages_max <= PIPE_DEF_BUFFERS) 299 295 return; 300 296 301 297 kfree(spd->pages); ··· 317 315 struct splice_pipe_desc spd = { 318 316 .pages = pages, 319 317 .partial = partial, 318 + .nr_pages_max = PIPE_DEF_BUFFERS, 320 319 .flags = flags, 321 320 .ops = &page_cache_pipe_buf_ops, 322 321 .spd_release = spd_release_page, ··· 329 326 index = *ppos >> PAGE_CACHE_SHIFT; 330 327 loff = *ppos & ~PAGE_CACHE_MASK; 331 328 req_pages = (len + loff + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 332 - nr_pages = min(req_pages, pipe->buffers); 329 + nr_pages = min(req_pages, spd.nr_pages_max); 333 330 334 331 /* 335 332 * Lookup the (hopefully) full range of pages we need. ··· 500 497 if (spd.nr_pages) 501 498 error = splice_to_pipe(pipe, &spd); 502 499 503 - splice_shrink_spd(pipe, &spd); 500 + splice_shrink_spd(&spd); 504 501 return error; 505 502 } 506 503 ··· 601 598 struct splice_pipe_desc spd = { 602 599 .pages = pages, 603 600 .partial = partial, 601 + .nr_pages_max = PIPE_DEF_BUFFERS, 604 602 .flags = flags, 605 603 .ops = &default_pipe_buf_ops, 606 604 .spd_release = spd_release_page, ··· 612 608 613 609 res = -ENOMEM; 614 610 vec = __vec; 615 - if (pipe->buffers > PIPE_DEF_BUFFERS) { 616 - vec = kmalloc(pipe->buffers * sizeof(struct iovec), GFP_KERNEL); 611 + if (spd.nr_pages_max > PIPE_DEF_BUFFERS) { 612 + vec = kmalloc(spd.nr_pages_max * sizeof(struct iovec), GFP_KERNEL); 617 613 if (!vec) 618 614 goto shrink_ret; 619 615 } ··· 621 617 offset = *ppos & ~PAGE_CACHE_MASK; 622 618 nr_pages = (len + offset + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 623 619 624 - for (i = 0; i < nr_pages && i < pipe->buffers && len; i++) { 620 + for (i = 0; i < nr_pages && i < spd.nr_pages_max && len; i++) { 625 621 struct page *page; 626 622 627 623 page = alloc_page(GFP_USER); ··· 669 665 shrink_ret: 670 666 if (vec != __vec) 671 667 kfree(vec); 672 - splice_shrink_spd(pipe, &spd); 668 + splice_shrink_spd(&spd); 673 669 return res; 674 670 675 671 err: ··· 1618 1614 struct splice_pipe_desc spd = { 1619 1615 .pages = pages, 1620 1616 .partial = partial, 1617 + .nr_pages_max = PIPE_DEF_BUFFERS, 1621 1618 .flags = flags, 1622 1619 .ops = &user_page_pipe_buf_ops, 1623 1620 .spd_release = spd_release_page, ··· 1634 1629 1635 1630 spd.nr_pages = get_iovec_page_array(iov, nr_segs, spd.pages, 1636 1631 spd.partial, false, 1637 - pipe->buffers); 1632 + spd.nr_pages_max); 1638 1633 if (spd.nr_pages <= 0) 1639 1634 ret = spd.nr_pages; 1640 1635 else 1641 1636 ret = splice_to_pipe(pipe, &spd); 1642 1637 1643 - splice_shrink_spd(pipe, &spd); 1638 + splice_shrink_spd(&spd); 1644 1639 return ret; 1645 1640 } 1646 1641
-1
include/linux/blkdev.h
··· 827 827 extern void blk_complete_request(struct request *); 828 828 extern void __blk_complete_request(struct request *); 829 829 extern void blk_abort_request(struct request *); 830 - extern void blk_abort_queue(struct request_queue *); 831 830 extern void blk_unprep_request(struct request *); 832 831 833 832 /*
+4 -4
include/linux/splice.h
··· 51 51 struct splice_pipe_desc { 52 52 struct page **pages; /* page map */ 53 53 struct partial_page *partial; /* pages[] may not be contig */ 54 - int nr_pages; /* number of pages in map */ 54 + int nr_pages; /* number of populated pages in map */ 55 + unsigned int nr_pages_max; /* pages[] & partial[] arrays size */ 55 56 unsigned int flags; /* splice flags */ 56 57 const struct pipe_buf_operations *ops;/* ops associated with output pipe */ 57 58 void (*spd_release)(struct splice_pipe_desc *, unsigned int); ··· 86 85 /* 87 86 * for dynamic pipe sizing 88 87 */ 89 - extern int splice_grow_spd(struct pipe_inode_info *, struct splice_pipe_desc *); 90 - extern void splice_shrink_spd(struct pipe_inode_info *, 91 - struct splice_pipe_desc *); 88 + extern int splice_grow_spd(const struct pipe_inode_info *, struct splice_pipe_desc *); 89 + extern void splice_shrink_spd(struct splice_pipe_desc *); 92 90 extern void spd_release_page(struct splice_pipe_desc *, unsigned int); 93 91 94 92 extern const struct pipe_buf_operations page_cache_pipe_buf_ops;
+3 -2
kernel/relay.c
··· 1235 1235 struct splice_pipe_desc spd = { 1236 1236 .pages = pages, 1237 1237 .nr_pages = 0, 1238 + .nr_pages_max = PIPE_DEF_BUFFERS, 1238 1239 .partial = partial, 1239 1240 .flags = flags, 1240 1241 .ops = &relay_pipe_buf_ops, ··· 1303 1302 ret += padding; 1304 1303 1305 1304 out: 1306 - splice_shrink_spd(pipe, &spd); 1307 - return ret; 1305 + splice_shrink_spd(&spd); 1306 + return ret; 1308 1307 } 1309 1308 1310 1309 static ssize_t relay_file_splice_read(struct file *in,
+4 -2
kernel/trace/trace.c
··· 3609 3609 .pages = pages_def, 3610 3610 .partial = partial_def, 3611 3611 .nr_pages = 0, /* This gets updated below. */ 3612 + .nr_pages_max = PIPE_DEF_BUFFERS, 3612 3613 .flags = flags, 3613 3614 .ops = &tracing_pipe_buf_ops, 3614 3615 .spd_release = tracing_spd_release_pipe, ··· 3681 3680 3682 3681 ret = splice_to_pipe(pipe, &spd); 3683 3682 out: 3684 - splice_shrink_spd(pipe, &spd); 3683 + splice_shrink_spd(&spd); 3685 3684 return ret; 3686 3685 3687 3686 out_err: ··· 4232 4231 struct splice_pipe_desc spd = { 4233 4232 .pages = pages_def, 4234 4233 .partial = partial_def, 4234 + .nr_pages_max = PIPE_DEF_BUFFERS, 4235 4235 .flags = flags, 4236 4236 .ops = &buffer_pipe_buf_ops, 4237 4237 .spd_release = buffer_spd_release, ··· 4320 4318 } 4321 4319 4322 4320 ret = splice_to_pipe(pipe, &spd); 4323 - splice_shrink_spd(pipe, &spd); 4321 + splice_shrink_spd(&spd); 4324 4322 out: 4325 4323 return ret; 4326 4324 }
+2 -1
mm/shmem.c
··· 1594 1594 struct splice_pipe_desc spd = { 1595 1595 .pages = pages, 1596 1596 .partial = partial, 1597 + .nr_pages_max = PIPE_DEF_BUFFERS, 1597 1598 .flags = flags, 1598 1599 .ops = &page_cache_pipe_buf_ops, 1599 1600 .spd_release = spd_release_page, ··· 1683 1682 if (spd.nr_pages) 1684 1683 error = splice_to_pipe(pipe, &spd); 1685 1684 1686 - splice_shrink_spd(pipe, &spd); 1685 + splice_shrink_spd(&spd); 1687 1686 1688 1687 if (error > 0) { 1689 1688 *ppos += error;
+1
net/core/skbuff.c
··· 1755 1755 struct splice_pipe_desc spd = { 1756 1756 .pages = pages, 1757 1757 .partial = partial, 1758 + .nr_pages_max = MAX_SKB_FRAGS, 1758 1759 .flags = flags, 1759 1760 .ops = &sock_pipe_buf_ops, 1760 1761 .spd_release = sock_spd_release,