@@ -57,6 +57,16 @@ static void __cachefiles_unmark_inode_in_use(struct cachefiles_object *object,
57
57
trace_cachefiles_mark_inactive (object , inode );
58
58
}
59
59
60
+ static void cachefiles_do_unmark_inode_in_use (struct cachefiles_object * object ,
61
+ struct dentry * dentry )
62
+ {
63
+ struct inode * inode = d_backing_inode (dentry );
64
+
65
+ inode_lock (inode );
66
+ __cachefiles_unmark_inode_in_use (object , dentry );
67
+ inode_unlock (inode );
68
+ }
69
+
60
70
/*
61
71
* Unmark a backing inode and tell cachefilesd that there's something that can
62
72
* be culled.
@@ -68,9 +78,7 @@ void cachefiles_unmark_inode_in_use(struct cachefiles_object *object,
68
78
struct inode * inode = file_inode (file );
69
79
70
80
if (inode ) {
71
- inode_lock (inode );
72
- __cachefiles_unmark_inode_in_use (object , file -> f_path .dentry );
73
- inode_unlock (inode );
81
+ cachefiles_do_unmark_inode_in_use (object , file -> f_path .dentry );
74
82
75
83
if (!test_bit (CACHEFILES_OBJECT_USING_TMPFILE , & object -> flags )) {
76
84
atomic_long_add (inode -> i_blocks , & cache -> b_released );
@@ -484,7 +492,7 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object)
484
492
object , d_backing_inode (path .dentry ), ret ,
485
493
cachefiles_trace_trunc_error );
486
494
file = ERR_PTR (ret );
487
- goto out_dput ;
495
+ goto out_unuse ;
488
496
}
489
497
}
490
498
@@ -494,15 +502,20 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object)
494
502
trace_cachefiles_vfs_error (object , d_backing_inode (path .dentry ),
495
503
PTR_ERR (file ),
496
504
cachefiles_trace_open_error );
497
- goto out_dput ;
505
+ goto out_unuse ;
498
506
}
499
507
if (unlikely (!file -> f_op -> read_iter ) ||
500
508
unlikely (!file -> f_op -> write_iter )) {
501
509
fput (file );
502
510
pr_notice ("Cache does not support read_iter and write_iter\n" );
503
511
file = ERR_PTR (- EINVAL );
512
+ goto out_unuse ;
504
513
}
505
514
515
+ goto out_dput ;
516
+
517
+ out_unuse :
518
+ cachefiles_do_unmark_inode_in_use (object , path .dentry );
506
519
out_dput :
507
520
dput (path .dentry );
508
521
out :
@@ -590,14 +603,16 @@ static bool cachefiles_open_file(struct cachefiles_object *object,
590
603
check_failed :
591
604
fscache_cookie_lookup_negative (object -> cookie );
592
605
cachefiles_unmark_inode_in_use (object , file );
593
- if ( ret == - ESTALE ) {
594
- fput ( file );
595
- dput ( dentry );
606
+ fput ( file );
607
+ dput ( dentry );
608
+ if ( ret == - ESTALE )
596
609
return cachefiles_create_file (object );
597
- }
610
+ return false;
611
+
598
612
error_fput :
599
613
fput (file );
600
614
error :
615
+ cachefiles_do_unmark_inode_in_use (object , dentry );
601
616
dput (dentry );
602
617
return false;
603
618
}
0 commit comments