CVS commit: [yamt-pagecache] src/sys/miscfs/genfs
Module Name:src Committed By: yamt Date: Mon Apr 22 13:08:06 UTC 2013 Modified Files: src/sys/miscfs/genfs [yamt-pagecache]: genfs_io.c Log Message: revert unnecessary diff To generate a diff of this commit: cvs rdiff -u -r1.53.2.17 -r1.53.2.18 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.53.2.17 src/sys/miscfs/genfs/genfs_io.c:1.53.2.18 --- src/sys/miscfs/genfs/genfs_io.c:1.53.2.17 Fri Nov 2 08:30:05 2012 +++ src/sys/miscfs/genfs/genfs_io.c Mon Apr 22 13:08:06 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.53.2.17 2012/11/02 08:30:05 yamt Exp $ */ +/* $NetBSD: genfs_io.c,v 1.53.2.18 2013/04/22 13:08:06 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.17 2012/11/02 08:30:05 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.18 2013/04/22 13:08:06 yamt Exp $"); #include #include @@ -592,7 +592,7 @@ startover: if (blkno == (daddr_t)-1) { int holepages = (round_page(offset + iobytes) - trunc_page(offset)) >> PAGE_SHIFT; - UVMHIST_LOG(ubchist, "lbn 0x%x -> RDONLY", lbn,0,0,0); + UVMHIST_LOG(ubchist, "lbn 0x%x -> HOLE", lbn,0,0,0); sawhole = true; memset((char *)kva + (offset - startoffset), 0,
CVS commit: [yamt-pagecache] src/sys/miscfs/genfs
Module Name:src Committed By: yamt Date: Fri Nov 2 08:30:05 UTC 2012 Modified Files: src/sys/miscfs/genfs [yamt-pagecache]: genfs_io.c Log Message: tweak integrity_sync cases some comments To generate a diff of this commit: cvs rdiff -u -r1.53.2.16 -r1.53.2.17 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.53.2.16 src/sys/miscfs/genfs/genfs_io.c:1.53.2.17 --- src/sys/miscfs/genfs/genfs_io.c:1.53.2.16 Wed Aug 1 22:34:15 2012 +++ src/sys/miscfs/genfs/genfs_io.c Fri Nov 2 08:30:05 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.53.2.16 2012/08/01 22:34:15 yamt Exp $ */ +/* $NetBSD: genfs_io.c,v 1.53.2.17 2012/11/02 08:30:05 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.16 2012/08/01 22:34:15 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.17 2012/11/02 08:30:05 yamt Exp $"); #include #include @@ -844,7 +844,8 @@ genfs_do_putpages(struct vnode *vp, off_ bool tryclean; /* try to pull off from the syncer's list */ bool onworklst; const bool integrity_sync = - (origflags & (PGO_LAZY|PGO_SYNCIO)) == PGO_SYNCIO; + (origflags & (PGO_LAZY|PGO_SYNCIO|PGO_CLEANIT)) == + (PGO_SYNCIO|PGO_CLEANIT); const bool dirtyonly = (origflags & (PGO_DEACTIVATE|PGO_FREE)) == 0; UVMHIST_FUNC("genfs_putpages"); UVMHIST_CALLED(ubchist); @@ -943,8 +944,11 @@ retry: bool protected; /* - * if we are asked to sync for integrity, we should wait on - * pages being written back by another threads as well. + * if !dirtyonly, iterate over all resident pages in the range. + * + * if dirtyonly, only possibly dirty pages are interested. + * however, if we are asked to sync for integrity, we should + * wait on pages being written back by another threads as well. */ pg = uvm_page_array_fill_and_peek(&a, uobj, nextoff, 0, @@ -1011,7 +1015,7 @@ retry: * don't bother to wait on other's activities * unless we are asked to sync for integrity. */ - if (!integrity_sync) { + if (!integrity_sync && (flags & PGO_RECLAIM) == 0) { wasclean = false; nextoff = pg->offset + PAGE_SIZE; uvm_page_array_advance(&a); @@ -1152,6 +1156,11 @@ retry: * * pass our cached array of pages so that hopefully * uvn_findpages can find some good pages in it. + * the array a was filled above with the one of + * following sets of flags: + * 0 + * UVM_PAGE_ARRAY_FILL_DIRTY + * UVM_PAGE_ARRAY_FILL_DIRTY|WRITEBACK */ nforw = maxpages - nback - 1;
CVS commit: [yamt-pagecache] src/sys/miscfs/genfs
Module Name:src Committed By: yamt Date: Wed Aug 1 21:13:46 UTC 2012 Modified Files: src/sys/miscfs/genfs [yamt-pagecache]: genfs_io.c Log Message: remove stale comments To generate a diff of this commit: cvs rdiff -u -r1.53.2.14 -r1.53.2.15 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.53.2.14 src/sys/miscfs/genfs/genfs_io.c:1.53.2.15 --- src/sys/miscfs/genfs/genfs_io.c:1.53.2.14 Wed May 23 10:08:14 2012 +++ src/sys/miscfs/genfs/genfs_io.c Wed Aug 1 21:13:45 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.53.2.14 2012/05/23 10:08:14 yamt Exp $ */ +/* $NetBSD: genfs_io.c,v 1.53.2.15 2012/08/01 21:13:45 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.14 2012/05/23 10:08:14 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.15 2012/08/01 21:13:45 yamt Exp $"); #include #include @@ -787,11 +787,6 @@ out_err: * (e.g. vm_map) before calling flush. * => if neither PGO_CLEANIT nor PGO_SYNCIO is set, we will not block * => if PGO_ALLPAGES is set, then all pages in the object will be processed. - * => NOTE: we rely on the fact that the object's memq is a TAILQ and - * that new pages are inserted on the tail end of the list. thus, - * we can make a complete pass through the object in one go by starting - * at the head and working towards the tail (new pages are put in - * front of us). * => NOTE: we are allowed to lock the page queues, so the caller * must not be holding the page queue lock. * @@ -808,19 +803,6 @@ out_err: * object we need to wait for the other PG_BUSY pages to clear * off (i.e. we need to do an iosync). also note that once a * page is PG_BUSY it must stay in its object until it is un-busyed. - * - * note on page traversal: - * we can traverse the pages in an object either by going down the - * linked list in "uobj->memq", or we can go over the address range - * by page doing hash table lookups for each address.depending - * on how many pages are in the object it may be cheaper to do one - * or the other. we set "by_list" to true if we are using memq. - * if the cost of a hash lookup was equal to the cost of the list - * traversal we could compare the number of pages in the start->stop - * range to the total number of pages in the object. however, it - * seems that a hash table lookup is more expensive than the linked - * list traversal, so we multiply the number of pages in the - * range by an estimate of the relatively higher cost of the hash lookup. */ int
CVS commit: [yamt-pagecache] src/sys/miscfs/genfs
Module Name:src Committed By: yamt Date: Sun Feb 5 08:23:41 UTC 2012 Modified Files: src/sys/miscfs/genfs [yamt-pagecache]: genfs_io.c Log Message: genfs_gop_write_rwmap: comment To generate a diff of this commit: cvs rdiff -u -r1.53.2.11 -r1.53.2.12 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.53.2.11 src/sys/miscfs/genfs/genfs_io.c:1.53.2.12 --- src/sys/miscfs/genfs/genfs_io.c:1.53.2.11 Sun Feb 5 05:01:26 2012 +++ src/sys/miscfs/genfs/genfs_io.c Sun Feb 5 08:23:41 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.53.2.11 2012/02/05 05:01:26 yamt Exp $ */ +/* $NetBSD: genfs_io.c,v 1.53.2.12 2012/02/05 08:23:41 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.11 2012/02/05 05:01:26 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.12 2012/02/05 08:23:41 yamt Exp $"); #include #include @@ -1333,8 +1333,17 @@ genfs_gop_write(struct vnode *vp, struct return error; } +/* + * genfs_gop_write_rwmap: + * + * a variant of genfs_gop_write. it's used by UDF for its directory buffers. + * this maps pages with PROT_WRITE so that VOP_STRATEGY can modifies + * the contents before writing it out to the underlying storage. + */ + int -genfs_gop_write_rwmap(struct vnode *vp, struct vm_page **pgs, int npages, int flags) +genfs_gop_write_rwmap(struct vnode *vp, struct vm_page **pgs, int npages, +int flags) { off_t off; vaddr_t kva;
CVS commit: [yamt-pagecache] src/sys/miscfs/genfs
Module Name:src Committed By: yamt Date: Sun Feb 5 05:01:26 UTC 2012 Modified Files: src/sys/miscfs/genfs [yamt-pagecache]: genfs_io.c Log Message: use unsigned comments assertions To generate a diff of this commit: cvs rdiff -u -r1.53.2.10 -r1.53.2.11 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.53.2.10 src/sys/miscfs/genfs/genfs_io.c:1.53.2.11 --- src/sys/miscfs/genfs/genfs_io.c:1.53.2.10 Wed Jan 25 00:40:08 2012 +++ src/sys/miscfs/genfs/genfs_io.c Sun Feb 5 05:01:26 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.53.2.10 2012/01/25 00:40:08 yamt Exp $ */ +/* $NetBSD: genfs_io.c,v 1.53.2.11 2012/02/05 05:01:26 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.10 2012/01/25 00:40:08 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.11 2012/02/05 05:01:26 yamt Exp $"); #include #include @@ -854,9 +854,10 @@ genfs_do_putpages(struct vnode *vp, off_ off_t nextoff; /* Even for strange MAXPHYS, the shift rounds down to a page */ #define maxpages (MAXPHYS >> PAGE_SHIFT) - int i, error; + unsigned int i; unsigned int npages, nback; - int freeflag; + unsigned int freeflag; + int error; struct vm_page *pgs[maxpages], *pg; struct uvm_page_array a; bool wasclean, needs_clean, yld; @@ -1040,7 +1041,7 @@ retry: /* * if we're freeing, remove all mappings of the page now. - * if we're cleaning, check if the page is needs to be cleaned. + * if we're cleaning, check if the page needs to be cleaned. */ protected = false; @@ -1181,6 +1182,10 @@ retry: struct vm_page *tpg = pgs[i]; KASSERT(tpg->uobject == uobj); + KASSERT(i == 0 || + pgs[i-1]->offset + PAGE_SIZE == tpg->offset); + KASSERT(!needs_clean || uvm_pagegetdirty(pgs[i]) != + UVM_PAGE_STATUS_DIRTY); if (tpg->offset < startoff || tpg->offset >= endoff) continue; if (flags & PGO_DEACTIVATE && tpg->wire_count == 0) { @@ -1218,6 +1223,7 @@ retry: if (needs_clean) { mutex_exit(slock); KASSERT(nextoff == pg->offset + PAGE_SIZE); + KASSERT(nback < npages); nextoff = pg->offset + ((npages - nback) << PAGE_SHIFT); KASSERT(pgs[nback] == pg); KASSERT(nextoff == pgs[npages - 1]->offset + PAGE_SIZE);
CVS commit: [yamt-pagecache] src/sys/miscfs/genfs
Module Name:src Committed By: yamt Date: Wed Jan 25 00:40:08 UTC 2012 Modified Files: src/sys/miscfs/genfs [yamt-pagecache]: genfs_io.c Log Message: comment To generate a diff of this commit: cvs rdiff -u -r1.53.2.9 -r1.53.2.10 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.53.2.9 src/sys/miscfs/genfs/genfs_io.c:1.53.2.10 --- src/sys/miscfs/genfs/genfs_io.c:1.53.2.9 Tue Jan 24 02:09:34 2012 +++ src/sys/miscfs/genfs/genfs_io.c Wed Jan 25 00:40:08 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.53.2.9 2012/01/24 02:09:34 yamt Exp $ */ +/* $NetBSD: genfs_io.c,v 1.53.2.10 2012/01/25 00:40:08 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.9 2012/01/24 02:09:34 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.10 2012/01/25 00:40:08 yamt Exp $"); #include #include @@ -1274,8 +1274,8 @@ skip_scan: #endif /* !defined(DEBUG) */ /* - * if we started any i/o and we're doing sync i/o, wait for all writes - * to finish. + * if we found or started any i/o and we're doing sync i/o, + * wait for all writes to finish. */ if (!wasclean && !async) {
CVS commit: [yamt-pagecache] src/sys/miscfs/genfs
Module Name:src Committed By: yamt Date: Tue Jan 24 02:09:35 UTC 2012 Modified Files: src/sys/miscfs/genfs [yamt-pagecache]: genfs_io.c Log Message: - g/c #if 0'ed code - minor optimization - comments To generate a diff of this commit: cvs rdiff -u -r1.53.2.8 -r1.53.2.9 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.53.2.8 src/sys/miscfs/genfs/genfs_io.c:1.53.2.9 --- src/sys/miscfs/genfs/genfs_io.c:1.53.2.8 Wed Jan 18 02:09:05 2012 +++ src/sys/miscfs/genfs/genfs_io.c Tue Jan 24 02:09:34 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.53.2.8 2012/01/18 02:09:05 yamt Exp $ */ +/* $NetBSD: genfs_io.c,v 1.53.2.9 2012/01/24 02:09:34 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.8 2012/01/18 02:09:05 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.9 2012/01/24 02:09:34 yamt Exp $"); #include #include @@ -224,6 +224,10 @@ startover: error = EBUSY; goto out_err; } + /* + * lock and unlock g_glock to ensure that no one is truncating + * the file behind us. + */ if (!genfs_node_rdtrylock(vp)) { genfs_rel_pages(ap->a_m, npages); @@ -590,19 +594,13 @@ startover: iobytes); skipbytes += iobytes; - mutex_enter(uobj->vmobjlock); - for (i = 0; i < holepages; i++) { -#if 0 -if (memwrite) { - uvm_pagemarkdirty(pgs[pidx + i], - UVM_PAGE_STATUS_DIRTY); -} -#endif -if (!blockalloc) { + if (!blockalloc) { +mutex_enter(uobj->vmobjlock); +for (i = 0; i < holepages; i++) { pgs[pidx + i]->flags |= PG_HOLE; } +mutex_exit(uobj->vmobjlock); } - mutex_exit(uobj->vmobjlock); continue; } @@ -887,7 +885,6 @@ genfs_do_putpages(struct vnode *vp, off_ (origflags & PGO_JOURNALLOCKED) == 0); retry: - written = false; flags = origflags; KASSERT((vp->v_iflag & VI_ONWORKLST) != 0 || (vp->v_iflag & VI_WRMAPDIRTY) == 0); @@ -939,10 +936,6 @@ retry: error = 0; wasclean = (vp->v_numoutput == 0); - nextoff = startoff; - if (endoff == 0 || flags & PGO_ALLPAGES) { - endoff = trunc_page(LLONG_MAX); - } /* * if this vnode is known not to have dirty pages, @@ -959,9 +952,14 @@ retry: } /* - * start the loop. + * start the loop to scan pages. */ + written = false; + nextoff = startoff; + if (endoff == 0 || flags & PGO_ALLPAGES) { + endoff = trunc_page(LLONG_MAX); + } freeflag = pagedaemon ? PG_PAGEOUT : PG_RELEASED; tryclean = true; uvm_page_array_init(&a); @@ -1102,7 +1100,14 @@ retry: /* * XXX PG_PAGER1 incompatibility check. - * this is a kludge for nfs. + * + * this is a kludge for nfs. nfs has two kind of dirty + * pages: + * - not written to the server yet + * - written to the server but not committed yet + * the latter is marked as PG_NEEDCOMMIT. (== PG_PAGER1) + * nfs doesn't want them being clustered together. + * * probably it's better to make PG_NEEDCOMMIT a first * level citizen for uvm/genfs. */
CVS commit: [yamt-pagecache] src/sys/miscfs/genfs
Module Name:src Committed By: yamt Date: Sat Jan 14 04:44:45 UTC 2012 Modified Files: src/sys/miscfs/genfs [yamt-pagecache]: genfs_io.c Log Message: fix overwrite case To generate a diff of this commit: cvs rdiff -u -r1.53.2.6 -r1.53.2.7 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.53.2.6 src/sys/miscfs/genfs/genfs_io.c:1.53.2.7 --- src/sys/miscfs/genfs/genfs_io.c:1.53.2.6 Tue Dec 20 13:46:17 2011 +++ src/sys/miscfs/genfs/genfs_io.c Sat Jan 14 04:44:45 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.53.2.6 2011/12/20 13:46:17 yamt Exp $ */ +/* $NetBSD: genfs_io.c,v 1.53.2.7 2012/01/14 04:44:45 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.6 2011/12/20 13:46:17 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.7 2012/01/14 04:44:45 yamt Exp $"); #include #include @@ -370,12 +370,10 @@ startover: struct vm_page *pg = pgs[ridx + i]; /* - * we should not see PG_HOLE pages here as it's a - * caller's responsibility to allocate blocks + * it's caller's responsibility to allocate blocks * beforehand for the overwrite case. */ - KASSERT((pg->flags & PG_HOLE) == 0); - pg->flags &= ~PG_RDONLY; + pg->flags &= ~(PG_RDONLY|PG_HOLE); /* * mark the page dirty. * otherwise another thread can do putpages and pull
CVS commit: [yamt-pagecache] src/sys/miscfs/genfs
Module Name:src Committed By: yamt Date: Wed Nov 30 14:31:30 UTC 2011 Modified Files: src/sys/miscfs/genfs [yamt-pagecache]: genfs_io.c Log Message: g/c #if 1 comment To generate a diff of this commit: cvs rdiff -u -r1.53.2.4 -r1.53.2.5 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.53.2.4 src/sys/miscfs/genfs/genfs_io.c:1.53.2.5 --- src/sys/miscfs/genfs/genfs_io.c:1.53.2.4 Sat Nov 26 15:19:06 2011 +++ src/sys/miscfs/genfs/genfs_io.c Wed Nov 30 14:31:29 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.53.2.4 2011/11/26 15:19:06 yamt Exp $ */ +/* $NetBSD: genfs_io.c,v 1.53.2.5 2011/11/30 14:31:29 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.4 2011/11/26 15:19:06 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.5 2011/11/30 14:31:29 yamt Exp $"); #include #include @@ -1094,9 +1094,12 @@ retry: pg->flags |= PG_BUSY; UVM_PAGE_OWN(pg, "genfs_putpages"); -#if 1 /* XXX notyet */ /* * first look backward. + * + * XXX implement PG_PAGER1 incompatibility check. + * probably it's better to make PG_NEEDCOMMIT a first + * level citizen for uvm/genfs. */ npages = MIN(maxpages >> 1, off >> PAGE_SHIFT); @@ -1113,9 +1116,6 @@ retry: memset(&pgs[npages - nback], 0, nback * sizeof(pgs[0])); } -#else - nback = 0; -#endif /* * then plug in our page of interest.
CVS commit: [yamt-pagecache] src/sys/miscfs/genfs
Module Name:src Committed By: yamt Date: Sun Nov 20 10:49:21 UTC 2011 Modified Files: src/sys/miscfs/genfs [yamt-pagecache]: genfs_io.c genfs_node.h Log Message: - simplify code - comments To generate a diff of this commit: cvs rdiff -u -r1.53.2.2 -r1.53.2.3 src/sys/miscfs/genfs/genfs_io.c cvs rdiff -u -r1.20 -r1.20.8.1 src/sys/miscfs/genfs/genfs_node.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.53.2.2 src/sys/miscfs/genfs/genfs_io.c:1.53.2.3 --- src/sys/miscfs/genfs/genfs_io.c:1.53.2.2 Thu Nov 10 14:37:33 2011 +++ src/sys/miscfs/genfs/genfs_io.c Sun Nov 20 10:49:20 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.53.2.2 2011/11/10 14:37:33 yamt Exp $ */ +/* $NetBSD: genfs_io.c,v 1.53.2.3 2011/11/20 10:49:20 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.2 2011/11/10 14:37:33 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.3 2011/11/20 10:49:20 yamt Exp $"); #include #include @@ -87,10 +87,8 @@ genfs_rel_pages(struct vm_page **pgs, in static void genfs_markdirty(struct vnode *vp) { - struct genfs_node * const gp = VTOG(vp); KASSERT(mutex_owned(vp->v_interlock)); - gp->g_dirtygen++; if ((vp->v_iflag & VI_ONWORKLST) == 0) { vn_syncer_add_to_worklist(vp, filedelay); } @@ -861,18 +859,16 @@ genfs_do_putpages(struct vnode *vp, off_ int i, error, npages, nback; int freeflag; struct vm_page *pgs[maxpages], *pg; - struct uvm_page_array ar; + struct uvm_page_array a; bool wasclean, needs_clean, yld; bool async = (origflags & PGO_SYNCIO) == 0; bool pagedaemon = curlwp == uvm.pagedaemon_lwp; struct lwp * const l = curlwp ? curlwp : &lwp0; - struct genfs_node * const gp = VTOG(vp); int flags; - int dirtygen; bool modified; /* if we write out any pages */ bool need_wapbl; bool has_trans; - bool cleanall; /* try to pull off from the syncer's list */ + bool tryclean; /* try to pull off from the syncer's list */ bool onworklst; const bool dirtyonly = (origflags & (PGO_DEACTIVATE|PGO_FREE)) == 0; @@ -894,6 +890,11 @@ retry: flags = origflags; KASSERT((vp->v_iflag & VI_ONWORKLST) != 0 || (vp->v_iflag & VI_WRMAPDIRTY) == 0); + + /* + * shortcut if we have no pages to process. + */ + if (uobj->uo_npages == 0 || (dirtyonly && radix_tree_empty_tagged_tree_p(&uobj->uo_pages, UVM_PAGE_DIRTY_TAG))) { @@ -957,29 +958,18 @@ retry: } /* - * start the loop. when scanning by list, hold the last page - * in the list before we start. pages allocated after we start - * will be added to the end of the list, so we can stop at the - * current last page. + * start the loop. */ - cleanall = (flags & PGO_CLEANIT) != 0 && wasclean && - startoff == 0 && endoff == trunc_page(LLONG_MAX) && - (vp->v_iflag & VI_ONWORKLST) != 0; - dirtygen = gp->g_dirtygen; freeflag = pagedaemon ? PG_PAGEOUT : PG_RELEASED; - - uvm_page_array_init(&ar); + tryclean = true; + uvm_page_array_init(&a); for (;;) { bool protected; - pg = uvm_page_array_peek(&ar); + pg = uvm_page_array_fill_and_peek(&a, uobj, off, dirtyonly); if (pg == NULL) { - if (uvm_page_array_fill(&ar, uobj, off, dirtyonly)) { -break; - } - pg = uvm_page_array_peek(&ar); - KASSERT(pg != NULL); + break; } /* @@ -987,21 +977,20 @@ retry: */ KASSERT(pg->uobject == uobj); - KASSERT((pg->flags & PG_MARKER) == 0); KASSERT((pg->flags & (PG_RELEASED|PG_PAGEOUT)) == 0 || - (pg->flags & (PG_BUSY|PG_MARKER)) != 0); + (pg->flags & (PG_BUSY)) != 0); KASSERT(pg->offset >= startoff); KASSERT(pg->offset >= off); KASSERT(!dirtyonly || uvm_pagegetdirty(pg) != UVM_PAGE_STATUS_CLEAN); - off = pg->offset + PAGE_SIZE; if (pg->offset >= endoff) { break; } if (pg->flags & (PG_RELEASED|PG_PAGEOUT)) { KASSERT((pg->flags & PG_BUSY) != 0); wasclean = false; - uvm_page_array_advance(&ar); + off = pg->offset + PAGE_SIZE; + uvm_page_array_advance(&a); continue; } @@ -1029,23 +1018,25 @@ retry: break; } off = pg->offset; /* visit this page again */ - if (yld) { -mutex_exit(slock); -preempt(); - } else { + if ((pg->flags & PG_BUSY) != 0) { pg->flags |= PG_WANTED; UVM_UNLOCK_AND_WAIT(pg, slock, 0, "genput", 0); + } else { +KASSERT(yld); +mutex_exit(slock); +preempt(); } /* * as we dropped the object lock, our cached pages can * be stale. */ - uvm_page_array_clear(&ar); + uvm_page_array_clear(&a); mutex_enter(slock); continue; } - uvm_page_array_advance(&ar); + off = pg->offset + PAGE_SIZE; + uvm_page_array_advance(&a); /* * if we're freeing, remove all mappings of the page now. @@ -1063,8 +1054,7 @@ retry: * from the
CVS commit: [yamt-pagecache] src/sys/miscfs/genfs
Module Name:src Committed By: yamt Date: Thu Nov 10 14:37:33 UTC 2011 Modified Files: src/sys/miscfs/genfs [yamt-pagecache]: genfs_io.c Log Message: - remove uobj->memq - fix UVM_PAGE_TRKOWN - comments To generate a diff of this commit: cvs rdiff -u -r1.53.2.1 -r1.53.2.2 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.53.2.1 src/sys/miscfs/genfs/genfs_io.c:1.53.2.2 --- src/sys/miscfs/genfs/genfs_io.c:1.53.2.1 Wed Nov 2 21:53:59 2011 +++ src/sys/miscfs/genfs/genfs_io.c Thu Nov 10 14:37:33 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.53.2.1 2011/11/02 21:53:59 yamt Exp $ */ +/* $NetBSD: genfs_io.c,v 1.53.2.2 2011/11/10 14:37:33 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.1 2011/11/02 21:53:59 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53.2.2 2011/11/10 14:37:33 yamt Exp $"); #include #include @@ -869,10 +869,10 @@ genfs_do_putpages(struct vnode *vp, off_ struct genfs_node * const gp = VTOG(vp); int flags; int dirtygen; - bool modified; + bool modified; /* if we write out any pages */ bool need_wapbl; bool has_trans; - bool cleanall; + bool cleanall; /* try to pull off from the syncer's list */ bool onworklst; const bool dirtyonly = (origflags & (PGO_DEACTIVATE|PGO_FREE)) == 0; @@ -894,7 +894,9 @@ retry: flags = origflags; KASSERT((vp->v_iflag & VI_ONWORKLST) != 0 || (vp->v_iflag & VI_WRMAPDIRTY) == 0); - if (uobj->uo_npages == 0) { + if (uobj->uo_npages == 0 || (dirtyonly && + radix_tree_empty_tagged_tree_p(&uobj->uo_pages, + UVM_PAGE_DIRTY_TAG))) { if (vp->v_iflag & VI_ONWORKLST) { vp->v_iflag &= ~VI_WRMAPDIRTY; if (LIST_FIRST(&vp->v_dirtyblkhd) == NULL) @@ -947,7 +949,7 @@ retry: if ((vp->v_iflag & VI_ONWORKLST) == 0) { #if !defined(DEBUG) - if ((flags & (PGO_FREE|PGO_DEACTIVATE)) == 0) { + if (dirtyonly) { goto skip_scan; } #endif /* !defined(DEBUG) */ @@ -1177,6 +1179,7 @@ retry: break; } nextpg->flags |= PG_BUSY; +UVM_PAGE_OWN(nextpg, "genfs_putpages2"); pgs[npages] = nextpg; uvm_page_array_advance(&ar); } @@ -1254,6 +1257,16 @@ retry: } uvm_page_array_fini(&ar); + /* + * update ctime/mtime if the modification we started writing out might + * be from mmap'ed write. + * + * this is necessary when an application keeps a file mmaped and + * repeatedly modifies it via the window. note that, because we + * don't always write-protect pages when cleaning, such modifications + * might not involve any page faults. + */ + if (modified && (vp->v_iflag & VI_WRMAPDIRTY) != 0 && (vp->v_type != VBLK || (vp->v_mount->mnt_flag & MNT_NODEVMTIME) == 0)) { @@ -1268,20 +1281,6 @@ retry: if (cleanall && wasclean && gp->g_dirtygen == dirtygen && (vp->v_iflag & VI_ONWORKLST) != 0) { -#if defined(DEBUG) - TAILQ_FOREACH(pg, &uobj->memq, listq.queue) { - if ((pg->flags & (PG_FAKE | PG_MARKER)) != 0) { -continue; - } - if (uvm_pagegetdirty(pg) == UVM_PAGE_STATUS_DIRTY) { -printf("%s: %p: dirty\n", __func__, pg); - } - if (uvm_pagegetdirty(pg) == UVM_PAGE_STATUS_UNKNOWN) { -printf("%s: %p: unknown\n", __func__, pg); - } - } -#endif /* defined(DEBUG) */ - KASSERT(radix_tree_empty_tagged_tree_p(&uobj->uo_pages, UVM_PAGE_DIRTY_TAG)); vp->v_iflag &= ~VI_WRMAPDIRTY;