@@ -362,18 +362,28 @@ static int ceph_init_request(struct netfs_io_request *rreq, struct file *file)
362
362
{
363
363
struct inode * inode = rreq -> inode ;
364
364
int got = 0 , want = CEPH_CAP_FILE_CACHE ;
365
+ struct ceph_netfs_request_data * priv ;
365
366
int ret = 0 ;
366
367
367
368
if (rreq -> origin != NETFS_READAHEAD )
368
369
return 0 ;
369
370
371
+ priv = kzalloc (sizeof (* priv ), GFP_NOFS );
372
+ if (!priv )
373
+ return - ENOMEM ;
374
+
370
375
if (file ) {
371
376
struct ceph_rw_context * rw_ctx ;
372
377
struct ceph_file_info * fi = file -> private_data ;
373
378
379
+ priv -> file_ra_pages = file -> f_ra .ra_pages ;
380
+ priv -> file_ra_disabled = file -> f_mode & FMODE_RANDOM ;
381
+
374
382
rw_ctx = ceph_find_rw_context (fi );
375
- if (rw_ctx )
383
+ if (rw_ctx ) {
384
+ rreq -> netfs_priv = priv ;
376
385
return 0 ;
386
+ }
377
387
}
378
388
379
389
/*
@@ -383,27 +393,40 @@ static int ceph_init_request(struct netfs_io_request *rreq, struct file *file)
383
393
ret = ceph_try_get_caps (inode , CEPH_CAP_FILE_RD , want , true, & got );
384
394
if (ret < 0 ) {
385
395
dout ("start_read %p, error getting cap\n" , inode );
386
- return ret ;
396
+ goto out ;
387
397
}
388
398
389
399
if (!(got & want )) {
390
400
dout ("start_read %p, no cache cap\n" , inode );
391
- return - EACCES ;
401
+ ret = - EACCES ;
402
+ goto out ;
403
+ }
404
+ if (ret == 0 ) {
405
+ ret = - EACCES ;
406
+ goto out ;
392
407
}
393
- if (ret == 0 )
394
- return - EACCES ;
395
408
396
- rreq -> netfs_priv = (void * )(uintptr_t )got ;
397
- return 0 ;
409
+ priv -> caps = got ;
410
+ rreq -> netfs_priv = priv ;
411
+
412
+ out :
413
+ if (ret < 0 )
414
+ kfree (priv );
415
+
416
+ return ret ;
398
417
}
399
418
400
419
static void ceph_netfs_free_request (struct netfs_io_request * rreq )
401
420
{
402
- struct ceph_inode_info * ci = ceph_inode (rreq -> inode );
403
- int got = (uintptr_t )rreq -> netfs_priv ;
421
+ struct ceph_netfs_request_data * priv = rreq -> netfs_priv ;
422
+
423
+ if (!priv )
424
+ return ;
404
425
405
- if (got )
406
- ceph_put_cap_refs (ci , got );
426
+ if (priv -> caps )
427
+ ceph_put_cap_refs (ceph_inode (rreq -> inode ), priv -> caps );
428
+ kfree (priv );
429
+ rreq -> netfs_priv = NULL ;
407
430
}
408
431
409
432
const struct netfs_request_ops ceph_netfs_ops = {
0 commit comments