Deleted Added
full compact
primary.c (246922) primary.c (247281)
1/*-
2 * Copyright (c) 2009 The FreeBSD Foundation
3 * Copyright (c) 2010-2011 Pawel Jakub Dawidek <pawel@dawidek.net>
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 The FreeBSD Foundation
3 * Copyright (c) 2010-2011 Pawel Jakub Dawidek <pawel@dawidek.net>
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/primary.c 246922 2013-02-17 21:12:34Z pjd $");
32__FBSDID("$FreeBSD: head/sbin/hastd/primary.c 247281 2013-02-25 20:09:07Z trociny $");
33
34#include <sys/types.h>
35#include <sys/time.h>
36#include <sys/bio.h>
37#include <sys/disk.h>
38#include <sys/stat.h>
39
40#include <geom/gate/g_gate.h>

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

298 size_t size;
299
300 buf = activemap_bitmap(res->hr_amp, &size);
301 PJDLOG_ASSERT(buf != NULL);
302 PJDLOG_ASSERT((size % res->hr_local_sectorsize) == 0);
303 if (pwrite(res->hr_localfd, buf, size, METADATA_SIZE) !=
304 (ssize_t)size) {
305 pjdlog_errno(LOG_ERR, "Unable to flush activemap to disk");
33
34#include <sys/types.h>
35#include <sys/time.h>
36#include <sys/bio.h>
37#include <sys/disk.h>
38#include <sys/stat.h>
39
40#include <geom/gate/g_gate.h>

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

298 size_t size;
299
300 buf = activemap_bitmap(res->hr_amp, &size);
301 PJDLOG_ASSERT(buf != NULL);
302 PJDLOG_ASSERT((size % res->hr_local_sectorsize) == 0);
303 if (pwrite(res->hr_localfd, buf, size, METADATA_SIZE) !=
304 (ssize_t)size) {
305 pjdlog_errno(LOG_ERR, "Unable to flush activemap to disk");
306 res->hr_stat_activemap_write_error++;
306 return (-1);
307 }
308 if (res->hr_metaflush == 1 && g_flush(res->hr_localfd) == -1) {
309 if (errno == EOPNOTSUPP) {
310 pjdlog_warning("The %s provider doesn't support flushing write cache. Disabling it.",
311 res->hr_localpath);
312 res->hr_metaflush = 0;
313 } else {
314 pjdlog_errno(LOG_ERR,
315 "Unable to flush disk cache on activemap update");
307 return (-1);
308 }
309 if (res->hr_metaflush == 1 && g_flush(res->hr_localfd) == -1) {
310 if (errno == EOPNOTSUPP) {
311 pjdlog_warning("The %s provider doesn't support flushing write cache. Disabling it.",
312 res->hr_localpath);
313 res->hr_metaflush = 0;
314 } else {
315 pjdlog_errno(LOG_ERR,
316 "Unable to flush disk cache on activemap update");
317 res->hr_stat_activemap_flush_error++;
316 return (-1);
317 }
318 }
319 return (0);
320}
321
322static bool
323real_remote(const struct hast_resource *res)

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

1931 if (!hio->hio_done)
1932 write_complete(res, hio);
1933 } else {
1934 if (ioctl(res->hr_ggatefd, G_GATE_CMD_DONE, ggio) == -1) {
1935 primary_exit(EX_OSERR,
1936 "G_GATE_CMD_DONE failed");
1937 }
1938 }
318 return (-1);
319 }
320 }
321 return (0);
322}
323
324static bool
325real_remote(const struct hast_resource *res)

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

1933 if (!hio->hio_done)
1934 write_complete(res, hio);
1935 } else {
1936 if (ioctl(res->hr_ggatefd, G_GATE_CMD_DONE, ggio) == -1) {
1937 primary_exit(EX_OSERR,
1938 "G_GATE_CMD_DONE failed");
1939 }
1940 }
1941 if (hio->hio_errors[0]) {
1942 switch (ggio->gctl_cmd) {
1943 case BIO_READ:
1944 res->hr_stat_read_error++;
1945 break;
1946 case BIO_WRITE:
1947 res->hr_stat_write_error++;
1948 break;
1949 case BIO_DELETE:
1950 res->hr_stat_delete_error++;
1951 break;
1952 case BIO_FLUSH:
1953 res->hr_stat_flush_error++;
1954 break;
1955 }
1956 }
1939 pjdlog_debug(2,
1940 "ggate_send: (%p) Moving request to the free queue.", hio);
1941 QUEUE_INSERT2(hio, free);
1942 }
1943 /* NOTREACHED */
1944 return (NULL);
1945}
1946

--- 498 unchanged lines hidden ---
1957 pjdlog_debug(2,
1958 "ggate_send: (%p) Moving request to the free queue.", hio);
1959 QUEUE_INSERT2(hio, free);
1960 }
1961 /* NOTREACHED */
1962 return (NULL);
1963}
1964

--- 498 unchanged lines hidden ---