Deleted Added
full compact
g_raid3.c (163206) g_raid3.c (163836)
1/*-
2 * Copyright (c) 2004-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org>
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-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org>
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/raid3/g_raid3.c 163206 2006-10-10 15:01:47Z pjd $");
28__FBSDID("$FreeBSD: head/sys/geom/raid3/g_raid3.c 163836 2006-10-31 21:23:51Z pjd $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/kernel.h>
33#include <sys/module.h>
34#include <sys/limits.h>
35#include <sys/lock.h>
36#include <sys/mutex.h>

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

1365 mtx_lock(&sc->sc_queue_mtx);
1366 bioq_insert_head(&sc->sc_queue, bp);
1367 wakeup(sc);
1368 wakeup(&sc->sc_queue);
1369 mtx_unlock(&sc->sc_queue_mtx);
1370}
1371
1372static void
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/kernel.h>
33#include <sys/module.h>
34#include <sys/limits.h>
35#include <sys/lock.h>
36#include <sys/mutex.h>

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

1365 mtx_lock(&sc->sc_queue_mtx);
1366 bioq_insert_head(&sc->sc_queue, bp);
1367 wakeup(sc);
1368 wakeup(&sc->sc_queue);
1369 mtx_unlock(&sc->sc_queue_mtx);
1370}
1371
1372static void
1373g_raid3_flush(struct g_raid3_softc *sc, struct bio *bp)
1374{
1375 struct bio_queue_head queue;
1376 struct g_raid3_disk *disk;
1377 struct g_consumer *cp;
1378 struct bio *cbp;
1379 u_int i;
1380
1381 bioq_init(&queue);
1382 for (i = 0; i < sc->sc_ndisks; i++) {
1383 disk = &sc->sc_disks[i];
1384 if (disk->d_state != G_RAID3_DISK_STATE_ACTIVE)
1385 continue;
1386 cbp = g_clone_bio(bp);
1387 if (cbp == NULL) {
1388 for (cbp = bioq_first(&queue); cbp != NULL;
1389 cbp = bioq_first(&queue)) {
1390 bioq_remove(&queue, cbp);
1391 g_destroy_bio(cbp);
1392 }
1393 if (bp->bio_error == 0)
1394 bp->bio_error = ENOMEM;
1395 g_io_deliver(bp, bp->bio_error);
1396 return;
1397 }
1398 bioq_insert_tail(&queue, cbp);
1399 cbp->bio_done = g_std_done;
1400 cbp->bio_caller1 = disk;
1401 cbp->bio_to = disk->d_consumer->provider;
1402 }
1403 for (cbp = bioq_first(&queue); cbp != NULL; cbp = bioq_first(&queue)) {
1404 bioq_remove(&queue, cbp);
1405 G_RAID3_LOGREQ(3, cbp, "Sending request.");
1406 disk = cbp->bio_caller1;
1407 cbp->bio_caller1 = NULL;
1408 cp = disk->d_consumer;
1409 KASSERT(cp->acr >= 1 && cp->acw >= 1 && cp->ace >= 1,
1410 ("Consumer %s not opened (r%dw%de%d).", cp->provider->name,
1411 cp->acr, cp->acw, cp->ace));
1412 g_io_request(cbp, disk->d_consumer);
1413 }
1414}
1415
1416static void
1373g_raid3_start(struct bio *bp)
1374{
1375 struct g_raid3_softc *sc;
1376
1377 sc = bp->bio_to->geom->softc;
1378 /*
1379 * If sc == NULL or there are no valid disks, provider's error
1380 * should be set and g_raid3_start() should not be called at all.

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

1385 bp->bio_to->error, bp->bio_to->name));
1386 G_RAID3_LOGREQ(3, bp, "Request received.");
1387
1388 switch (bp->bio_cmd) {
1389 case BIO_READ:
1390 case BIO_WRITE:
1391 case BIO_DELETE:
1392 break;
1417g_raid3_start(struct bio *bp)
1418{
1419 struct g_raid3_softc *sc;
1420
1421 sc = bp->bio_to->geom->softc;
1422 /*
1423 * If sc == NULL or there are no valid disks, provider's error
1424 * should be set and g_raid3_start() should not be called at all.

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

1429 bp->bio_to->error, bp->bio_to->name));
1430 G_RAID3_LOGREQ(3, bp, "Request received.");
1431
1432 switch (bp->bio_cmd) {
1433 case BIO_READ:
1434 case BIO_WRITE:
1435 case BIO_DELETE:
1436 break;
1437 case BIO_FLUSH:
1438 g_raid3_flush(sc, bp);
1439 return;
1393 case BIO_GETATTR:
1394 default:
1395 g_io_deliver(bp, EOPNOTSUPP);
1396 return;
1397 }
1398 mtx_lock(&sc->sc_queue_mtx);
1399 bioq_insert_tail(&sc->sc_queue, bp);
1400 G_RAID3_DEBUG(4, "%s: Waking up %p.", __func__, sc);

--- 2100 unchanged lines hidden ---
1440 case BIO_GETATTR:
1441 default:
1442 g_io_deliver(bp, EOPNOTSUPP);
1443 return;
1444 }
1445 mtx_lock(&sc->sc_queue_mtx);
1446 bioq_insert_tail(&sc->sc_queue, bp);
1447 G_RAID3_DEBUG(4, "%s: Waking up %p.", __func__, sc);

--- 2100 unchanged lines hidden ---