From patchwork Tue Jun 4 15:10:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 1109969 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="by4JaETl"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45JFjs25Bpz9s3l for ; Wed, 5 Jun 2019 01:10:56 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 616513EAB95 for ; Tue, 4 Jun 2019 17:10:49 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) by picard.linux.it (Postfix) with ESMTP id 9B4763EAA54 for ; Tue, 4 Jun 2019 17:10:43 +0200 (CEST) Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id ACB0160071D for ; Tue, 4 Jun 2019 17:10:45 +0200 (CEST) Received: by mail-wm1-x341.google.com with SMTP id d17so445424wmb.3 for ; Tue, 04 Jun 2019 08:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cd0jL1l37AnAOITWAtpWiSM2eipoS5jrsZBNVNTYX+Y=; b=by4JaETlUxK8Sj9bFkvoi3uSw1FzFALFVuZ6ZhcaO1IaDAWVoYYXdcyqjV6oxKHydJ 7oYR74yw8/jy3ZI/jmJM3esmrz4+Ga0s4cUX5oYA5hue8pN/KMo9/T+jIio075E7g/M0 m0RaDsD+hverwxYkoNmaWfrKlNEGPIG7wRqY+gn/yfgzqvz8mGsnPnpg3sWofoj3f+dE KHwZxv8fIM0FufqVCztUJ1hDE6J91XHmSohxw2w99y9daSuJRwGHLGSjq9gXgzJdNrCF rjpy4SR/KJPMjcTmwjT2I6HaDEkkdNArJun+k4ttKMHRs4T4Rw/0+jDaoRsZl19xXRPc ZGJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cd0jL1l37AnAOITWAtpWiSM2eipoS5jrsZBNVNTYX+Y=; b=rk7S19lK59ac+t92vh7+mIW2j1ZpUJcaBdgneX9RIPuJHZDkqE77+K9tbPmKx+gJ9Y Yl+VeyTD2ngaFhrJZ1EHe491RGzd6DbwtYsr3ddzCj9kOKScwooc19P55WQFRdQFf23z kTV5Wl5eKHF3IWkSfzZTDALfruFxot8bLXK+c42uoaAxf3iXUGoARiIEe1EZEH0OpT5D BDWvpwANU9fQZkjDZHQZBpJ1Yjd5Y388h44uDUCjeR/TvWvPwe4c1SefrDcoYIo5LzMB 9VFTbAsb/DnYhJLmnbm3i4YViQ+uG+fIxWwGTdK0XB0Eotelee0efERZKqzUyyl+zkbd WRzg== X-Gm-Message-State: APjAAAV8SPYi5pK+Be/VZ2hrRmfhUAD8HdnegtcOQtcsz9FOBq3pVqM1 MA5EGAzQVw3ZEJc/v2wveF8= X-Google-Smtp-Source: APXvYqzoS/F608X6NNxHUoRRU3U0zMg5YiNwbZPvcZGzR8gnpSKhAL2mhiJPhhiZAemkXoBv4RgvvQ== X-Received: by 2002:a1c:f901:: with SMTP id x1mr6430198wmh.157.1559661042766; Tue, 04 Jun 2019 08:10:42 -0700 (PDT) Received: from localhost.localdomain (p548C66C4.dip0.t-ipconnect.de. [84.140.102.196]) by smtp.gmail.com with ESMTPSA id l7sm9077326wmh.20.2019.06.04.08.10.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 08:10:42 -0700 (PDT) From: Amir Goldstein To: Petr Vorel Date: Tue, 4 Jun 2019 18:10:35 +0300 Message-Id: <20190604151035.6123-2-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604151035.6123-1-amir73il@gmail.com> References: <20190604151035.6123-1-amir73il@gmail.com> X-Virus-Scanned: clamav-milter 0.99.2 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_HELO_NONE, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Cc: Jan Kara , Miklos Szeredi , linux-unionfs@vger.kernel.org, ltp@lists.linux.it Subject: [LTP] [PATCH v2 2/2] fanotify06: Close all file descriptors of read events X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" With overlayfs test case on kernel v4.19, we get extra events. If we do not close the event->fd file descriptros of all the events that we read, overlayfs will fail to unmount at the end of the test and test will retry un-mounting for a while. Signed-off-by: Amir Goldstein --- .../kernel/syscalls/fanotify/fanotify06.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/testcases/kernel/syscalls/fanotify/fanotify06.c b/testcases/kernel/syscalls/fanotify/fanotify06.c index e053da0e5..273c1f0c4 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify06.c +++ b/testcases/kernel/syscalls/fanotify/fanotify06.c @@ -148,6 +148,17 @@ static void verify_event(int group, struct fanotify_event_metadata *event) } } +/* Close all file descriptors of read events */ +static void close_events_fd(struct fanotify_event_metadata *event, int buflen) +{ + while (buflen >= (int)FAN_EVENT_METADATA_LEN) { + if (event->fd != FAN_NOFD) + SAFE_CLOSE(event->fd); + buflen -= (int)FAN_EVENT_METADATA_LEN; + event++; + } +} + void test_fanotify(unsigned int n) { int ret; @@ -198,17 +209,16 @@ void test_fanotify(unsigned int n) } else { verify_event(i, event); } - if (event->fd != FAN_NOFD) - SAFE_CLOSE(event->fd); + close_events_fd(event, ret); } + for (p = 1; p < FANOTIFY_PRIORITIES; p++) { for (i = 0; i < GROUPS_PER_PRIO; i++) { ret = read(fd_notify[p][i], event_buf, EVENT_BUF_LEN); if (ret > 0) { tst_res(TFAIL, "group %d got event", p*GROUPS_PER_PRIO + i); - if (event->fd != FAN_NOFD) - SAFE_CLOSE(event->fd); + close_events_fd((void *)event_buf, ret); } else if (ret == 0) { tst_brk(TBROK, "zero length " "read from fanotify fd");