aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/ops_dentry.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-03-20 12:30:04 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2006-03-20 12:30:04 -0500
commitc752666c17f870fa8ae9f16804dd457e9e6daaec (patch)
treec3c48383f386a24edbdf3c6292f25b587e6d9368 /fs/gfs2/ops_dentry.c
parent419c93e0b6b9eef0bf26b8ad415f2a5bf4300119 (diff)
[GFS2] Fix bug in directory code and tidy up
Due to a typo, the dir leaf split operation was (for the first split in a directory) writing the new hash vaules at the wrong offset. This is now fixed. Also some other tidy ups are included: - We use GFS2's hash function for dentries (see ops_dentry.c) so that we don't have to keep recalculating the hash values. - A lot of common code is eliminated between the various directory lookup routines. - Better error checking on directory lookup (previously different routines checked for different errors) - The leaf split operation has a couple of redundant operations removed from it, so it should be faster. There is still further scope for further clean ups in the directory code, and readdir in particular could do with slimming down a bit. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/ops_dentry.c')
-rw-r--r--fs/gfs2/ops_dentry.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c
index 7f6139288519..b54608f9df50 100644
--- a/fs/gfs2/ops_dentry.c
+++ b/fs/gfs2/ops_dentry.c
@@ -38,25 +38,26 @@
38static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd) 38static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
39{ 39{
40 struct dentry *parent = dget_parent(dentry); 40 struct dentry *parent = dget_parent(dentry);
41 struct gfs2_sbd *sdp = parent->d_inode->i_sb->s_fs_info;
41 struct gfs2_inode *dip = parent->d_inode->u.generic_ip; 42 struct gfs2_inode *dip = parent->d_inode->u.generic_ip;
42 struct inode *inode; 43 struct inode *inode = dentry->d_inode;
43 struct gfs2_holder d_gh; 44 struct gfs2_holder d_gh;
44 struct gfs2_inode *ip; 45 struct gfs2_inode *ip;
45 struct gfs2_inum inum; 46 struct gfs2_inum inum;
46 unsigned int type; 47 unsigned int type;
47 int error; 48 int error;
48 49
49 lock_kernel();
50
51 inode = dentry->d_inode;
52 if (inode && is_bad_inode(inode)) 50 if (inode && is_bad_inode(inode))
53 goto invalid; 51 goto invalid;
54 52
53 if (sdp->sd_args.ar_localcaching)
54 goto valid;
55
55 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh); 56 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh);
56 if (error) 57 if (error)
57 goto fail; 58 goto fail;
58 59
59 error = gfs2_dir_search(dip, &dentry->d_name, &inum, &type); 60 error = gfs2_dir_search(parent->d_inode, &dentry->d_name, &inum, &type);
60 switch (error) { 61 switch (error) {
61 case 0: 62 case 0:
62 if (!inode) 63 if (!inode)
@@ -84,7 +85,6 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
84 gfs2_glock_dq_uninit(&d_gh); 85 gfs2_glock_dq_uninit(&d_gh);
85 86
86 valid: 87 valid:
87 unlock_kernel();
88 dput(parent); 88 dput(parent);
89 return 1; 89 return 1;
90 90
@@ -99,7 +99,6 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
99 } 99 }
100 d_drop(dentry); 100 d_drop(dentry);
101 101
102 unlock_kernel();
103 dput(parent); 102 dput(parent);
104 return 0; 103 return 0;
105 104
@@ -107,12 +106,18 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
107 gfs2_glock_dq_uninit(&d_gh); 106 gfs2_glock_dq_uninit(&d_gh);
108 107
109 fail: 108 fail:
110 unlock_kernel();
111 dput(parent); 109 dput(parent);
112 return 0; 110 return 0;
113} 111}
114 112
113static int gfs2_dhash(struct dentry *dentry, struct qstr *str)
114{
115 str->hash = gfs2_disk_hash(str->name, str->len);
116 return 0;
117}
118
115struct dentry_operations gfs2_dops = { 119struct dentry_operations gfs2_dops = {
116 .d_revalidate = gfs2_drevalidate, 120 .d_revalidate = gfs2_drevalidate,
121 .d_hash = gfs2_dhash,
117}; 122};
118 123