Linux: Use positional r/w, not llseek
authorSimon Wilkinson <sxw@inf.ed.ac.uk>
Wed, 19 May 2010 17:11:58 +0000 (18:11 +0100)
committerDerrick Brashear <shadow@dementia.org>
Wed, 19 May 2010 18:21:27 +0000 (11:21 -0700)
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 <adeason@sinenomine.net>
Reviewed-by: Marc Dionne <marc.c.dionne@gmail.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

acinclude.m4
src/afs/LINUX/osi_compat.h
src/afs/LINUX/osi_file.c

index 2ba05df..189ee95 100644 (file)
@@ -870,9 +870,6 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
                 AC_CHECK_LINUX_FUNC([svc_addr_in],
                                     [#include <linux/sunrpc/svc.h>],
                                     [svc_addr_in(NULL);])
-                AC_CHECK_LINUX_FUNC([vfs_llseek],
-                                    [#include <linux/fs.h>],
-                                    [vfs_llseek(NULL, 0, 0);])
                 AC_CHECK_LINUX_FUNC([zero_user_segments],
                                     [#include <linux/highmem.h>],
                                     [zero_user_segments(NULL, 0, 0, 0, 0);])
index c9a2878..7088625 100644 (file)
@@ -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 */
 
index 991e677..a3ccde5 100644 (file)
@@ -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;