diff options
author | Lars Ellenberg <lars.ellenberg@linbit.com> | 2010-08-11 17:28:00 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2010-10-14 12:38:19 -0400 |
commit | 80a40e439e5a3f30b0a6210a1add6d7c33392e54 (patch) | |
tree | 4442914b7bb70a1d9bde4be3cd3eb7085738ed66 /drivers/block/drbd/drbd_receiver.c | |
parent | 1d7734a0df02ff5068ff8baa1447c7baee601db1 (diff) |
drbd: reduce code duplication when receiving data requests
also canonicalize the return values of read_for_csum
and drbd_rs_begin_io to return -ESOMETHING, or 0 for success.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_receiver.c')
-rw-r--r-- | drivers/block/drbd/drbd_receiver.c | 46 |
1 files changed, 12 insertions, 34 deletions
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 2f9320be4906..346aed98027f 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c | |||
@@ -2068,21 +2068,12 @@ static int receive_DataRequest(struct drbd_conf *mdev, struct p_header *h) | |||
2068 | case P_DATA_REQUEST: | 2068 | case P_DATA_REQUEST: |
2069 | e->w.cb = w_e_end_data_req; | 2069 | e->w.cb = w_e_end_data_req; |
2070 | fault_type = DRBD_FAULT_DT_RD; | 2070 | fault_type = DRBD_FAULT_DT_RD; |
2071 | break; | 2071 | /* application IO, don't drbd_rs_begin_io */ |
2072 | goto submit; | ||
2073 | |||
2072 | case P_RS_DATA_REQUEST: | 2074 | case P_RS_DATA_REQUEST: |
2073 | e->w.cb = w_e_end_rsdata_req; | 2075 | e->w.cb = w_e_end_rsdata_req; |
2074 | fault_type = DRBD_FAULT_RS_RD; | 2076 | fault_type = DRBD_FAULT_RS_RD; |
2075 | /* Eventually this should become asynchronously. Currently it | ||
2076 | * blocks the whole receiver just to delay the reading of a | ||
2077 | * resync data block. | ||
2078 | * the drbd_work_queue mechanism is made for this... | ||
2079 | */ | ||
2080 | if (!drbd_rs_begin_io(mdev, sector)) { | ||
2081 | /* we have been interrupted, | ||
2082 | * probably connection lost! */ | ||
2083 | D_ASSERT(signal_pending(current)); | ||
2084 | goto out_free_e; | ||
2085 | } | ||
2086 | break; | 2077 | break; |
2087 | 2078 | ||
2088 | case P_OV_REPLY: | 2079 | case P_OV_REPLY: |
@@ -2108,13 +2099,8 @@ static int receive_DataRequest(struct drbd_conf *mdev, struct p_header *h) | |||
2108 | } else if (h->command == P_OV_REPLY) { | 2099 | } else if (h->command == P_OV_REPLY) { |
2109 | e->w.cb = w_e_end_ov_reply; | 2100 | e->w.cb = w_e_end_ov_reply; |
2110 | dec_rs_pending(mdev); | 2101 | dec_rs_pending(mdev); |
2111 | break; | 2102 | /* drbd_rs_begin_io done when we sent this request */ |
2112 | } | 2103 | goto submit; |
2113 | |||
2114 | if (!drbd_rs_begin_io(mdev, sector)) { | ||
2115 | /* we have been interrupted, probably connection lost! */ | ||
2116 | D_ASSERT(signal_pending(current)); | ||
2117 | goto out_free_e; | ||
2118 | } | 2104 | } |
2119 | break; | 2105 | break; |
2120 | 2106 | ||
@@ -2133,31 +2119,23 @@ static int receive_DataRequest(struct drbd_conf *mdev, struct p_header *h) | |||
2133 | } | 2119 | } |
2134 | e->w.cb = w_e_end_ov_req; | 2120 | e->w.cb = w_e_end_ov_req; |
2135 | fault_type = DRBD_FAULT_RS_RD; | 2121 | fault_type = DRBD_FAULT_RS_RD; |
2136 | /* Eventually this should become asynchronous. Currently it | ||
2137 | * blocks the whole receiver just to delay the reading of a | ||
2138 | * resync data block. | ||
2139 | * the drbd_work_queue mechanism is made for this... | ||
2140 | */ | ||
2141 | if (!drbd_rs_begin_io(mdev, sector)) { | ||
2142 | /* we have been interrupted, | ||
2143 | * probably connection lost! */ | ||
2144 | D_ASSERT(signal_pending(current)); | ||
2145 | goto out_free_e; | ||
2146 | } | ||
2147 | break; | 2122 | break; |
2148 | 2123 | ||
2149 | |||
2150 | default: | 2124 | default: |
2151 | dev_err(DEV, "unexpected command (%s) in receive_DataRequest\n", | 2125 | dev_err(DEV, "unexpected command (%s) in receive_DataRequest\n", |
2152 | cmdname(h->command)); | 2126 | cmdname(h->command)); |
2153 | fault_type = DRBD_FAULT_MAX; | 2127 | fault_type = DRBD_FAULT_MAX; |
2128 | goto out_free_e; | ||
2154 | } | 2129 | } |
2155 | 2130 | ||
2156 | spin_lock_irq(&mdev->req_lock); | 2131 | if (drbd_rs_begin_io(mdev, e->sector)) |
2157 | list_add(&e->w.list, &mdev->read_ee); | 2132 | goto out_free_e; |
2158 | spin_unlock_irq(&mdev->req_lock); | ||
2159 | 2133 | ||
2134 | submit: | ||
2160 | inc_unacked(mdev); | 2135 | inc_unacked(mdev); |
2136 | spin_lock_irq(&mdev->req_lock); | ||
2137 | list_add_tail(&e->w.list, &mdev->read_ee); | ||
2138 | spin_unlock_irq(&mdev->req_lock); | ||
2161 | 2139 | ||
2162 | if (drbd_submit_ee(mdev, e, READ, fault_type) == 0) | 2140 | if (drbd_submit_ee(mdev, e, READ, fault_type) == 0) |
2163 | return TRUE; | 2141 | return TRUE; |