I'm testing the attached patch. So far it seems to work, although it should really be reviewed by someone more familiar with kernel development history.
(I looked at the implementation of file_dentry() in 4.6 and simplified it to account for the lack of d_real() support in older kernels. My main worry is that I may be missing some corner cases that apply to older kernels but were no longer of concern by the time file_dentry() was added.)
--- a/acinclude.m4 +++ b/acinclude.m4 @@ -965,6 +965,9 @@ AC_CHECK_LINUX_FUNC([do_sync_read], [#include <linux/fs.h>], [do_sync_read(NULL, NULL, 0, NULL);]) + AC_CHECK_LINUX_FUNC([file_dentry], + [#include <linux/fs.h>], + [struct file *f; file_dentry(f);]) AC_CHECK_LINUX_FUNC([find_task_by_pid], [#include <linux/sched.h>], [pid_t p; find_task_by_pid(p);]) --- a/src/afs/LINUX/osi_compat.h +++ b/src/afs/LINUX/osi_compat.h @@ -47,6 +47,10 @@ # endif #endif +#ifndef HAVE_LINUX_FILE_DENTRY +#define file_dentry(file) ((file)->f_dentry) +#endif + #if defined(HAVE_LINUX_LOCKS_LOCK_FILE_WAIT) # define flock_lock_file_wait locks_lock_file_wait #endif