Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Let I/O errors override inode update errors in UFS.



details:   https://anonhg.NetBSD.org/src/rev/adcb329ada25
branches:  trunk
changeset: 336973:adcb329ada25
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Mar 28 17:45:47 2015 +0000

description:
Let I/O errors override inode update errors in UFS.

Fixes tests/fs/vfs/t_io:read_fault for UFS.

diffstat:

 sys/ufs/ext2fs/ext2fs_readwrite.c |  16 ++++++++++++----
 sys/ufs/lfs/ulfs_readwrite.c      |  16 ++++++++++++----
 sys/ufs/ufs/ufs_readwrite.c       |  19 ++++++++++++++-----
 tests/fs/vfs/t_io.c               |   8 ++------
 4 files changed, 40 insertions(+), 19 deletions(-)

diffs (212 lines):

diff -r 5f3034fc5b24 -r adcb329ada25 sys/ufs/ext2fs/ext2fs_readwrite.c
--- a/sys/ufs/ext2fs/ext2fs_readwrite.c Sat Mar 28 17:35:59 2015 +0000
+++ b/sys/ufs/ext2fs/ext2fs_readwrite.c Sat Mar 28 17:45:47 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ext2fs_readwrite.c,v 1.72 2015/03/28 17:23:42 maxv Exp $       */
+/*     $NetBSD: ext2fs_readwrite.c,v 1.73 2015/03/28 17:45:47 riastradh Exp $  */
 
 /*-
  * Copyright (c) 1993
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.72 2015/03/28 17:23:42 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.73 2015/03/28 17:45:47 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -232,9 +232,10 @@
 }
 
 static int
-ext2fs_post_read_update(struct vnode *vp, int ioflag, int error)
+ext2fs_post_read_update(struct vnode *vp, int ioflag, int oerror)
 {
        struct inode *ip = VTOI(vp);
+       int error = oerror;
 
        if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) {
                ip->i_flag |= IN_ACCESS;
@@ -242,6 +243,9 @@
                        error = ext2fs_update(vp, NULL, NULL, UPDATE_WAIT);
        }
 
+       /* Read error overrides any inode update error.  */
+       if (oerror)
+               error = oerror;
        return error;
 }
 
@@ -434,9 +438,10 @@
 
 static int
 ext2fs_post_write_update(struct vnode *vp, struct uio *uio, int ioflag,
-    kauth_cred_t cred, off_t osize, int resid, int extended, int error)
+    kauth_cred_t cred, off_t osize, int resid, int extended, int oerror)
 {
        struct inode *ip = VTOI(vp);
+       int error = oerror;
 
        /* Trigger ctime and mtime updates, and atime if MNT_RELATIME.  */
        ip->i_flag |= IN_CHANGE | IN_UPDATE;
@@ -480,5 +485,8 @@
        /* Make sure the vnode uvm size matches the inode file size.  */
        KASSERT(vp->v_size == ext2fs_size(ip));
 
+       /* Write error overrides any inode update error.  */
+       if (oerror)
+               error = oerror;
        return error;
 }
diff -r 5f3034fc5b24 -r adcb329ada25 sys/ufs/lfs/ulfs_readwrite.c
--- a/sys/ufs/lfs/ulfs_readwrite.c      Sat Mar 28 17:35:59 2015 +0000
+++ b/sys/ufs/lfs/ulfs_readwrite.c      Sat Mar 28 17:45:47 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ulfs_readwrite.c,v 1.13 2015/03/28 17:23:42 maxv Exp $ */
+/*     $NetBSD: ulfs_readwrite.c,v 1.14 2015/03/28 17:45:47 riastradh Exp $    */
 /*  from NetBSD: ufs_readwrite.c,v 1.105 2013/01/22 09:39:18 dholland Exp  */
 
 /*-
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.13 2015/03/28 17:23:42 maxv Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.14 2015/03/28 17:45:47 riastradh Exp $");
 
 #ifdef LFS_READWRITE
 #define        FS                      struct lfs
@@ -227,9 +227,10 @@
 }
 
 static int
-ulfs_post_read_update(struct vnode *vp, int ioflag, int error)
+ulfs_post_read_update(struct vnode *vp, int ioflag, int oerror)
 {
        struct inode *ip = VTOI(vp);
+       int error = oerror;
 
        if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) {
                ip->i_flag |= IN_ACCESS;
@@ -238,6 +239,9 @@
                }
        }
 
+       /* Read error overrides any inode update error.  */
+       if (oerror)
+               error = oerror;
        return error;
 }
 
@@ -584,9 +588,10 @@
 
 static int
 ulfs_post_write_update(struct vnode *vp, struct uio *uio, int ioflag,
-    kauth_cred_t cred, off_t osize, int resid, int extended, int error)
+    kauth_cred_t cred, off_t osize, int resid, int extended, int oerror)
 {
        struct inode *ip = VTOI(vp);
+       int error = oerror;
 
        /* Trigger ctime and mtime updates, and atime if MNT_RELATIME.  */
        ip->i_flag |= IN_CHANGE | IN_UPDATE;
@@ -637,5 +642,8 @@
        /* Make sure the vnode uvm size matches the inode file size.  */
        KASSERT(vp->v_size == ip->i_size);
 
+       /* Write error overrides any inode update error.  */
+       if (oerror)
+               error = oerror;
        return error;
 }
diff -r 5f3034fc5b24 -r adcb329ada25 sys/ufs/ufs/ufs_readwrite.c
--- a/sys/ufs/ufs/ufs_readwrite.c       Sat Mar 28 17:35:59 2015 +0000
+++ b/sys/ufs/ufs/ufs_readwrite.c       Sat Mar 28 17:45:47 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_readwrite.c,v 1.113 2015/03/28 17:23:42 maxv Exp $ */
+/*     $NetBSD: ufs_readwrite.c,v 1.114 2015/03/28 17:45:47 riastradh Exp $    */
 
 /*-
  * Copyright (c) 1993
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.113 2015/03/28 17:23:42 maxv Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.114 2015/03/28 17:45:47 riastradh Exp $");
 
 #ifdef LFS_READWRITE
 #define        FS                      struct lfs
@@ -238,21 +238,26 @@
 }
 
 static int
-ufs_post_read_update(struct vnode *vp, int ioflag, int error)
+ufs_post_read_update(struct vnode *vp, int ioflag, int oerror)
 {
        struct inode *ip = VTOI(vp);
+       int error = oerror;
 
        if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) {
                ip->i_flag |= IN_ACCESS;
                if ((ioflag & IO_SYNC) == IO_SYNC) {
                        error = UFS_WAPBL_BEGIN(vp->v_mount);
                        if (error)
-                               return error;
+                               goto out;
                        error = UFS_UPDATE(vp, NULL, NULL, UPDATE_WAIT);
                        UFS_WAPBL_END(vp->v_mount);
                }
        }
 
+out:
+       /* Read error overrides any inode update error.  */
+       if (oerror)
+               error = oerror;
        return error;
 }
 
@@ -614,9 +619,10 @@
 
 static int
 ufs_post_write_update(struct vnode *vp, struct uio *uio, int ioflag,
-    kauth_cred_t cred, off_t osize, int resid, int extended, int error)
+    kauth_cred_t cred, off_t osize, int resid, int extended, int oerror)
 {
        struct inode *ip = VTOI(vp);
+       int error = oerror;
 
        /* Trigger ctime and mtime updates, and atime if MNT_RELATIME.  */
        ip->i_flag |= IN_CHANGE | IN_UPDATE;
@@ -666,5 +672,8 @@
        /* Make sure the vnode uvm size matches the inode file size.  */
        KASSERT(vp->v_size == ip->i_size);
 
+       /* Write error overrides any inode update error.  */
+       if (oerror)
+               error = oerror;
        return error;
 }
diff -r 5f3034fc5b24 -r adcb329ada25 tests/fs/vfs/t_io.c
--- a/tests/fs/vfs/t_io.c       Sat Mar 28 17:35:59 2015 +0000
+++ b/tests/fs/vfs/t_io.c       Sat Mar 28 17:45:47 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_io.c,v 1.14 2015/03/28 16:39:31 riastradh Exp $      */
+/*     $NetBSD: t_io.c,v 1.15 2015/03/28 17:45:47 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -233,11 +233,7 @@
        ATF_REQUIRE_EQ(rump_sys_write(fd, &ch, 1), 1);
        RL(rump_sys_close(fd));
        RL(fd = rump_sys_open("file", O_RDONLY | O_SYNC | O_RSYNC));
-       if (FSTYPE_EXT2FS(tc) ||
-           FSTYPE_FFS(tc) ||
-           FSTYPE_FFSLOG(tc) ||
-           FSTYPE_LFS(tc) ||
-           FSTYPE_MSDOS(tc) ||
+       if (FSTYPE_MSDOS(tc) ||
            FSTYPE_SYSVBFS(tc))
                atf_tc_expect_fail("bad sync atime update code path");
        ATF_REQUIRE_ERRNO(EFAULT, rump_sys_read(fd, NULL, 1) == -1);



Home | Main Index | Thread Index | Old Index