@@ -221,62 +221,79 @@ static void ocf_req_complete(struct ocf_request *req, int error)
221221 ocf_io_put (& req -> ioi .io );
222222}
223223
224- static int ocf_core_submit_io_fast (struct ocf_io * io , struct ocf_request * req ,
225- ocf_core_t core , ocf_cache_t cache )
224+ static inline int _ocf_core_submit_io_fast_rd_generic (struct ocf_io * io ,
225+ struct ocf_request * req )
226226{
227- ocf_req_cache_mode_t original_cache_mode ;
228- int fast ;
229-
230- if (req -> d2c ) {
231- return - OCF_ERR_IO ;
232- }
227+ int res ;
233228
234229 switch (req -> cache_mode ) {
235- case ocf_req_cache_mode_wt :
236- case ocf_req_cache_mode_wa :
237- case ocf_req_cache_mode_wi :
238- if (io -> dir == OCF_READ && req -> core_line_count <= MAX_FAST_PATH_CACHE_LINES ) {
239- if (ocf_read_generic_fast (req ))
240- return 0 ;
241- ocf_req_clear_map (req );
242- }
243- break ;
244-
245- case ocf_req_cache_mode_wb :
246- case ocf_req_cache_mode_wo :
247- if (io -> dir == OCF_READ && req -> core_line_count <= MAX_FAST_PATH_CACHE_LINES )
248- return ocf_read_generic_fast (req ) ? 0 : - OCF_ERR_IO ;
249- break ;
250- default :
251- break ;
230+ case ocf_req_cache_mode_wt :
231+ case ocf_req_cache_mode_wa :
232+ case ocf_req_cache_mode_wi :
233+ case ocf_req_cache_mode_wb :
234+ case ocf_req_cache_mode_wo :
235+ res = ocf_read_generic_try_fast (req );
236+ break ;
237+ default :
238+ break ;
252239 }
253240
254- original_cache_mode = req -> cache_mode ;
241+ if (res == OCF_FAST_PATH_NO )
242+ ocf_req_clear_map (req );
243+
244+ return res ;
245+ }
255246
247+ static inline ocf_req_cache_mode_t _ocf_core_req_resolve_fast_mode (
248+ ocf_cache_t cache , struct ocf_request * req )
249+ {
256250 switch (req -> cache_mode ) {
257- case ocf_req_cache_mode_pt :
258- return - OCF_ERR_IO ;
259- case ocf_req_cache_mode_wb :
260- case ocf_req_cache_mode_wo :
261- if (io -> dir == OCF_WRITE )
262- req -> cache_mode = ocf_req_cache_mode_fast ;
263- break ;
264- default :
265- if (cache -> use_submit_io_fast )
251+ case ocf_req_cache_mode_wb :
252+ case ocf_req_cache_mode_wo :
253+ return ocf_req_cache_mode_fast ;
254+ default :
266255 break ;
256+ }
267257
268- if (io -> dir == OCF_WRITE )
269- return - OCF_ERR_IO ;
258+ if (! cache -> use_submit_io_fast )
259+ return ocf_req_cache_mode_max ;
270260
271- req -> cache_mode = ocf_req_cache_mode_fast ;
261+ return ocf_req_cache_mode_fast ;
262+ }
263+
264+ static int ocf_core_submit_io_fast (struct ocf_io * io , struct ocf_request * req ,
265+ ocf_cache_t cache )
266+ {
267+ ocf_req_cache_mode_t original_mode , resolved_mode ;
268+ int ret ;
269+
270+ if (req -> d2c ) {
271+ return OCF_FAST_PATH_NO ;
272272 }
273273
274- fast = ocf_engine_hndl_fast_req (req );
275- if (fast != OCF_FAST_PATH_NO )
276- return 0 ;
274+ if (req -> cache_mode == ocf_req_cache_mode_pt )
275+ return OCF_FAST_PATH_NO ;
276+
277+ /* If a read request isn't too big for a lookup in submission context,
278+ check it is a read-hit and if cache line lock could be acquired
279+ without waiting. If so, submit immediately */
280+ if (req -> rw == OCF_READ ) {
281+ if (req -> core_line_count <= MAX_FAST_PATH_CACHE_LINES )
282+ return _ocf_core_submit_io_fast_rd_generic (io , req );
283+ }
284+
285+ resolved_mode = _ocf_core_req_resolve_fast_mode (cache , req );
286+ if (resolved_mode == ocf_req_cache_mode_max )
287+ return OCF_FAST_PATH_NO ;
288+
289+ original_mode = req -> cache_mode ;
290+ req -> cache_mode = resolved_mode ;
291+
292+ ret = ocf_engine_hndl_fast_req (req );
293+ if (ret == OCF_FAST_PATH_NO )
294+ req -> cache_mode = original_mode ;
277295
278- req -> cache_mode = original_cache_mode ;
279- return - OCF_ERR_IO ;
296+ return ret ;
280297}
281298
282299static void ocf_core_volume_submit_io (struct ocf_io * io )
@@ -321,7 +338,7 @@ static void ocf_core_volume_submit_io(struct ocf_io *io)
321338 /* Prevent race condition */
322339 ocf_req_get (req );
323340
324- if (! ocf_core_submit_io_fast (io , req , core , cache )) {
341+ if (ocf_core_submit_io_fast (io , req , cache ) == OCF_FAST_PATH_YES ) {
325342 ocf_core_seq_cutoff_update (core , req );
326343 ocf_req_put (req );
327344 return ;
0 commit comments