Including <sys/tmpfs.h> into non-kernel software leads to a compilation error because, without _KERNEL defined, the macro TMPFS_VALIDATE_DIR is invoked, but never defined. User-level software that includes sys/tmpfs.h must define _KERNEL to make the definition of TMPFS_VALIDATE_DIR visible.
Then, that software depends on <sys/lock.h> to be included to define MPASS. If that software doesn't include <sys/lock.h> itself, then changes in system headers could cause an indirect inclusion of <sys/lock.h> to disappear, and introduce compilation errors and warnings where there were none previously.
This change puts all the inline functions that, directly or indirectly, invoke MPASS into the scope of the _KERNEL block, allowing many user-space includers of <sys/tmpfs.h> to stop defining _KERNEL. For the sake of those that still define _KERNEL before including <sys/tmpfs.h>, it includes <sys/lock.h> in the scope of the _KERNEL block.