From owner-svn-src-user@freebsd.org Tue Mar 21 08:24:42 2017 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2E0C0D169F9 for ; Tue, 21 Mar 2017 08:24:42 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EFCDB1C40; Tue, 21 Mar 2017 08:24:41 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2L8OflK001492; Tue, 21 Mar 2017 08:24:41 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2L8Ofwj001491; Tue, 21 Mar 2017 08:24:41 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201703210824.v2L8Ofwj001491@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Tue, 21 Mar 2017 08:24:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r315664 - user/pho/stress2/lib X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2017 08:24:42 -0000 Author: pho Date: Tue Mar 21 08:24:40 2017 New Revision: 315664 URL: https://svnweb.freebsd.org/changeset/base/315664 Log: Limit number of retries. Sponsored by: Dell EMC Isilon Modified: user/pho/stress2/lib/resources.c Modified: user/pho/stress2/lib/resources.c ============================================================================== --- user/pho/stress2/lib/resources.c Tue Mar 21 08:23:44 2017 (r315663) +++ user/pho/stress2/lib/resources.c Tue Mar 21 08:24:40 2017 (r315664) @@ -157,25 +157,23 @@ void cleanupdf() void getdf(int64_t *block, int64_t *inode) { - int i, j; + int i; char buf[128]; snprintf(lockpath, sizeof(lockpath), "%s/lock", op->cd); - for (j = 0; j < 10; j++) { - for (i = 0; i < 10000; i++) { - if ((lockfd = open(lockpath, - O_CREAT | O_TRUNC | O_WRONLY | O_EXCL, 0644)) != -1) - break; - usleep(10000); /* sleep 1/100 sec */ - if (i > 0 && i % 1000 == 0) - fprintf(stderr, "%s is waiting for lock file %s\n", - getprogname(), lockpath); - } - if (lockfd != -1) + for (i = 0; i < 10000; i++) { + if ((lockfd = open(lockpath, + O_CREAT | O_TRUNC | O_WRONLY | O_EXCL, 0644)) != -1) break; - fprintf(stderr, "%s. Removing stale %s\n", getprogname(), lockpath); - unlink(lockpath); + usleep(10000); /* sleep 1/100 sec */ + if (i > 0 && i % 1000 == 0) + fprintf(stderr, "%s is waiting for lock file %s\n", + getprogname(), lockpath); } + if (lockfd != -1) + break; + fprintf(stderr, "%s. Removing stale %s\n", getprogname(), lockpath); + unlink(lockpath); if (lockfd == -1) errx(1, "%s. Can not create %s\n", getprogname(), lockpath); snprintf(dfpath, sizeof(dfpath), "%s/df", op->cd);