geom_vfs.c (238892) | geom_vfs.c (241896) |
---|---|
1/*- 2 * Copyright (c) 2004 Poul-Henning Kamp 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) 2004 Poul-Henning Kamp 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/geom/geom_vfs.c 238892 2012-07-29 20:04:09Z mav $"); | 28__FBSDID("$FreeBSD: head/sys/geom/geom_vfs.c 241896 2012-10-22 17:50:54Z kib $"); |
29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/bio.h> 33#include <sys/kernel.h> 34#include <sys/lock.h> 35#include <sys/malloc.h> 36#include <sys/mutex.h> 37#include <sys/vnode.h> | 29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/bio.h> 33#include <sys/kernel.h> 34#include <sys/lock.h> 35#include <sys/malloc.h> 36#include <sys/mutex.h> 37#include <sys/vnode.h> |
38#include <sys/mount.h> /* XXX Temporary for VFS_LOCK_GIANT */ | 38#include |
39 40#include <geom/geom.h> 41#include <geom/geom_vfs.h> 42 43/* 44 * subroutines for use by filesystems. 45 * 46 * XXX: should maybe live somewhere else ? --- 42 unchanged lines hidden (view full) --- 89} 90 91static void 92g_vfs_done(struct bio *bip) 93{ 94 struct g_consumer *cp; 95 struct g_vfs_softc *sc; 96 struct buf *bp; | 39 40#include <geom/geom.h> 41#include <geom/geom_vfs.h> 42 43/* 44 * subroutines for use by filesystems. 45 * 46 * XXX: should maybe live somewhere else ? --- 42 unchanged lines hidden (view full) --- 89} 90 91static void 92g_vfs_done(struct bio *bip) 93{ 94 struct g_consumer *cp; 95 struct g_vfs_softc *sc; 96 struct buf *bp; |
97 int vfslocked, destroy; | 97 int destroy; |
98 struct mount *mp; 99 struct vnode *vp; 100 struct cdev *cdevp; 101 102 /* 103 * Collect statistics on synchronous and asynchronous read 104 * and write counts for disks that have associated filesystems. 105 * Since this run by the g_up thread it is single threaded and --- 47 unchanged lines hidden (view full) --- 153 g_destroy_bio(bip); 154 155 mtx_lock(&sc->sc_mtx); 156 destroy = ((--sc->sc_active) == 0 && sc->sc_orphaned); 157 mtx_unlock(&sc->sc_mtx); 158 if (destroy) 159 g_post_event(g_vfs_destroy, cp, M_WAITOK, NULL); 160 | 98 struct mount *mp; 99 struct vnode *vp; 100 struct cdev *cdevp; 101 102 /* 103 * Collect statistics on synchronous and asynchronous read 104 * and write counts for disks that have associated filesystems. 105 * Since this run by the g_up thread it is single threaded and --- 47 unchanged lines hidden (view full) --- 153 g_destroy_bio(bip); 154 155 mtx_lock(&sc->sc_mtx); 156 destroy = ((--sc->sc_active) == 0 && sc->sc_orphaned); 157 mtx_unlock(&sc->sc_mtx); 158 if (destroy) 159 g_post_event(g_vfs_destroy, cp, M_WAITOK, NULL); 160 |
161 vfslocked = VFS_LOCK_GIANT(((struct mount *)NULL)); | |
162 bufdone(bp); | 161 bufdone(bp); |
163 VFS_UNLOCK_GIANT(vfslocked); | |
164} 165 166void 167g_vfs_strategy(struct bufobj *bo, struct buf *bp) 168{ 169 struct g_vfs_softc *sc; 170 struct g_consumer *cp; 171 struct bio *bip; | 162} 163 164void 165g_vfs_strategy(struct bufobj *bo, struct buf *bp) 166{ 167 struct g_vfs_softc *sc; 168 struct g_consumer *cp; 169 struct bio *bip; |
172 int vfslocked; | |
173 174 cp = bo->bo_private; 175 sc = cp->geom->softc; 176 177 /* 178 * If the provider has orphaned us, just return EXIO. 179 */ 180 mtx_lock(&sc->sc_mtx); 181 if (sc->sc_orphaned) { 182 mtx_unlock(&sc->sc_mtx); 183 bp->b_error = ENXIO; 184 bp->b_ioflags |= BIO_ERROR; | 170 171 cp = bo->bo_private; 172 sc = cp->geom->softc; 173 174 /* 175 * If the provider has orphaned us, just return EXIO. 176 */ 177 mtx_lock(&sc->sc_mtx); 178 if (sc->sc_orphaned) { 179 mtx_unlock(&sc->sc_mtx); 180 bp->b_error = ENXIO; 181 bp->b_ioflags |= BIO_ERROR; |
185 vfslocked = VFS_LOCK_GIANT(((struct mount *)NULL)); | |
186 bufdone(bp); | 182 bufdone(bp); |
187 VFS_UNLOCK_GIANT(vfslocked); | |
188 return; 189 } 190 sc->sc_active++; 191 mtx_unlock(&sc->sc_mtx); 192 193 bip = g_alloc_bio(); 194 bip->bio_cmd = bp->b_iocmd; 195 bip->bio_offset = bp->b_iooffset; --- 33 unchanged lines hidden (view full) --- 229int 230g_vfs_open(struct vnode *vp, struct g_consumer **cpp, const char *fsname, int wr) 231{ 232 struct g_geom *gp; 233 struct g_provider *pp; 234 struct g_consumer *cp; 235 struct g_vfs_softc *sc; 236 struct bufobj *bo; | 183 return; 184 } 185 sc->sc_active++; 186 mtx_unlock(&sc->sc_mtx); 187 188 bip = g_alloc_bio(); 189 bip->bio_cmd = bp->b_iocmd; 190 bip->bio_offset = bp->b_iooffset; --- 33 unchanged lines hidden (view full) --- 224int 225g_vfs_open(struct vnode *vp, struct g_consumer **cpp, const char *fsname, int wr) 226{ 227 struct g_geom *gp; 228 struct g_provider *pp; 229 struct g_consumer *cp; 230 struct g_vfs_softc *sc; 231 struct bufobj *bo; |
237 int vfslocked; | |
238 int error; 239 240 g_topology_assert(); 241 242 *cpp = NULL; 243 bo = &vp->v_bufobj; 244 if (bo->bo_private != vp) 245 return (EBUSY); --- 8 unchanged lines hidden (view full) --- 254 gp->softc = sc; 255 cp = g_new_consumer(gp); 256 g_attach(cp, pp); 257 error = g_access(cp, 1, wr, wr); 258 if (error) { 259 g_wither_geom(gp, ENXIO); 260 return (error); 261 } | 232 int error; 233 234 g_topology_assert(); 235 236 *cpp = NULL; 237 bo = &vp->v_bufobj; 238 if (bo->bo_private != vp) 239 return (EBUSY); --- 8 unchanged lines hidden (view full) --- 248 gp->softc = sc; 249 cp = g_new_consumer(gp); 250 g_attach(cp, pp); 251 error = g_access(cp, 1, wr, wr); 252 if (error) { 253 g_wither_geom(gp, ENXIO); 254 return (error); 255 } |
262 vfslocked = VFS_LOCK_GIANT(vp->v_mount); | |
263 vnode_create_vobject(vp, pp->mediasize, curthread); | 256 vnode_create_vobject(vp, pp->mediasize, curthread); |
264 VFS_UNLOCK_GIANT(vfslocked); | |
265 *cpp = cp; 266 cp->private = vp; 267 bo->bo_ops = g_vfs_bufops; 268 bo->bo_private = cp; 269 bo->bo_bsize = pp->sectorsize; 270 271 return (error); 272} --- 19 unchanged lines hidden --- | 257 *cpp = cp; 258 cp->private = vp; 259 bo->bo_ops = g_vfs_bufops; 260 bo->bo_private = cp; 261 bo->bo_bsize = pp->sectorsize; 262 263 return (error); 264} --- 19 unchanged lines hidden --- |