fsnotify: Add wrapper around fsnotify_add_event
[ Upstream commit 1ad03c3a326a86e259389592117252c851873395 ] fsnotify_add_event is growing in number of parameters, which in 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. Link: https://lore.kernel.org/r/20211025192746.66445-10-krisman@collabora.com Suggested-by: Amir Goldstein <amir73il@gmail.com> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
24eda1b5e6
commit
44844158ee
@@ -781,7 +781,7 @@ static int fanotify_handle_event(struct fsnotify_group *group, u32 mask,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fsn_event = &event->fse;
|
fsn_event = &event->fse;
|
||||||
ret = fsnotify_add_event(group, fsn_event, fanotify_merge,
|
ret = fsnotify_insert_event(group, fsn_event, fanotify_merge,
|
||||||
fanotify_insert_event);
|
fanotify_insert_event);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
/* Permission events shouldn't be merged */
|
/* Permission events shouldn't be merged */
|
||||||
|
@@ -123,7 +123,7 @@ int inotify_handle_inode_event(struct fsnotify_mark *inode_mark, u32 mask,
|
|||||||
if (len)
|
if (len)
|
||||||
strcpy(event->name, name->name);
|
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) {
|
if (ret) {
|
||||||
/* Our event wasn't used in the end. Free it. */
|
/* Our event wasn't used in the end. Free it. */
|
||||||
fsnotify_destroy_event(group, fsn_event);
|
fsnotify_destroy_event(group, fsn_event);
|
||||||
|
@@ -78,7 +78,7 @@ void fsnotify_destroy_event(struct fsnotify_group *group,
|
|||||||
* 2 if the event was not queued - either the queue of events has overflown
|
* 2 if the event was not queued - either the queue of events has overflown
|
||||||
* or the group is shutting down.
|
* or the group is shutting down.
|
||||||
*/
|
*/
|
||||||
int fsnotify_add_event(struct fsnotify_group *group,
|
int fsnotify_insert_event(struct fsnotify_group *group,
|
||||||
struct fsnotify_event *event,
|
struct fsnotify_event *event,
|
||||||
int (*merge)(struct fsnotify_group *,
|
int (*merge)(struct fsnotify_group *,
|
||||||
struct fsnotify_event *),
|
struct fsnotify_event *),
|
||||||
|
@@ -498,16 +498,25 @@ extern int fsnotify_fasync(int fd, struct file *file, int on);
|
|||||||
extern void fsnotify_destroy_event(struct fsnotify_group *group,
|
extern void fsnotify_destroy_event(struct fsnotify_group *group,
|
||||||
struct fsnotify_event *event);
|
struct fsnotify_event *event);
|
||||||
/* attach the event to the group notification queue */
|
/* attach the event to the group notification queue */
|
||||||
extern int fsnotify_add_event(struct fsnotify_group *group,
|
extern int fsnotify_insert_event(struct fsnotify_group *group,
|
||||||
struct fsnotify_event *event,
|
struct fsnotify_event *event,
|
||||||
int (*merge)(struct fsnotify_group *,
|
int (*merge)(struct fsnotify_group *,
|
||||||
struct fsnotify_event *),
|
struct fsnotify_event *),
|
||||||
void (*insert)(struct fsnotify_group *,
|
void (*insert)(struct fsnotify_group *,
|
||||||
struct fsnotify_event *));
|
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 */
|
/* Queue overflow event to a notification group */
|
||||||
static inline void fsnotify_queue_overflow(struct fsnotify_group *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)
|
static inline bool fsnotify_is_overflow_event(u32 mask)
|
||||||
|
Reference in New Issue
Block a user