Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs/genfs Simplify genfs_getpages_read async/unlock p...



details:   https://anonhg.NetBSD.org/src/rev/f0cb88e975df
branches:  trunk
changeset: 822701:f0cb88e975df
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Apr 01 19:57:54 2017 +0000

description:
Simplify genfs_getpages_read async/unlock protocol.

Previously the caller unlocked for error or sync I/O, whereas
genfs_getpages_read unlocked on successful async.

Now caller unlocks in every case, and genfs_getpages_read doesn't
touch the lock.

diffstat:

 sys/miscfs/genfs/genfs_io.c |  11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diffs (42 lines):

diff -r b7f3484734d3 -r f0cb88e975df sys/miscfs/genfs/genfs_io.c
--- a/sys/miscfs/genfs/genfs_io.c       Sat Apr 01 19:35:56 2017 +0000
+++ b/sys/miscfs/genfs/genfs_io.c       Sat Apr 01 19:57:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: genfs_io.c,v 1.66 2017/03/30 09:12:21 hannken Exp $    */
+/*     $NetBSD: genfs_io.c,v 1.67 2017/04/01 19:57:54 riastradh Exp $  */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.66 2017/03/30 09:12:21 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.67 2017/04/01 19:57:54 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -428,11 +428,11 @@
        mutex_exit(uobj->vmobjlock);
        error = genfs_getpages_read(vp, pgs, npages, startoffset, diskeof,
            async, memwrite, blockalloc, glocked);
-       if (error == 0 && async)
-               goto out_err_free;
        if (!glocked) {
                genfs_node_unlock(vp);
        }
+       if (error == 0 && async)
+               goto out_err_free;
        mutex_enter(uobj->vmobjlock);
 
        /*
@@ -714,9 +714,6 @@
        nestiobuf_done(mbp, skipbytes, error);
        if (async) {
                UVMHIST_LOG(ubchist, "returning 0 (async)",0,0,0,0);
-               if (!glocked) {
-                       genfs_node_unlock(vp);
-               }
                return 0;
        }
        if (bp != NULL) {



Home | Main Index | Thread Index | Old Index