From bf2e4dd23e751540666c0c7961e47d4b5d06667b Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Wed, 19 May 2010 18:11:58 +0100 Subject: [PATCH] Linux: Use positional r/w, not llseek The Linux read/write file operations take a position. Use this position to determine where we're reading or writing in a file, rather than using the vfs_llseek() operator to set the file position argument. This avoids a potential race condition, as well as simplifying this code. Change-Id: I82b4a109f9871fa2ce5b308bc32923b1bf910920 Reviewed-on: http://gerrit.openafs.org/1993 Reviewed-by: Andrew Deason Reviewed-by: Marc Dionne Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- acinclude.m4 | 3 --- src/afs/LINUX/osi_compat.h | 9 --------- src/afs/LINUX/osi_file.c | 9 +-------- 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 2ba05df..189ee95 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -870,9 +870,6 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) AC_CHECK_LINUX_FUNC([svc_addr_in], [#include ], [svc_addr_in(NULL);]) - AC_CHECK_LINUX_FUNC([vfs_llseek], - [#include ], - [vfs_llseek(NULL, 0, 0);]) AC_CHECK_LINUX_FUNC([zero_user_segments], [#include ], [zero_user_segments(NULL, 0, 0, 0, 0);]) diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h index c9a2878..7088625 100644 --- a/src/afs/LINUX/osi_compat.h +++ b/src/afs/LINUX/osi_compat.h @@ -234,15 +234,6 @@ zero_user_segments(struct page *pp, unsigned int from1, unsigned int to1, } #endif -#ifndef HAVE_LINUX_VFS_LLSEEK -static inline loff_t -vfs_llseek(struct file *filp, loff_t offset, int origin) { - if (filp->f_op->llseek) - return filp->f_op->llseek(filp, offset, origin); - return default_llseek(filp, offset, origin); -} -#endif - #ifndef HAVE_LINUX_KERNEL_SETSOCKOPT /* Available from 2.6.19 */ diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c index 991e677..a3ccde5 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -387,12 +387,6 @@ osi_rdwr(struct osi_file *osifile, uio_t * uiop, int rw) set_fs(get_ds()); } - /* seek to the desired position. Return -1 on error. */ - if (vfs_llseek(filp, (loff_t) uiop->uio_offset, 0) != uiop->uio_offset) { - code = -1; - goto out; - } - while (code == 0 && uiop->uio_resid > 0 && uiop->uio_iovcnt > 0) { iov = uiop->uio_iov; count = iov->iov_len; @@ -402,12 +396,11 @@ osi_rdwr(struct osi_file *osifile, uio_t * uiop, int rw) continue; } - pos = filp->f_pos; + pos = uiop->uio_offset; if (rw == UIO_READ) code = filp->f_op->read(filp, iov->iov_base, count, &pos); else code = filp->f_op->write(filp, iov->iov_base, count, &pos); - filp->f_pos = pos; if (code < 0) { code = -code; -- 1.9.4