aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorIan Kent <raven@themaw.net>2011-01-14 13:46:19 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2011-01-15 20:07:41 -0500
commit71e469db242c2eeb00faf9caf7d9e00150c00a6e (patch)
tree8fdb7f6900edca6f2973f9ae64331895112f017e /fs
parente61da20a50d21725ff27571a6dff9468e4fb7146 (diff)
autofs4: Clean up dentry operations
There are now two distinct dentry operations uses. One for dentrys that trigger mounts and one for dentrys that do not. Rationalize the use of these dentry operations and rename them to reflect their function. Signed-off-by: Ian Kent <raven@themaw.net> Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/autofs4/autofs_i.h7
-rw-r--r--fs/autofs4/inode.c12
-rw-r--r--fs/autofs4/root.c36
3 files changed, 26 insertions, 29 deletions
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index f4b4030cf406..c28085cb82a5 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -206,11 +206,8 @@ extern const struct inode_operations autofs4_symlink_inode_operations;
206extern const struct inode_operations autofs4_dir_inode_operations; 206extern const struct inode_operations autofs4_dir_inode_operations;
207extern const struct file_operations autofs4_dir_operations; 207extern const struct file_operations autofs4_dir_operations;
208extern const struct file_operations autofs4_root_operations; 208extern const struct file_operations autofs4_root_operations;
209 209extern const struct dentry_operations autofs4_dentry_operations;
210/* Operations methods */ 210extern const struct dentry_operations autofs4_mount_dentry_operations;
211
212struct vfsmount *autofs4_d_automount(struct path *);
213int autofs4_d_manage(struct dentry *, bool);
214 211
215/* VFS automount flags management functions */ 212/* VFS automount flags management functions */
216 213
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index dac3dc79ccb4..427c35746340 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -251,12 +251,6 @@ static struct autofs_info *autofs4_mkroot(struct autofs_sb_info *sbi)
251 return ino; 251 return ino;
252} 252}
253 253
254static const struct dentry_operations autofs4_sb_dentry_operations = {
255 .d_automount = autofs4_d_automount,
256 .d_manage = autofs4_d_manage,
257 .d_release = autofs4_dentry_release,
258};
259
260int autofs4_fill_super(struct super_block *s, void *data, int silent) 254int autofs4_fill_super(struct super_block *s, void *data, int silent)
261{ 255{
262 struct inode * root_inode; 256 struct inode * root_inode;
@@ -311,7 +305,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
311 goto fail_iput; 305 goto fail_iput;
312 pipe = NULL; 306 pipe = NULL;
313 307
314 d_set_d_op(root, &autofs4_sb_dentry_operations); 308 d_set_d_op(root, &autofs4_dentry_operations);
315 root->d_fsdata = ino; 309 root->d_fsdata = ino;
316 310
317 /* Can this call block? */ 311 /* Can this call block? */
@@ -322,8 +316,10 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
322 goto fail_dput; 316 goto fail_dput;
323 } 317 }
324 318
325 if (autofs_type_trigger(sbi->type)) 319 if (autofs_type_trigger(sbi->type)) {
320 d_set_d_op(root, &autofs4_mount_dentry_operations);
326 __managed_dentry_set_managed(root); 321 __managed_dentry_set_managed(root);
322 }
327 323
328 root_inode->i_fop = &autofs4_root_operations; 324 root_inode->i_fop = &autofs4_root_operations;
329 root_inode->i_op = &autofs4_dir_inode_operations; 325 root_inode->i_op = &autofs4_dir_inode_operations;
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 52af410a831d..62c1229a4d31 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -35,6 +35,8 @@ static long autofs4_root_compat_ioctl(struct file *,unsigned int,unsigned long);
35#endif 35#endif
36static int autofs4_dir_open(struct inode *inode, struct file *file); 36static int autofs4_dir_open(struct inode *inode, struct file *file);
37static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *); 37static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *);
38static struct vfsmount *autofs4_d_automount(struct path *);
39static int autofs4_d_manage(struct dentry *, bool);
38 40
39const struct file_operations autofs4_root_operations = { 41const struct file_operations autofs4_root_operations = {
40 .open = dcache_dir_open, 42 .open = dcache_dir_open,
@@ -64,6 +66,18 @@ const struct inode_operations autofs4_dir_inode_operations = {
64 .rmdir = autofs4_dir_rmdir, 66 .rmdir = autofs4_dir_rmdir,
65}; 67};
66 68
69/* For dentries that don't initiate mounting */
70const struct dentry_operations autofs4_dentry_operations = {
71 .d_release = autofs4_dentry_release,
72};
73
74/* For dentries that do initiate mounting */
75const struct dentry_operations autofs4_mount_dentry_operations = {
76 .d_automount = autofs4_d_automount,
77 .d_manage = autofs4_d_manage,
78 .d_release = autofs4_dentry_release,
79};
80
67static void autofs4_add_active(struct dentry *dentry) 81static void autofs4_add_active(struct dentry *dentry)
68{ 82{
69 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); 83 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
@@ -158,18 +172,6 @@ void autofs4_dentry_release(struct dentry *de)
158 } 172 }
159} 173}
160 174
161/* For dentries of directories in the root dir */
162static const struct dentry_operations autofs4_root_dentry_operations = {
163 .d_release = autofs4_dentry_release,
164};
165
166/* For other dentries */
167static const struct dentry_operations autofs4_dentry_operations = {
168 .d_automount = autofs4_d_automount,
169 .d_manage = autofs4_d_manage,
170 .d_release = autofs4_dentry_release,
171};
172
173static struct dentry *autofs4_lookup_active(struct dentry *dentry) 175static struct dentry *autofs4_lookup_active(struct dentry *dentry)
174{ 176{
175 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); 177 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
@@ -337,7 +339,7 @@ static struct dentry *autofs4_mountpoint_changed(struct path *path)
337 return path->dentry; 339 return path->dentry;
338} 340}
339 341
340struct vfsmount *autofs4_d_automount(struct path *path) 342static struct vfsmount *autofs4_d_automount(struct path *path)
341{ 343{
342 struct dentry *dentry = path->dentry; 344 struct dentry *dentry = path->dentry;
343 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); 345 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
@@ -501,7 +503,7 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
501 if (active) { 503 if (active) {
502 return active; 504 return active;
503 } else { 505 } else {
504 d_set_d_op(dentry, &autofs4_root_dentry_operations); 506 d_set_d_op(dentry, &autofs4_dentry_operations);
505 507
506 /* 508 /*
507 * A dentry that is not within the root can never trigger a 509 * A dentry that is not within the root can never trigger a
@@ -514,7 +516,7 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
514 516
515 /* Mark entries in the root as mount triggers */ 517 /* Mark entries in the root as mount triggers */
516 if (autofs_type_indirect(sbi->type) && IS_ROOT(dentry->d_parent)) { 518 if (autofs_type_indirect(sbi->type) && IS_ROOT(dentry->d_parent)) {
517 d_set_d_op(dentry, &autofs4_dentry_operations); 519 d_set_d_op(dentry, &autofs4_mount_dentry_operations);
518 __managed_dentry_set_managed(dentry); 520 __managed_dentry_set_managed(dentry);
519 } 521 }
520 522
@@ -573,6 +575,8 @@ static int autofs4_dir_symlink(struct inode *dir,
573 } 575 }
574 d_add(dentry, inode); 576 d_add(dentry, inode);
575 577
578 d_set_d_op(dentry, &autofs4_dentry_operations);
579
576 dentry->d_fsdata = ino; 580 dentry->d_fsdata = ino;
577 ino->dentry = dget(dentry); 581 ino->dentry = dget(dentry);
578 atomic_inc(&ino->count); 582 atomic_inc(&ino->count);
@@ -791,7 +795,7 @@ static inline int autofs4_ask_umount(struct vfsmount *mnt, int __user *p)
791int is_autofs4_dentry(struct dentry *dentry) 795int is_autofs4_dentry(struct dentry *dentry)
792{ 796{
793 return dentry && dentry->d_inode && 797 return dentry && dentry->d_inode &&
794 (dentry->d_op == &autofs4_root_dentry_operations || 798 (dentry->d_op == &autofs4_mount_dentry_operations ||
795 dentry->d_op == &autofs4_dentry_operations) && 799 dentry->d_op == &autofs4_dentry_operations) &&
796 dentry->d_fsdata != NULL; 800 dentry->d_fsdata != NULL;
797} 801}