Commit 796a6b521d0eadb338adf8cf7e482351c3a8a7b4
1 parent
c177c2ac8c
Exists in
master
and in
39 other branches
Kill CL_PROPAGATION, sanitize fs/pnode.c:get_source()
First of all, get_source() never results in CL_PROPAGATION alone. We either get CL_MAKE_SHARED (for the continuation of peer group) or CL_SLAVE (slave that is not shared) or both (beginning of peer group among slaves). Massage the code to make that explicit, kill CL_PROPAGATION test in clone_mnt() (nothing sets CL_MAKE_SHARED without CL_PROPAGATION and in clone_mnt() we are checking CL_PROPAGATION after we'd found that there's no CL_SLAVE, so the check for CL_MAKE_SHARED would do just as well). Fix comments, while we are at it... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 3 changed files with 19 additions and 14 deletions Side-by-side Diff
fs/namespace.c
... | ... | @@ -573,7 +573,7 @@ |
573 | 573 | mnt->mnt_master = old; |
574 | 574 | CLEAR_MNT_SHARED(mnt); |
575 | 575 | } else if (!(flag & CL_PRIVATE)) { |
576 | - if ((flag & CL_PROPAGATION) || IS_MNT_SHARED(old)) | |
576 | + if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(old)) | |
577 | 577 | list_add(&mnt->mnt_share, &old->mnt_share); |
578 | 578 | if (IS_MNT_SLAVE(old)) |
579 | 579 | list_add(&mnt->mnt_slave, &old->mnt_slave); |
fs/pnode.c
... | ... | @@ -86,7 +86,7 @@ |
86 | 86 | |
87 | 87 | /* |
88 | 88 | * slave 'mnt' to a peer mount that has the |
89 | - * same root dentry. If none is available than | |
89 | + * same root dentry. If none is available then | |
90 | 90 | * slave it to anything that is available. |
91 | 91 | */ |
92 | 92 | while ((peer_mnt = next_peer(peer_mnt)) != mnt && |
... | ... | @@ -147,6 +147,11 @@ |
147 | 147 | * get the next mount in the propagation tree. |
148 | 148 | * @m: the mount seen last |
149 | 149 | * @origin: the original mount from where the tree walk initiated |
150 | + * | |
151 | + * Note that peer groups form contiguous segments of slave lists. | |
152 | + * We rely on that in get_source() to be able to find out if | |
153 | + * vfsmount found while iterating with propagation_next() is | |
154 | + * a peer of one we'd found earlier. | |
150 | 155 | */ |
151 | 156 | static struct vfsmount *propagation_next(struct vfsmount *m, |
152 | 157 | struct vfsmount *origin) |
153 | 158 | |
... | ... | @@ -186,11 +191,7 @@ |
186 | 191 | { |
187 | 192 | struct vfsmount *p_last_src = NULL; |
188 | 193 | struct vfsmount *p_last_dest = NULL; |
189 | - *type = CL_PROPAGATION; | |
190 | 194 | |
191 | - if (IS_MNT_SHARED(dest)) | |
192 | - *type |= CL_MAKE_SHARED; | |
193 | - | |
194 | 195 | while (last_dest != dest->mnt_master) { |
195 | 196 | p_last_dest = last_dest; |
196 | 197 | p_last_src = last_src; |
197 | 198 | |
... | ... | @@ -202,13 +203,18 @@ |
202 | 203 | do { |
203 | 204 | p_last_dest = next_peer(p_last_dest); |
204 | 205 | } while (IS_MNT_NEW(p_last_dest)); |
206 | + /* is that a peer of the earlier? */ | |
207 | + if (dest == p_last_dest) { | |
208 | + *type = CL_MAKE_SHARED; | |
209 | + return p_last_src; | |
210 | + } | |
205 | 211 | } |
206 | - | |
207 | - if (dest != p_last_dest) { | |
208 | - *type |= CL_SLAVE; | |
209 | - return last_src; | |
210 | - } else | |
211 | - return p_last_src; | |
212 | + /* slave of the earlier, then */ | |
213 | + *type = CL_SLAVE; | |
214 | + /* beginning of peer group among the slaves? */ | |
215 | + if (IS_MNT_SHARED(dest)) | |
216 | + *type |= CL_MAKE_SHARED; | |
217 | + return last_src; | |
212 | 218 | } |
213 | 219 | |
214 | 220 | /* |
fs/pnode.h