| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ffs_alloc.c,v 1.106.8.7 2008/12/30 19:30:31 christos Exp $ */ | | 1 | /* $NetBSD: ffs_alloc.c,v 1.106.8.8 2009/01/04 19:20:32 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008 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.106.8.7 2008/12/30 19:30:31 christos Exp $"); | | 73 | __KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.106.8.8 2009/01/04 19:20:32 christos 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 | #endif | | 78 | #endif |
79 | | | 79 | |
80 | #include <sys/param.h> | | 80 | #include <sys/param.h> |
81 | #include <sys/systm.h> | | 81 | #include <sys/systm.h> |
82 | #include <sys/buf.h> | | 82 | #include <sys/buf.h> |
83 | #include <sys/fstrans.h> | | 83 | #include <sys/fstrans.h> |
84 | #include <sys/kauth.h> | | 84 | #include <sys/kauth.h> |
85 | #include <sys/kernel.h> | | 85 | #include <sys/kernel.h> |
86 | #include <sys/mount.h> | | 86 | #include <sys/mount.h> |
| @@ -196,27 +196,28 @@ ffs_alloc(struct inode *ip, daddr_t lbn, | | | @@ -196,27 +196,28 @@ ffs_alloc(struct inode *ip, daddr_t lbn, |
196 | pg = uvm_pagelookup(uobj, off); | | 196 | pg = uvm_pagelookup(uobj, off); |
197 | KASSERT(pg != NULL); | | 197 | KASSERT(pg != NULL); |
198 | KASSERT(pg->owner == curproc->p_pid); | | 198 | KASSERT(pg->owner == curproc->p_pid); |
199 | off += PAGE_SIZE; | | 199 | off += PAGE_SIZE; |
200 | } | | 200 | } |
201 | mutex_exit(&uobj->vmobjlock); | | 201 | mutex_exit(&uobj->vmobjlock); |
202 | } | | 202 | } |
203 | #endif | | 203 | #endif |
204 | | | 204 | |
205 | *bnp = 0; | | 205 | *bnp = 0; |
206 | #ifdef DIAGNOSTIC | | 206 | #ifdef DIAGNOSTIC |
207 | if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) { | | 207 | if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) { |
208 | printf("dev = 0x%llx, bsize = %d, size = %d, fs = %s\n", | | 208 | printf("dev = 0x%llx, bsize = %d, size = %d, fs = %s\n", |
209 | ip->i_dev, fs->fs_bsize, size, fs->fs_fsmnt); | | 209 | (unsigned long long)ip->i_dev, fs->fs_bsize, size, |
| | | 210 | fs->fs_fsmnt); |
210 | panic("ffs_alloc: bad size"); | | 211 | panic("ffs_alloc: bad size"); |
211 | } | | 212 | } |
212 | if (cred == NOCRED) | | 213 | if (cred == NOCRED) |
213 | panic("ffs_alloc: missing credential"); | | 214 | panic("ffs_alloc: missing credential"); |
214 | #endif /* DIAGNOSTIC */ | | 215 | #endif /* DIAGNOSTIC */ |
215 | if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0) | | 216 | if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0) |
216 | goto nospace; | | 217 | goto nospace; |
217 | if (freespace(fs, fs->fs_minfree) <= 0 && | | 218 | if (freespace(fs, fs->fs_minfree) <= 0 && |
218 | kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL) != 0) | | 219 | kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL) != 0) |
219 | goto nospace; | | 220 | goto nospace; |
220 | #ifdef QUOTA | | 221 | #ifdef QUOTA |
221 | mutex_exit(&ump->um_lock); | | 222 | mutex_exit(&ump->um_lock); |
222 | if ((error = chkdq(ip, btodb(size), cred, 0)) != 0) | | 223 | if ((error = chkdq(ip, btodb(size), cred, 0)) != 0) |
| @@ -304,27 +305,28 @@ ffs_realloccg(struct inode *ip, daddr_t | | | @@ -304,27 +305,28 @@ ffs_realloccg(struct inode *ip, daddr_t |
304 | KASSERT(pg->owner == curproc->p_pid); | | 305 | KASSERT(pg->owner == curproc->p_pid); |
305 | KASSERT((pg->flags & PG_CLEAN) == 0); | | 306 | KASSERT((pg->flags & PG_CLEAN) == 0); |
306 | off += PAGE_SIZE; | | 307 | off += PAGE_SIZE; |
307 | } | | 308 | } |
308 | mutex_exit(&uobj->vmobjlock); | | 309 | mutex_exit(&uobj->vmobjlock); |
309 | } | | 310 | } |
310 | #endif | | 311 | #endif |
311 | | | 312 | |
312 | #ifdef DIAGNOSTIC | | 313 | #ifdef DIAGNOSTIC |
313 | if ((u_int)osize > fs->fs_bsize || fragoff(fs, osize) != 0 || | | 314 | if ((u_int)osize > fs->fs_bsize || fragoff(fs, osize) != 0 || |
314 | (u_int)nsize > fs->fs_bsize || fragoff(fs, nsize) != 0) { | | 315 | (u_int)nsize > fs->fs_bsize || fragoff(fs, nsize) != 0) { |
315 | printf( | | 316 | printf( |
316 | "dev = 0x%llx, bsize = %d, osize = %d, nsize = %d, fs = %s\n", | | 317 | "dev = 0x%llx, bsize = %d, osize = %d, nsize = %d, fs = %s\n", |
317 | ip->i_dev, fs->fs_bsize, osize, nsize, fs->fs_fsmnt); | | 318 | (unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize, |
| | | 319 | fs->fs_fsmnt); |
318 | panic("ffs_realloccg: bad size"); | | 320 | panic("ffs_realloccg: bad size"); |
319 | } | | 321 | } |
320 | if (cred == NOCRED) | | 322 | if (cred == NOCRED) |
321 | panic("ffs_realloccg: missing credential"); | | 323 | panic("ffs_realloccg: missing credential"); |
322 | #endif /* DIAGNOSTIC */ | | 324 | #endif /* DIAGNOSTIC */ |
323 | if (freespace(fs, fs->fs_minfree) <= 0 && | | 325 | if (freespace(fs, fs->fs_minfree) <= 0 && |
324 | kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL) != 0) { | | 326 | kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL) != 0) { |
325 | mutex_exit(&ump->um_lock); | | 327 | mutex_exit(&ump->um_lock); |
326 | goto nospace; | | 328 | goto nospace; |
327 | } | | 329 | } |
328 | if (fs->fs_magic == FS_UFS2_MAGIC) | | 330 | if (fs->fs_magic == FS_UFS2_MAGIC) |
329 | bprev = ufs_rw64(ip->i_ffs2_db[lbprev], UFS_FSNEEDSWAP(fs)); | | 331 | bprev = ufs_rw64(ip->i_ffs2_db[lbprev], UFS_FSNEEDSWAP(fs)); |
330 | else | | 332 | else |