Deleted Added
full compact
ffs_rawread.c (150010) ffs_rawread.c (156225)
1/*-
2 * Copyright (c) 2000-2003 Tor Egge
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2000-2003 Tor Egge
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/ufs/ffs/ffs_rawread.c 150010 2005-09-12 01:21:42Z tegge $");
28__FBSDID("$FreeBSD: head/sys/ufs/ffs/ffs_rawread.c 156225 2006-03-02 22:13:28Z tegge $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/fcntl.h>
33#include <sys/file.h>
34#include <sys/stat.h>
35#include <sys/proc.h>
36#include <sys/limits.h>

--- 59 unchanged lines hidden (view full) ---

96
97static int
98ffs_rawread_sync(struct vnode *vp, struct thread *td)
99{
100 int spl;
101 int error;
102 int upgraded;
103 struct bufobj *bo;
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/fcntl.h>
33#include <sys/file.h>
34#include <sys/stat.h>
35#include <sys/proc.h>
36#include <sys/limits.h>

--- 59 unchanged lines hidden (view full) ---

96
97static int
98ffs_rawread_sync(struct vnode *vp, struct thread *td)
99{
100 int spl;
101 int error;
102 int upgraded;
103 struct bufobj *bo;
104 struct mount *mp;
104
105 /* Check for dirty mmap, pending writes and dirty buffers */
106 spl = splbio();
107 VI_LOCK(vp);
108 bo = &vp->v_bufobj;
109 if (bo->bo_numoutput > 0 ||
110 bo->bo_dirty.bv_cnt > 0 ||
111 (vp->v_iflag & VI_OBJDIRTY) != 0) {
112 splx(spl);
113 VI_UNLOCK(vp);
114
105
106 /* Check for dirty mmap, pending writes and dirty buffers */
107 spl = splbio();
108 VI_LOCK(vp);
109 bo = &vp->v_bufobj;
110 if (bo->bo_numoutput > 0 ||
111 bo->bo_dirty.bv_cnt > 0 ||
112 (vp->v_iflag & VI_OBJDIRTY) != 0) {
113 splx(spl);
114 VI_UNLOCK(vp);
115
115 if (VOP_ISLOCKED(vp, td) != LK_EXCLUSIVE) {
116 if (vn_start_write(vp, &mp, V_NOWAIT) != 0) {
117 if (VOP_ISLOCKED(vp, td) != LK_EXCLUSIVE)
118 upgraded = 1;
119 else
120 upgraded = 0;
121 VOP_UNLOCK(vp, 0, td);
122 (void) vn_start_write(vp, &mp, V_WAIT);
123 VOP_LOCK(vp, LK_EXCLUSIVE, td);
124 } else if (VOP_ISLOCKED(vp, td) != LK_EXCLUSIVE) {
116 upgraded = 1;
117 /* Upgrade to exclusive lock, this might block */
118 VOP_LOCK(vp, LK_UPGRADE, td);
119 } else
120 upgraded = 0;
121
122
123 /* Attempt to msync mmap() regions to clean dirty mmap */

--- 32 unchanged lines hidden (view full) ---

156 spl = splbio();
157 if (bo->bo_numoutput > 0 || bo->bo_dirty.bv_cnt > 0)
158 panic("ffs_rawread_sync: dirty bufs");
159 }
160 splx(spl);
161 VI_UNLOCK(vp);
162 if (upgraded != 0)
163 VOP_LOCK(vp, LK_DOWNGRADE, td);
125 upgraded = 1;
126 /* Upgrade to exclusive lock, this might block */
127 VOP_LOCK(vp, LK_UPGRADE, td);
128 } else
129 upgraded = 0;
130
131
132 /* Attempt to msync mmap() regions to clean dirty mmap */

--- 32 unchanged lines hidden (view full) ---

165 spl = splbio();
166 if (bo->bo_numoutput > 0 || bo->bo_dirty.bv_cnt > 0)
167 panic("ffs_rawread_sync: dirty bufs");
168 }
169 splx(spl);
170 VI_UNLOCK(vp);
171 if (upgraded != 0)
172 VOP_LOCK(vp, LK_DOWNGRADE, td);
173 vn_finished_write(mp);
164 } else {
165 splx(spl);
166 VI_UNLOCK(vp);
167 }
168 return 0;
169}
170
171

--- 306 unchanged lines hidden ---
174 } else {
175 splx(spl);
176 VI_UNLOCK(vp);
177 }
178 return 0;
179}
180
181

--- 306 unchanged lines hidden ---