aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd/drbd_req.c
diff options
context:
space:
mode:
authorLars Ellenberg <lars.ellenberg@linbit.com>2013-03-19 13:16:50 -0400
committerJens Axboe <axboe@kernel.dk>2013-03-22 20:14:00 -0400
commit6d9febe237146156947f0da8407c620b5c33c1df (patch)
treef1839ad3ba66f255581b2f9e68b29d5a78c40642 /drivers/block/drbd/drbd_req.c
parentebfd5d8f715167b886c9401e6b123847187f137b (diff)
drbd: split __drbd_make_request in before and after drbd_al_begin_io
This is in preparation to be able to defer requests that need to wait for an activity log transaction to a submitter workqueue. Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/drbd/drbd_req.c')
-rw-r--r--drivers/block/drbd/drbd_req.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
index 7d1ff1aaeb71..96d5968fc1e4 100644
--- a/drivers/block/drbd/drbd_req.c
+++ b/drivers/block/drbd/drbd_req.c
@@ -34,14 +34,14 @@
34static bool drbd_may_do_local_read(struct drbd_conf *mdev, sector_t sector, int size); 34static bool drbd_may_do_local_read(struct drbd_conf *mdev, sector_t sector, int size);
35 35
36/* Update disk stats at start of I/O request */ 36/* Update disk stats at start of I/O request */
37static void _drbd_start_io_acct(struct drbd_conf *mdev, struct drbd_request *req, struct bio *bio) 37static void _drbd_start_io_acct(struct drbd_conf *mdev, struct drbd_request *req)
38{ 38{
39 const int rw = bio_data_dir(bio); 39 const int rw = bio_data_dir(req->master_bio);
40 int cpu; 40 int cpu;
41 cpu = part_stat_lock(); 41 cpu = part_stat_lock();
42 part_round_stats(cpu, &mdev->vdisk->part0); 42 part_round_stats(cpu, &mdev->vdisk->part0);
43 part_stat_inc(cpu, &mdev->vdisk->part0, ios[rw]); 43 part_stat_inc(cpu, &mdev->vdisk->part0, ios[rw]);
44 part_stat_add(cpu, &mdev->vdisk->part0, sectors[rw], bio_sectors(bio)); 44 part_stat_add(cpu, &mdev->vdisk->part0, sectors[rw], req->i.size >> 9);
45 (void) cpu; /* The macro invocations above want the cpu argument, I do not like 45 (void) cpu; /* The macro invocations above want the cpu argument, I do not like
46 the compiler warning about cpu only assigned but never used... */ 46 the compiler warning about cpu only assigned but never used... */
47 part_inc_in_flight(&mdev->vdisk->part0, rw); 47 part_inc_in_flight(&mdev->vdisk->part0, rw);
@@ -1020,12 +1020,16 @@ drbd_submit_req_private_bio(struct drbd_request *req)
1020 bio_endio(bio, -EIO); 1020 bio_endio(bio, -EIO);
1021} 1021}
1022 1022
1023void __drbd_make_request(struct drbd_conf *mdev, struct bio *bio, unsigned long start_time) 1023/* returns the new drbd_request pointer, if the caller is expected to
1024 * drbd_send_and_submit() it (to save latency), or NULL if we queued the
1025 * request on the submitter thread.
1026 * Returns ERR_PTR(-ENOMEM) if we cannot allocate a drbd_request.
1027 */
1028struct drbd_request *
1029drbd_request_prepare(struct drbd_conf *mdev, struct bio *bio, unsigned long start_time)
1024{ 1030{
1025 const int rw = bio_rw(bio); 1031 const int rw = bio_data_dir(bio);
1026 struct bio_and_error m = { NULL, };
1027 struct drbd_request *req; 1032 struct drbd_request *req;
1028 bool no_remote = false;
1029 1033
1030 /* allocate outside of all locks; */ 1034 /* allocate outside of all locks; */
1031 req = drbd_req_new(mdev, bio); 1035 req = drbd_req_new(mdev, bio);
@@ -1035,7 +1039,7 @@ void __drbd_make_request(struct drbd_conf *mdev, struct bio *bio, unsigned long
1035 * if user cannot handle io errors, that's not our business. */ 1039 * if user cannot handle io errors, that's not our business. */
1036 dev_err(DEV, "could not kmalloc() req\n"); 1040 dev_err(DEV, "could not kmalloc() req\n");
1037 bio_endio(bio, -ENOMEM); 1041 bio_endio(bio, -ENOMEM);
1038 return; 1042 return ERR_PTR(-ENOMEM);
1039 } 1043 }
1040 req->start_time = start_time; 1044 req->start_time = start_time;
1041 1045
@@ -1057,6 +1061,15 @@ void __drbd_make_request(struct drbd_conf *mdev, struct bio *bio, unsigned long
1057 drbd_al_begin_io(mdev, &req->i, true); 1061 drbd_al_begin_io(mdev, &req->i, true);
1058 } 1062 }
1059 1063
1064 return req;
1065}
1066
1067static void drbd_send_and_submit(struct drbd_conf *mdev, struct drbd_request *req)
1068{
1069 const int rw = bio_rw(req->master_bio);
1070 struct bio_and_error m = { NULL, };
1071 bool no_remote = false;
1072
1060 spin_lock_irq(&mdev->tconn->req_lock); 1073 spin_lock_irq(&mdev->tconn->req_lock);
1061 if (rw == WRITE) { 1074 if (rw == WRITE) {
1062 /* This may temporarily give up the req_lock, 1075 /* This may temporarily give up the req_lock,
@@ -1079,7 +1092,7 @@ void __drbd_make_request(struct drbd_conf *mdev, struct bio *bio, unsigned long
1079 } 1092 }
1080 1093
1081 /* Update disk stats */ 1094 /* Update disk stats */
1082 _drbd_start_io_acct(mdev, req, bio); 1095 _drbd_start_io_acct(mdev, req);
1083 1096
1084 /* We fail READ/READA early, if we can not serve it. 1097 /* We fail READ/READA early, if we can not serve it.
1085 * We must do this before req is registered on any lists. 1098 * We must do this before req is registered on any lists.
@@ -1137,7 +1150,14 @@ out:
1137 1150
1138 if (m.bio) 1151 if (m.bio)
1139 complete_master_bio(mdev, &m); 1152 complete_master_bio(mdev, &m);
1140 return; 1153}
1154
1155void __drbd_make_request(struct drbd_conf *mdev, struct bio *bio, unsigned long start_time)
1156{
1157 struct drbd_request *req = drbd_request_prepare(mdev, bio, start_time);
1158 if (IS_ERR_OR_NULL(req))
1159 return;
1160 drbd_send_and_submit(mdev, req);
1141} 1161}
1142 1162
1143void drbd_make_request(struct request_queue *q, struct bio *bio) 1163void drbd_make_request(struct request_queue *q, struct bio *bio)