From nobody@FreeBSD.org  Wed Sep 18 20:33:21 2013
Return-Path: <nobody@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 ESMTP id B6478151
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 18 Sep 2013 20:33:21 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 89E3524A1
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 18 Sep 2013 20:33:21 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r8IKXK6S048407
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 18 Sep 2013 20:33:20 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r8IKXKwO048401;
	Wed, 18 Sep 2013 20:33:20 GMT
	(envelope-from nobody)
Message-Id: <201309182033.r8IKXKwO048401@oldred.freebsd.org>
Date: Wed, 18 Sep 2013 20:33:20 GMT
From: dennis chang <dchang@panasas.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: vop_stdfsync() incorrectly retries too many times
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         182214
>Category:       kern
>Synopsis:       vop_stdfsync() incorrectly retries too many times
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 18 20:40:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     dennis chang
>Release:        7.2 and 10
>Organization:
panasas
>Environment:
>Description:
  687         /*
  688          * If synchronous the caller expects us to completely resolve all
  689          * dirty buffers in the system.  Wait for in-progress I/O to
  690          * complete (which could include background bitmap writes), then
  691          * retry if dirty blocks still exist.
  692          */
  693         if (ap->a_waitfor == MNT_WAIT) {
  694                 bufobj_wwait(bo, 0, 0);
  695                 if (bo->bo_dirty.bv_cnt > 0) {
  696                         /*
  697                          * If we are unable to write any of these buffers
  698                          * then we fail now rather than trying endlessly
  699                          * to write them out.
  700                          */
  701                         TAILQ_FOREACH(bp, &bo->bo_dirty.bv_hd, b_bobufs)
  702                                 if ((error = bp->b_error) == 0)  ---> error is constantly overwritten. It should bail out when any buffer has an error.
  703                                         continue;
  704                         if (error == 0 && --maxretry >= 0)  ----> error is from the last buffer, instead of any buffer.
  705                                 goto loop1;
  706                         error = EAGAIN;
  707                 }
  708         }
>How-To-Repeat:

>Fix:
  687         /*
  688          * If synchronous the caller expects us to completely resolve all
  689          * dirty buffers in the system.  Wait for in-progress I/O to
  690          * complete (which could include background bitmap writes), then
  691          * retry if dirty blocks still exist.
  692          */
  693         if (ap->a_waitfor == MNT_WAIT) {
  694                 bufobj_wwait(bo, 0, 0);
  695                 if (bo->bo_dirty.bv_cnt > 0) {
  696                         /*
  697                          * If we are unable to write any of these buffers
  698                          * then we fail now rather than trying endlessly
  699                          * to write them out.
  700                          */
  701                         TAILQ_FOREACH(bp, &bo->bo_dirty.bv_hd, b_bobufs) {
  702                                 if (bp->b_error)
  703                                         error = b_error;
                                              break;
                                      }
                              }
  704                         if (error == 0 && --maxretry >= 0)
  705                                 goto loop1;
  706                         error = EAGAIN;
  707                 }
  708         }

>Release-Note:
>Audit-Trail:
>Unformatted:
