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
parent[GFS2] Add gfs2meta filesystem (diff)
downloadlinux-dev-c752666c17f870fa8ae9f16804dd457e9e6daaec.tar.xz
linux-dev-c752666c17f870fa8ae9f16804dd457e9e6daaec.zip
[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 @@
static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
{
struct dentry *parent = dget_parent(dentry);
+ struct gfs2_sbd *sdp = parent->d_inode->i_sb->s_fs_info;
struct gfs2_inode *dip = parent->d_inode->u.generic_ip;
- struct inode *inode;
+ struct inode *inode = dentry->d_inode;
struct gfs2_holder d_gh;
struct gfs2_inode *ip;
struct gfs2_inum inum;
unsigned int type;
int error;
- lock_kernel();
-
- inode = dentry->d_inode;
if (inode && is_bad_inode(inode))
goto invalid;
+ if (sdp->sd_args.ar_localcaching)
+ goto valid;
+
error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh);
if (error)
goto fail;
- error = gfs2_dir_search(dip, &dentry->d_name, &inum, &type);
+ error = gfs2_dir_search(parent->d_inode, &dentry->d_name, &inum, &type);
switch (error) {
case 0:
if (!inode)
@@ -84,7 +85,6 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
gfs2_glock_dq_uninit(&d_gh);
valid:
- unlock_kernel();
dput(parent);
return 1;
@@ -99,7 +99,6 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
}
d_drop(dentry);
- unlock_kernel();
dput(parent);
return 0;
@@ -107,12 +106,18 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
gfs2_glock_dq_uninit(&d_gh);
fail:
- unlock_kernel();
dput(parent);
return 0;
}
+static int gfs2_dhash(struct dentry *dentry, struct qstr *str)
+{
+ str->hash = gfs2_disk_hash(str->name, str->len);
+ return 0;
+}
+
struct dentry_operations gfs2_dops = {
.d_revalidate = gfs2_drevalidate,
+ .d_hash = gfs2_dhash,
};