diff options
author | Eric Paris <eparis@redhat.com> | 2010-10-28 17:21:56 -0400 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2010-10-28 17:22:13 -0400 |
commit | 6ad2d4e3e97ee4bfde0b45e8dfe37911330fc4aa (patch) | |
tree | 6a4b98f659a886147088a983170fa75e5113f017 | |
parent | 9343919c1495b085a4a1cf4cbada8d7888daf099 (diff) |
fsnotify: implement ordering between notifiers
fanotify needs to be able to specify that some groups get events before
others. They use this idea to make sure that a hierarchical storage
manager gets access to files before programs which actually use them. This
is purely infrastructure. Everything will have a priority of 0, but the
infrastructure will exist for it to be non-zero.
Signed-off-by: Eric Paris <eparis@redhat.com>
-rw-r--r-- | fs/notify/inode_mark.c | 9 | ||||
-rw-r--r-- | fs/notify/vfsmount_mark.c | 6 | ||||
-rw-r--r-- | include/linux/fsnotify_backend.h | 8 |
3 files changed, 20 insertions, 3 deletions
diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c index 21ed10660b80..4c29fcf557d1 100644 --- a/fs/notify/inode_mark.c +++ b/fs/notify/inode_mark.c | |||
@@ -177,7 +177,8 @@ void fsnotify_set_inode_mark_mask_locked(struct fsnotify_mark *mark, | |||
177 | * Attach an initialized mark to a given inode. | 177 | * Attach an initialized mark to a given inode. |
178 | * These marks may be used for the fsnotify backend to determine which | 178 | * These marks may be used for the fsnotify backend to determine which |
179 | * event types should be delivered to which group and for which inodes. These | 179 | * event types should be delivered to which group and for which inodes. These |
180 | * marks are ordered according to the group's location in memory. | 180 | * marks are ordered according to priority, highest number first, and then by |
181 | * the group's location in memory. | ||
181 | */ | 182 | */ |
182 | int fsnotify_add_inode_mark(struct fsnotify_mark *mark, | 183 | int fsnotify_add_inode_mark(struct fsnotify_mark *mark, |
183 | struct fsnotify_group *group, struct inode *inode, | 184 | struct fsnotify_group *group, struct inode *inode, |
@@ -211,7 +212,11 @@ int fsnotify_add_inode_mark(struct fsnotify_mark *mark, | |||
211 | goto out; | 212 | goto out; |
212 | } | 213 | } |
213 | 214 | ||
214 | if (mark->group < lmark->group) | 215 | if (mark->group->priority < lmark->group->priority) |
216 | continue; | ||
217 | |||
218 | if ((mark->group->priority == lmark->group->priority) && | ||
219 | (mark->group < lmark->group)) | ||
215 | continue; | 220 | continue; |
216 | 221 | ||
217 | hlist_add_before_rcu(&mark->i.i_list, &lmark->i.i_list); | 222 | hlist_add_before_rcu(&mark->i.i_list, &lmark->i.i_list); |
diff --git a/fs/notify/vfsmount_mark.c b/fs/notify/vfsmount_mark.c index 56772b578fbd..85eebff6d0d7 100644 --- a/fs/notify/vfsmount_mark.c +++ b/fs/notify/vfsmount_mark.c | |||
@@ -169,7 +169,11 @@ int fsnotify_add_vfsmount_mark(struct fsnotify_mark *mark, | |||
169 | goto out; | 169 | goto out; |
170 | } | 170 | } |
171 | 171 | ||
172 | if (mark->group < lmark->group) | 172 | if (mark->group->priority < lmark->group->priority) |
173 | continue; | ||
174 | |||
175 | if ((mark->group->priority == lmark->group->priority) && | ||
176 | (mark->group < lmark->group)) | ||
173 | continue; | 177 | continue; |
174 | 178 | ||
175 | hlist_add_before_rcu(&mark->m.m_list, &lmark->m.m_list); | 179 | hlist_add_before_rcu(&mark->m.m_list, &lmark->m.m_list); |
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index e40190d16878..825329534162 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h | |||
@@ -129,6 +129,14 @@ struct fsnotify_group { | |||
129 | wait_queue_head_t notification_waitq; /* read() on the notification file blocks on this waitq */ | 129 | wait_queue_head_t notification_waitq; /* read() on the notification file blocks on this waitq */ |
130 | unsigned int q_len; /* events on the queue */ | 130 | unsigned int q_len; /* events on the queue */ |
131 | unsigned int max_events; /* maximum events allowed on the list */ | 131 | unsigned int max_events; /* maximum events allowed on the list */ |
132 | /* | ||
133 | * Valid fsnotify group priorities. Events are send in order from highest | ||
134 | * priority to lowest priority. We default to the lowest priority. | ||
135 | */ | ||
136 | #define FS_PRIO_0 0 /* normal notifiers, no permissions */ | ||
137 | #define FS_PRIO_1 1 /* fanotify content based access control */ | ||
138 | #define FS_PRIO_2 2 /* fanotify pre-content access */ | ||
139 | unsigned int priority; | ||
132 | 140 | ||
133 | /* stores all fastpath marks assoc with this group so they can be cleaned on unregister */ | 141 | /* stores all fastpath marks assoc with this group so they can be cleaned on unregister */ |
134 | spinlock_t mark_lock; /* protect marks_list */ | 142 | spinlock_t mark_lock; /* protect marks_list */ |