File tree Expand file tree Collapse file tree 2 files changed +7
-14
lines changed Expand file tree Collapse file tree 2 files changed +7
-14
lines changed Original file line number Diff line number Diff line change 26
26
27
27
#include "internal.h"
28
28
29
- bool __file_ref_put_badval (file_ref_t * ref , unsigned long cnt )
29
+ static noinline bool __file_ref_put_badval (file_ref_t * ref , unsigned long cnt )
30
30
{
31
31
/*
32
32
* If the reference count was already in the dead zone, then this
Original file line number Diff line number Diff line change @@ -61,7 +61,6 @@ static inline void file_ref_init(file_ref_t *ref, unsigned long cnt)
61
61
atomic_long_set (& ref -> refcnt , cnt - 1 );
62
62
}
63
63
64
- bool __file_ref_put_badval (file_ref_t * ref , unsigned long cnt );
65
64
bool __file_ref_put (file_ref_t * ref , unsigned long cnt );
66
65
67
66
/**
@@ -178,20 +177,14 @@ static __always_inline __must_check bool file_ref_put(file_ref_t *ref)
178
177
*/
179
178
static __always_inline __must_check bool file_ref_put_close (file_ref_t * ref )
180
179
{
181
- long old , new ;
180
+ long old ;
182
181
183
182
old = atomic_long_read (& ref -> refcnt );
184
- do {
185
- if (unlikely (old < 0 ))
186
- return __file_ref_put_badval (ref , old );
187
-
188
- if (old == FILE_REF_ONEREF )
189
- new = FILE_REF_DEAD ;
190
- else
191
- new = old - 1 ;
192
- } while (!atomic_long_try_cmpxchg (& ref -> refcnt , & old , new ));
193
-
194
- return new == FILE_REF_DEAD ;
183
+ if (likely (old == FILE_REF_ONEREF )) {
184
+ if (likely (atomic_long_try_cmpxchg (& ref -> refcnt , & old , FILE_REF_DEAD )))
185
+ return true;
186
+ }
187
+ return file_ref_put (ref );
195
188
}
196
189
197
190
/**
You can’t perform that action at this time.
0 commit comments