Re: [PATCH v3] fs: Replace user_access_{begin/end} by scoped user access

From: Christophe Leroy (CS GROUP)

Date: Tue Mar 24 2026 - 07:59:40 EST




Le 18/03/2026 à 16:53, Linus Torvalds a écrit :
On Wed, 18 Mar 2026 at 08:49, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

#define dirent_size(dirent, len) offsetof(typeof(dirent), d_name[len])

That 'typeof(dirent)' needs to be 'typeof(*(dirent))' to be convenient.

It was correct in the patch I attached, but I'll just point it out anyway.

And we actually have a helper macro for that: struct_offset(). Which
wasn't what I used in that attached patch, but *should* have been.

IOW, the macro should look something like

#define dirent_size(dirent, len) struct_offset(dirent, d_name[len])


Sending v5 (series of 2) with your suggested patch as patch 1.

Following feedback from David which I tend to agree with, I left it as you did initialy.

struct_offset() has only one caller and I don't feel it has much added value compared to offsetof(typeof(),) pattern which is more explicit and already used 144 times in the kernel:

$ git grep "offsetof(typeof(" | wc -l
144

Christophe