linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH v3 11/13] fsnotify: add fsnotify_connector_inode() wrapper
Date: Fri, 20 Apr 2018 16:10:59 -0700	[thread overview]
Message-ID: <1524265861-6316-12-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1524265861-6316-1-git-send-email-amir73il@gmail.com>

Soon we will be changing the way to dereference an inode object from
connector object. Introduce a wrapper to abstract this dereference.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/notify/fdinfo.c               |  4 ++--
 fs/notify/mark.c                 |  3 ++-
 include/linux/fsnotify_backend.h |  6 ++++++
 kernel/audit_tree.c              | 11 ++++++-----
 4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c
index 10aac1942c9f..b3cf03e347a8 100644
--- a/fs/notify/fdinfo.c
+++ b/fs/notify/fdinfo.c
@@ -81,7 +81,7 @@ static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
 		return;
 
 	inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark);
-	inode = igrab(mark->connector->inode);
+	inode = igrab(fsnotify_connector_inode(mark->connector));
 	if (inode) {
 		/*
 		 * IN_ALL_EVENTS represents all of the mask bits
@@ -117,7 +117,7 @@ static void fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
 		mflags |= FAN_MARK_IGNORED_SURV_MODIFY;
 
 	if (mark->connector->type == FSNOTIFY_OBJ_TYPE_INODE) {
-		inode = igrab(mark->connector->inode);
+		inode = igrab(fsnotify_connector_inode(mark->connector));
 		if (!inode)
 			return;
 		seq_printf(m, "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x ",
diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index 771178c46eeb..7103a0a442e7 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -140,7 +140,8 @@ void fsnotify_recalc_mask(struct fsnotify_mark_connector *conn)
 	__fsnotify_recalc_mask(conn);
 	spin_unlock(&conn->lock);
 	if (conn->type == FSNOTIFY_OBJ_TYPE_INODE)
-		__fsnotify_update_child_dentry_flags(conn->inode);
+		__fsnotify_update_child_dentry_flags(
+				fsnotify_connector_inode(conn));
 }
 
 /* Free all connectors queued for freeing once SRCU period ends */
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index b2826dd1e68c..6e9397c16124 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -279,6 +279,12 @@ static inline struct inode *fsnotify_obj_inode(struct fsnotify_obj *obj)
 	return container_of(obj, struct inode, i_fsnotify);
 }
 
+static inline struct inode *fsnotify_connector_inode(
+		struct fsnotify_mark_connector *conn)
+{
+	return conn->inode;
+}
+
 /*
  * A mark is simply an object attached to an in core inode which allows an
  * fsnotify listener to indicate they are either no longer interested in events
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index eadee98f5a12..529e4757f4e1 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -183,7 +183,7 @@ static unsigned long chunk_to_key(struct audit_chunk *chunk)
 	 */
 	if (WARN_ON_ONCE(!chunk->mark.connector))
 		return 0;
-	return (unsigned long)chunk->mark.connector->inode;
+	return (unsigned long)fsnotify_connector_inode(chunk->mark.connector);
 }
 
 static inline struct list_head *chunk_hash(unsigned long key)
@@ -258,7 +258,7 @@ static void untag_chunk(struct node *p)
 	spin_lock(&entry->lock);
 	/*
 	 * mark_mutex protects mark from getting detached and thus also from
-	 * mark->connector->inode getting NULL.
+	 * mark->connector->obj getting NULL.
 	 */
 	if (chunk->dead || !(entry->flags & FSNOTIFY_MARK_FLAG_ATTACHED)) {
 		spin_unlock(&entry->lock);
@@ -288,8 +288,9 @@ static void untag_chunk(struct node *p)
 	if (!new)
 		goto Fallback;
 
-	if (fsnotify_add_inode_mark_locked(&new->mark, entry->connector->inode,
-					   1)) {
+	if (fsnotify_add_inode_mark_locked(&new->mark,
+				fsnotify_connector_inode(entry->connector),
+				1)) {
 		fsnotify_put_mark(&new->mark);
 		goto Fallback;
 	}
@@ -434,7 +435,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
 	}
 
 	if (fsnotify_add_inode_mark_locked(chunk_entry,
-			     old_entry->connector->inode, 1)) {
+			fsnotify_connector_inode(old_entry->connector), 1)) {
 		spin_unlock(&old_entry->lock);
 		mutex_unlock(&old_entry->group->mark_mutex);
 		fsnotify_put_mark(chunk_entry);
-- 
2.7.4

  parent reply	other threads:[~2018-04-20 23:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-20 23:10 [PATCH v3 00/13] Preparing for fanotify super block marks Amir Goldstein
2018-04-20 23:10 ` [PATCH v3 01/13] fsnotify: use type id to identify connector object type Amir Goldstein
2018-04-20 23:10 ` [PATCH v3 02/13] fsnotify: remove redundant arguments to handle_event() Amir Goldstein
2018-04-20 23:10 ` [PATCH v3 03/13] fsnotify: introduce marks iteration helpers Amir Goldstein
2018-04-20 23:10 ` [PATCH v3 04/13] fsnotify: generalize iteration of marks by object type Amir Goldstein
2018-04-20 23:10 ` [PATCH v3 05/13] fsnotify: generalize send_to_group() Amir Goldstein
2018-04-20 23:10 ` [PATCH v3 06/13] fanotify: generalize fanotify_should_send_event() Amir Goldstein
2018-05-18 10:47   ` Jan Kara
2018-04-20 23:10 ` [PATCH v3 07/13] fsnotify: add fsnotify_add_inode_mark() wrappers Amir Goldstein
2018-04-20 23:10 ` [PATCH v3 08/13] fsnotify: introduce prototype struct fsnotify_obj Amir Goldstein
2018-05-18 12:02   ` Jan Kara
2018-04-20 23:10 ` [PATCH v3 09/13] fsnotify: pass fsnotify_obj instead of **connp argument Amir Goldstein
2018-04-20 23:10 ` [PATCH v3 10/13] fsnotify: pass object and object type to fsnotify_add_mark() Amir Goldstein
2018-04-20 23:10 ` Amir Goldstein [this message]
2018-05-18 12:48   ` [PATCH v3 11/13] fsnotify: add fsnotify_connector_inode() wrapper Jan Kara
2018-04-20 23:11 ` [PATCH v3 12/13] fsnotify: let connector point to abstract fsnotify_obj Amir Goldstein
2018-04-20 23:11 ` [PATCH v3 13/13] fanotify: factor out helpers to add/remove mark Amir Goldstein
2018-05-18 13:09 ` [PATCH v3 00/13] Preparing for fanotify super block marks Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1524265861-6316-12-git-send-email-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).