Deleted Added
full compact
secondary.c (225831) secondary.c (225832)
1/*-
2 * Copyright (c) 2009-2010 The FreeBSD Foundation
3 * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *

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

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009-2010 The FreeBSD Foundation
3 * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *

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

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sbin/hastd/secondary.c 225831 2011-09-28 13:13:43Z pjd $");
32__FBSDID("$FreeBSD: head/sbin/hastd/secondary.c 225832 2011-09-28 13:19:47Z pjd $");
33
34#include <sys/param.h>
35#include <sys/time.h>
36#include <sys/bio.h>
37#include <sys/disk.h>
38#include <sys/stat.h>
39
40#include <err.h>

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

659 * FLUSH requests.
660 */
661static void *
662disk_thread(void *arg)
663{
664 struct hast_resource *res = arg;
665 struct hio *hio;
666 ssize_t ret;
33
34#include <sys/param.h>
35#include <sys/time.h>
36#include <sys/bio.h>
37#include <sys/disk.h>
38#include <sys/stat.h>
39
40#include <err.h>

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

659 * FLUSH requests.
660 */
661static void *
662disk_thread(void *arg)
663{
664 struct hast_resource *res = arg;
665 struct hio *hio;
666 ssize_t ret;
667 bool clear_activemap;
667 bool clear_activemap, logerror;
668
669 clear_activemap = true;
670
671 for (;;) {
672 pjdlog_debug(2, "disk: Taking request.");
673 QUEUE_TAKE(disk, hio);
674 while (clear_activemap) {
675 unsigned char *map;

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

697 break;
698 }
699 free(map);
700 clear_activemap = false;
701 pjdlog_debug(1, "Local activemap cleared.");
702 break;
703 }
704 reqlog(LOG_DEBUG, 2, -1, hio, "disk: (%p) Got request: ", hio);
668
669 clear_activemap = true;
670
671 for (;;) {
672 pjdlog_debug(2, "disk: Taking request.");
673 QUEUE_TAKE(disk, hio);
674 while (clear_activemap) {
675 unsigned char *map;

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

697 break;
698 }
699 free(map);
700 clear_activemap = false;
701 pjdlog_debug(1, "Local activemap cleared.");
702 break;
703 }
704 reqlog(LOG_DEBUG, 2, -1, hio, "disk: (%p) Got request: ", hio);
705 logerror = true;
705 /* Handle the actual request. */
706 switch (hio->hio_cmd) {
707 case HIO_READ:
708 ret = pread(res->hr_localfd, hio->hio_data,
709 hio->hio_length,
710 hio->hio_offset + res->hr_localoff);
711 if (ret < 0)
712 hio->hio_error = errno;

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

731 hio->hio_offset + res->hr_localoff,
732 hio->hio_length);
733 if (ret < 0)
734 hio->hio_error = errno;
735 else
736 hio->hio_error = 0;
737 break;
738 case HIO_FLUSH:
706 /* Handle the actual request. */
707 switch (hio->hio_cmd) {
708 case HIO_READ:
709 ret = pread(res->hr_localfd, hio->hio_data,
710 hio->hio_length,
711 hio->hio_offset + res->hr_localoff);
712 if (ret < 0)
713 hio->hio_error = errno;

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

732 hio->hio_offset + res->hr_localoff,
733 hio->hio_length);
734 if (ret < 0)
735 hio->hio_error = errno;
736 else
737 hio->hio_error = 0;
738 break;
739 case HIO_FLUSH:
740 if (!res->hr_localflush) {
741 ret = -1;
742 hio->hio_error = EOPNOTSUPP;
743 logerror = false;
744 break;
745 }
739 ret = g_flush(res->hr_localfd);
746 ret = g_flush(res->hr_localfd);
740 if (ret < 0)
747 if (ret < 0) {
748 if (errno == EOPNOTSUPP)
749 res->hr_localflush = false;
741 hio->hio_error = errno;
750 hio->hio_error = errno;
742 else
751 } else {
743 hio->hio_error = 0;
752 hio->hio_error = 0;
753 }
744 break;
745 }
754 break;
755 }
746 if (hio->hio_error != 0) {
756 if (logerror && hio->hio_error != 0) {
747 reqlog(LOG_ERR, 0, hio->hio_error, hio,
748 "Request failed: ");
749 }
750 pjdlog_debug(2, "disk: (%p) Moving request to the send queue.",
751 hio);
752 QUEUE_INSERT(send, hio);
753 }
754 /* NOTREACHED */

--- 59 unchanged lines hidden ---
757 reqlog(LOG_ERR, 0, hio->hio_error, hio,
758 "Request failed: ");
759 }
760 pjdlog_debug(2, "disk: (%p) Moving request to the send queue.",
761 hio);
762 QUEUE_INSERT(send, hio);
763 }
764 /* NOTREACHED */

--- 59 unchanged lines hidden ---