diff options
Diffstat (limited to 'fs/bfs/dir.c')
-rw-r--r-- | fs/bfs/dir.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c index 034950cb3cbe..87ee5ccee348 100644 --- a/fs/bfs/dir.c +++ b/fs/bfs/dir.c | |||
@@ -32,16 +32,17 @@ static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir) | |||
32 | struct inode *dir = f->f_path.dentry->d_inode; | 32 | struct inode *dir = f->f_path.dentry->d_inode; |
33 | struct buffer_head *bh; | 33 | struct buffer_head *bh; |
34 | struct bfs_dirent *de; | 34 | struct bfs_dirent *de; |
35 | struct bfs_sb_info *info = BFS_SB(dir->i_sb); | ||
35 | unsigned int offset; | 36 | unsigned int offset; |
36 | int block; | 37 | int block; |
37 | 38 | ||
38 | lock_kernel(); | 39 | mutex_lock(&info->bfs_lock); |
39 | 40 | ||
40 | if (f->f_pos & (BFS_DIRENT_SIZE - 1)) { | 41 | if (f->f_pos & (BFS_DIRENT_SIZE - 1)) { |
41 | printf("Bad f_pos=%08lx for %s:%08lx\n", | 42 | printf("Bad f_pos=%08lx for %s:%08lx\n", |
42 | (unsigned long)f->f_pos, | 43 | (unsigned long)f->f_pos, |
43 | dir->i_sb->s_id, dir->i_ino); | 44 | dir->i_sb->s_id, dir->i_ino); |
44 | unlock_kernel(); | 45 | mutex_unlock(&info->bfs_lock); |
45 | return -EBADF; | 46 | return -EBADF; |
46 | } | 47 | } |
47 | 48 | ||
@@ -61,7 +62,7 @@ static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir) | |||
61 | le16_to_cpu(de->ino), | 62 | le16_to_cpu(de->ino), |
62 | DT_UNKNOWN) < 0) { | 63 | DT_UNKNOWN) < 0) { |
63 | brelse(bh); | 64 | brelse(bh); |
64 | unlock_kernel(); | 65 | mutex_unlock(&info->bfs_lock); |
65 | return 0; | 66 | return 0; |
66 | } | 67 | } |
67 | } | 68 | } |
@@ -71,7 +72,7 @@ static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir) | |||
71 | brelse(bh); | 72 | brelse(bh); |
72 | } | 73 | } |
73 | 74 | ||
74 | unlock_kernel(); | 75 | mutex_unlock(&info->bfs_lock); |
75 | return 0; | 76 | return 0; |
76 | } | 77 | } |
77 | 78 | ||
@@ -95,10 +96,10 @@ static int bfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
95 | inode = new_inode(s); | 96 | inode = new_inode(s); |
96 | if (!inode) | 97 | if (!inode) |
97 | return -ENOSPC; | 98 | return -ENOSPC; |
98 | lock_kernel(); | 99 | mutex_lock(&info->bfs_lock); |
99 | ino = find_first_zero_bit(info->si_imap, info->si_lasti); | 100 | ino = find_first_zero_bit(info->si_imap, info->si_lasti); |
100 | if (ino > info->si_lasti) { | 101 | if (ino > info->si_lasti) { |
101 | unlock_kernel(); | 102 | mutex_unlock(&info->bfs_lock); |
102 | iput(inode); | 103 | iput(inode); |
103 | return -ENOSPC; | 104 | return -ENOSPC; |
104 | } | 105 | } |
@@ -125,10 +126,10 @@ static int bfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
125 | if (err) { | 126 | if (err) { |
126 | inode_dec_link_count(inode); | 127 | inode_dec_link_count(inode); |
127 | iput(inode); | 128 | iput(inode); |
128 | unlock_kernel(); | 129 | mutex_unlock(&info->bfs_lock); |
129 | return err; | 130 | return err; |
130 | } | 131 | } |
131 | unlock_kernel(); | 132 | mutex_unlock(&info->bfs_lock); |
132 | d_instantiate(dentry, inode); | 133 | d_instantiate(dentry, inode); |
133 | return 0; | 134 | return 0; |
134 | } | 135 | } |
@@ -139,22 +140,23 @@ static struct dentry *bfs_lookup(struct inode *dir, struct dentry *dentry, | |||
139 | struct inode *inode = NULL; | 140 | struct inode *inode = NULL; |
140 | struct buffer_head *bh; | 141 | struct buffer_head *bh; |
141 | struct bfs_dirent *de; | 142 | struct bfs_dirent *de; |
143 | struct bfs_sb_info *info = BFS_SB(dir->i_sb); | ||
142 | 144 | ||
143 | if (dentry->d_name.len > BFS_NAMELEN) | 145 | if (dentry->d_name.len > BFS_NAMELEN) |
144 | return ERR_PTR(-ENAMETOOLONG); | 146 | return ERR_PTR(-ENAMETOOLONG); |
145 | 147 | ||
146 | lock_kernel(); | 148 | mutex_lock(&info->bfs_lock); |
147 | bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); | 149 | bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); |
148 | if (bh) { | 150 | if (bh) { |
149 | unsigned long ino = (unsigned long)le16_to_cpu(de->ino); | 151 | unsigned long ino = (unsigned long)le16_to_cpu(de->ino); |
150 | brelse(bh); | 152 | brelse(bh); |
151 | inode = bfs_iget(dir->i_sb, ino); | 153 | inode = bfs_iget(dir->i_sb, ino); |
152 | if (IS_ERR(inode)) { | 154 | if (IS_ERR(inode)) { |
153 | unlock_kernel(); | 155 | mutex_unlock(&info->bfs_lock); |
154 | return ERR_CAST(inode); | 156 | return ERR_CAST(inode); |
155 | } | 157 | } |
156 | } | 158 | } |
157 | unlock_kernel(); | 159 | mutex_unlock(&info->bfs_lock); |
158 | d_add(dentry, inode); | 160 | d_add(dentry, inode); |
159 | return NULL; | 161 | return NULL; |
160 | } | 162 | } |
@@ -163,13 +165,14 @@ static int bfs_link(struct dentry *old, struct inode *dir, | |||
163 | struct dentry *new) | 165 | struct dentry *new) |
164 | { | 166 | { |
165 | struct inode *inode = old->d_inode; | 167 | struct inode *inode = old->d_inode; |
168 | struct bfs_sb_info *info = BFS_SB(inode->i_sb); | ||
166 | int err; | 169 | int err; |
167 | 170 | ||
168 | lock_kernel(); | 171 | mutex_lock(&info->bfs_lock); |
169 | err = bfs_add_entry(dir, new->d_name.name, new->d_name.len, | 172 | err = bfs_add_entry(dir, new->d_name.name, new->d_name.len, |
170 | inode->i_ino); | 173 | inode->i_ino); |
171 | if (err) { | 174 | if (err) { |
172 | unlock_kernel(); | 175 | mutex_unlock(&info->bfs_lock); |
173 | return err; | 176 | return err; |
174 | } | 177 | } |
175 | inc_nlink(inode); | 178 | inc_nlink(inode); |
@@ -177,19 +180,19 @@ static int bfs_link(struct dentry *old, struct inode *dir, | |||
177 | mark_inode_dirty(inode); | 180 | mark_inode_dirty(inode); |
178 | atomic_inc(&inode->i_count); | 181 | atomic_inc(&inode->i_count); |
179 | d_instantiate(new, inode); | 182 | d_instantiate(new, inode); |
180 | unlock_kernel(); | 183 | mutex_unlock(&info->bfs_lock); |
181 | return 0; | 184 | return 0; |
182 | } | 185 | } |
183 | 186 | ||
184 | static int bfs_unlink(struct inode *dir, struct dentry *dentry) | 187 | static int bfs_unlink(struct inode *dir, struct dentry *dentry) |
185 | { | 188 | { |
186 | int error = -ENOENT; | 189 | int error = -ENOENT; |
187 | struct inode *inode; | 190 | struct inode *inode = dentry->d_inode; |
188 | struct buffer_head *bh; | 191 | struct buffer_head *bh; |
189 | struct bfs_dirent *de; | 192 | struct bfs_dirent *de; |
193 | struct bfs_sb_info *info = BFS_SB(inode->i_sb); | ||
190 | 194 | ||
191 | inode = dentry->d_inode; | 195 | mutex_lock(&info->bfs_lock); |
192 | lock_kernel(); | ||
193 | bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); | 196 | bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); |
194 | if (!bh || (le16_to_cpu(de->ino) != inode->i_ino)) | 197 | if (!bh || (le16_to_cpu(de->ino) != inode->i_ino)) |
195 | goto out_brelse; | 198 | goto out_brelse; |
@@ -210,7 +213,7 @@ static int bfs_unlink(struct inode *dir, struct dentry *dentry) | |||
210 | 213 | ||
211 | out_brelse: | 214 | out_brelse: |
212 | brelse(bh); | 215 | brelse(bh); |
213 | unlock_kernel(); | 216 | mutex_unlock(&info->bfs_lock); |
214 | return error; | 217 | return error; |
215 | } | 218 | } |
216 | 219 | ||
@@ -220,6 +223,7 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
220 | struct inode *old_inode, *new_inode; | 223 | struct inode *old_inode, *new_inode; |
221 | struct buffer_head *old_bh, *new_bh; | 224 | struct buffer_head *old_bh, *new_bh; |
222 | struct bfs_dirent *old_de, *new_de; | 225 | struct bfs_dirent *old_de, *new_de; |
226 | struct bfs_sb_info *info; | ||
223 | int error = -ENOENT; | 227 | int error = -ENOENT; |
224 | 228 | ||
225 | old_bh = new_bh = NULL; | 229 | old_bh = new_bh = NULL; |
@@ -227,7 +231,9 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
227 | if (S_ISDIR(old_inode->i_mode)) | 231 | if (S_ISDIR(old_inode->i_mode)) |
228 | return -EINVAL; | 232 | return -EINVAL; |
229 | 233 | ||
230 | lock_kernel(); | 234 | info = BFS_SB(old_inode->i_sb); |
235 | |||
236 | mutex_lock(&info->bfs_lock); | ||
231 | old_bh = bfs_find_entry(old_dir, | 237 | old_bh = bfs_find_entry(old_dir, |
232 | old_dentry->d_name.name, | 238 | old_dentry->d_name.name, |
233 | old_dentry->d_name.len, &old_de); | 239 | old_dentry->d_name.len, &old_de); |
@@ -264,7 +270,7 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
264 | error = 0; | 270 | error = 0; |
265 | 271 | ||
266 | end_rename: | 272 | end_rename: |
267 | unlock_kernel(); | 273 | mutex_unlock(&info->bfs_lock); |
268 | brelse(old_bh); | 274 | brelse(old_bh); |
269 | brelse(new_bh); | 275 | brelse(new_bh); |
270 | return error; | 276 | return error; |