Linux 4.14 compat: vfs_read & vfs_write

The kernel_read & kernel_write functions have always wrapped the
vfs_read & vfs_write functions respectively.  However, they could
not be used by vn_rdwr() since the offset wasn't passed as a
pointer.  This prevented us from being able to properly update
the file offset.

Linux 4.14 unexported vfs_read & vfs_write but also changed the
signature of kernel_read & kernel_write to provide the needed
functionality.  Use these updated functions when available.

Reviewed-by: Pritam Baral <pritam@pritambaral.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #656 
Closes #667
This commit is contained in:
Brian Behlendorf
2017-11-15 17:19:23 -08:00
committed by GitHub
parent 35a44fcb8d
commit ed19bccfb6
3 changed files with 105 additions and 17 deletions
+4 -17
View File
@@ -211,35 +211,22 @@ int
vn_rdwr(uio_rw_t uio, vnode_t *vp, void *addr, ssize_t len, offset_t off,
uio_seg_t seg, int ioflag, rlim64_t x2, void *x3, ssize_t *residp)
{
loff_t offset;
mm_segment_t saved_fs;
struct file *fp;
struct file *fp = vp->v_file;
loff_t offset = off;
int rc;
ASSERT(uio == UIO_WRITE || uio == UIO_READ);
ASSERT(vp);
ASSERT(vp->v_file);
ASSERT(seg == UIO_SYSSPACE);
ASSERT((ioflag & ~FAPPEND) == 0);
fp = vp->v_file;
offset = off;
if (ioflag & FAPPEND)
offset = fp->f_pos;
/* Writable user data segment must be briefly increased for this
* process so we can use the user space read call paths to write
* in to memory allocated by the kernel. */
saved_fs = get_fs();
set_fs(get_ds());
if (uio & UIO_WRITE)
rc = vfs_write(fp, addr, len, &offset);
rc = spl_kernel_write(fp, addr, len, &offset);
else
rc = vfs_read(fp, addr, len, &offset);
rc = spl_kernel_read(fp, addr, len, &offset);
set_fs(saved_fs);
fp->f_pos = offset;
if (rc < 0)