From owner-svn-src-head@FreeBSD.ORG Tue Dec 10 19:58:10 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AD3392FF; Tue, 10 Dec 2013 19:58:10 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 80F011AB0; Tue, 10 Dec 2013 19:58:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBAJwAUY093731; Tue, 10 Dec 2013 19:58:10 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBAJwAKI093730; Tue, 10 Dec 2013 19:58:10 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201312101958.rBAJwAKI093730@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 10 Dec 2013 19:58:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r259192 - head/sbin/hastd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Dec 2013 19:58:10 -0000 Author: trociny Date: Tue Dec 10 19:58:10 2013 New Revision: 259192 URL: http://svnweb.freebsd.org/changeset/base/259192 Log: Add some macros to make the code more readable (no functional chages). MFC after: 2 weeks Modified: head/sbin/hastd/primary.c Modified: head/sbin/hastd/primary.c ============================================================================== --- head/sbin/hastd/primary.c Tue Dec 10 19:56:26 2013 (r259191) +++ head/sbin/hastd/primary.c Tue Dec 10 19:58:10 2013 (r259192) @@ -233,6 +233,10 @@ static pthread_mutex_t metadata_lock; mtx_unlock(&hio_##name##_list_lock); \ } while (0) +#define ISFULLSYNC(hio) ((hio)->hio_replication == HAST_REPLICATION_FULLSYNC) +#define ISMEMSYNC(hio) ((hio)->hio_replication == HAST_REPLICATION_MEMSYNC) +#define ISASYNC(hio) ((hio)->hio_replication == HAST_REPLICATION_ASYNC) + #define SYNCREQ(hio) do { \ (hio)->hio_ggio.gctl_unit = -1; \ (hio)->hio_ggio.gctl_seq = 1; \ @@ -240,9 +244,9 @@ static pthread_mutex_t metadata_lock; #define ISSYNCREQ(hio) ((hio)->hio_ggio.gctl_unit == -1) #define SYNCREQDONE(hio) do { (hio)->hio_ggio.gctl_unit = -2; } while (0) #define ISSYNCREQDONE(hio) ((hio)->hio_ggio.gctl_unit == -2) -#define ISMEMSYNCWRITE(hio) \ - (((hio)->hio_replication == HAST_REPLICATION_MEMSYNC && \ - (hio)->hio_ggio.gctl_cmd == BIO_WRITE && !ISSYNCREQ(hio))) + +#define ISMEMSYNCWRITE(hio) (ISMEMSYNC(hio) && \ + (hio)->hio_ggio.gctl_cmd == BIO_WRITE && !ISSYNCREQ(hio)) static struct hast_resource *gres; @@ -1356,7 +1360,7 @@ ggate_recv_thread(void *arg) } else { mtx_unlock(&res->hr_amp_lock); } - if (hio->hio_replication == HAST_REPLICATION_MEMSYNC) { + if (ISMEMSYNC(hio)) { hio->hio_memsyncacked = false; refcnt_init(&hio->hio_writecount, ncomps); } @@ -1441,8 +1445,7 @@ local_send_thread(void *arg) ret, (intmax_t)ggio->gctl_length); } else { hio->hio_errors[ncomp] = 0; - if (hio->hio_replication == - HAST_REPLICATION_ASYNC) { + if (ISASYNC(hio)) { ggio->gctl_error = 0; write_complete(res, hio); }