]> git.proxmox.com Git - mirror_spl-debian.git/commitdiff
- Fix write-only behavior in vn-open()
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Fri, 4 Apr 2008 17:08:12 +0000 (17:08 +0000)
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Fri, 4 Apr 2008 17:08:12 +0000 (17:08 +0000)
- Ensure we have at least 1 write-only splat test
- Fix return codes for vn_* Solaris does not use negative return
  codes in the kernel.  So linux errno's must be inverted.

git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@67 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c

modules/spl/spl-vnode.c
modules/splat/splat-atomic.c
modules/splat/splat-vnode.c

index 401c6e0e862d5bdde24d972c32796afe38d1e562..10b2277612d3ddb7abc1969b5198222db3b96667 100644 (file)
@@ -52,7 +52,7 @@ vn_alloc(int flag)
                vp->v_type = 0;
        }
 
-       return (vp);
+       return vp;
 } /* vn_alloc() */
 EXPORT_SYMBOL(vn_alloc);
 
@@ -69,9 +69,10 @@ vn_open(const char *path, uio_seg_t seg, int flags, int mode,
 {
         struct file *fp;
         struct kstat stat;
-        int rc, saved_umask, flags_rw;
+        int rc, saved_umask;
        vnode_t *vp;
 
+       BUG_ON(!(flags & (FWRITE | FREAD)));
        BUG_ON(seg != UIO_SYSSPACE);
        BUG_ON(!vpp);
        *vpp = NULL;
@@ -79,13 +80,12 @@ vn_open(const char *path, uio_seg_t seg, int flags, int mode,
        if (!(flags & FCREAT) && (flags & FWRITE))
                flags |= FEXCL;
 
-       flags_rw = flags & (FWRITE | FREAD);
-       flags &= ~(FWRITE | FREAD);
-       switch (flags_rw) {
-               case FWRITE:            flags |= O_WRONLY;
-               case FREAD:             flags |= O_RDONLY;
-               case (FWRITE | FREAD):  flags |= O_RDWR;
-       }
+       /* Note for filp_open() the two low bits must be remapped to mean:
+        * 01 - read-only  -> 00 read-only
+        * 10 - write-only -> 01 write-only
+        * 11 - read-write -> 10 read-write
+        */
+       flags--;
 
        if (flags & FCREAT)
                saved_umask = xchg(&current->fs->umask, 0);
@@ -96,18 +96,18 @@ vn_open(const char *path, uio_seg_t seg, int flags, int mode,
                (void)xchg(&current->fs->umask, saved_umask);
 
         if (IS_ERR(fp))
-               return PTR_ERR(fp);
+               return -PTR_ERR(fp);
 
         rc = vfs_getattr(fp->f_vfsmnt, fp->f_dentry, &stat);
        if (rc) {
                filp_close(fp, 0);
-               return rc;
+               return -rc;
        }
 
        vp = vn_alloc(KM_SLEEP);
        if (!vp) {
                filp_close(fp, 0);
-               return -ENOMEM;
+               return ENOMEM;
        }
 
        mutex_enter(&vp->v_lock);
@@ -131,7 +131,7 @@ vn_openat(const char *path, uio_seg_t seg, int flags, int mode,
 
        realpath = kmalloc(strlen(path) + 2, GFP_KERNEL);
        if (!realpath)
-               return -ENOMEM;
+               return ENOMEM;
 
        sprintf(realpath, "/%s", path);
        rc = vn_open(realpath, seg, flags, mode, vpp, x1, x2);
@@ -175,13 +175,13 @@ vn_rdwr(uio_rw_t uio, vnode_t *vp, void *addr, ssize_t len, offset_t off,
        set_fs(saved_fs);
 
        if (rc < 0)
-               return rc;
+               return -rc;
 
        if (residp) {
                *residp = len - rc;
        } else {
                if (rc != len)
-                       return -EIO;
+                       return EIO;
        }
 
        return 0;
@@ -199,7 +199,7 @@ vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4)
         rc = filp_close(vp->v_file, 0);
         vn_free(vp);
 
-       return rc;
+       return -rc;
 } /* vn_close() */
 EXPORT_SYMBOL(vn_close);
 
@@ -248,7 +248,7 @@ exit2:
 exit1:
         path_release(&nd);
 exit:
-        return rc;
+        return -rc;
 
 slashes:
         rc = !dentry->d_inode ? -ENOENT :
@@ -338,7 +338,7 @@ exit2:
 exit1:
         path_release(&oldnd);
 exit:
-        return rc;
+        return -rc;
 }
 EXPORT_SYMBOL(vn_rename);
 
@@ -357,7 +357,7 @@ vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4)
 
         rc = vfs_getattr(fp->f_vfsmnt, fp->f_dentry, &stat);
        if (rc)
-               return rc;
+               return -rc;
 
        vap->va_type          = vn_get_sol_type(stat.mode);
        vap->va_mode          = stat.mode;
@@ -377,7 +377,7 @@ vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4)
        vap->va_rdev          = stat.rdev;
        vap->va_blocks        = stat.blocks;
 
-        return rc;
+        return 0;
 }
 EXPORT_SYMBOL(vn_getattr);
 
@@ -391,7 +391,7 @@ int vn_fsync(vnode_t *vp, int flags, void *x3, void *x4)
        if (flags & FDSYNC)
                datasync = 1;
 
-       return file_fsync(vp->v_file, vp->v_file->f_dentry, datasync);
+       return -file_fsync(vp->v_file, vp->v_file->f_dentry, datasync);
 } /* vn_fsync() */
 EXPORT_SYMBOL(vn_fsync);
 
index c170cc05e9083d38dd61bf15796668e03924f81a..43876d78adf5ad2783551f9686c5ca0bbf20f542 100644 (file)
@@ -95,8 +95,8 @@ splat_atomic_work(void *priv)
                     (long unsigned)ap->ap_atomic,
                     (long unsigned)ap->ap_atomic_exited);
 
-       thread_exit();
        wake_up(&ap->ap_waitq);
+       thread_exit();
 }
 
 static int
index 8578ea20a24a90baca25eacec46d3340727146f3..c8368b5cbedc6e16c195cfb97f2874ffa7420267 100644 (file)
@@ -287,7 +287,7 @@ splat_vnode_test6(struct file *file, void *arg)
        int rc;
 
        if ((rc = vn_open(SPLAT_VNODE_TEST_FILE_RW, UIO_SYSSPACE,
-                         FWRITE | FREAD | FCREAT | FEXCL, 0644, &vp, 0, 0))) {
+                         FWRITE | FCREAT | FEXCL, 0644, &vp, 0, 0))) {
                splat_vprint(file, SPLAT_VNODE_TEST6_NAME,
                             "Failed to vn_open test file: %s (%d)\n",
                             SPLAT_VNODE_TEST_FILE_RW, rc);