From patchwork Wed May 17 15:48:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zorro Lang X-Patchwork-Id: 9731517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 784D560363 for ; Wed, 17 May 2017 15:48:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68F272863B for ; Wed, 17 May 2017 15:48:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D9F328651; Wed, 17 May 2017 15:48:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F14362863B for ; Wed, 17 May 2017 15:48:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751398AbdEQPsy (ORCPT ); Wed, 17 May 2017 11:48:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42110 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751300AbdEQPsy (ORCPT ); Wed, 17 May 2017 11:48:54 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 61A09C04B94B for ; Wed, 17 May 2017 15:48:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 61A09C04B94B Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=zlang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 61A09C04B94B Received: from localhost.localdomain.com (vpn1-5-79.pek2.redhat.com [10.72.5.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C8CB5DD70 for ; Wed, 17 May 2017 15:48:52 +0000 (UTC) From: Zorro Lang To: fstests@vger.kernel.org Subject: [PATCH] fsstress: cleanup flist with test directory together Date: Wed, 17 May 2017 23:48:47 +0800 Message-Id: <1495036127-11648-1-git-send-email-zlang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 17 May 2017 15:48:53 +0000 (UTC) Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The "-c" option of fsstress will clean up the test directory after each run. But it only does "rm -rf $dir". If run fsstress likes: fsstress -d $test_dir -n 1000 -p 10 -l 0 -c fsstress will remove all test directories at the end of each run, but the flist still save those *deleted* entries. It'll cause more and more useless ENOENT failures. So we need to release all entries in flist too. Signed-off-by: Zorro Lang --- ltp/fsstress.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index 6d8f117..e9fd276 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -280,6 +280,7 @@ int attr_list_path(pathname_t *, char *, const int, int, attrlist_cursor_t *); int attr_remove_path(pathname_t *, const char *, int); int attr_set_path(pathname_t *, const char *, const char *, const int, int); void check_cwd(void); +void cleanup_flist(void); int creat_path(pathname_t *, mode_t); void dcache_enter(int, int); void dcache_init(void); @@ -794,6 +795,25 @@ check_cwd(void) #endif } +/* + * go thru flist and release all entries + * + * NOTE: this function shouldn't be called until the end of a process + */ +void +cleanup_flist(void) +{ + flist_t *flp; + int i; + + for (i = 0, flp = flist; i < FT_nft; i++, flp++) { + flp->nslots = 0; + flp->nfiles = 0; + free(flp->fents); + flp->fents = NULL; + } +} + int creat_path(pathname_t *name, mode_t mode) { @@ -945,6 +965,7 @@ errout: if (cleanup) { sprintf(cmd, "rm -rf %s", buf); system(cmd); + cleanup_flist(); } }