fsnotify: create a wrapper fsnotify_find_inode_mark()
authorAmir Goldstein <amir73il@gmail.com>
Sun, 17 Mar 2024 18:41:47 +0000 (20:41 +0200)
committerJan Kara <jack@suse.cz>
Thu, 4 Apr 2024 14:24:16 +0000 (16:24 +0200)
In preparation to passing an object pointer to fsnotify_find_mark(), add
a wrapper fsnotify_find_inode_mark() and use it where possible.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Message-Id: <20240317184154.1200192-4-amir73il@gmail.com>

fs/nfsd/filecache.c
fs/notify/dnotify/dnotify.c
fs/notify/inotify/inotify_user.c
include/linux/fsnotify_backend.h
kernel/audit_tree.c
kernel/audit_watch.c

index ddd3e0d9cfa63e6f39f4495653876414afabfc60..ad9083ca144ba2c3a1469d89b126a70db2011b61 100644 (file)
@@ -159,8 +159,8 @@ nfsd_file_mark_find_or_create(struct nfsd_file *nf, struct inode *inode)
 
        do {
                fsnotify_group_lock(nfsd_file_fsnotify_group);
-               mark = fsnotify_find_mark(&inode->i_fsnotify_marks,
-                                         nfsd_file_fsnotify_group);
+               mark = fsnotify_find_inode_mark(inode,
+                                               nfsd_file_fsnotify_group);
                if (mark) {
                        nfm = nfsd_file_mark_get(container_of(mark,
                                                 struct nfsd_file_mark,
index 3464fa7e85380f94b0331371c69a221743ae5e9c..f3669403fabf15b96e79f7d4857f3cd33a83b44c 100644 (file)
@@ -162,7 +162,7 @@ void dnotify_flush(struct file *filp, fl_owner_t id)
        if (!S_ISDIR(inode->i_mode))
                return;
 
-       fsn_mark = fsnotify_find_mark(&inode->i_fsnotify_marks, dnotify_group);
+       fsn_mark = fsnotify_find_inode_mark(inode, dnotify_group);
        if (!fsn_mark)
                return;
        dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
@@ -326,7 +326,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned int arg)
        fsnotify_group_lock(dnotify_group);
 
        /* add the new_fsn_mark or find an old one. */
-       fsn_mark = fsnotify_find_mark(&inode->i_fsnotify_marks, dnotify_group);
+       fsn_mark = fsnotify_find_inode_mark(inode, dnotify_group);
        if (fsn_mark) {
                dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
                spin_lock(&fsn_mark->lock);
index 85d8fdd55329438d52deeed3fb53ead13798bceb..4ffc30606e0b91796eb9240a4cdab13cdf969b0e 100644 (file)
@@ -544,7 +544,7 @@ static int inotify_update_existing_watch(struct fsnotify_group *group,
        int create = (arg & IN_MASK_CREATE);
        int ret;
 
-       fsn_mark = fsnotify_find_mark(&inode->i_fsnotify_marks, group);
+       fsn_mark = fsnotify_find_inode_mark(inode, group);
        if (!fsn_mark)
                return -ENOENT;
        else if (create) {
index d4e3bc55d17451d7d8cc77f92d9752a51954398f..992b57a7e95f43fcc5abadf9f9a37259cc132f41 100644 (file)
@@ -789,6 +789,13 @@ static inline int fsnotify_add_inode_mark_locked(struct fsnotify_mark *mark,
                                        FSNOTIFY_OBJ_TYPE_INODE, add_flags);
 }
 
+static inline struct fsnotify_mark *fsnotify_find_inode_mark(
+                                               struct inode *inode,
+                                               struct fsnotify_group *group)
+{
+       return fsnotify_find_mark(&inode->i_fsnotify_marks, group);
+}
+
 /* given a group and a mark, flag mark to be freed when all references are dropped */
 extern void fsnotify_destroy_mark(struct fsnotify_mark *mark,
                                  struct fsnotify_group *group);
index 1b07e6f12a07a85a3fc97df244d1120bc4e4c150..f2f38903b2fe383c93b049452b4f6196921e59f4 100644 (file)
@@ -463,7 +463,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
        int n;
 
        fsnotify_group_lock(audit_tree_group);
-       mark = fsnotify_find_mark(&inode->i_fsnotify_marks, audit_tree_group);
+       mark = fsnotify_find_inode_mark(inode, audit_tree_group);
        if (!mark)
                return create_chunk(inode, tree);
 
index 7a98cd176a127d2ef1726024a34ad9674b54c28f..7f358740e95826a8fd52e8ec2a2a5a0b92643497 100644 (file)
@@ -90,7 +90,7 @@ static inline struct audit_parent *audit_find_parent(struct inode *inode)
        struct audit_parent *parent = NULL;
        struct fsnotify_mark *entry;
 
-       entry = fsnotify_find_mark(&inode->i_fsnotify_marks, audit_watch_group);
+       entry = fsnotify_find_inode_mark(inode, audit_watch_group);
        if (entry)
                parent = container_of(entry, struct audit_parent, mark);