Sun Jul 26 00:20:14 2020 UTC ()
skip the assertions about page-locking when allocating to the extattr bmap,
since extattrs do not use the page cache.


(chs)
diff -r1.167 -r1.168 src/sys/ufs/ffs/ffs_alloc.c

cvs diff -r1.167 -r1.168 src/sys/ufs/ffs/ffs_alloc.c (expand / switch to unified diff)

--- src/sys/ufs/ffs/ffs_alloc.c 2020/04/18 19:18:34 1.167
+++ src/sys/ufs/ffs/ffs_alloc.c 2020/07/26 00:20:13 1.168
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ffs_alloc.c,v 1.167 2020/04/18 19:18:34 christos Exp $ */ 1/* $NetBSD: ffs_alloc.c,v 1.168 2020/07/26 00:20:13 chs Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Wasabi Systems, Inc. 8 * by Wasabi Systems, Inc.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -60,27 +60,27 @@ @@ -60,27 +60,27 @@
60 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 60 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
61 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 61 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
62 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 62 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
63 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 63 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 64 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
65 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 65 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
66 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 66 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
67 * SUCH DAMAGE. 67 * SUCH DAMAGE.
68 * 68 *
69 * @(#)ffs_alloc.c 8.19 (Berkeley) 7/13/95 69 * @(#)ffs_alloc.c 8.19 (Berkeley) 7/13/95
70 */ 70 */
71 71
72#include <sys/cdefs.h> 72#include <sys/cdefs.h>
73__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.167 2020/04/18 19:18:34 christos Exp $"); 73__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.168 2020/07/26 00:20:13 chs Exp $");
74 74
75#if defined(_KERNEL_OPT) 75#if defined(_KERNEL_OPT)
76#include "opt_ffs.h" 76#include "opt_ffs.h"
77#include "opt_quota.h" 77#include "opt_quota.h"
78#include "opt_uvm_page_trkown.h" 78#include "opt_uvm_page_trkown.h"
79#endif 79#endif
80 80
81#include <sys/param.h> 81#include <sys/param.h>
82#include <sys/systm.h> 82#include <sys/systm.h>
83#include <sys/buf.h> 83#include <sys/buf.h>
84#include <sys/cprng.h> 84#include <sys/cprng.h>
85#include <sys/kauth.h> 85#include <sys/kauth.h>
86#include <sys/kernel.h> 86#include <sys/kernel.h>
@@ -194,27 +194,27 @@ ffs_alloc(struct inode *ip, daddr_t lbn, @@ -194,27 +194,27 @@ ffs_alloc(struct inode *ip, daddr_t lbn,
194 * Sanity-check that allocations within the file size 194 * Sanity-check that allocations within the file size
195 * do not allow other threads to read the stale contents 195 * do not allow other threads to read the stale contents
196 * of newly allocated blocks. 196 * of newly allocated blocks.
197 * Usually pages will exist to cover the new allocation. 197 * Usually pages will exist to cover the new allocation.
198 * There is an optimization in ffs_write() where we skip 198 * There is an optimization in ffs_write() where we skip
199 * creating pages if several conditions are met: 199 * creating pages if several conditions are met:
200 * - the file must not be mapped (in any user address space). 200 * - the file must not be mapped (in any user address space).
201 * - the write must cover whole pages and whole blocks. 201 * - the write must cover whole pages and whole blocks.
202 * If those conditions are not met then pages must exist and 202 * If those conditions are not met then pages must exist and
203 * be locked by the current thread. 203 * be locked by the current thread.
204 */ 204 */
205 205
206 struct vnode *vp = ITOV(ip); 206 struct vnode *vp = ITOV(ip);
207 if (vp->v_type == VREG && 207 if (vp->v_type == VREG && (flags & IO_EXT) == 0 &&
208 ffs_lblktosize(fs, (voff_t)lbn) < round_page(vp->v_size) && 208 ffs_lblktosize(fs, (voff_t)lbn) < round_page(vp->v_size) &&
209 ((vp->v_vflag & VV_MAPPED) != 0 || (size & PAGE_MASK) != 0 || 209 ((vp->v_vflag & VV_MAPPED) != 0 || (size & PAGE_MASK) != 0 ||
210 ffs_blkoff(fs, size) != 0)) { 210 ffs_blkoff(fs, size) != 0)) {
211 struct vm_page *pg __diagused; 211 struct vm_page *pg __diagused;
212 struct uvm_object *uobj = &vp->v_uobj; 212 struct uvm_object *uobj = &vp->v_uobj;
213 voff_t off = trunc_page(ffs_lblktosize(fs, lbn)); 213 voff_t off = trunc_page(ffs_lblktosize(fs, lbn));
214 voff_t endoff = round_page(ffs_lblktosize(fs, lbn) + size); 214 voff_t endoff = round_page(ffs_lblktosize(fs, lbn) + size);
215 215
216 rw_enter(uobj->vmobjlock, RW_WRITER); 216 rw_enter(uobj->vmobjlock, RW_WRITER);
217 while (off < endoff) { 217 while (off < endoff) {
218 pg = uvm_pagelookup(uobj, off); 218 pg = uvm_pagelookup(uobj, off);
219 KASSERT((pg != NULL && pg->owner_tag != NULL && 219 KASSERT((pg != NULL && pg->owner_tag != NULL &&
220 pg->owner == curproc->p_pid && 220 pg->owner == curproc->p_pid &&