From patchwork Wed Feb 13 14:54:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 10810107 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D3FE139A for ; Wed, 13 Feb 2019 14:55:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 630DD2D5C1 for ; Wed, 13 Feb 2019 14:55:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 579B72D3EB; Wed, 13 Feb 2019 14:55:05 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 034342D5C9 for ; Wed, 13 Feb 2019 14:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403927AbfBMOzD (ORCPT ); Wed, 13 Feb 2019 09:55:03 -0500 Received: from mx2.suse.de ([195.135.220.15]:60244 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731302AbfBMOzA (ORCPT ); Wed, 13 Feb 2019 09:55:00 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D5E8AAD3A; Wed, 13 Feb 2019 14:54:55 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 56D5F1E41EE; Wed, 13 Feb 2019 15:54:54 +0100 (CET) From: Jan Kara To: Cc: Amir Goldstein , Konstantin Khlebnikov , Vivek Trivedi , Orion Poplawski , Jan Kara Subject: [PATCH 3/6] fsnotify: Create function to remove event from notification list Date: Wed, 13 Feb 2019 15:54:40 +0100 Message-Id: <20190213145443.26836-4-jack@suse.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190213145443.26836-1-jack@suse.cz> References: <20190213145443.26836-1-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Create function to remove event from the notification list. Later it will be used from more places. Signed-off-by: Jan Kara Reviewed-by: Amir Goldstein --- fs/notify/notification.c | 20 +++++++++++++------- include/linux/fsnotify_backend.h | 3 +++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/fs/notify/notification.c b/fs/notify/notification.c index 3c3e36745f59..2195a5cf745a 100644 --- a/fs/notify/notification.c +++ b/fs/notify/notification.c @@ -141,6 +141,18 @@ int fsnotify_add_event(struct fsnotify_group *group, return ret; } +void fsnotify_remove_queued_event(struct fsnotify_group *group, + struct fsnotify_event *event) +{ + assert_spin_locked(&group->notification_lock); + /* + * We need to init list head for the case of overflow event so that + * check in fsnotify_add_event() works + */ + list_del_init(&event->list); + group->q_len--; +} + /* * Remove and return the first event from the notification list. It is the * responsibility of the caller to destroy the obtained event @@ -155,13 +167,7 @@ struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group) event = list_first_entry(&group->notification_list, struct fsnotify_event, list); - /* - * We need to init list head for the case of overflow event so that - * check in fsnotify_add_event() works - */ - list_del_init(&event->list); - group->q_len--; - + fsnotify_remove_queued_event(group, event); return event; } diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 7639774e7475..cddf839bac96 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -416,6 +416,9 @@ extern bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group); extern struct fsnotify_event *fsnotify_peek_first_event(struct fsnotify_group *group); /* return AND dequeue the first event on the notification queue */ extern struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group); +/* Remove event queued in the notification list */ +extern void fsnotify_remove_queued_event(struct fsnotify_group *group, + struct fsnotify_event *event); /* functions used to manipulate the marks attached to inodes */