diff --git a/acinclude.m4 b/acinclude.m4 index f82248c14e..959e3c5208 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -966,6 +966,9 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) dnl Function existence checks + AC_CHECK_LINUX_FUNC([__vfs_read], + [#include ], + [__vfs_read(NULL, NULL, 0, NULL);]) AC_CHECK_LINUX_FUNC([bdi_init], [#include ], [bdi_init(NULL);]) diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h index e8816d56d7..e9f6ca11b6 100644 --- a/src/afs/LINUX/osi_compat.h +++ b/src/afs/LINUX/osi_compat.h @@ -631,4 +631,24 @@ afs_d_invalidate(struct dentry *dp) #endif } +static inline int +afs_file_read(struct file *filp, char __user *buf, size_t len, loff_t *pos) +{ +#if defined(HAVE_LINUX___VFS_READ) + return __vfs_read(filp, buf, len, pos); +#else + return filp->f_op->read(filp, buf, len, pos); +#endif +} + +static inline int +afs_file_write(struct file *filp, char __user *buf, size_t len, loff_t *pos) +{ +#if defined(HAVE_LINUX___VFS_READ) + return __vfs_write(filp, buf, len, pos); +#else + return filp->f_op->write(filp, buf, len, pos); +#endif +} + #endif /* AFS_LINUX_OSI_COMPAT_H */ diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c index 8cdff4bf92..c050715245 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -375,9 +375,9 @@ osi_rdwr(struct osi_file *osifile, struct uio *uiop, int rw) pos = uiop->uio_offset; if (rw == UIO_READ) - code = filp->f_op->read(filp, iov->iov_base, count, &pos); + code = afs_file_read(filp, iov->iov_base, count, &pos); else - code = filp->f_op->write(filp, iov->iov_base, count, &pos); + code = afs_file_write(filp, iov->iov_base, count, &pos); if (code < 0) { code = -code; diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 5869eb980c..5b9d5aa48c 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -819,8 +819,10 @@ struct file_operations afs_file_fops = { #ifdef STRUCT_FILE_OPERATIONS_HAS_READ_ITER .read_iter = afs_linux_read_iter, .write_iter = afs_linux_write_iter, +# if !defined(HAVE_LINUX___VFS_READ) .read = new_sync_read, .write = new_sync_write, +# endif #elif defined(HAVE_LINUX_GENERIC_FILE_AIO_READ) .aio_read = afs_linux_aio_read, .aio_write = afs_linux_aio_write,