Re: [PATCH 0/3] Convert nsproxy, groups, and creds to refcount_t

From: David Howells
Date: Tue Jul 21 2020 - 07:02:36 EST


> https://github.com/ereshetova/linux-stable/commits/refcount_t_fs

Looking at "fs, cachefiles: convert cachefiles_object.usage from atomic_t to
refcount_t", I see:

- u = atomic_inc_return(&object->usage);
+ refcount_inc(&object->usage);
trace_cachefiles_ref(object, _object->cookie,
- (enum cachefiles_obj_ref_trace)why, u);
+ (enum cachefiles_obj_ref_trace)why, refcount_read(&object->usage));
return &object->fscache;

This change is *not* equivalent. There's a reason I'm using
atomic_inc_return() and not atomic_inc(),atomic_read(). Yes, the small window
*does* occasionally produce incorrect tracing, and, yes, when that happens it
does make things confusing.

- u = atomic_dec_return(&object->usage);
trace_cachefiles_ref(object, _object->cookie,
- (enum cachefiles_obj_ref_trace)why, u);
- ASSERTCMP(u, !=, -1);
- if (u == 0) {
+ (enum cachefiles_obj_ref_trace)why, refcount_read(&object->usage) - 1);
+ if (refcount_dec_and_test(&object->usage)) {

This is also not equivalent. Again, there's a reason I'm using
atomic_dec_return() and not atomic_read(),atomic_dec_and_test().

So, please drop the cachefiles/fscache patches or use refcount_inc_return()
and refcount_dec_return().

Another reason to please drop these patches is that they will cause my
fscache-iter branch to bounce. A lot of this code is deleted/heavily
rewritten:

https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=fscache-iter

Thanks,
David