Skip to content

Commit eff0d13

Browse files
committed
Merge branch 'for-3.6/drivers' of git://git.kernel.dk/linux-block
Pull block driver changes from Jens Axboe: - Making the plugging support for drivers a bit more sane from Neil. This supersedes the plugging change from Shaohua as well. - The usual round of drbd updates. - Using a tail add instead of a head add in the request completion for ndb, making us find the most completed request more quickly. - A few floppy changes, getting rid of a duplicated flag and also running the floppy init async (since it takes forever in boot terms) from Andi. * 'for-3.6/drivers' of git://git.kernel.dk/linux-block: floppy: remove duplicated flag FD_RAW_NEED_DISK blk: pass from_schedule to non-request unplug functions. block: stack unplug blk: centralize non-request unplug handling. md: remove plug_cnt feature of plugging. block/nbd: micro-optimization in nbd request completion drbd: announce FLUSH/FUA capability to upper layers drbd: fix max_bio_size to be unsigned drbd: flush drbd work queue before invalidate/invalidate remote drbd: fix potential access after free drbd: call local-io-error handler early drbd: do not reset rs_pending_cnt too early drbd: reset congestion information before reporting it in /proc/drbd drbd: report congestion if we are waiting for some userland callback drbd: differentiate between normal and forced detach drbd: cleanup, remove two unused global flags floppy: Run floppy initialization asynchronous
2 parents 8cf1a3f + 10af813 commit eff0d13

File tree

19 files changed

+238
-177
lines changed

19 files changed

+238
-177
lines changed

block/blk-core.c

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2909,23 +2909,47 @@ static void queue_unplugged(struct request_queue *q, unsigned int depth,
29092909

29102910
}
29112911

2912-
static void flush_plug_callbacks(struct blk_plug *plug)
2912+
static void flush_plug_callbacks(struct blk_plug *plug, bool from_schedule)
29132913
{
29142914
LIST_HEAD(callbacks);
29152915

2916-
if (list_empty(&plug->cb_list))
2917-
return;
2918-
2919-
list_splice_init(&plug->cb_list, &callbacks);
2916+
while (!list_empty(&plug->cb_list)) {
2917+
list_splice_init(&plug->cb_list, &callbacks);
29202918

2921-
while (!list_empty(&callbacks)) {
2922-
struct blk_plug_cb *cb = list_first_entry(&callbacks,
2919+
while (!list_empty(&callbacks)) {
2920+
struct blk_plug_cb *cb = list_first_entry(&callbacks,
29232921
struct blk_plug_cb,
29242922
list);
2925-
list_del(&cb->list);
2926-
cb->callback(cb);
2923+
list_del(&cb->list);
2924+
cb->callback(cb, from_schedule);
2925+
}
2926+
}
2927+
}
2928+
2929+
struct blk_plug_cb *blk_check_plugged(blk_plug_cb_fn unplug, void *data,
2930+
int size)
2931+
{
2932+
struct blk_plug *plug = current->plug;
2933+
struct blk_plug_cb *cb;
2934+
2935+
if (!plug)
2936+
return NULL;
2937+
2938+
list_for_each_entry(cb, &plug->cb_list, list)
2939+
if (cb->callback == unplug && cb->data == data)
2940+
return cb;
2941+
2942+
/* Not currently on the callback list */
2943+
BUG_ON(size < sizeof(*cb));
2944+
cb = kzalloc(size, GFP_ATOMIC);
2945+
if (cb) {
2946+
cb->data = data;
2947+
cb->callback = unplug;
2948+
list_add(&cb->list, &plug->cb_list);
29272949
}
2950+
return cb;
29282951
}
2952+
EXPORT_SYMBOL(blk_check_plugged);
29292953

29302954
void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
29312955
{
@@ -2937,7 +2961,7 @@ void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
29372961

29382962
BUG_ON(plug->magic != PLUG_MAGIC);
29392963

2940-
flush_plug_callbacks(plug);
2964+
flush_plug_callbacks(plug, from_schedule);
29412965
if (list_empty(&plug->list))
29422966
return;
29432967

drivers/block/drbd/drbd_actlog.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ w_al_write_transaction(struct drbd_conf *mdev, struct drbd_work *w, int unused)
411411
+ mdev->ldev->md.al_offset + mdev->al_tr_pos;
412412

413413
if (!drbd_md_sync_page_io(mdev, mdev->ldev, sector, WRITE))
414-
drbd_chk_io_error(mdev, 1, true);
414+
drbd_chk_io_error(mdev, 1, DRBD_META_IO_ERROR);
415415

416416
if (++mdev->al_tr_pos >
417417
div_ceil(mdev->act_log->nr_elements, AL_EXTENTS_PT))
@@ -876,7 +876,11 @@ int __drbd_set_out_of_sync(struct drbd_conf *mdev, sector_t sector, int size,
876876
unsigned int enr, count = 0;
877877
struct lc_element *e;
878878

879-
if (size <= 0 || (size & 0x1ff) != 0 || size > DRBD_MAX_BIO_SIZE) {
879+
/* this should be an empty REQ_FLUSH */
880+
if (size == 0)
881+
return 0;
882+
883+
if (size < 0 || (size & 0x1ff) != 0 || size > DRBD_MAX_BIO_SIZE) {
880884
dev_err(DEV, "sector: %llus, size: %d\n",
881885
(unsigned long long)sector, size);
882886
return 0;

drivers/block/drbd/drbd_bitmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ static int bm_rw(struct drbd_conf *mdev, int rw, unsigned flags, unsigned lazy_w
10961096

10971097
if (ctx->error) {
10981098
dev_alert(DEV, "we had at least one MD IO ERROR during bitmap IO\n");
1099-
drbd_chk_io_error(mdev, 1, true);
1099+
drbd_chk_io_error(mdev, 1, DRBD_META_IO_ERROR);
11001100
err = -EIO; /* ctx->error ? */
11011101
}
11021102

@@ -1212,7 +1212,7 @@ int drbd_bm_write_page(struct drbd_conf *mdev, unsigned int idx) __must_hold(loc
12121212
wait_until_done_or_disk_failure(mdev, mdev->ldev, &ctx->done);
12131213

12141214
if (ctx->error)
1215-
drbd_chk_io_error(mdev, 1, true);
1215+
drbd_chk_io_error(mdev, 1, DRBD_META_IO_ERROR);
12161216
/* that should force detach, so the in memory bitmap will be
12171217
* gone in a moment as well. */
12181218

drivers/block/drbd/drbd_int.h

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,6 @@ enum {
813813
SIGNAL_ASENDER, /* whether asender wants to be interrupted */
814814
SEND_PING, /* whether asender should send a ping asap */
815815

816-
UNPLUG_QUEUED, /* only relevant with kernel 2.4 */
817816
UNPLUG_REMOTE, /* sending a "UnplugRemote" could help */
818817
MD_DIRTY, /* current uuids and flags not yet on disk */
819818
DISCARD_CONCURRENT, /* Set on one node, cleared on the peer! */
@@ -824,7 +823,6 @@ enum {
824823
CRASHED_PRIMARY, /* This node was a crashed primary.
825824
* Gets cleared when the state.conn
826825
* goes into C_CONNECTED state. */
827-
NO_BARRIER_SUPP, /* underlying block device doesn't implement barriers */
828826
CONSIDER_RESYNC,
829827

830828
MD_NO_FUA, /* Users wants us to not use FUA/FLUSH on meta data dev */
@@ -834,6 +832,7 @@ enum {
834832
BITMAP_IO_QUEUED, /* Started bitmap IO */
835833
GO_DISKLESS, /* Disk is being detached, on io-error or admin request. */
836834
WAS_IO_ERROR, /* Local disk failed returned IO error */
835+
FORCE_DETACH, /* Force-detach from local disk, aborting any pending local IO */
837836
RESYNC_AFTER_NEG, /* Resync after online grow after the attach&negotiate finished. */
838837
NET_CONGESTED, /* The data socket is congested */
839838

@@ -851,6 +850,13 @@ enum {
851850
AL_SUSPENDED, /* Activity logging is currently suspended. */
852851
AHEAD_TO_SYNC_SOURCE, /* Ahead -> SyncSource queued */
853852
STATE_SENT, /* Do not change state/UUIDs while this is set */
853+
854+
CALLBACK_PENDING, /* Whether we have a call_usermodehelper(, UMH_WAIT_PROC)
855+
* pending, from drbd worker context.
856+
* If set, bdi_write_congested() returns true,
857+
* so shrink_page_list() would not recurse into,
858+
* and potentially deadlock on, this drbd worker.
859+
*/
854860
};
855861

856862
struct drbd_bitmap; /* opaque for drbd_conf */
@@ -1130,8 +1136,8 @@ struct drbd_conf {
11301136
int rs_in_flight; /* resync sectors in flight (to proxy, in proxy and from proxy) */
11311137
int rs_planed; /* resync sectors already planned */
11321138
atomic_t ap_in_flight; /* App sectors in flight (waiting for ack) */
1133-
int peer_max_bio_size;
1134-
int local_max_bio_size;
1139+
unsigned int peer_max_bio_size;
1140+
unsigned int local_max_bio_size;
11351141
};
11361142

11371143
static inline struct drbd_conf *minor_to_mdev(unsigned int minor)
@@ -1435,9 +1441,9 @@ struct bm_extent {
14351441
* hash table. */
14361442
#define HT_SHIFT 8
14371443
#define DRBD_MAX_BIO_SIZE (1U<<(9+HT_SHIFT))
1438-
#define DRBD_MAX_BIO_SIZE_SAFE (1 << 12) /* Works always = 4k */
1444+
#define DRBD_MAX_BIO_SIZE_SAFE (1U << 12) /* Works always = 4k */
14391445

1440-
#define DRBD_MAX_SIZE_H80_PACKET (1 << 15) /* The old header only allows packets up to 32Kib data */
1446+
#define DRBD_MAX_SIZE_H80_PACKET (1U << 15) /* The old header only allows packets up to 32Kib data */
14411447

14421448
/* Number of elements in the app_reads_hash */
14431449
#define APP_R_HSIZE 15
@@ -1840,12 +1846,20 @@ static inline int drbd_request_state(struct drbd_conf *mdev,
18401846
return _drbd_request_state(mdev, mask, val, CS_VERBOSE + CS_ORDERED);
18411847
}
18421848

1849+
enum drbd_force_detach_flags {
1850+
DRBD_IO_ERROR,
1851+
DRBD_META_IO_ERROR,
1852+
DRBD_FORCE_DETACH,
1853+
};
1854+
18431855
#define __drbd_chk_io_error(m,f) __drbd_chk_io_error_(m,f, __func__)
1844-
static inline void __drbd_chk_io_error_(struct drbd_conf *mdev, int forcedetach, const char *where)
1856+
static inline void __drbd_chk_io_error_(struct drbd_conf *mdev,
1857+
enum drbd_force_detach_flags forcedetach,
1858+
const char *where)
18451859
{
18461860
switch (mdev->ldev->dc.on_io_error) {
18471861
case EP_PASS_ON:
1848-
if (!forcedetach) {
1862+
if (forcedetach == DRBD_IO_ERROR) {
18491863
if (__ratelimit(&drbd_ratelimit_state))
18501864
dev_err(DEV, "Local IO failed in %s.\n", where);
18511865
if (mdev->state.disk > D_INCONSISTENT)
@@ -1856,6 +1870,8 @@ static inline void __drbd_chk_io_error_(struct drbd_conf *mdev, int forcedetach,
18561870
case EP_DETACH:
18571871
case EP_CALL_HELPER:
18581872
set_bit(WAS_IO_ERROR, &mdev->flags);
1873+
if (forcedetach == DRBD_FORCE_DETACH)
1874+
set_bit(FORCE_DETACH, &mdev->flags);
18591875
if (mdev->state.disk > D_FAILED) {
18601876
_drbd_set_state(_NS(mdev, disk, D_FAILED), CS_HARD, NULL);
18611877
dev_err(DEV,
@@ -1875,7 +1891,7 @@ static inline void __drbd_chk_io_error_(struct drbd_conf *mdev, int forcedetach,
18751891
*/
18761892
#define drbd_chk_io_error(m,e,f) drbd_chk_io_error_(m,e,f, __func__)
18771893
static inline void drbd_chk_io_error_(struct drbd_conf *mdev,
1878-
int error, int forcedetach, const char *where)
1894+
int error, enum drbd_force_detach_flags forcedetach, const char *where)
18791895
{
18801896
if (error) {
18811897
unsigned long flags;
@@ -2405,15 +2421,17 @@ static inline void dec_ap_bio(struct drbd_conf *mdev)
24052421
int ap_bio = atomic_dec_return(&mdev->ap_bio_cnt);
24062422

24072423
D_ASSERT(ap_bio >= 0);
2424+
2425+
if (ap_bio == 0 && test_bit(BITMAP_IO, &mdev->flags)) {
2426+
if (!test_and_set_bit(BITMAP_IO_QUEUED, &mdev->flags))
2427+
drbd_queue_work(&mdev->data.work, &mdev->bm_io_work.w);
2428+
}
2429+
24082430
/* this currently does wake_up for every dec_ap_bio!
24092431
* maybe rather introduce some type of hysteresis?
24102432
* e.g. (ap_bio == mxb/2 || ap_bio == 0) ? */
24112433
if (ap_bio < mxb)
24122434
wake_up(&mdev->misc_wait);
2413-
if (ap_bio == 0 && test_bit(BITMAP_IO, &mdev->flags)) {
2414-
if (!test_and_set_bit(BITMAP_IO_QUEUED, &mdev->flags))
2415-
drbd_queue_work(&mdev->data.work, &mdev->bm_io_work.w);
2416-
}
24172435
}
24182436

24192437
static inline int drbd_set_ed_uuid(struct drbd_conf *mdev, u64 val)

drivers/block/drbd/drbd_main.c

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,13 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
15141514

15151515
/* Do not change the order of the if above and the two below... */
15161516
if (os.pdsk == D_DISKLESS && ns.pdsk > D_DISKLESS) { /* attach on the peer */
1517+
/* we probably will start a resync soon.
1518+
* make sure those things are properly reset. */
1519+
mdev->rs_total = 0;
1520+
mdev->rs_failed = 0;
1521+
atomic_set(&mdev->rs_pending_cnt, 0);
1522+
drbd_rs_cancel_all(mdev);
1523+
15171524
drbd_send_uuids(mdev);
15181525
drbd_send_state(mdev, ns);
15191526
}
@@ -1630,9 +1637,24 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
16301637
eh = mdev->ldev->dc.on_io_error;
16311638
was_io_error = test_and_clear_bit(WAS_IO_ERROR, &mdev->flags);
16321639

1633-
/* Immediately allow completion of all application IO, that waits
1634-
for completion from the local disk. */
1635-
tl_abort_disk_io(mdev);
1640+
if (was_io_error && eh == EP_CALL_HELPER)
1641+
drbd_khelper(mdev, "local-io-error");
1642+
1643+
/* Immediately allow completion of all application IO,
1644+
* that waits for completion from the local disk,
1645+
* if this was a force-detach due to disk_timeout
1646+
* or administrator request (drbdsetup detach --force).
1647+
* Do NOT abort otherwise.
1648+
* Aborting local requests may cause serious problems,
1649+
* if requests are completed to upper layers already,
1650+
* and then later the already submitted local bio completes.
1651+
* This can cause DMA into former bio pages that meanwhile
1652+
* have been re-used for other things.
1653+
* So aborting local requests may cause crashes,
1654+
* or even worse, silent data corruption.
1655+
*/
1656+
if (test_and_clear_bit(FORCE_DETACH, &mdev->flags))
1657+
tl_abort_disk_io(mdev);
16361658

16371659
/* current state still has to be D_FAILED,
16381660
* there is only one way out: to D_DISKLESS,
@@ -1653,9 +1675,6 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
16531675
drbd_md_sync(mdev);
16541676
}
16551677
put_ldev(mdev);
1656-
1657-
if (was_io_error && eh == EP_CALL_HELPER)
1658-
drbd_khelper(mdev, "local-io-error");
16591678
}
16601679

16611680
/* second half of local IO error, failure to attach,
@@ -1669,10 +1688,6 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
16691688
"ASSERT FAILED: disk is %s while going diskless\n",
16701689
drbd_disk_str(mdev->state.disk));
16711690

1672-
mdev->rs_total = 0;
1673-
mdev->rs_failed = 0;
1674-
atomic_set(&mdev->rs_pending_cnt, 0);
1675-
16761691
if (ns.conn >= C_CONNECTED)
16771692
drbd_send_state(mdev, ns);
16781693

@@ -2194,7 +2209,8 @@ int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags fl
21942209
{
21952210
struct p_sizes p;
21962211
sector_t d_size, u_size;
2197-
int q_order_type, max_bio_size;
2212+
int q_order_type;
2213+
unsigned int max_bio_size;
21982214
int ok;
21992215

22002216
if (get_ldev_if_state(mdev, D_NEGOTIATING)) {
@@ -2203,7 +2219,7 @@ int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags fl
22032219
u_size = mdev->ldev->dc.disk_size;
22042220
q_order_type = drbd_queue_order_type(mdev);
22052221
max_bio_size = queue_max_hw_sectors(mdev->ldev->backing_bdev->bd_disk->queue) << 9;
2206-
max_bio_size = min_t(int, max_bio_size, DRBD_MAX_BIO_SIZE);
2222+
max_bio_size = min(max_bio_size, DRBD_MAX_BIO_SIZE);
22072223
put_ldev(mdev);
22082224
} else {
22092225
d_size = 0;
@@ -2214,7 +2230,7 @@ int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags fl
22142230

22152231
/* Never allow old drbd (up to 8.3.7) to see more than 32KiB */
22162232
if (mdev->agreed_pro_version <= 94)
2217-
max_bio_size = min_t(int, max_bio_size, DRBD_MAX_SIZE_H80_PACKET);
2233+
max_bio_size = min(max_bio_size, DRBD_MAX_SIZE_H80_PACKET);
22182234

22192235
p.d_size = cpu_to_be64(d_size);
22202236
p.u_size = cpu_to_be64(u_size);
@@ -3541,6 +3557,22 @@ static int drbd_congested(void *congested_data, int bdi_bits)
35413557
goto out;
35423558
}
35433559

3560+
if (test_bit(CALLBACK_PENDING, &mdev->flags)) {
3561+
r |= (1 << BDI_async_congested);
3562+
/* Without good local data, we would need to read from remote,
3563+
* and that would need the worker thread as well, which is
3564+
* currently blocked waiting for that usermode helper to
3565+
* finish.
3566+
*/
3567+
if (!get_ldev_if_state(mdev, D_UP_TO_DATE))
3568+
r |= (1 << BDI_sync_congested);
3569+
else
3570+
put_ldev(mdev);
3571+
r &= bdi_bits;
3572+
reason = 'c';
3573+
goto out;
3574+
}
3575+
35443576
if (get_ldev(mdev)) {
35453577
q = bdev_get_queue(mdev->ldev->backing_bdev);
35463578
r = bdi_congested(&q->backing_dev_info, bdi_bits);
@@ -3604,6 +3636,7 @@ struct drbd_conf *drbd_new_device(unsigned int minor)
36043636
q->backing_dev_info.congested_data = mdev;
36053637

36063638
blk_queue_make_request(q, drbd_make_request);
3639+
blk_queue_flush(q, REQ_FLUSH | REQ_FUA);
36073640
/* Setting the max_hw_sectors to an odd value of 8kibyte here
36083641
This triggers a max_bio_size message upon first attach or connect */
36093642
blk_queue_max_hw_sectors(q, DRBD_MAX_BIO_SIZE_SAFE >> 8);
@@ -3870,7 +3903,7 @@ void drbd_md_sync(struct drbd_conf *mdev)
38703903
if (!drbd_md_sync_page_io(mdev, mdev->ldev, sector, WRITE)) {
38713904
/* this was a try anyways ... */
38723905
dev_err(DEV, "meta data update failed!\n");
3873-
drbd_chk_io_error(mdev, 1, true);
3906+
drbd_chk_io_error(mdev, 1, DRBD_META_IO_ERROR);
38743907
}
38753908

38763909
/* Update mdev->ldev->md.la_size_sect,
@@ -3950,9 +3983,9 @@ int drbd_md_read(struct drbd_conf *mdev, struct drbd_backing_dev *bdev)
39503983

39513984
spin_lock_irq(&mdev->req_lock);
39523985
if (mdev->state.conn < C_CONNECTED) {
3953-
int peer;
3986+
unsigned int peer;
39543987
peer = be32_to_cpu(buffer->la_peer_max_bio_size);
3955-
peer = max_t(int, peer, DRBD_MAX_BIO_SIZE_SAFE);
3988+
peer = max(peer, DRBD_MAX_BIO_SIZE_SAFE);
39563989
mdev->peer_max_bio_size = peer;
39573990
}
39583991
spin_unlock_irq(&mdev->req_lock);

0 commit comments

Comments
 (0)