From owner-svn-src-head@FreeBSD.ORG Wed Sep 28 13:19:47 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D35B8106566B; Wed, 28 Sep 2011 13:19:47 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B886C8FC0C; Wed, 28 Sep 2011 13:19:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8SDJlkG074718; Wed, 28 Sep 2011 13:19:47 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8SDJlv7074713; Wed, 28 Sep 2011 13:19:47 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201109281319.p8SDJlv7074713@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Wed, 28 Sep 2011 13:19:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225832 - head/sbin/hastd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Wed, 28 Sep 2011 13:19:48 -0000 Author: pjd Date: Wed Sep 28 13:19:47 2011 New Revision: 225832 URL: http://svn.freebsd.org/changeset/base/225832 Log: If the underlying provider doesn't support BIO_FLUSH, log it only once and don't bother trying in the future. MFC after: 3 days Modified: head/sbin/hastd/hast.h head/sbin/hastd/parse.y head/sbin/hastd/primary.c head/sbin/hastd/secondary.c Modified: head/sbin/hastd/hast.h ============================================================================== --- head/sbin/hastd/hast.h Wed Sep 28 13:13:43 2011 (r225831) +++ head/sbin/hastd/hast.h Wed Sep 28 13:19:47 2011 (r225832) @@ -167,6 +167,8 @@ struct hast_resource { off_t hr_local_mediasize; /* Sector size of local provider. */ unsigned int hr_local_sectorsize; + /* Is flushing write cache supported by the local provider? */ + bool hr_localflush; /* Flush write cache on metadata updates? */ int hr_metaflush; Modified: head/sbin/hastd/parse.y ============================================================================== --- head/sbin/hastd/parse.y Wed Sep 28 13:13:43 2011 (r225831) +++ head/sbin/hastd/parse.y Wed Sep 28 13:19:47 2011 (r225832) @@ -788,6 +788,7 @@ resource_start: STR curres->hr_provname[0] = '\0'; curres->hr_localpath[0] = '\0'; curres->hr_localfd = -1; + curres->hr_localflush = true; curres->hr_metaflush = -1; curres->hr_remoteaddr[0] = '\0'; curres->hr_sourceaddr[0] = '\0'; Modified: head/sbin/hastd/primary.c ============================================================================== --- head/sbin/hastd/primary.c Wed Sep 28 13:13:43 2011 (r225831) +++ head/sbin/hastd/primary.c Wed Sep 28 13:19:47 2011 (r225832) @@ -1304,8 +1304,15 @@ local_send_thread(void *arg) } break; case BIO_FLUSH: + if (!res->hr_localflush) { + ret = -1; + errno = EOPNOTSUPP; + break; + } ret = g_flush(res->hr_localfd); if (ret < 0) { + if (errno == EOPNOTSUPP) + res->hr_localflush = false; hio->hio_errors[ncomp] = errno; reqlog(LOG_WARNING, 0, ggio, "Local request failed (%s): ", Modified: head/sbin/hastd/secondary.c ============================================================================== --- head/sbin/hastd/secondary.c Wed Sep 28 13:13:43 2011 (r225831) +++ head/sbin/hastd/secondary.c Wed Sep 28 13:19:47 2011 (r225832) @@ -664,7 +664,7 @@ disk_thread(void *arg) struct hast_resource *res = arg; struct hio *hio; ssize_t ret; - bool clear_activemap; + bool clear_activemap, logerror; clear_activemap = true; @@ -702,6 +702,7 @@ disk_thread(void *arg) break; } reqlog(LOG_DEBUG, 2, -1, hio, "disk: (%p) Got request: ", hio); + logerror = true; /* Handle the actual request. */ switch (hio->hio_cmd) { case HIO_READ: @@ -736,14 +737,23 @@ disk_thread(void *arg) hio->hio_error = 0; break; case HIO_FLUSH: + if (!res->hr_localflush) { + ret = -1; + hio->hio_error = EOPNOTSUPP; + logerror = false; + break; + } ret = g_flush(res->hr_localfd); - if (ret < 0) + if (ret < 0) { + if (errno == EOPNOTSUPP) + res->hr_localflush = false; hio->hio_error = errno; - else + } else { hio->hio_error = 0; + } break; } - if (hio->hio_error != 0) { + if (logerror && hio->hio_error != 0) { reqlog(LOG_ERR, 0, hio->hio_error, hio, "Request failed: "); }