Linux: Don't pass f_pos down to the filesystem
authorSimon Wilkinson <sxw@inf.ed.ac.uk>
Fri, 23 Apr 2010 15:54:39 +0000 (16:54 +0100)
committerDerrick Brashear <shadow@dementia.org>
Mon, 26 Apr 2010 04:05:00 +0000 (21:05 -0700)
In 2.6.8, Linux shifted from passing f_pos directly to the read
and write routines, and started passing a copy. This helps reduce,
but does not remove, the race issues with f_pos itself. Make this
change for us.

Take the opportunity to remove the uneccessary macros, and tidy up
some casting.

Change-Id: I3b4cdf1e6e8127cbe0055829605268953c4397a6
Reviewed-on: http://gerrit.openafs.org/1818
Reviewed-by: Marc Dionne <marc.c.dionne@gmail.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/afs/LINUX/osi_file.c

index 8b2151a..ba6c873 100644 (file)
@@ -363,9 +363,6 @@ osi_InitCacheInfo(char *aname)
 }
 
 
-#define FOP_READ(F, B, C) (F)->f_op->read(F, B, (size_t)(C), &(F)->f_pos)
-#define FOP_WRITE(F, B, C) (F)->f_op->write(F, B, (size_t)(C), &(F)->f_pos)
-
 /* osi_rdwr
  * seek, then read or write to an open inode. addrp points to data in
  * kernel space.
@@ -377,8 +374,9 @@ osi_rdwr(struct osi_file *osifile, uio_t * uiop, int rw)
     KERNEL_SPACE_DECL;
     int code = 0;
     struct iovec *iov;
-    afs_size_t count;
+    size_t count;
     unsigned long savelim;
+    loff_t pos;
 
     savelim = current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur;
     current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
@@ -401,10 +399,12 @@ osi_rdwr(struct osi_file *osifile, uio_t * uiop, int rw)
            continue;
        }
 
+       pos = filp->f_pos;
        if (rw == UIO_READ)
-           code = FOP_READ(filp, iov->iov_base, count);
+           code = filp->f_op->read(filp, iov->iov_base, count, &pos);
        else
-           code = FOP_WRITE(filp, iov->iov_base, count);
+           code = filp->f_op->write(filp, iov->iov_base, count, &pos);
+       filp->f_pos = pos;
 
        if (code < 0) {
            code = -code;