Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp207773pxt; Wed, 4 Aug 2021 09:07:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNkOu4bFkIfUQhkXEOJ18wQ8E1a9ejQ4+nHyHksBI9oztdzRbrQm03uW7bk4Swx1opJF79 X-Received: by 2002:a5e:961a:: with SMTP id a26mr100545ioq.90.1628093279612; Wed, 04 Aug 2021 09:07:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628093279; cv=none; d=google.com; s=arc-20160816; b=reL+nxTarvaqEBR76zQ+ZPFLA+QdCykFf7fLn5aKE9kMRfrL1hME/W3ARSYfJchLxT E0kiVdu7Lbi/aGAaT8t3AnReioXruPfzmr1z0ZXb57u6foJl4axPzECdHPC+Cntmn6Wr zf5L9m8FIdnu8ptEJ7Rw+aSelBl3z2+1w7giENitKUg6WI/a9bi2iKQtSSPOcbuNpdY2 06tRGE831SpV4ZcTW3bS7OM0KUhXITU8eom2OdWN+y8ZK31k6BqC3kSukgFitvn5kkG8 anJv2nnyEMi3Vf872vX3umoiV6qfCUAd4QPicAXM0+7CT90VNj+k49pajrahOGmq9Dnj v8hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cxISluUNtv2EFb/+b1mIM4VmE+anmeLpxgivpOZM6us=; b=GmyVwMs3sZiyYn6Mg9t/4UKr666iq7z+LYDHh2Sb/eeFVRCr9szl9GragWh3B5b5j8 DqlK5udtDzgIb0/02TUmCGqE6IW1mLlBj/lYvRU0lBvSmhvps18xdbGENc39Nx2oEZTs 6pMB/CSOuMz93k1midynFcBNA1Vcjpjn/t5tShT9/nFadRuZzTvapC1pRNaTCPsJi1EI C3uzWtAswrp8k6MpbaAscYCNlXDi2AyKNzHQawScsEFiEEwvfVTrQN5rhUyBnJ8li/Ty oG0ZNczD6Gjf6SN6evAk+7r4nk8T+NLebRYxg96CvDymjpdi/iqE2T1a0uHByoBO/p5g Z3Fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b39si718019jav.84.2021.08.04.09.07.45; Wed, 04 Aug 2021 09:07:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232154AbhHDQHN (ORCPT + 99 others); Wed, 4 Aug 2021 12:07:13 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:41952 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231894AbhHDQHL (ORCPT ); Wed, 4 Aug 2021 12:07:11 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 899A61F4080F From: Gabriel Krisman Bertazi To: jack@suse.com, amir73il@gmail.com Cc: djwong@kernel.org, tytso@mit.edu, david@fromorbit.com, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-api@vger.kernel.org, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v5 08/23] fsnotify: Add wrapper around fsnotify_add_event Date: Wed, 4 Aug 2021 12:05:57 -0400 Message-Id: <20210804160612.3575505-9-krisman@collabora.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210804160612.3575505-1-krisman@collabora.com> References: <20210804160612.3575505-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org fsnotify_add_event is growing in number of parameters, which is most case are just passed a NULL pointer. So, split out a new fsnotify_insert_event function to clean things up for users who don't need an insert hook. Suggested-by: Amir Goldstein Reviewed-by: Amir Goldstein Signed-off-by: Gabriel Krisman Bertazi --- fs/notify/fanotify/fanotify.c | 4 ++-- fs/notify/inotify/inotify_fsnotify.c | 2 +- fs/notify/notification.c | 12 ++++++------ include/linux/fsnotify_backend.h | 23 ++++++++++++++++------- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index c3eefe3f6494..acf78c0ed219 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -781,8 +781,8 @@ static int fanotify_handle_event(struct fsnotify_group *group, u32 mask, } fsn_event = &event->fse; - ret = fsnotify_add_event(group, fsn_event, fanotify_merge, - fanotify_insert_event); + ret = fsnotify_insert_event(group, fsn_event, fanotify_merge, + fanotify_insert_event); if (ret) { /* Permission events shouldn't be merged */ BUG_ON(ret == 1 && mask & FANOTIFY_PERM_EVENTS); diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c index d1a64daa0171..a96582cbfad1 100644 --- a/fs/notify/inotify/inotify_fsnotify.c +++ b/fs/notify/inotify/inotify_fsnotify.c @@ -116,7 +116,7 @@ int inotify_handle_inode_event(struct fsnotify_mark *inode_mark, u32 mask, if (len) strcpy(event->name, name->name); - ret = fsnotify_add_event(group, fsn_event, inotify_merge, NULL); + ret = fsnotify_add_event(group, fsn_event, inotify_merge); if (ret) { /* Our event wasn't used in the end. Free it. */ fsnotify_destroy_event(group, fsn_event); diff --git a/fs/notify/notification.c b/fs/notify/notification.c index 32f45543b9c6..44bb10f50715 100644 --- a/fs/notify/notification.c +++ b/fs/notify/notification.c @@ -78,12 +78,12 @@ void fsnotify_destroy_event(struct fsnotify_group *group, * 2 if the event was not queued - either the queue of events has overflown * or the group is shutting down. */ -int fsnotify_add_event(struct fsnotify_group *group, - struct fsnotify_event *event, - int (*merge)(struct fsnotify_group *, - struct fsnotify_event *), - void (*insert)(struct fsnotify_group *, - struct fsnotify_event *)) +int fsnotify_insert_event(struct fsnotify_group *group, + struct fsnotify_event *event, + int (*merge)(struct fsnotify_group *, + struct fsnotify_event *), + void (*insert)(struct fsnotify_group *, + struct fsnotify_event *)) { int ret = 0; struct list_head *list = &group->notification_list; diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 2b5fb9327a77..cd4ca11f129e 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -495,16 +495,25 @@ extern int fsnotify_fasync(int fd, struct file *file, int on); extern void fsnotify_destroy_event(struct fsnotify_group *group, struct fsnotify_event *event); /* attach the event to the group notification queue */ -extern int fsnotify_add_event(struct fsnotify_group *group, - struct fsnotify_event *event, - int (*merge)(struct fsnotify_group *, - struct fsnotify_event *), - void (*insert)(struct fsnotify_group *, - struct fsnotify_event *)); +extern int fsnotify_insert_event(struct fsnotify_group *group, + struct fsnotify_event *event, + int (*merge)(struct fsnotify_group *, + struct fsnotify_event *), + void (*insert)(struct fsnotify_group *, + struct fsnotify_event *)); + +static inline int fsnotify_add_event(struct fsnotify_group *group, + struct fsnotify_event *event, + int (*merge)(struct fsnotify_group *, + struct fsnotify_event *)) +{ + return fsnotify_insert_event(group, event, merge, NULL); +} + /* Queue overflow event to a notification group */ static inline void fsnotify_queue_overflow(struct fsnotify_group *group) { - fsnotify_add_event(group, group->overflow_event, NULL, NULL); + fsnotify_add_event(group, group->overflow_event, NULL); } static inline bool fsnotify_is_overflow_event(u32 mask) -- 2.32.0