diff options
Diffstat (limited to 'fs/notify/inode_mark.c')
| -rw-r--r-- | fs/notify/inode_mark.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c index c925579ba011..4292f9e23ae8 100644 --- a/fs/notify/inode_mark.c +++ b/fs/notify/inode_mark.c | |||
| @@ -141,7 +141,32 @@ struct fsnotify_mark *fsnotify_find_inode_mark(struct fsnotify_group *group, | |||
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | /* | 143 | /* |
| 144 | * Attach an initialized mark mark to a given group and inode. | 144 | * If we are setting a mark mask on an inode mark we should pin the inode |
| 145 | * in memory. | ||
| 146 | */ | ||
| 147 | void fsnotify_set_inode_mark_mask_locked(struct fsnotify_mark *mark, | ||
| 148 | __u32 mask) | ||
| 149 | { | ||
| 150 | struct inode *inode; | ||
| 151 | |||
| 152 | assert_spin_locked(&mark->lock); | ||
| 153 | |||
| 154 | if (mask && | ||
| 155 | mark->i.inode && | ||
| 156 | !(mark->flags & FSNOTIFY_MARK_FLAG_OBJECT_PINNED)) { | ||
| 157 | mark->flags |= FSNOTIFY_MARK_FLAG_OBJECT_PINNED; | ||
| 158 | inode = igrab(mark->i.inode); | ||
| 159 | /* | ||
| 160 | * we shouldn't be able to get here if the inode wasn't | ||
| 161 | * already safely held in memory. But bug in case it | ||
| 162 | * ever is wrong. | ||
| 163 | */ | ||
| 164 | BUG_ON(!inode); | ||
| 165 | } | ||
| 166 | } | ||
| 167 | |||
| 168 | /* | ||
| 169 | * Attach an initialized mark to a given group and inode. | ||
| 145 | * These marks may be used for the fsnotify backend to determine which | 170 | * These marks may be used for the fsnotify backend to determine which |
| 146 | * event types should be delivered to which group and for which inodes. | 171 | * event types should be delivered to which group and for which inodes. |
| 147 | */ | 172 | */ |
| @@ -152,10 +177,6 @@ int fsnotify_add_inode_mark(struct fsnotify_mark *mark, | |||
| 152 | struct fsnotify_mark *lmark = NULL; | 177 | struct fsnotify_mark *lmark = NULL; |
| 153 | int ret = 0; | 178 | int ret = 0; |
| 154 | 179 | ||
| 155 | inode = igrab(inode); | ||
| 156 | if (unlikely(!inode)) | ||
| 157 | return -EINVAL; | ||
| 158 | |||
| 159 | mark->flags = FSNOTIFY_MARK_FLAG_INODE; | 180 | mark->flags = FSNOTIFY_MARK_FLAG_INODE; |
| 160 | 181 | ||
| 161 | assert_spin_locked(&mark->lock); | 182 | assert_spin_locked(&mark->lock); |
| @@ -175,10 +196,8 @@ int fsnotify_add_inode_mark(struct fsnotify_mark *mark, | |||
| 175 | 196 | ||
| 176 | spin_unlock(&inode->i_lock); | 197 | spin_unlock(&inode->i_lock); |
| 177 | 198 | ||
| 178 | if (lmark) { | 199 | if (lmark) |
| 179 | ret = -EEXIST; | 200 | ret = -EEXIST; |
| 180 | iput(inode); | ||
| 181 | } | ||
| 182 | 201 | ||
| 183 | return ret; | 202 | return ret; |
| 184 | } | 203 | } |
