diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-01-21 11:18:39 -0500 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2011-08-29 05:26:31 -0400 |
commit | dac1389ccc273b5486f2931c64c8e1672f233727 (patch) | |
tree | 51c0c5e5886928edbc7c9b8b5afa33d95698c507 /drivers/block | |
parent | de696716e8c40475d259fb49b3876ca0d9415970 (diff) |
drbd: Add read_requests tree
We do not do collision detection for read requests, but we still need to
look up the request objects when we receive a package over the network.
Using the same data structure for read and write requests results in
simpler code once the tl_hash and app_reads_hash tables are removed.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 3 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 1 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_req.c | 13 |
3 files changed, 13 insertions, 4 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index 058371318da4..46a4332d3441 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
@@ -1019,7 +1019,8 @@ struct drbd_conf { | |||
1019 | struct hlist_head *tl_hash; | 1019 | struct hlist_head *tl_hash; |
1020 | unsigned int tl_hash_s; | 1020 | unsigned int tl_hash_s; |
1021 | 1021 | ||
1022 | /* Interval tree of pending local write requests */ | 1022 | /* Interval tree of pending local requests */ |
1023 | struct rb_root read_requests; | ||
1023 | struct rb_root write_requests; | 1024 | struct rb_root write_requests; |
1024 | 1025 | ||
1025 | /* blocks to resync in this run [unit BM_BLOCK_SIZE] */ | 1026 | /* blocks to resync in this run [unit BM_BLOCK_SIZE] */ |
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 4d85838f53e3..c0ea5baa9a1b 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -3473,6 +3473,7 @@ struct drbd_conf *drbd_new_device(unsigned int minor) | |||
3473 | /* no need to lock access, we are still initializing this minor device. */ | 3473 | /* no need to lock access, we are still initializing this minor device. */ |
3474 | if (!tl_init(mdev)) | 3474 | if (!tl_init(mdev)) |
3475 | goto out_no_tl; | 3475 | goto out_no_tl; |
3476 | mdev->read_requests = RB_ROOT; | ||
3476 | mdev->write_requests = RB_ROOT; | 3477 | mdev->write_requests = RB_ROOT; |
3477 | 3478 | ||
3478 | mdev->app_reads_hash = kzalloc(APP_R_HSIZE*sizeof(void *), GFP_KERNEL); | 3479 | mdev->app_reads_hash = kzalloc(APP_R_HSIZE*sizeof(void *), GFP_KERNEL); |
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index 593576fcf64e..d2a78c4ee919 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c | |||
@@ -260,10 +260,15 @@ void _req_may_be_done(struct drbd_request *req, struct bio_and_error *m) | |||
260 | 260 | ||
261 | /* remove the request from the conflict detection | 261 | /* remove the request from the conflict detection |
262 | * respective block_id verification hash */ | 262 | * respective block_id verification hash */ |
263 | if (!hlist_unhashed(&req->collision)) { | 263 | if (!drbd_interval_empty(&req->i)) { |
264 | struct rb_root *root; | ||
265 | |||
264 | hlist_del(&req->collision); | 266 | hlist_del(&req->collision); |
265 | if (!drbd_interval_empty(&req->i)) | 267 | if (rw == WRITE) |
266 | drbd_remove_interval(&mdev->write_requests, &req->i); | 268 | root = &mdev->write_requests; |
269 | else | ||
270 | root = &mdev->read_requests; | ||
271 | drbd_remove_interval(root, &req->i); | ||
267 | } else | 272 | } else |
268 | D_ASSERT((s & (RQ_NET_MASK & ~RQ_NET_DONE)) == 0); | 273 | D_ASSERT((s & (RQ_NET_MASK & ~RQ_NET_DONE)) == 0); |
269 | 274 | ||
@@ -332,6 +337,7 @@ static int _req_conflicts(struct drbd_request *req) | |||
332 | struct hlist_head *slot; | 337 | struct hlist_head *slot; |
333 | 338 | ||
334 | D_ASSERT(hlist_unhashed(&req->collision)); | 339 | D_ASSERT(hlist_unhashed(&req->collision)); |
340 | D_ASSERT(drbd_interval_empty(&req->i)); | ||
335 | 341 | ||
336 | if (!get_net_conf(mdev)) | 342 | if (!get_net_conf(mdev)) |
337 | return 0; | 343 | return 0; |
@@ -493,6 +499,7 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what, | |||
493 | /* so we can verify the handle in the answer packet | 499 | /* so we can verify the handle in the answer packet |
494 | * corresponding hlist_del is in _req_may_be_done() */ | 500 | * corresponding hlist_del is in _req_may_be_done() */ |
495 | hlist_add_head(&req->collision, ar_hash_slot(mdev, req->i.sector)); | 501 | hlist_add_head(&req->collision, ar_hash_slot(mdev, req->i.sector)); |
502 | drbd_insert_interval(&mdev->read_requests, &req->i); | ||
496 | 503 | ||
497 | set_bit(UNPLUG_REMOTE, &mdev->flags); | 504 | set_bit(UNPLUG_REMOTE, &mdev->flags); |
498 | 505 | ||