Deleted Added
full compact
g_journal.c (163894) g_journal.c (163906)
1/*-
2 * Copyright (c) 2005-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) 2005-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/journal/g_journal.c 163894 2006-11-02 00:37:39Z pjd $");
28__FBSDID("$FreeBSD: head/sys/geom/journal/g_journal.c 163906 2006-11-02 09:14:18Z 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>

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

595 return (error);
596 pp = cp->provider;
597 g_topology_unlock();
598 /* Metadata is stored in last sector. */
599 buf = g_read_data(cp, pp->mediasize - pp->sectorsize, pp->sectorsize,
600 &error);
601 g_topology_lock();
602 g_access(cp, -1, 0, 0);
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>

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

595 return (error);
596 pp = cp->provider;
597 g_topology_unlock();
598 /* Metadata is stored in last sector. */
599 buf = g_read_data(cp, pp->mediasize - pp->sectorsize, pp->sectorsize,
600 &error);
601 g_topology_lock();
602 g_access(cp, -1, 0, 0);
603 if (error != 0) {
603 if (buf == NULL) {
604 GJ_DEBUG(1, "Cannot read metadata from %s (error=%d).",
605 cp->provider->name, error);
604 GJ_DEBUG(1, "Cannot read metadata from %s (error=%d).",
605 cp->provider->name, error);
606 if (buf != NULL)
607 g_free(buf);
608 return (error);
609 }
610
611 /* Decode metadata. */
612 error = journal_metadata_decode(buf, md);
613 g_free(buf);
614 /* Is this is gjournal provider at all? */
615 if (strcmp(md->md_magic, G_JOURNAL_MAGIC) != 0)

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

1617 cend = MIN(oend, bp->bio_offset + bp->bio_length);
1618 GJ_DEBUG(2, "Got part of the request from %u (%jd-%jd).",
1619 i, (intmax_t)cstart, (intmax_t)cend);
1620 break;
1621 }
1622 }
1623 if (bp != NULL) {
1624 if (bp->bio_data == NULL) {
606 return (error);
607 }
608
609 /* Decode metadata. */
610 error = journal_metadata_decode(buf, md);
611 g_free(buf);
612 /* Is this is gjournal provider at all? */
613 if (strcmp(md->md_magic, G_JOURNAL_MAGIC) != 0)

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

1615 cend = MIN(oend, bp->bio_offset + bp->bio_length);
1616 GJ_DEBUG(2, "Got part of the request from %u (%jd-%jd).",
1617 i, (intmax_t)cstart, (intmax_t)cend);
1618 break;
1619 }
1620 }
1621 if (bp != NULL) {
1622 if (bp->bio_data == NULL) {
1625 nbp = g_clone_bio(pbp);
1623 nbp = g_duplicate_bio(pbp);
1626 nbp->bio_cflags = GJ_BIO_READ;
1627 nbp->bio_data =
1628 pbp->bio_data + cstart - pbp->bio_offset;
1629 nbp->bio_offset =
1630 bp->bio_joffset + cstart - bp->bio_offset;
1631 nbp->bio_length = cend - cstart;
1632 nbp->bio_done = g_journal_read_done;
1633 g_io_request(nbp, sc->sc_jconsumer);

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

1641 if (oend > cend)
1642 g_journal_read(sc, pbp, cend, oend);
1643 } else {
1644 /*
1645 * No data in memory, no data in journal.
1646 * Its time for asking data provider.
1647 */
1648 GJ_DEBUG(3, "READ(data): (%jd, %jd)", ostart, oend);
1624 nbp->bio_cflags = GJ_BIO_READ;
1625 nbp->bio_data =
1626 pbp->bio_data + cstart - pbp->bio_offset;
1627 nbp->bio_offset =
1628 bp->bio_joffset + cstart - bp->bio_offset;
1629 nbp->bio_length = cend - cstart;
1630 nbp->bio_done = g_journal_read_done;
1631 g_io_request(nbp, sc->sc_jconsumer);

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

1639 if (oend > cend)
1640 g_journal_read(sc, pbp, cend, oend);
1641 } else {
1642 /*
1643 * No data in memory, no data in journal.
1644 * Its time for asking data provider.
1645 */
1646 GJ_DEBUG(3, "READ(data): (%jd, %jd)", ostart, oend);
1649 nbp = g_clone_bio(pbp);
1647 nbp = g_duplicate_bio(pbp);
1650 nbp->bio_cflags = GJ_BIO_READ;
1651 nbp->bio_data = pbp->bio_data + ostart - pbp->bio_offset;
1652 nbp->bio_offset = ostart;
1653 nbp->bio_length = oend - ostart;
1654 nbp->bio_done = g_journal_read_done;
1655 g_io_request(nbp, sc->sc_dconsumer);
1656 /* We have the whole request, return here. */
1657 return;

--- 1385 unchanged lines hidden ---
1648 nbp->bio_cflags = GJ_BIO_READ;
1649 nbp->bio_data = pbp->bio_data + ostart - pbp->bio_offset;
1650 nbp->bio_offset = ostart;
1651 nbp->bio_length = oend - ostart;
1652 nbp->bio_done = g_journal_read_done;
1653 g_io_request(nbp, sc->sc_dconsumer);
1654 /* We have the whole request, return here. */
1655 return;

--- 1385 unchanged lines hidden ---