| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: lfs.c,v 1.41 2013/10/19 01:09:58 christos Exp $ */ | | 1 | /* $NetBSD: lfs.c,v 1.42 2014/07/12 19:44:00 dholland Exp $ */ |
2 | /*- | | 2 | /*- |
3 | * Copyright (c) 2003 The NetBSD Foundation, Inc. | | 3 | * Copyright (c) 2003 The NetBSD Foundation, Inc. |
4 | * All rights reserved. | | 4 | * All rights reserved. |
5 | * | | 5 | * |
6 | * This code is derived from software contributed to The NetBSD Foundation | | 6 | * This code is derived from software contributed to The NetBSD Foundation |
7 | * by Konrad E. Schroder <perseant@hhhh.org>. | | 7 | * by Konrad E. Schroder <perseant@hhhh.org>. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -75,49 +75,49 @@ | | | @@ -75,49 +75,49 @@ |
75 | #include <ufs/lfs/lfs_inode.h> | | 75 | #include <ufs/lfs/lfs_inode.h> |
76 | #undef vnode | | 76 | #undef vnode |
77 | | | 77 | |
78 | #include <assert.h> | | 78 | #include <assert.h> |
79 | #include <err.h> | | 79 | #include <err.h> |
80 | #include <errno.h> | | 80 | #include <errno.h> |
81 | #include <stdarg.h> | | 81 | #include <stdarg.h> |
82 | #include <stdio.h> | | 82 | #include <stdio.h> |
83 | #include <stdlib.h> | | 83 | #include <stdlib.h> |
84 | #include <string.h> | | 84 | #include <string.h> |
85 | #include <unistd.h> | | 85 | #include <unistd.h> |
86 | #include <util.h> | | 86 | #include <util.h> |
87 | | | 87 | |
| | | 88 | #include "fsutil.h" |
88 | #include "bufcache.h" | | 89 | #include "bufcache.h" |
89 | #include "vnode.h" | | 90 | #include "vnode.h" |
90 | #include "lfs_user.h" | | 91 | #include "lfs_user.h" |
91 | #include "segwrite.h" | | 92 | #include "segwrite.h" |
92 | #include "kernelops.h" | | 93 | #include "kernelops.h" |
93 | | | 94 | |
94 | #define panic call_panic | | 95 | #define panic call_panic |
95 | | | 96 | |
96 | extern u_int32_t cksum(void *, size_t); | | 97 | extern u_int32_t cksum(void *, size_t); |
97 | extern u_int32_t lfs_sb_cksum(struct dlfs *); | | 98 | extern u_int32_t lfs_sb_cksum(struct dlfs *); |
98 | extern void pwarn(const char *, ...); | | 99 | extern void pwarn(const char *, ...); |
99 | | | 100 | |
100 | extern struct uvnodelst vnodelist; | | 101 | extern struct uvnodelst vnodelist; |
101 | extern struct uvnodelst getvnodelist[VNODE_HASH_MAX]; | | 102 | extern struct uvnodelst getvnodelist[VNODE_HASH_MAX]; |
102 | extern int nvnodes; | | 103 | extern int nvnodes; |
103 | | | 104 | |
104 | long dev_bsize = DEV_BSIZE; | | 105 | long dev_bsize = DEV_BSIZE; |
105 | | | 106 | |
106 | static int | | 107 | static int |
107 | lfs_fragextend(struct uvnode *, int, int, daddr_t, struct ubuf **); | | 108 | lfs_fragextend(struct uvnode *, int, int, daddr_t, struct ubuf **); |
108 | | | 109 | |
109 | int fsdirty = 0; | | 110 | int fsdirty = 0; |
110 | void (*panic_func)(int, const char *, va_list) = my_vpanic; | | | |
111 | | | 111 | |
112 | /* | | 112 | /* |
113 | * LFS buffer and uvnode operations | | 113 | * LFS buffer and uvnode operations |
114 | */ | | 114 | */ |
115 | | | 115 | |
116 | int | | 116 | int |
117 | lfs_vop_strategy(struct ubuf * bp) | | 117 | lfs_vop_strategy(struct ubuf * bp) |
118 | { | | 118 | { |
119 | int count; | | 119 | int count; |
120 | | | 120 | |
121 | if (bp->b_flags & B_READ) { | | 121 | if (bp->b_flags & B_READ) { |
122 | count = kops.ko_pread(bp->b_vp->v_fd, bp->b_data, bp->b_bcount, | | 122 | count = kops.ko_pread(bp->b_vp->v_fd, bp->b_data, bp->b_bcount, |
123 | bp->b_blkno * dev_bsize); | | 123 | bp->b_blkno * dev_bsize); |
| @@ -825,39 +825,32 @@ check_summary(struct lfs *fs, SEGSUM *sp | | | @@ -825,39 +825,32 @@ check_summary(struct lfs *fs, SEGSUM *sp |
825 | pwarn("Partial segment at 0x%" PRIx32 " data checksum" | | 825 | pwarn("Partial segment at 0x%" PRIx32 " data checksum" |
826 | " mismatch: given 0x%x, computed 0x%x\n", | | 826 | " mismatch: given 0x%x, computed 0x%x\n", |
827 | pseg_addr, sp->ss_datasum, ccksum); | | 827 | pseg_addr, sp->ss_datasum, ccksum); |
828 | free(datap); | | 828 | free(datap); |
829 | return 0; | | 829 | return 0; |
830 | } | | 830 | } |
831 | free(datap); | | 831 | free(datap); |
832 | assert(bc >= 0); | | 832 | assert(bc >= 0); |
833 | return bc; | | 833 | return bc; |
834 | } | | 834 | } |
835 | | | 835 | |
836 | /* print message and exit */ | | 836 | /* print message and exit */ |
837 | void | | 837 | void |
838 | my_vpanic(int fatal, const char *fmt, va_list ap) | | | |
839 | { | | | |
840 | (void) vprintf(fmt, ap); | | | |
841 | exit(8); | | | |
842 | } | | | |
843 | | | | |
844 | void | | | |
845 | call_panic(const char *fmt, ...) | | 838 | call_panic(const char *fmt, ...) |
846 | { | | 839 | { |
847 | va_list ap; | | 840 | va_list ap; |
848 | | | 841 | |
849 | va_start(ap, fmt); | | 842 | va_start(ap, fmt); |
850 | panic_func(1, fmt, ap); | | 843 | vmsg(1, fmt, ap); |
851 | va_end(ap); | | 844 | va_end(ap); |
852 | } | | 845 | } |
853 | | | 846 | |
854 | /* Allocate a new inode. */ | | 847 | /* Allocate a new inode. */ |
855 | struct uvnode * | | 848 | struct uvnode * |
856 | lfs_valloc(struct lfs *fs, ino_t ino) | | 849 | lfs_valloc(struct lfs *fs, ino_t ino) |
857 | { | | 850 | { |
858 | struct ubuf *bp, *cbp; | | 851 | struct ubuf *bp, *cbp; |
859 | struct ifile *ifp; | | 852 | struct ifile *ifp; |
860 | ino_t new_ino; | | 853 | ino_t new_ino; |
861 | int error; | | 854 | int error; |
862 | CLEANERINFO *cip; | | 855 | CLEANERINFO *cip; |
863 | | | 856 | |