@@ -58,7 +58,7 @@ struct fuse_file *fuse_file_alloc(struct fuse_conn *fc)
58
58
}
59
59
60
60
INIT_LIST_HEAD (& ff -> write_entry );
61
- atomic_set (& ff -> count , 0 );
61
+ atomic_set (& ff -> count , 1 );
62
62
RB_CLEAR_NODE (& ff -> polled_node );
63
63
init_waitqueue_head (& ff -> poll_wait );
64
64
@@ -75,7 +75,7 @@ void fuse_file_free(struct fuse_file *ff)
75
75
kfree (ff );
76
76
}
77
77
78
- struct fuse_file * fuse_file_get (struct fuse_file * ff )
78
+ static struct fuse_file * fuse_file_get (struct fuse_file * ff )
79
79
{
80
80
atomic_inc (& ff -> count );
81
81
return ff ;
@@ -100,6 +100,7 @@ static void fuse_file_put(struct fuse_file *ff, bool sync)
100
100
iput (req -> misc .release .inode );
101
101
fuse_put_request (ff -> fc , req );
102
102
} else if (sync ) {
103
+ __set_bit (FR_FORCE , & req -> flags );
103
104
__clear_bit (FR_BACKGROUND , & req -> flags );
104
105
fuse_request_send (ff -> fc , req );
105
106
iput (req -> misc .release .inode );
@@ -146,7 +147,7 @@ int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,
146
147
ff -> open_flags &= ~FOPEN_DIRECT_IO ;
147
148
148
149
ff -> nodeid = nodeid ;
149
- file -> private_data = fuse_file_get ( ff ) ;
150
+ file -> private_data = ff ;
150
151
151
152
return 0 ;
152
153
}
@@ -245,14 +246,9 @@ static void fuse_prepare_release(struct fuse_file *ff, int flags, int opcode)
245
246
246
247
void fuse_release_common (struct file * file , int opcode )
247
248
{
248
- struct fuse_file * ff ;
249
- struct fuse_req * req ;
250
-
251
- ff = file -> private_data ;
252
- if (unlikely (!ff ))
253
- return ;
249
+ struct fuse_file * ff = file -> private_data ;
250
+ struct fuse_req * req = ff -> reserved_req ;
254
251
255
- req = ff -> reserved_req ;
256
252
fuse_prepare_release (ff , file -> f_flags , opcode );
257
253
258
254
if (ff -> flock ) {
@@ -297,13 +293,13 @@ static int fuse_release(struct inode *inode, struct file *file)
297
293
298
294
void fuse_sync_release (struct fuse_file * ff , int flags )
299
295
{
300
- WARN_ON (atomic_read (& ff -> count ) > 1 );
296
+ WARN_ON (atomic_read (& ff -> count ) != 1 );
301
297
fuse_prepare_release (ff , flags , FUSE_RELEASE );
302
- __set_bit ( FR_FORCE , & ff -> reserved_req -> flags );
303
- __clear_bit ( FR_BACKGROUND , & ff -> reserved_req -> flags );
304
- fuse_request_send ( ff -> fc , ff -> reserved_req );
305
- fuse_put_request ( ff -> fc , ff -> reserved_req );
306
- kfree (ff );
298
+ /*
299
+ * iput(NULL) is a no-op and since the refcount is 1 and everything's
300
+ * synchronous, we are fine with not doing igrab() here"
301
+ */
302
+ fuse_file_put (ff , true );
307
303
}
308
304
EXPORT_SYMBOL_GPL (fuse_sync_release );
309
305
0 commit comments