Re: [PATCH v2] nfs: add dummy definition for nfsd_file

Vincent Mailhol
2025-04-23T08:55:35Z

On 23/04/2025 at 09:32, NeilBrown wrote:
> On Wed, 23 Apr 2025, Pali Rohár wrote:
>> On Wednesday 23 April 2025 07:54:40 NeilBrown wrote:
>>> On Wed, 23 Apr 2025, Pali Rohár wrote:

(...)

>>> Actually I do object to this fix (though I've been busy and hadn't had
>>> much change to look at it properly).
>>> The fix is ugly. At the very least it should be wrapping in an
>>> #if GCC_VERSION < whatever

I acknowledge that the fix is a bit ugly, but Mike is the only one who
has proposed a solution so far.

One other solution would be to directly modify the rcupdate helpers. I
am not sure of rcupdate's internals, but as far as I understand, in C,
attributes or qualifier can be either before or after the type. For
example,

const char *

is the same as

char const *

The only thing which matters is to have the qualifier or the attribute
before the * (otherwise, it will apply to the pointed value and not to
the pointer itself).

Below patch solves the build problem:

--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -522,29 +522,29 @@ static inline bool lockdep_assert_rcu_helper(bool c)

#define __rcu_access_pointer(p, local, space) \
({ \
- typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
+ typeof(p) local = (__force typeof(p))READ_ONCE(p); \
rcu_check_sparse(p, space); \
- ((typeof(*p) __force __kernel *)(local)); \
+ (__force __kernel typeof(p))(local); \
})
#define __rcu_dereference_check(p, local, c, space) \
({ \
/* Dependency order vs. p above. */ \
- typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
+ typeof(p) local = (__force typeof(p))READ_ONCE(p); \
RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_check() usage"); \
rcu_check_sparse(p, space); \
- ((typeof(*p) __force __kernel *)(local)); \
+ (__force __kernel typeof(p))(local); \
})
#define __rcu_dereference_protected(p, local, c, space) \
({ \
RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_protected() usage"); \
rcu_check_sparse(p, space); \
- ((typeof(*p) __force __kernel *)(p)); \
+ (__force __kernel typeof(p))(p); \
})
#define __rcu_dereference_raw(p, local) \
({ \
/* Dependency order vs. p above. */ \
typeof(p) local = READ_ONCE(p); \
- ((typeof(*p) __force __kernel *)(local)); \
+ (__force __kernel typeof(p))(local); \
})
#define rcu_dereference_raw(p) __rcu_dereference_raw(p, __UNIQUE_ID(rcu))

---

Does the above make more sense? If so, I can formalize it and submit
it.

Yours sincerely,
Vincent Mailhol