aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-18 15:12:45 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-18 15:12:45 -0400
commite75437fb9322cf0ac707046a12d78a25f9d52ccf (patch)
tree959fbda9d606f500e5c554eb68984111a9e6b3b3 /drivers/block
parentd3dc366bbaf07c125561e90d6da4bb147741101a (diff)
parentb277da0a8a594308e17881f4926879bd5fca2a2d (diff)
Merge branch 'for-3.18/drivers' of git://git.kernel.dk/linux-block
Pull block layer driver update from Jens Axboe: "This is the block driver pull request for 3.18. Not a lot in there this round, and nothing earth shattering. - A round of drbd fixes from the linbit team, and an improvement in asender performance. - Removal of deprecated (and unused) IRQF_DISABLED flag in rsxx and hd from Michael Opdenacker. - Disable entropy collection from flash devices by default, from Mike Snitzer. - A small collection of xen blkfront/back fixes from Roger Pau Monné and Vitaly Kuznetsov" * 'for-3.18/drivers' of git://git.kernel.dk/linux-block: block: disable entropy contributions for nonrot devices xen, blkfront: factor out flush-related checks from do_blkif_request() xen-blkback: fix leak on grant map error path xen/blkback: unmap all persistent grants when frontend gets disconnected rsxx: Remove deprecated IRQF_DISABLED block: hd: remove deprecated IRQF_DISABLED drbd: use RB_DECLARE_CALLBACKS() to define augment callbacks drbd: compute the end before rb_insert_augmented() drbd: Add missing newline in resync progress display in /proc/drbd drbd: reduce lock contention in drbd_worker drbd: Improve asender performance drbd: Get rid of the WORK_PENDING macro drbd: Get rid of the __no_warn and __cond_lock macros drbd: Avoid inconsistent locking warning drbd: Remove superfluous newline from "resync_extents" debugfs entry. drbd: Use consistent names for all the bi_end_io callbacks drbd: Use better variable names
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/drbd/drbd_actlog.c4
-rw-r--r--drivers/block/drbd/drbd_bitmap.c6
-rw-r--r--drivers/block/drbd/drbd_debugfs.c2
-rw-r--r--drivers/block/drbd/drbd_int.h19
-rw-r--r--drivers/block/drbd/drbd_interval.c40
-rw-r--r--drivers/block/drbd/drbd_main.c28
-rw-r--r--drivers/block/drbd/drbd_proc.c4
-rw-r--r--drivers/block/drbd/drbd_receiver.c52
-rw-r--r--drivers/block/drbd/drbd_req.c2
-rw-r--r--drivers/block/drbd/drbd_state.c18
-rw-r--r--drivers/block/drbd/drbd_worker.c51
-rw-r--r--drivers/block/hd.c12
-rw-r--r--drivers/block/mtip32xx/mtip32xx.c1
-rw-r--r--drivers/block/nbd.c1
-rw-r--r--drivers/block/null_blk.c1
-rw-r--r--drivers/block/nvme-core.c1
-rw-r--r--drivers/block/rsxx/core.c2
-rw-r--r--drivers/block/rsxx/dev.c1
-rw-r--r--drivers/block/skd_main.c1
-rw-r--r--drivers/block/xen-blkback/blkback.c1
-rw-r--r--drivers/block/xen-blkback/xenbus.c6
-rw-r--r--drivers/block/xen-blkfront.c12
-rw-r--r--drivers/block/zram/zram_drv.c1
23 files changed, 121 insertions, 145 deletions
diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c
index d26a3fa63688..a2dfa169237d 100644
--- a/drivers/block/drbd/drbd_actlog.c
+++ b/drivers/block/drbd/drbd_actlog.c
@@ -158,14 +158,14 @@ static int _drbd_md_sync_page_io(struct drbd_device *device,
158 if (bio_add_page(bio, device->md_io.page, size, 0) != size) 158 if (bio_add_page(bio, device->md_io.page, size, 0) != size)
159 goto out; 159 goto out;
160 bio->bi_private = device; 160 bio->bi_private = device;
161 bio->bi_end_io = drbd_md_io_complete; 161 bio->bi_end_io = drbd_md_endio;
162 bio->bi_rw = rw; 162 bio->bi_rw = rw;
163 163
164 if (!(rw & WRITE) && device->state.disk == D_DISKLESS && device->ldev == NULL) 164 if (!(rw & WRITE) && device->state.disk == D_DISKLESS && device->ldev == NULL)
165 /* special case, drbd_md_read() during drbd_adm_attach(): no get_ldev */ 165 /* special case, drbd_md_read() during drbd_adm_attach(): no get_ldev */
166 ; 166 ;
167 else if (!get_ldev_if_state(device, D_ATTACHING)) { 167 else if (!get_ldev_if_state(device, D_ATTACHING)) {
168 /* Corresponding put_ldev in drbd_md_io_complete() */ 168 /* Corresponding put_ldev in drbd_md_endio() */
169 drbd_err(device, "ASSERT FAILED: get_ldev_if_state() == 1 in _drbd_md_sync_page_io()\n"); 169 drbd_err(device, "ASSERT FAILED: get_ldev_if_state() == 1 in _drbd_md_sync_page_io()\n");
170 err = -ENODEV; 170 err = -ENODEV;
171 goto out; 171 goto out;
diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
index 426c97aef900..434c77dcc99e 100644
--- a/drivers/block/drbd/drbd_bitmap.c
+++ b/drivers/block/drbd/drbd_bitmap.c
@@ -941,7 +941,7 @@ static void drbd_bm_aio_ctx_destroy(struct kref *kref)
941} 941}
942 942
943/* bv_page may be a copy, or may be the original */ 943/* bv_page may be a copy, or may be the original */
944static void bm_async_io_complete(struct bio *bio, int error) 944static void drbd_bm_endio(struct bio *bio, int error)
945{ 945{
946 struct drbd_bm_aio_ctx *ctx = bio->bi_private; 946 struct drbd_bm_aio_ctx *ctx = bio->bi_private;
947 struct drbd_device *device = ctx->device; 947 struct drbd_device *device = ctx->device;
@@ -1027,7 +1027,7 @@ static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, int page_nr) __must_ho
1027 * according to api. Do we want to assert that? */ 1027 * according to api. Do we want to assert that? */
1028 bio_add_page(bio, page, len, 0); 1028 bio_add_page(bio, page, len, 0);
1029 bio->bi_private = ctx; 1029 bio->bi_private = ctx;
1030 bio->bi_end_io = bm_async_io_complete; 1030 bio->bi_end_io = drbd_bm_endio;
1031 1031
1032 if (drbd_insert_fault(device, (rw & WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD)) { 1032 if (drbd_insert_fault(device, (rw & WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD)) {
1033 bio->bi_rw |= rw; 1033 bio->bi_rw |= rw;
@@ -1125,7 +1125,7 @@ static int bm_rw(struct drbd_device *device, const unsigned int flags, unsigned
1125 } 1125 }
1126 1126
1127 /* 1127 /*
1128 * We initialize ctx->in_flight to one to make sure bm_async_io_complete 1128 * We initialize ctx->in_flight to one to make sure drbd_bm_endio
1129 * will not set ctx->done early, and decrement / test it here. If there 1129 * will not set ctx->done early, and decrement / test it here. If there
1130 * are still some bios in flight, we need to wait for them here. 1130 * are still some bios in flight, we need to wait for them here.
1131 * If all IO is done already (or nothing had been submitted), there is 1131 * If all IO is done already (or nothing had been submitted), there is
diff --git a/drivers/block/drbd/drbd_debugfs.c b/drivers/block/drbd/drbd_debugfs.c
index 5c20b18540b8..900d4d3272d1 100644
--- a/drivers/block/drbd/drbd_debugfs.c
+++ b/drivers/block/drbd/drbd_debugfs.c
@@ -695,7 +695,7 @@ static void resync_dump_detail(struct seq_file *m, struct lc_element *e)
695{ 695{
696 struct bm_extent *bme = lc_entry(e, struct bm_extent, lce); 696 struct bm_extent *bme = lc_entry(e, struct bm_extent, lce);
697 697
698 seq_printf(m, "%5d %s %s %s\n", bme->rs_left, 698 seq_printf(m, "%5d %s %s %s", bme->rs_left,
699 test_bit(BME_NO_WRITES, &bme->flags) ? "NO_WRITES" : "---------", 699 test_bit(BME_NO_WRITES, &bme->flags) ? "NO_WRITES" : "---------",
700 test_bit(BME_LOCKED, &bme->flags) ? "LOCKED" : "------", 700 test_bit(BME_LOCKED, &bme->flags) ? "LOCKED" : "------",
701 test_bit(BME_PRIORITY, &bme->flags) ? "PRIORITY" : "--------" 701 test_bit(BME_PRIORITY, &bme->flags) ? "PRIORITY" : "--------"
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 1a000016ccdf..9b22f8f01b57 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -61,8 +61,6 @@
61# define __must_hold(x) 61# define __must_hold(x)
62#endif 62#endif
63 63
64#define __no_warn(lock, stmt) do { __acquire(lock); stmt; __release(lock); } while (0)
65
66/* module parameter, defined in drbd_main.c */ 64/* module parameter, defined in drbd_main.c */
67extern unsigned int minor_count; 65extern unsigned int minor_count;
68extern bool disable_sendpage; 66extern bool disable_sendpage;
@@ -1483,7 +1481,7 @@ extern int drbd_khelper(struct drbd_device *device, char *cmd);
1483 1481
1484/* drbd_worker.c */ 1482/* drbd_worker.c */
1485/* bi_end_io handlers */ 1483/* bi_end_io handlers */
1486extern void drbd_md_io_complete(struct bio *bio, int error); 1484extern void drbd_md_endio(struct bio *bio, int error);
1487extern void drbd_peer_request_endio(struct bio *bio, int error); 1485extern void drbd_peer_request_endio(struct bio *bio, int error);
1488extern void drbd_request_endio(struct bio *bio, int error); 1486extern void drbd_request_endio(struct bio *bio, int error);
1489extern int drbd_worker(struct drbd_thread *thi); 1487extern int drbd_worker(struct drbd_thread *thi);
@@ -2100,16 +2098,19 @@ static inline bool is_sync_state(enum drbd_conns connection_state)
2100 2098
2101/** 2099/**
2102 * get_ldev() - Increase the ref count on device->ldev. Returns 0 if there is no ldev 2100 * get_ldev() - Increase the ref count on device->ldev. Returns 0 if there is no ldev
2103 * @M: DRBD device. 2101 * @_device: DRBD device.
2102 * @_min_state: Minimum device state required for success.
2104 * 2103 *
2105 * You have to call put_ldev() when finished working with device->ldev. 2104 * You have to call put_ldev() when finished working with device->ldev.
2106 */ 2105 */
2107#define get_ldev(M) __cond_lock(local, _get_ldev_if_state(M,D_INCONSISTENT)) 2106#define get_ldev_if_state(_device, _min_state) \
2108#define get_ldev_if_state(M,MINS) __cond_lock(local, _get_ldev_if_state(M,MINS)) 2107 (_get_ldev_if_state((_device), (_min_state)) ? \
2108 ({ __acquire(x); true; }) : false)
2109#define get_ldev(_device) get_ldev_if_state(_device, D_INCONSISTENT)
2109 2110
2110static inline void put_ldev(struct drbd_device *device) 2111static inline void put_ldev(struct drbd_device *device)
2111{ 2112{
2112 enum drbd_disk_state ds = device->state.disk; 2113 enum drbd_disk_state disk_state = device->state.disk;
2113 /* We must check the state *before* the atomic_dec becomes visible, 2114 /* We must check the state *before* the atomic_dec becomes visible,
2114 * or we have a theoretical race where someone hitting zero, 2115 * or we have a theoretical race where someone hitting zero,
2115 * while state still D_FAILED, will then see D_DISKLESS in the 2116 * while state still D_FAILED, will then see D_DISKLESS in the
@@ -2122,10 +2123,10 @@ static inline void put_ldev(struct drbd_device *device)
2122 __release(local); 2123 __release(local);
2123 D_ASSERT(device, i >= 0); 2124 D_ASSERT(device, i >= 0);
2124 if (i == 0) { 2125 if (i == 0) {
2125 if (ds == D_DISKLESS) 2126 if (disk_state == D_DISKLESS)
2126 /* even internal references gone, safe to destroy */ 2127 /* even internal references gone, safe to destroy */
2127 drbd_device_post_work(device, DESTROY_DISK); 2128 drbd_device_post_work(device, DESTROY_DISK);
2128 if (ds == D_FAILED) 2129 if (disk_state == D_FAILED)
2129 /* all application IO references gone. */ 2130 /* all application IO references gone. */
2130 if (!test_and_set_bit(GOING_DISKLESS, &device->flags)) 2131 if (!test_and_set_bit(GOING_DISKLESS, &device->flags))
2131 drbd_device_post_work(device, GO_DISKLESS); 2132 drbd_device_post_work(device, GO_DISKLESS);
diff --git a/drivers/block/drbd/drbd_interval.c b/drivers/block/drbd/drbd_interval.c
index 89c497c630b4..51b25ad85251 100644
--- a/drivers/block/drbd/drbd_interval.c
+++ b/drivers/block/drbd/drbd_interval.c
@@ -37,40 +37,8 @@ compute_subtree_last(struct drbd_interval *node)
37 return max; 37 return max;
38} 38}
39 39
40static void augment_propagate(struct rb_node *rb, struct rb_node *stop) 40RB_DECLARE_CALLBACKS(static, augment_callbacks, struct drbd_interval, rb,
41{ 41 sector_t, end, compute_subtree_last);
42 while (rb != stop) {
43 struct drbd_interval *node = rb_entry(rb, struct drbd_interval, rb);
44 sector_t subtree_last = compute_subtree_last(node);
45 if (node->end == subtree_last)
46 break;
47 node->end = subtree_last;
48 rb = rb_parent(&node->rb);
49 }
50}
51
52static void augment_copy(struct rb_node *rb_old, struct rb_node *rb_new)
53{
54 struct drbd_interval *old = rb_entry(rb_old, struct drbd_interval, rb);
55 struct drbd_interval *new = rb_entry(rb_new, struct drbd_interval, rb);
56
57 new->end = old->end;
58}
59
60static void augment_rotate(struct rb_node *rb_old, struct rb_node *rb_new)
61{
62 struct drbd_interval *old = rb_entry(rb_old, struct drbd_interval, rb);
63 struct drbd_interval *new = rb_entry(rb_new, struct drbd_interval, rb);
64
65 new->end = old->end;
66 old->end = compute_subtree_last(old);
67}
68
69static const struct rb_augment_callbacks augment_callbacks = {
70 augment_propagate,
71 augment_copy,
72 augment_rotate,
73};
74 42
75/** 43/**
76 * drbd_insert_interval - insert a new interval into a tree 44 * drbd_insert_interval - insert a new interval into a tree
@@ -79,6 +47,7 @@ bool
79drbd_insert_interval(struct rb_root *root, struct drbd_interval *this) 47drbd_insert_interval(struct rb_root *root, struct drbd_interval *this)
80{ 48{
81 struct rb_node **new = &root->rb_node, *parent = NULL; 49 struct rb_node **new = &root->rb_node, *parent = NULL;
50 sector_t this_end = this->sector + (this->size >> 9);
82 51
83 BUG_ON(!IS_ALIGNED(this->size, 512)); 52 BUG_ON(!IS_ALIGNED(this->size, 512));
84 53
@@ -87,6 +56,8 @@ drbd_insert_interval(struct rb_root *root, struct drbd_interval *this)
87 rb_entry(*new, struct drbd_interval, rb); 56 rb_entry(*new, struct drbd_interval, rb);
88 57
89 parent = *new; 58 parent = *new;
59 if (here->end < this_end)
60 here->end = this_end;
90 if (this->sector < here->sector) 61 if (this->sector < here->sector)
91 new = &(*new)->rb_left; 62 new = &(*new)->rb_left;
92 else if (this->sector > here->sector) 63 else if (this->sector > here->sector)
@@ -99,6 +70,7 @@ drbd_insert_interval(struct rb_root *root, struct drbd_interval *this)
99 return false; 70 return false;
100 } 71 }
101 72
73 this->end = this_end;
102 rb_link_node(&this->rb, parent, new); 74 rb_link_node(&this->rb, parent, new);
103 rb_insert_augmented(&this->rb, root, &augment_callbacks); 75 rb_insert_augmented(&this->rb, root, &augment_callbacks);
104 return true; 76 return true;
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 9b465bb68487..973c185c9cfe 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -1622,13 +1622,13 @@ int drbd_send_dblock(struct drbd_peer_device *peer_device, struct drbd_request *
1622 struct drbd_socket *sock; 1622 struct drbd_socket *sock;
1623 struct p_data *p; 1623 struct p_data *p;
1624 unsigned int dp_flags = 0; 1624 unsigned int dp_flags = 0;
1625 int dgs; 1625 int digest_size;
1626 int err; 1626 int err;
1627 1627
1628 sock = &peer_device->connection->data; 1628 sock = &peer_device->connection->data;
1629 p = drbd_prepare_command(peer_device, sock); 1629 p = drbd_prepare_command(peer_device, sock);
1630 dgs = peer_device->connection->integrity_tfm ? 1630 digest_size = peer_device->connection->integrity_tfm ?
1631 crypto_hash_digestsize(peer_device->connection->integrity_tfm) : 0; 1631 crypto_hash_digestsize(peer_device->connection->integrity_tfm) : 0;
1632 1632
1633 if (!p) 1633 if (!p)
1634 return -EIO; 1634 return -EIO;
@@ -1659,9 +1659,9 @@ int drbd_send_dblock(struct drbd_peer_device *peer_device, struct drbd_request *
1659 1659
1660 /* our digest is still only over the payload. 1660 /* our digest is still only over the payload.
1661 * TRIM does not carry any payload. */ 1661 * TRIM does not carry any payload. */
1662 if (dgs) 1662 if (digest_size)
1663 drbd_csum_bio(peer_device->connection->integrity_tfm, req->master_bio, p + 1); 1663 drbd_csum_bio(peer_device->connection->integrity_tfm, req->master_bio, p + 1);
1664 err = __send_command(peer_device->connection, device->vnr, sock, P_DATA, sizeof(*p) + dgs, NULL, req->i.size); 1664 err = __send_command(peer_device->connection, device->vnr, sock, P_DATA, sizeof(*p) + digest_size, NULL, req->i.size);
1665 if (!err) { 1665 if (!err) {
1666 /* For protocol A, we have to memcpy the payload into 1666 /* For protocol A, we have to memcpy the payload into
1667 * socket buffers, as we may complete right away 1667 * socket buffers, as we may complete right away
@@ -1674,23 +1674,23 @@ int drbd_send_dblock(struct drbd_peer_device *peer_device, struct drbd_request *
1674 * out ok after sending on this side, but does not fit on the 1674 * out ok after sending on this side, but does not fit on the
1675 * receiving side, we sure have detected corruption elsewhere. 1675 * receiving side, we sure have detected corruption elsewhere.
1676 */ 1676 */
1677 if (!(req->rq_state & (RQ_EXP_RECEIVE_ACK | RQ_EXP_WRITE_ACK)) || dgs) 1677 if (!(req->rq_state & (RQ_EXP_RECEIVE_ACK | RQ_EXP_WRITE_ACK)) || digest_size)
1678 err = _drbd_send_bio(peer_device, req->master_bio); 1678 err = _drbd_send_bio(peer_device, req->master_bio);
1679 else 1679 else
1680 err = _drbd_send_zc_bio(peer_device, req->master_bio); 1680 err = _drbd_send_zc_bio(peer_device, req->master_bio);
1681 1681
1682 /* double check digest, sometimes buffers have been modified in flight. */ 1682 /* double check digest, sometimes buffers have been modified in flight. */
1683 if (dgs > 0 && dgs <= 64) { 1683 if (digest_size > 0 && digest_size <= 64) {
1684 /* 64 byte, 512 bit, is the largest digest size 1684 /* 64 byte, 512 bit, is the largest digest size
1685 * currently supported in kernel crypto. */ 1685 * currently supported in kernel crypto. */
1686 unsigned char digest[64]; 1686 unsigned char digest[64];
1687 drbd_csum_bio(peer_device->connection->integrity_tfm, req->master_bio, digest); 1687 drbd_csum_bio(peer_device->connection->integrity_tfm, req->master_bio, digest);
1688 if (memcmp(p + 1, digest, dgs)) { 1688 if (memcmp(p + 1, digest, digest_size)) {
1689 drbd_warn(device, 1689 drbd_warn(device,
1690 "Digest mismatch, buffer modified by upper layers during write: %llus +%u\n", 1690 "Digest mismatch, buffer modified by upper layers during write: %llus +%u\n",
1691 (unsigned long long)req->i.sector, req->i.size); 1691 (unsigned long long)req->i.sector, req->i.size);
1692 } 1692 }
1693 } /* else if (dgs > 64) { 1693 } /* else if (digest_size > 64) {
1694 ... Be noisy about digest too large ... 1694 ... Be noisy about digest too large ...
1695 } */ 1695 } */
1696 } 1696 }
@@ -1711,13 +1711,13 @@ int drbd_send_block(struct drbd_peer_device *peer_device, enum drbd_packet cmd,
1711 struct drbd_socket *sock; 1711 struct drbd_socket *sock;
1712 struct p_data *p; 1712 struct p_data *p;
1713 int err; 1713 int err;
1714 int dgs; 1714 int digest_size;
1715 1715
1716 sock = &peer_device->connection->data; 1716 sock = &peer_device->connection->data;
1717 p = drbd_prepare_command(peer_device, sock); 1717 p = drbd_prepare_command(peer_device, sock);
1718 1718
1719 dgs = peer_device->connection->integrity_tfm ? 1719 digest_size = peer_device->connection->integrity_tfm ?
1720 crypto_hash_digestsize(peer_device->connection->integrity_tfm) : 0; 1720 crypto_hash_digestsize(peer_device->connection->integrity_tfm) : 0;
1721 1721
1722 if (!p) 1722 if (!p)
1723 return -EIO; 1723 return -EIO;
@@ -1725,9 +1725,9 @@ int drbd_send_block(struct drbd_peer_device *peer_device, enum drbd_packet cmd,
1725 p->block_id = peer_req->block_id; 1725 p->block_id = peer_req->block_id;
1726 p->seq_num = 0; /* unused */ 1726 p->seq_num = 0; /* unused */
1727 p->dp_flags = 0; 1727 p->dp_flags = 0;
1728 if (dgs) 1728 if (digest_size)
1729 drbd_csum_ee(peer_device->connection->integrity_tfm, peer_req, p + 1); 1729 drbd_csum_ee(peer_device->connection->integrity_tfm, peer_req, p + 1);
1730 err = __send_command(peer_device->connection, device->vnr, sock, cmd, sizeof(*p) + dgs, NULL, peer_req->i.size); 1730 err = __send_command(peer_device->connection, device->vnr, sock, cmd, sizeof(*p) + digest_size, NULL, peer_req->i.size);
1731 if (!err) 1731 if (!err)
1732 err = _drbd_send_zc_ee(peer_device, peer_req); 1732 err = _drbd_send_zc_ee(peer_device, peer_req);
1733 mutex_unlock(&sock->mutex); /* locked by drbd_prepare_command() */ 1733 mutex_unlock(&sock->mutex); /* locked by drbd_prepare_command() */
diff --git a/drivers/block/drbd/drbd_proc.c b/drivers/block/drbd/drbd_proc.c
index 06e6147c7601..3b10fa6cb039 100644
--- a/drivers/block/drbd/drbd_proc.c
+++ b/drivers/block/drbd/drbd_proc.c
@@ -142,10 +142,12 @@ static void drbd_syncer_progress(struct drbd_device *device, struct seq_file *se
142 (unsigned long) Bit2KB(rs_left >> 10), 142 (unsigned long) Bit2KB(rs_left >> 10),
143 (unsigned long) Bit2KB(rs_total >> 10)); 143 (unsigned long) Bit2KB(rs_total >> 10));
144 else 144 else
145 seq_printf(seq, "(%lu/%lu)K\n\t", 145 seq_printf(seq, "(%lu/%lu)K",
146 (unsigned long) Bit2KB(rs_left), 146 (unsigned long) Bit2KB(rs_left),
147 (unsigned long) Bit2KB(rs_total)); 147 (unsigned long) Bit2KB(rs_total));
148 148
149 seq_printf(seq, "\n\t");
150
149 /* see drivers/md/md.c 151 /* see drivers/md/md.c
150 * We do not want to overflow, so the order of operands and 152 * We do not want to overflow, so the order of operands and
151 * the * 100 / 100 trick are important. We do a +1 to be 153 * the * 100 / 100 trick are important. We do a +1 to be
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 9342b8da73ab..6960fb064731 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -1371,9 +1371,9 @@ int drbd_submit_peer_request(struct drbd_device *device,
1371 struct bio *bio; 1371 struct bio *bio;
1372 struct page *page = peer_req->pages; 1372 struct page *page = peer_req->pages;
1373 sector_t sector = peer_req->i.sector; 1373 sector_t sector = peer_req->i.sector;
1374 unsigned ds = peer_req->i.size; 1374 unsigned data_size = peer_req->i.size;
1375 unsigned n_bios = 0; 1375 unsigned n_bios = 0;
1376 unsigned nr_pages = (ds + PAGE_SIZE -1) >> PAGE_SHIFT; 1376 unsigned nr_pages = (data_size + PAGE_SIZE -1) >> PAGE_SHIFT;
1377 int err = -ENOMEM; 1377 int err = -ENOMEM;
1378 1378
1379 if (peer_req->flags & EE_IS_TRIM_USE_ZEROOUT) { 1379 if (peer_req->flags & EE_IS_TRIM_USE_ZEROOUT) {
@@ -1388,7 +1388,7 @@ int drbd_submit_peer_request(struct drbd_device *device,
1388 list_add_tail(&peer_req->w.list, &device->active_ee); 1388 list_add_tail(&peer_req->w.list, &device->active_ee);
1389 spin_unlock_irq(&device->resource->req_lock); 1389 spin_unlock_irq(&device->resource->req_lock);
1390 if (blkdev_issue_zeroout(device->ldev->backing_bdev, 1390 if (blkdev_issue_zeroout(device->ldev->backing_bdev,
1391 sector, ds >> 9, GFP_NOIO)) 1391 sector, data_size >> 9, GFP_NOIO))
1392 peer_req->flags |= EE_WAS_ERROR; 1392 peer_req->flags |= EE_WAS_ERROR;
1393 drbd_endio_write_sec_final(peer_req); 1393 drbd_endio_write_sec_final(peer_req);
1394 return 0; 1394 return 0;
@@ -1426,12 +1426,12 @@ next_bio:
1426 ++n_bios; 1426 ++n_bios;
1427 1427
1428 if (rw & REQ_DISCARD) { 1428 if (rw & REQ_DISCARD) {
1429 bio->bi_iter.bi_size = ds; 1429 bio->bi_iter.bi_size = data_size;
1430 goto submit; 1430 goto submit;
1431 } 1431 }
1432 1432
1433 page_chain_for_each(page) { 1433 page_chain_for_each(page) {
1434 unsigned len = min_t(unsigned, ds, PAGE_SIZE); 1434 unsigned len = min_t(unsigned, data_size, PAGE_SIZE);
1435 if (!bio_add_page(bio, page, len, 0)) { 1435 if (!bio_add_page(bio, page, len, 0)) {
1436 /* A single page must always be possible! 1436 /* A single page must always be possible!
1437 * But in case it fails anyways, 1437 * But in case it fails anyways,
@@ -1446,11 +1446,11 @@ next_bio:
1446 } 1446 }
1447 goto next_bio; 1447 goto next_bio;
1448 } 1448 }
1449 ds -= len; 1449 data_size -= len;
1450 sector += len >> 9; 1450 sector += len >> 9;
1451 --nr_pages; 1451 --nr_pages;
1452 } 1452 }
1453 D_ASSERT(device, ds == 0); 1453 D_ASSERT(device, data_size == 0);
1454submit: 1454submit:
1455 D_ASSERT(device, page == NULL); 1455 D_ASSERT(device, page == NULL);
1456 1456
@@ -1591,24 +1591,24 @@ read_in_block(struct drbd_peer_device *peer_device, u64 id, sector_t sector,
1591 const sector_t capacity = drbd_get_capacity(device->this_bdev); 1591 const sector_t capacity = drbd_get_capacity(device->this_bdev);
1592 struct drbd_peer_request *peer_req; 1592 struct drbd_peer_request *peer_req;
1593 struct page *page; 1593 struct page *page;
1594 int dgs, ds, err; 1594 int digest_size, err;
1595 unsigned int data_size = pi->size; 1595 unsigned int data_size = pi->size, ds;
1596 void *dig_in = peer_device->connection->int_dig_in; 1596 void *dig_in = peer_device->connection->int_dig_in;
1597 void *dig_vv = peer_device->connection->int_dig_vv; 1597 void *dig_vv = peer_device->connection->int_dig_vv;
1598 unsigned long *data; 1598 unsigned long *data;
1599 struct p_trim *trim = (pi->cmd == P_TRIM) ? pi->data : NULL; 1599 struct p_trim *trim = (pi->cmd == P_TRIM) ? pi->data : NULL;
1600 1600
1601 dgs = 0; 1601 digest_size = 0;
1602 if (!trim && peer_device->connection->peer_integrity_tfm) { 1602 if (!trim && peer_device->connection->peer_integrity_tfm) {
1603 dgs = crypto_hash_digestsize(peer_device->connection->peer_integrity_tfm); 1603 digest_size = crypto_hash_digestsize(peer_device->connection->peer_integrity_tfm);
1604 /* 1604 /*
1605 * FIXME: Receive the incoming digest into the receive buffer 1605 * FIXME: Receive the incoming digest into the receive buffer
1606 * here, together with its struct p_data? 1606 * here, together with its struct p_data?
1607 */ 1607 */
1608 err = drbd_recv_all_warn(peer_device->connection, dig_in, dgs); 1608 err = drbd_recv_all_warn(peer_device->connection, dig_in, digest_size);
1609 if (err) 1609 if (err)
1610 return NULL; 1610 return NULL;
1611 data_size -= dgs; 1611 data_size -= digest_size;
1612 } 1612 }
1613 1613
1614 if (trim) { 1614 if (trim) {
@@ -1661,16 +1661,16 @@ read_in_block(struct drbd_peer_device *peer_device, u64 id, sector_t sector,
1661 ds -= len; 1661 ds -= len;
1662 } 1662 }
1663 1663
1664 if (dgs) { 1664 if (digest_size) {
1665 drbd_csum_ee(peer_device->connection->peer_integrity_tfm, peer_req, dig_vv); 1665 drbd_csum_ee(peer_device->connection->peer_integrity_tfm, peer_req, dig_vv);
1666 if (memcmp(dig_in, dig_vv, dgs)) { 1666 if (memcmp(dig_in, dig_vv, digest_size)) {
1667 drbd_err(device, "Digest integrity check FAILED: %llus +%u\n", 1667 drbd_err(device, "Digest integrity check FAILED: %llus +%u\n",
1668 (unsigned long long)sector, data_size); 1668 (unsigned long long)sector, data_size);
1669 drbd_free_peer_req(device, peer_req); 1669 drbd_free_peer_req(device, peer_req);
1670 return NULL; 1670 return NULL;
1671 } 1671 }
1672 } 1672 }
1673 device->recv_cnt += data_size>>9; 1673 device->recv_cnt += data_size >> 9;
1674 return peer_req; 1674 return peer_req;
1675} 1675}
1676 1676
@@ -1708,17 +1708,17 @@ static int recv_dless_read(struct drbd_peer_device *peer_device, struct drbd_req
1708 struct bio_vec bvec; 1708 struct bio_vec bvec;
1709 struct bvec_iter iter; 1709 struct bvec_iter iter;
1710 struct bio *bio; 1710 struct bio *bio;
1711 int dgs, err, expect; 1711 int digest_size, err, expect;
1712 void *dig_in = peer_device->connection->int_dig_in; 1712 void *dig_in = peer_device->connection->int_dig_in;
1713 void *dig_vv = peer_device->connection->int_dig_vv; 1713 void *dig_vv = peer_device->connection->int_dig_vv;
1714 1714
1715 dgs = 0; 1715 digest_size = 0;
1716 if (peer_device->connection->peer_integrity_tfm) { 1716 if (peer_device->connection->peer_integrity_tfm) {
1717 dgs = crypto_hash_digestsize(peer_device->connection->peer_integrity_tfm); 1717 digest_size = crypto_hash_digestsize(peer_device->connection->peer_integrity_tfm);
1718 err = drbd_recv_all_warn(peer_device->connection, dig_in, dgs); 1718 err = drbd_recv_all_warn(peer_device->connection, dig_in, digest_size);
1719 if (err) 1719 if (err)
1720 return err; 1720 return err;
1721 data_size -= dgs; 1721 data_size -= digest_size;
1722 } 1722 }
1723 1723
1724 /* optimistically update recv_cnt. if receiving fails below, 1724 /* optimistically update recv_cnt. if receiving fails below,
@@ -1738,9 +1738,9 @@ static int recv_dless_read(struct drbd_peer_device *peer_device, struct drbd_req
1738 data_size -= expect; 1738 data_size -= expect;
1739 } 1739 }
1740 1740
1741 if (dgs) { 1741 if (digest_size) {
1742 drbd_csum_bio(peer_device->connection->peer_integrity_tfm, bio, dig_vv); 1742 drbd_csum_bio(peer_device->connection->peer_integrity_tfm, bio, dig_vv);
1743 if (memcmp(dig_in, dig_vv, dgs)) { 1743 if (memcmp(dig_in, dig_vv, digest_size)) {
1744 drbd_err(peer_device, "Digest integrity check FAILED. Broken NICs?\n"); 1744 drbd_err(peer_device, "Digest integrity check FAILED. Broken NICs?\n");
1745 return -EINVAL; 1745 return -EINVAL;
1746 } 1746 }
@@ -5561,6 +5561,7 @@ int drbd_asender(struct drbd_thread *thi)
5561 * rv < expected: "woken" by signal during receive 5561 * rv < expected: "woken" by signal during receive
5562 * rv == 0 : "connection shut down by peer" 5562 * rv == 0 : "connection shut down by peer"
5563 */ 5563 */
5564received_more:
5564 if (likely(rv > 0)) { 5565 if (likely(rv > 0)) {
5565 received += rv; 5566 received += rv;
5566 buf += rv; 5567 buf += rv;
@@ -5636,6 +5637,11 @@ int drbd_asender(struct drbd_thread *thi)
5636 expect = header_size; 5637 expect = header_size;
5637 cmd = NULL; 5638 cmd = NULL;
5638 } 5639 }
5640 if (test_bit(SEND_PING, &connection->flags))
5641 continue;
5642 rv = drbd_recv_short(connection->meta.socket, buf, expect-received, MSG_DONTWAIT);
5643 if (rv > 0)
5644 goto received_more;
5639 } 5645 }
5640 5646
5641 if (0) { 5647 if (0) {
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
index c67717d572d1..5a01c53dddeb 100644
--- a/drivers/block/drbd/drbd_req.c
+++ b/drivers/block/drbd/drbd_req.c
@@ -1645,6 +1645,6 @@ void request_timer_fn(unsigned long data)
1645 ? oldest_submit_jif + dt : now + et; 1645 ? oldest_submit_jif + dt : now + et;
1646 nt = time_before(ent, dt) ? ent : dt; 1646 nt = time_before(ent, dt) ? ent : dt;
1647out: 1647out:
1648 spin_unlock_irq(&connection->resource->req_lock); 1648 spin_unlock_irq(&device->resource->req_lock);
1649 mod_timer(&device->request_timer, nt); 1649 mod_timer(&device->request_timer, nt);
1650} 1650}
diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
index c35c0f001bb7..84b11f887d73 100644
--- a/drivers/block/drbd/drbd_state.c
+++ b/drivers/block/drbd/drbd_state.c
@@ -136,50 +136,50 @@ enum drbd_role conn_highest_peer(struct drbd_connection *connection)
136 136
137enum drbd_disk_state conn_highest_disk(struct drbd_connection *connection) 137enum drbd_disk_state conn_highest_disk(struct drbd_connection *connection)
138{ 138{
139 enum drbd_disk_state ds = D_DISKLESS; 139 enum drbd_disk_state disk_state = D_DISKLESS;
140 struct drbd_peer_device *peer_device; 140 struct drbd_peer_device *peer_device;
141 int vnr; 141 int vnr;
142 142
143 rcu_read_lock(); 143 rcu_read_lock();
144 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { 144 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
145 struct drbd_device *device = peer_device->device; 145 struct drbd_device *device = peer_device->device;
146 ds = max_t(enum drbd_disk_state, ds, device->state.disk); 146 disk_state = max_t(enum drbd_disk_state, disk_state, device->state.disk);
147 } 147 }
148 rcu_read_unlock(); 148 rcu_read_unlock();
149 149
150 return ds; 150 return disk_state;
151} 151}
152 152
153enum drbd_disk_state conn_lowest_disk(struct drbd_connection *connection) 153enum drbd_disk_state conn_lowest_disk(struct drbd_connection *connection)
154{ 154{
155 enum drbd_disk_state ds = D_MASK; 155 enum drbd_disk_state disk_state = D_MASK;
156 struct drbd_peer_device *peer_device; 156 struct drbd_peer_device *peer_device;
157 int vnr; 157 int vnr;
158 158
159 rcu_read_lock(); 159 rcu_read_lock();
160 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { 160 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
161 struct drbd_device *device = peer_device->device; 161 struct drbd_device *device = peer_device->device;
162 ds = min_t(enum drbd_disk_state, ds, device->state.disk); 162 disk_state = min_t(enum drbd_disk_state, disk_state, device->state.disk);
163 } 163 }
164 rcu_read_unlock(); 164 rcu_read_unlock();
165 165
166 return ds; 166 return disk_state;
167} 167}
168 168
169enum drbd_disk_state conn_highest_pdsk(struct drbd_connection *connection) 169enum drbd_disk_state conn_highest_pdsk(struct drbd_connection *connection)
170{ 170{
171 enum drbd_disk_state ds = D_DISKLESS; 171 enum drbd_disk_state disk_state = D_DISKLESS;
172 struct drbd_peer_device *peer_device; 172 struct drbd_peer_device *peer_device;
173 int vnr; 173 int vnr;
174 174
175 rcu_read_lock(); 175 rcu_read_lock();
176 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { 176 idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
177 struct drbd_device *device = peer_device->device; 177 struct drbd_device *device = peer_device->device;
178 ds = max_t(enum drbd_disk_state, ds, device->state.pdsk); 178 disk_state = max_t(enum drbd_disk_state, disk_state, device->state.pdsk);
179 } 179 }
180 rcu_read_unlock(); 180 rcu_read_unlock();
181 181
182 return ds; 182 return disk_state;
183} 183}
184 184
185enum drbd_conns conn_lowest_conn(struct drbd_connection *connection) 185enum drbd_conns conn_lowest_conn(struct drbd_connection *connection)
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c
index 50776b362828..d2d1f97511bd 100644
--- a/drivers/block/drbd/drbd_worker.c
+++ b/drivers/block/drbd/drbd_worker.c
@@ -43,10 +43,10 @@ static int make_ov_request(struct drbd_device *, int);
43static int make_resync_request(struct drbd_device *, int); 43static int make_resync_request(struct drbd_device *, int);
44 44
45/* endio handlers: 45/* endio handlers:
46 * drbd_md_io_complete (defined here) 46 * drbd_md_endio (defined here)
47 * drbd_request_endio (defined here) 47 * drbd_request_endio (defined here)
48 * drbd_peer_request_endio (defined here) 48 * drbd_peer_request_endio (defined here)
49 * bm_async_io_complete (defined in drbd_bitmap.c) 49 * drbd_bm_endio (defined in drbd_bitmap.c)
50 * 50 *
51 * For all these callbacks, note the following: 51 * For all these callbacks, note the following:
52 * The callbacks will be called in irq context by the IDE drivers, 52 * The callbacks will be called in irq context by the IDE drivers,
@@ -65,7 +65,7 @@ rwlock_t global_state_lock;
65/* used for synchronous meta data and bitmap IO 65/* used for synchronous meta data and bitmap IO
66 * submitted by drbd_md_sync_page_io() 66 * submitted by drbd_md_sync_page_io()
67 */ 67 */
68void drbd_md_io_complete(struct bio *bio, int error) 68void drbd_md_endio(struct bio *bio, int error)
69{ 69{
70 struct drbd_device *device; 70 struct drbd_device *device;
71 71
@@ -1853,9 +1853,12 @@ static void drbd_ldev_destroy(struct drbd_device *device)
1853 device->resync = NULL; 1853 device->resync = NULL;
1854 lc_destroy(device->act_log); 1854 lc_destroy(device->act_log);
1855 device->act_log = NULL; 1855 device->act_log = NULL;
1856 __no_warn(local, 1856
1857 drbd_free_ldev(device->ldev); 1857 __acquire(local);
1858 device->ldev = NULL;); 1858 drbd_free_ldev(device->ldev);
1859 device->ldev = NULL;
1860 __release(local);
1861
1859 clear_bit(GOING_DISKLESS, &device->flags); 1862 clear_bit(GOING_DISKLESS, &device->flags);
1860 wake_up(&device->misc_wait); 1863 wake_up(&device->misc_wait);
1861} 1864}
@@ -1928,19 +1931,18 @@ void __update_timing_details(
1928 ++(*cb_nr); 1931 ++(*cb_nr);
1929} 1932}
1930 1933
1931#define WORK_PENDING(work_bit, todo) (todo & (1UL << work_bit))
1932static void do_device_work(struct drbd_device *device, const unsigned long todo) 1934static void do_device_work(struct drbd_device *device, const unsigned long todo)
1933{ 1935{
1934 if (WORK_PENDING(MD_SYNC, todo)) 1936 if (test_bit(MD_SYNC, &todo))
1935 do_md_sync(device); 1937 do_md_sync(device);
1936 if (WORK_PENDING(RS_DONE, todo) || 1938 if (test_bit(RS_DONE, &todo) ||
1937 WORK_PENDING(RS_PROGRESS, todo)) 1939 test_bit(RS_PROGRESS, &todo))
1938 update_on_disk_bitmap(device, WORK_PENDING(RS_DONE, todo)); 1940 update_on_disk_bitmap(device, test_bit(RS_DONE, &todo));
1939 if (WORK_PENDING(GO_DISKLESS, todo)) 1941 if (test_bit(GO_DISKLESS, &todo))
1940 go_diskless(device); 1942 go_diskless(device);
1941 if (WORK_PENDING(DESTROY_DISK, todo)) 1943 if (test_bit(DESTROY_DISK, &todo))
1942 drbd_ldev_destroy(device); 1944 drbd_ldev_destroy(device);
1943 if (WORK_PENDING(RS_START, todo)) 1945 if (test_bit(RS_START, &todo))
1944 do_start_resync(device); 1946 do_start_resync(device);
1945} 1947}
1946 1948
@@ -1992,22 +1994,13 @@ static bool dequeue_work_batch(struct drbd_work_queue *queue, struct list_head *
1992 return !list_empty(work_list); 1994 return !list_empty(work_list);
1993} 1995}
1994 1996
1995static bool dequeue_work_item(struct drbd_work_queue *queue, struct list_head *work_list)
1996{
1997 spin_lock_irq(&queue->q_lock);
1998 if (!list_empty(&queue->q))
1999 list_move(queue->q.next, work_list);
2000 spin_unlock_irq(&queue->q_lock);
2001 return !list_empty(work_list);
2002}
2003
2004static void wait_for_work(struct drbd_connection *connection, struct list_head *work_list) 1997static void wait_for_work(struct drbd_connection *connection, struct list_head *work_list)
2005{ 1998{
2006 DEFINE_WAIT(wait); 1999 DEFINE_WAIT(wait);
2007 struct net_conf *nc; 2000 struct net_conf *nc;
2008 int uncork, cork; 2001 int uncork, cork;
2009 2002
2010 dequeue_work_item(&connection->sender_work, work_list); 2003 dequeue_work_batch(&connection->sender_work, work_list);
2011 if (!list_empty(work_list)) 2004 if (!list_empty(work_list))
2012 return; 2005 return;
2013 2006
@@ -2033,8 +2026,6 @@ static void wait_for_work(struct drbd_connection *connection, struct list_head *
2033 prepare_to_wait(&connection->sender_work.q_wait, &wait, TASK_INTERRUPTIBLE); 2026 prepare_to_wait(&connection->sender_work.q_wait, &wait, TASK_INTERRUPTIBLE);
2034 spin_lock_irq(&connection->resource->req_lock); 2027 spin_lock_irq(&connection->resource->req_lock);
2035 spin_lock(&connection->sender_work.q_lock); /* FIXME get rid of this one? */ 2028 spin_lock(&connection->sender_work.q_lock); /* FIXME get rid of this one? */
2036 /* dequeue single item only,
2037 * we still use drbd_queue_work_front() in some places */
2038 if (!list_empty(&connection->sender_work.q)) 2029 if (!list_empty(&connection->sender_work.q))
2039 list_splice_tail_init(&connection->sender_work.q, work_list); 2030 list_splice_tail_init(&connection->sender_work.q, work_list);
2040 spin_unlock(&connection->sender_work.q_lock); /* FIXME get rid of this one? */ 2031 spin_unlock(&connection->sender_work.q_lock); /* FIXME get rid of this one? */
@@ -2121,7 +2112,7 @@ int drbd_worker(struct drbd_thread *thi)
2121 if (get_t_state(thi) != RUNNING) 2112 if (get_t_state(thi) != RUNNING)
2122 break; 2113 break;
2123 2114
2124 while (!list_empty(&work_list)) { 2115 if (!list_empty(&work_list)) {
2125 w = list_first_entry(&work_list, struct drbd_work, list); 2116 w = list_first_entry(&work_list, struct drbd_work, list);
2126 list_del_init(&w->list); 2117 list_del_init(&w->list);
2127 update_worker_timing_details(connection, w->cb); 2118 update_worker_timing_details(connection, w->cb);
@@ -2137,13 +2128,13 @@ int drbd_worker(struct drbd_thread *thi)
2137 update_worker_timing_details(connection, do_unqueued_work); 2128 update_worker_timing_details(connection, do_unqueued_work);
2138 do_unqueued_work(connection); 2129 do_unqueued_work(connection);
2139 } 2130 }
2140 while (!list_empty(&work_list)) { 2131 if (!list_empty(&work_list)) {
2141 w = list_first_entry(&work_list, struct drbd_work, list); 2132 w = list_first_entry(&work_list, struct drbd_work, list);
2142 list_del_init(&w->list); 2133 list_del_init(&w->list);
2143 update_worker_timing_details(connection, w->cb); 2134 update_worker_timing_details(connection, w->cb);
2144 w->cb(w, 1); 2135 w->cb(w, 1);
2145 } 2136 } else
2146 dequeue_work_batch(&connection->sender_work, &work_list); 2137 dequeue_work_batch(&connection->sender_work, &work_list);
2147 } while (!list_empty(&work_list) || test_bit(DEVICE_WORK_PENDING, &connection->flags)); 2138 } while (!list_empty(&work_list) || test_bit(DEVICE_WORK_PENDING, &connection->flags));
2148 2139
2149 rcu_read_lock(); 2140 rcu_read_lock();
diff --git a/drivers/block/hd.c b/drivers/block/hd.c
index 8a290c08262f..3abb121825bc 100644
--- a/drivers/block/hd.c
+++ b/drivers/block/hd.c
@@ -694,16 +694,6 @@ static const struct block_device_operations hd_fops = {
694 .getgeo = hd_getgeo, 694 .getgeo = hd_getgeo,
695}; 695};
696 696
697/*
698 * This is the hard disk IRQ description. The IRQF_DISABLED in sa_flags
699 * means we run the IRQ-handler with interrupts disabled: this is bad for
700 * interrupt latency, but anything else has led to problems on some
701 * machines.
702 *
703 * We enable interrupts in some of the routines after making sure it's
704 * safe.
705 */
706
707static int __init hd_init(void) 697static int __init hd_init(void)
708{ 698{
709 int drive; 699 int drive;
@@ -761,7 +751,7 @@ static int __init hd_init(void)
761 p->cyl, p->head, p->sect); 751 p->cyl, p->head, p->sect);
762 } 752 }
763 753
764 if (request_irq(HD_IRQ, hd_interrupt, IRQF_DISABLED, "hd", NULL)) { 754 if (request_irq(HD_IRQ, hd_interrupt, 0, "hd", NULL)) {
765 printk("hd: unable to get IRQ%d for the hard disk driver\n", 755 printk("hd: unable to get IRQ%d for the hard disk driver\n",
766 HD_IRQ); 756 HD_IRQ);
767 goto out1; 757 goto out1;
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 6b7e8d0fba99..1bd5f523f8fd 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3954,6 +3954,7 @@ skip_create_disk:
3954 3954
3955 /* Set device limits. */ 3955 /* Set device limits. */
3956 set_bit(QUEUE_FLAG_NONROT, &dd->queue->queue_flags); 3956 set_bit(QUEUE_FLAG_NONROT, &dd->queue->queue_flags);
3957 clear_bit(QUEUE_FLAG_ADD_RANDOM, &dd->queue->queue_flags);
3957 blk_queue_max_segments(dd->queue, MTIP_MAX_SG); 3958 blk_queue_max_segments(dd->queue, MTIP_MAX_SG);
3958 blk_queue_physical_block_size(dd->queue, 4096); 3959 blk_queue_physical_block_size(dd->queue, 4096);
3959 blk_queue_max_hw_sectors(dd->queue, 0xffff); 3960 blk_queue_max_hw_sectors(dd->queue, 0xffff);
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index fb31b8ee4372..4bc2a5cb9935 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -847,6 +847,7 @@ static int __init nbd_init(void)
847 * Tell the block layer that we are not a rotational device 847 * Tell the block layer that we are not a rotational device
848 */ 848 */
849 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, disk->queue); 849 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, disk->queue);
850 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, disk->queue);
850 disk->queue->limits.discard_granularity = 512; 851 disk->queue->limits.discard_granularity = 512;
851 disk->queue->limits.max_discard_sectors = UINT_MAX; 852 disk->queue->limits.max_discard_sectors = UINT_MAX;
852 disk->queue->limits.discard_zeroes_data = 0; 853 disk->queue->limits.discard_zeroes_data = 0;
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index ac50a2931044..2671a3f02f0c 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -521,6 +521,7 @@ static int null_add_dev(void)
521 521
522 nullb->q->queuedata = nullb; 522 nullb->q->queuedata = nullb;
523 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, nullb->q); 523 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, nullb->q);
524 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, nullb->q);
524 525
525 disk = nullb->disk = alloc_disk_node(1, home_node); 526 disk = nullb->disk = alloc_disk_node(1, home_node);
526 if (!disk) { 527 if (!disk) {
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index 02351e217165..e2bb8afbeae5 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -1916,6 +1916,7 @@ static struct nvme_ns *nvme_alloc_ns(struct nvme_dev *dev, unsigned nsid,
1916 ns->queue->queue_flags = QUEUE_FLAG_DEFAULT; 1916 ns->queue->queue_flags = QUEUE_FLAG_DEFAULT;
1917 queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, ns->queue); 1917 queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, ns->queue);
1918 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, ns->queue); 1918 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, ns->queue);
1919 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, ns->queue);
1919 blk_queue_make_request(ns->queue, nvme_make_request); 1920 blk_queue_make_request(ns->queue, nvme_make_request);
1920 ns->dev = dev; 1921 ns->dev = dev;
1921 ns->queue->queuedata = ns; 1922 ns->queue->queuedata = ns;
diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c
index 3265ce94d282..d8b2488aaade 100644
--- a/drivers/block/rsxx/core.c
+++ b/drivers/block/rsxx/core.c
@@ -837,7 +837,7 @@ static int rsxx_pci_probe(struct pci_dev *dev,
837 "Failed to enable MSI\n"); 837 "Failed to enable MSI\n");
838 } 838 }
839 839
840 st = request_irq(dev->irq, rsxx_isr, IRQF_DISABLED | IRQF_SHARED, 840 st = request_irq(dev->irq, rsxx_isr, IRQF_SHARED,
841 DRIVER_NAME, card); 841 DRIVER_NAME, card);
842 if (st) { 842 if (st) {
843 dev_err(CARD_TO_DEV(card), 843 dev_err(CARD_TO_DEV(card),
diff --git a/drivers/block/rsxx/dev.c b/drivers/block/rsxx/dev.c
index 2839d37e5af7..40ee7705df63 100644
--- a/drivers/block/rsxx/dev.c
+++ b/drivers/block/rsxx/dev.c
@@ -307,6 +307,7 @@ int rsxx_setup_dev(struct rsxx_cardinfo *card)
307 blk_queue_physical_block_size(card->queue, RSXX_HW_BLK_SIZE); 307 blk_queue_physical_block_size(card->queue, RSXX_HW_BLK_SIZE);
308 308
309 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, card->queue); 309 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, card->queue);
310 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, card->queue);
310 if (rsxx_discard_supported(card)) { 311 if (rsxx_discard_supported(card)) {
311 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, card->queue); 312 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, card->queue);
312 blk_queue_max_discard_sectors(card->queue, 313 blk_queue_max_discard_sectors(card->queue,
diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index 8fcdcfb4b472..1e46eb2305c0 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -4426,6 +4426,7 @@ static int skd_cons_disk(struct skd_device *skdev)
4426 q->limits.discard_zeroes_data = 1; 4426 q->limits.discard_zeroes_data = 1;
4427 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); 4427 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
4428 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q); 4428 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
4429 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, q);
4429 4430
4430 spin_lock_irqsave(&skdev->lock, flags); 4431 spin_lock_irqsave(&skdev->lock, flags);
4431 pr_debug("%s:%s:%d stopping %s queue\n", 4432 pr_debug("%s:%s:%d stopping %s queue\n",
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 64c60edcdfbc..63fc7f06a014 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -763,6 +763,7 @@ again:
763 BUG_ON(new_map_idx >= segs_to_map); 763 BUG_ON(new_map_idx >= segs_to_map);
764 if (unlikely(map[new_map_idx].status != 0)) { 764 if (unlikely(map[new_map_idx].status != 0)) {
765 pr_debug(DRV_PFX "invalid buffer -- could not remap it\n"); 765 pr_debug(DRV_PFX "invalid buffer -- could not remap it\n");
766 put_free_pages(blkif, &pages[seg_idx]->page, 1);
766 pages[seg_idx]->handle = BLKBACK_INVALID_HANDLE; 767 pages[seg_idx]->handle = BLKBACK_INVALID_HANDLE;
767 ret |= 1; 768 ret |= 1;
768 goto next; 769 goto next;
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 0b13b1c9a01e..630a489e757d 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -270,6 +270,9 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
270 blkif->blk_rings.common.sring = NULL; 270 blkif->blk_rings.common.sring = NULL;
271 } 271 }
272 272
273 /* Remove all persistent grants and the cache of ballooned pages. */
274 xen_blkbk_free_caches(blkif);
275
273 return 0; 276 return 0;
274} 277}
275 278
@@ -281,9 +284,6 @@ static void xen_blkif_free(struct xen_blkif *blkif)
281 xen_blkif_disconnect(blkif); 284 xen_blkif_disconnect(blkif);
282 xen_vbd_free(&blkif->vbd); 285 xen_vbd_free(&blkif->vbd);
283 286
284 /* Remove all persistent grants and the cache of ballooned pages. */
285 xen_blkbk_free_caches(blkif);
286
287 /* Make sure everything is drained before shutting down */ 287 /* Make sure everything is drained before shutting down */
288 BUG_ON(blkif->persistent_gnt_c != 0); 288 BUG_ON(blkif->persistent_gnt_c != 0);
289 BUG_ON(atomic_read(&blkif->persistent_gnt_in_use) != 0); 289 BUG_ON(atomic_read(&blkif->persistent_gnt_in_use) != 0);
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 37af03e9d859..5ac312f6e0be 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -582,6 +582,14 @@ static inline void flush_requests(struct blkfront_info *info)
582 notify_remote_via_irq(info->irq); 582 notify_remote_via_irq(info->irq);
583} 583}
584 584
585static inline bool blkif_request_flush_valid(struct request *req,
586 struct blkfront_info *info)
587{
588 return ((req->cmd_type != REQ_TYPE_FS) ||
589 ((req->cmd_flags & (REQ_FLUSH | REQ_FUA)) &&
590 !info->flush_op));
591}
592
585/* 593/*
586 * do_blkif_request 594 * do_blkif_request
587 * read a block; request is in a request queue 595 * read a block; request is in a request queue
@@ -604,9 +612,7 @@ static void do_blkif_request(struct request_queue *rq)
604 612
605 blk_start_request(req); 613 blk_start_request(req);
606 614
607 if ((req->cmd_type != REQ_TYPE_FS) || 615 if (blkif_request_flush_valid(req, info)) {
608 ((req->cmd_flags & (REQ_FLUSH | REQ_FUA)) &&
609 !info->flush_op)) {
610 __blk_end_request_all(req, -EIO); 616 __blk_end_request_all(req, -EIO);
611 continue; 617 continue;
612 } 618 }
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 3b850164c65c..0e63e8aa8279 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1031,6 +1031,7 @@ static int create_device(struct zram *zram, int device_id)
1031 set_capacity(zram->disk, 0); 1031 set_capacity(zram->disk, 0);
1032 /* zram devices sort of resembles non-rotational disks */ 1032 /* zram devices sort of resembles non-rotational disks */
1033 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue); 1033 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue);
1034 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, zram->disk->queue);
1034 /* 1035 /*
1035 * To ensure that we always get PAGE_SIZE aligned 1036 * To ensure that we always get PAGE_SIZE aligned
1036 * and n*PAGE_SIZED sized I/O requests. 1037 * and n*PAGE_SIZED sized I/O requests.