@@ -305,7 +305,6 @@ ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
305
305
{
306
306
struct cachefiles_req * req ;
307
307
struct cachefiles_msg * msg ;
308
- unsigned long id = 0 ;
309
308
size_t n ;
310
309
int ret = 0 ;
311
310
XA_STATE (xas , & cache -> reqs , cache -> req_id_next );
@@ -340,49 +339,37 @@ ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
340
339
cachefiles_grab_object (req -> object , cachefiles_obj_get_read_req );
341
340
xa_unlock (& cache -> reqs );
342
341
343
- id = xas .xa_index ;
344
-
345
342
if (msg -> opcode == CACHEFILES_OP_OPEN ) {
346
343
ret = cachefiles_ondemand_get_fd (req );
347
344
if (ret ) {
348
345
cachefiles_ondemand_set_object_close (req -> object );
349
- goto error ;
346
+ goto out ;
350
347
}
351
348
}
352
349
353
- msg -> msg_id = id ;
350
+ msg -> msg_id = xas . xa_index ;
354
351
msg -> object_id = req -> object -> ondemand -> ondemand_id ;
355
352
356
353
if (copy_to_user (_buffer , msg , n ) != 0 ) {
357
354
ret = - EFAULT ;
358
- goto err_put_fd ;
359
- }
360
-
361
- cachefiles_put_object (req -> object , cachefiles_obj_put_read_req );
362
- /* CLOSE request has no reply */
363
- if (msg -> opcode == CACHEFILES_OP_CLOSE ) {
364
- xa_erase (& cache -> reqs , id );
365
- complete (& req -> done );
355
+ if (msg -> opcode == CACHEFILES_OP_OPEN )
356
+ close_fd (((struct cachefiles_open * )msg -> data )-> fd );
366
357
}
367
-
368
- cachefiles_req_put (req );
369
- return n ;
370
-
371
- err_put_fd :
372
- if (msg -> opcode == CACHEFILES_OP_OPEN )
373
- close_fd (((struct cachefiles_open * )msg -> data )-> fd );
374
- error :
358
+ out :
375
359
cachefiles_put_object (req -> object , cachefiles_obj_put_read_req );
376
- xas_reset (& xas );
377
- xas_lock (& xas );
378
- if (xas_load (& xas ) == req ) {
379
- req -> error = ret ;
380
- complete (& req -> done );
381
- xas_store (& xas , NULL );
360
+ /* Remove error request and CLOSE request has no reply */
361
+ if (ret || msg -> opcode == CACHEFILES_OP_CLOSE ) {
362
+ xas_reset (& xas );
363
+ xas_lock (& xas );
364
+ if (xas_load (& xas ) == req ) {
365
+ req -> error = ret ;
366
+ complete (& req -> done );
367
+ xas_store (& xas , NULL );
368
+ }
369
+ xas_unlock (& xas );
382
370
}
383
- xas_unlock (& xas );
384
371
cachefiles_req_put (req );
385
- return ret ;
372
+ return ret ? ret : n ;
386
373
}
387
374
388
375
typedef int (* init_req_fn )(struct cachefiles_req * req , void * private );
0 commit comments