aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorMark Fasheh <mark.fasheh@oracle.com>2007-09-11 18:22:06 -0400
committerMark Fasheh <mark.fasheh@oracle.com>2007-10-12 14:54:38 -0400
commitbe94d11704ef79030fd2e6a0c41b4a7f65f9e860 (patch)
tree10b060625c464db127210acc00e8aa80b43ce6f3 /fs/ocfs2
parent0bfbbf62a8b5a129ba2c689283bfece80a601aba (diff)
ocfs2: Provide convenience function for ino lookup
A couple paths which needed to just match a parent dir + name pair to an inode number were a bit messy because they had to deal with ocfs2_find_files_on_disk() which returns a larger number of values. Provide a convenience function, ocfs2_lookup_ino_from_name() which internalizes all the extra accounting. Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com> Reviewed-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/dir.c17
-rw-r--r--fs/ocfs2/dir.h2
-rw-r--r--fs/ocfs2/export.c8
-rw-r--r--fs/ocfs2/namei.c9
-rw-r--r--fs/ocfs2/sysfile.c10
5 files changed, 25 insertions, 21 deletions
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 4bb54406354b..4791683a119c 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -628,6 +628,23 @@ leave:
628 return status; 628 return status;
629} 629}
630 630
631/*
632 * Convenience function for callers which just want the block number
633 * mapped to a name and don't require the full dirent info, etc.
634 */
635int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name,
636 int namelen, u64 *blkno)
637{
638 int ret;
639 struct buffer_head *bh = NULL;
640 struct ocfs2_dir_entry *dirent = NULL;
641
642 ret = ocfs2_find_files_on_disk(name, namelen, blkno, dir, &bh, &dirent);
643 brelse(bh);
644
645 return ret;
646}
647
631/* Check for a name within a directory. 648/* Check for a name within a directory.
632 * 649 *
633 * Return 0 if the name does not exist 650 * Return 0 if the name does not exist
diff --git a/fs/ocfs2/dir.h b/fs/ocfs2/dir.h
index 3e65f91b034d..d03eaaa5cfd4 100644
--- a/fs/ocfs2/dir.h
+++ b/fs/ocfs2/dir.h
@@ -61,6 +61,8 @@ int ocfs2_find_files_on_disk(const char *name,
61 struct inode *inode, 61 struct inode *inode,
62 struct buffer_head **dirent_bh, 62 struct buffer_head **dirent_bh,
63 struct ocfs2_dir_entry **dirent); 63 struct ocfs2_dir_entry **dirent);
64int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name,
65 int namelen, u64 *blkno);
64int ocfs2_readdir(struct file *filp, void *dirent, filldir_t filldir); 66int ocfs2_readdir(struct file *filp, void *dirent, filldir_t filldir);
65int ocfs2_dir_foreach(struct inode *inode, loff_t *f_pos, void *priv, 67int ocfs2_dir_foreach(struct inode *inode, loff_t *f_pos, void *priv,
66 filldir_t filldir); 68 filldir_t filldir);
diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c
index bc48177bd183..c3bbc198f9ce 100644
--- a/fs/ocfs2/export.c
+++ b/fs/ocfs2/export.c
@@ -88,8 +88,6 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)
88 struct dentry *parent; 88 struct dentry *parent;
89 struct inode *inode; 89 struct inode *inode;
90 struct inode *dir = child->d_inode; 90 struct inode *dir = child->d_inode;
91 struct buffer_head *dirent_bh = NULL;
92 struct ocfs2_dir_entry *dirent;
93 91
94 mlog_entry("(0x%p, '%.*s')\n", child, 92 mlog_entry("(0x%p, '%.*s')\n", child,
95 child->d_name.len, child->d_name.name); 93 child->d_name.len, child->d_name.name);
@@ -105,8 +103,7 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)
105 goto bail; 103 goto bail;
106 } 104 }
107 105
108 status = ocfs2_find_files_on_disk("..", 2, &blkno, dir, &dirent_bh, 106 status = ocfs2_lookup_ino_from_name(dir, "..", 2, &blkno);
109 &dirent);
110 if (status < 0) { 107 if (status < 0) {
111 parent = ERR_PTR(-ENOENT); 108 parent = ERR_PTR(-ENOENT);
112 goto bail_unlock; 109 goto bail_unlock;
@@ -131,9 +128,6 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)
131bail_unlock: 128bail_unlock:
132 ocfs2_meta_unlock(dir, 0); 129 ocfs2_meta_unlock(dir, 0);
133 130
134 if (dirent_bh)
135 brelse(dirent_bh);
136
137bail: 131bail:
138 mlog_exit_ptr(parent); 132 mlog_exit_ptr(parent);
139 133
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index aae6c0bf6696..98aeebc2c9fa 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -101,10 +101,8 @@ static struct dentry *ocfs2_lookup(struct inode *dir, struct dentry *dentry,
101{ 101{
102 int status; 102 int status;
103 u64 blkno; 103 u64 blkno;
104 struct buffer_head *dirent_bh = NULL;
105 struct inode *inode = NULL; 104 struct inode *inode = NULL;
106 struct dentry *ret; 105 struct dentry *ret;
107 struct ocfs2_dir_entry *dirent;
108 struct ocfs2_inode_info *oi; 106 struct ocfs2_inode_info *oi;
109 107
110 mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry, 108 mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry,
@@ -126,9 +124,8 @@ static struct dentry *ocfs2_lookup(struct inode *dir, struct dentry *dentry,
126 goto bail; 124 goto bail;
127 } 125 }
128 126
129 status = ocfs2_find_files_on_disk(dentry->d_name.name, 127 status = ocfs2_lookup_ino_from_name(dir, dentry->d_name.name,
130 dentry->d_name.len, &blkno, 128 dentry->d_name.len, &blkno);
131 dir, &dirent_bh, &dirent);
132 if (status < 0) 129 if (status < 0)
133 goto bail_add; 130 goto bail_add;
134 131
@@ -183,8 +180,6 @@ bail_unlock:
183 ocfs2_meta_unlock(dir, 0); 180 ocfs2_meta_unlock(dir, 0);
184 181
185bail: 182bail:
186 if (dirent_bh)
187 brelse(dirent_bh);
188 183
189 mlog_exit_ptr(ret); 184 mlog_exit_ptr(ret);
190 185
diff --git a/fs/ocfs2/sysfile.c b/fs/ocfs2/sysfile.c
index 5df6e35d09b1..fd2e846e3e6f 100644
--- a/fs/ocfs2/sysfile.c
+++ b/fs/ocfs2/sysfile.c
@@ -100,17 +100,14 @@ static struct inode * _ocfs2_get_system_file_inode(struct ocfs2_super *osb,
100 char namebuf[40]; 100 char namebuf[40];
101 struct inode *inode = NULL; 101 struct inode *inode = NULL;
102 u64 blkno; 102 u64 blkno;
103 struct buffer_head *dirent_bh = NULL;
104 struct ocfs2_dir_entry *de = NULL;
105 int status = 0; 103 int status = 0;
106 104
107 ocfs2_sprintf_system_inode_name(namebuf, 105 ocfs2_sprintf_system_inode_name(namebuf,
108 sizeof(namebuf), 106 sizeof(namebuf),
109 type, slot); 107 type, slot);
110 108
111 status = ocfs2_find_files_on_disk(namebuf, strlen(namebuf), 109 status = ocfs2_lookup_ino_from_name(osb->sys_root_inode, namebuf,
112 &blkno, osb->sys_root_inode, 110 strlen(namebuf), &blkno);
113 &dirent_bh, &de);
114 if (status < 0) { 111 if (status < 0) {
115 goto bail; 112 goto bail;
116 } 113 }
@@ -122,8 +119,7 @@ static struct inode * _ocfs2_get_system_file_inode(struct ocfs2_super *osb,
122 goto bail; 119 goto bail;
123 } 120 }
124bail: 121bail:
125 if (dirent_bh) 122
126 brelse(dirent_bh);
127 return inode; 123 return inode;
128} 124}
129 125