diff options
author | Christoph Hellwig <hch@infradead.org> | 2010-10-10 05:36:30 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-10-25 21:26:14 -0400 |
commit | 4d4eb36679adbdd75495e1bbfe7ac40e4ae41dea (patch) | |
tree | f5cef4647a54e8a65ab518db8edeeea6b7a8652d /fs/notify | |
parent | be9eee2e8b87e335531a3ae13abb8d26e834c438 (diff) |
fsnotify: use dget_parent
Use dget_parent instead of opencoding it. This simplifies the code, but
more importanly prepares for the more complicated locking for a parent
dget in the dcache scale patch series.
It means we do grab a reference to the parent now if need to be watched,
but not with the specified mask. If this turns out to be a problem
we'll have to revisit it, but for now let's keep as much as possible
dcache internals inside dcache.[ch].
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/notify')
-rw-r--r-- | fs/notify/fsnotify.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index 36802420d69a..4498a208df94 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c | |||
@@ -88,8 +88,6 @@ void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) | |||
88 | { | 88 | { |
89 | struct dentry *parent; | 89 | struct dentry *parent; |
90 | struct inode *p_inode; | 90 | struct inode *p_inode; |
91 | bool send = false; | ||
92 | bool should_update_children = false; | ||
93 | 91 | ||
94 | if (!dentry) | 92 | if (!dentry) |
95 | dentry = path->dentry; | 93 | dentry = path->dentry; |
@@ -97,29 +95,12 @@ void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) | |||
97 | if (!(dentry->d_flags & DCACHE_FSNOTIFY_PARENT_WATCHED)) | 95 | if (!(dentry->d_flags & DCACHE_FSNOTIFY_PARENT_WATCHED)) |
98 | return; | 96 | return; |
99 | 97 | ||
100 | spin_lock(&dentry->d_lock); | 98 | parent = dget_parent(dentry); |
101 | parent = dentry->d_parent; | ||
102 | p_inode = parent->d_inode; | 99 | p_inode = parent->d_inode; |
103 | 100 | ||
104 | if (fsnotify_inode_watches_children(p_inode)) { | 101 | if (unlikely(!fsnotify_inode_watches_children(p_inode))) |
105 | if (p_inode->i_fsnotify_mask & mask) { | 102 | __fsnotify_update_child_dentry_flags(p_inode); |
106 | dget(parent); | 103 | else if (p_inode->i_fsnotify_mask & mask) { |
107 | send = true; | ||
108 | } | ||
109 | } else { | ||
110 | /* | ||
111 | * The parent doesn't care about events on it's children but | ||
112 | * at least one child thought it did. We need to run all the | ||
113 | * children and update their d_flags to let them know p_inode | ||
114 | * doesn't care about them any more. | ||
115 | */ | ||
116 | dget(parent); | ||
117 | should_update_children = true; | ||
118 | } | ||
119 | |||
120 | spin_unlock(&dentry->d_lock); | ||
121 | |||
122 | if (send) { | ||
123 | /* we are notifying a parent so come up with the new mask which | 104 | /* we are notifying a parent so come up with the new mask which |
124 | * specifies these are events which came from a child. */ | 105 | * specifies these are events which came from a child. */ |
125 | mask |= FS_EVENT_ON_CHILD; | 106 | mask |= FS_EVENT_ON_CHILD; |
@@ -130,13 +111,9 @@ void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) | |||
130 | else | 111 | else |
131 | fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE, | 112 | fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE, |
132 | dentry->d_name.name, 0); | 113 | dentry->d_name.name, 0); |
133 | dput(parent); | ||
134 | } | 114 | } |
135 | 115 | ||
136 | if (unlikely(should_update_children)) { | 116 | dput(parent); |
137 | __fsnotify_update_child_dentry_flags(p_inode); | ||
138 | dput(parent); | ||
139 | } | ||
140 | } | 117 | } |
141 | EXPORT_SYMBOL_GPL(__fsnotify_parent); | 118 | EXPORT_SYMBOL_GPL(__fsnotify_parent); |
142 | 119 | ||