diff options
Diffstat (limited to 'fs/ext2')
| -rw-r--r-- | fs/ext2/namei.c | 54 |
1 files changed, 19 insertions, 35 deletions
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index ad1432a2a62e..4ca824985321 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c | |||
| @@ -36,22 +36,6 @@ | |||
| 36 | #include "acl.h" | 36 | #include "acl.h" |
| 37 | #include "xip.h" | 37 | #include "xip.h" |
| 38 | 38 | ||
| 39 | /* | ||
| 40 | * Couple of helper functions - make the code slightly cleaner. | ||
| 41 | */ | ||
| 42 | |||
| 43 | static inline void ext2_inc_count(struct inode *inode) | ||
| 44 | { | ||
| 45 | inode->i_nlink++; | ||
| 46 | mark_inode_dirty(inode); | ||
| 47 | } | ||
| 48 | |||
| 49 | static inline void ext2_dec_count(struct inode *inode) | ||
| 50 | { | ||
| 51 | inode->i_nlink--; | ||
| 52 | mark_inode_dirty(inode); | ||
| 53 | } | ||
| 54 | |||
| 55 | static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode) | 39 | static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode) |
| 56 | { | 40 | { |
| 57 | int err = ext2_add_link(dentry, inode); | 41 | int err = ext2_add_link(dentry, inode); |
| @@ -59,7 +43,7 @@ static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode) | |||
| 59 | d_instantiate(dentry, inode); | 43 | d_instantiate(dentry, inode); |
| 60 | return 0; | 44 | return 0; |
| 61 | } | 45 | } |
| 62 | ext2_dec_count(inode); | 46 | inode_dec_link_count(inode); |
| 63 | iput(inode); | 47 | iput(inode); |
| 64 | return err; | 48 | return err; |
| 65 | } | 49 | } |
| @@ -201,7 +185,7 @@ out: | |||
| 201 | return err; | 185 | return err; |
| 202 | 186 | ||
| 203 | out_fail: | 187 | out_fail: |
| 204 | ext2_dec_count(inode); | 188 | inode_dec_link_count(inode); |
| 205 | iput (inode); | 189 | iput (inode); |
| 206 | goto out; | 190 | goto out; |
| 207 | } | 191 | } |
| @@ -215,7 +199,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir, | |||
| 215 | return -EMLINK; | 199 | return -EMLINK; |
| 216 | 200 | ||
| 217 | inode->i_ctime = CURRENT_TIME_SEC; | 201 | inode->i_ctime = CURRENT_TIME_SEC; |
| 218 | ext2_inc_count(inode); | 202 | inode_inc_link_count(inode); |
| 219 | atomic_inc(&inode->i_count); | 203 | atomic_inc(&inode->i_count); |
| 220 | 204 | ||
| 221 | return ext2_add_nondir(dentry, inode); | 205 | return ext2_add_nondir(dentry, inode); |
| @@ -229,7 +213,7 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode) | |||
| 229 | if (dir->i_nlink >= EXT2_LINK_MAX) | 213 | if (dir->i_nlink >= EXT2_LINK_MAX) |
| 230 | goto out; | 214 | goto out; |
| 231 | 215 | ||
| 232 | ext2_inc_count(dir); | 216 | inode_inc_link_count(dir); |
| 233 | 217 | ||
| 234 | inode = ext2_new_inode (dir, S_IFDIR | mode); | 218 | inode = ext2_new_inode (dir, S_IFDIR | mode); |
| 235 | err = PTR_ERR(inode); | 219 | err = PTR_ERR(inode); |
| @@ -243,7 +227,7 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode) | |||
| 243 | else | 227 | else |
| 244 | inode->i_mapping->a_ops = &ext2_aops; | 228 | inode->i_mapping->a_ops = &ext2_aops; |
| 245 | 229 | ||
| 246 | ext2_inc_count(inode); | 230 | inode_inc_link_count(inode); |
| 247 | 231 | ||
| 248 | err = ext2_make_empty(inode, dir); | 232 | err = ext2_make_empty(inode, dir); |
| 249 | if (err) | 233 | if (err) |
| @@ -258,11 +242,11 @@ out: | |||
| 258 | return err; | 242 | return err; |
| 259 | 243 | ||
| 260 | out_fail: | 244 | out_fail: |
| 261 | ext2_dec_count(inode); | 245 | inode_dec_link_count(inode); |
| 262 | ext2_dec_count(inode); | 246 | inode_dec_link_count(inode); |
| 263 | iput(inode); | 247 | iput(inode); |
| 264 | out_dir: | 248 | out_dir: |
| 265 | ext2_dec_count(dir); | 249 | inode_dec_link_count(dir); |
| 266 | goto out; | 250 | goto out; |
| 267 | } | 251 | } |
| 268 | 252 | ||
| @@ -282,7 +266,7 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry) | |||
| 282 | goto out; | 266 | goto out; |
| 283 | 267 | ||
| 284 | inode->i_ctime = dir->i_ctime; | 268 | inode->i_ctime = dir->i_ctime; |
| 285 | ext2_dec_count(inode); | 269 | inode_dec_link_count(inode); |
| 286 | err = 0; | 270 | err = 0; |
| 287 | out: | 271 | out: |
| 288 | return err; | 272 | return err; |
| @@ -297,8 +281,8 @@ static int ext2_rmdir (struct inode * dir, struct dentry *dentry) | |||
| 297 | err = ext2_unlink(dir, dentry); | 281 | err = ext2_unlink(dir, dentry); |
| 298 | if (!err) { | 282 | if (!err) { |
| 299 | inode->i_size = 0; | 283 | inode->i_size = 0; |
| 300 | ext2_dec_count(inode); | 284 | inode_dec_link_count(inode); |
| 301 | ext2_dec_count(dir); | 285 | inode_dec_link_count(dir); |
| 302 | } | 286 | } |
| 303 | } | 287 | } |
| 304 | return err; | 288 | return err; |
| @@ -338,41 +322,41 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry, | |||
| 338 | new_de = ext2_find_entry (new_dir, new_dentry, &new_page); | 322 | new_de = ext2_find_entry (new_dir, new_dentry, &new_page); |
| 339 | if (!new_de) | 323 | if (!new_de) |
| 340 | goto out_dir; | 324 | goto out_dir; |
| 341 | ext2_inc_count(old_inode); | 325 | inode_inc_link_count(old_inode); |
| 342 | ext2_set_link(new_dir, new_de, new_page, old_inode); | 326 | ext2_set_link(new_dir, new_de, new_page, old_inode); |
| 343 | new_inode->i_ctime = CURRENT_TIME_SEC; | 327 | new_inode->i_ctime = CURRENT_TIME_SEC; |
| 344 | if (dir_de) | 328 | if (dir_de) |
| 345 | new_inode->i_nlink--; | 329 | new_inode->i_nlink--; |
| 346 | ext2_dec_count(new_inode); | 330 | inode_dec_link_count(new_inode); |
| 347 | } else { | 331 | } else { |
| 348 | if (dir_de) { | 332 | if (dir_de) { |
| 349 | err = -EMLINK; | 333 | err = -EMLINK; |
| 350 | if (new_dir->i_nlink >= EXT2_LINK_MAX) | 334 | if (new_dir->i_nlink >= EXT2_LINK_MAX) |
| 351 | goto out_dir; | 335 | goto out_dir; |
| 352 | } | 336 | } |
| 353 | ext2_inc_count(old_inode); | 337 | inode_inc_link_count(old_inode); |
| 354 | err = ext2_add_link(new_dentry, old_inode); | 338 | err = ext2_add_link(new_dentry, old_inode); |
| 355 | if (err) { | 339 | if (err) { |
| 356 | ext2_dec_count(old_inode); | 340 | inode_dec_link_count(old_inode); |
| 357 | goto out_dir; | 341 | goto out_dir; |
| 358 | } | 342 | } |
| 359 | if (dir_de) | 343 | if (dir_de) |
| 360 | ext2_inc_count(new_dir); | 344 | inode_inc_link_count(new_dir); |
| 361 | } | 345 | } |
| 362 | 346 | ||
| 363 | /* | 347 | /* |
| 364 | * Like most other Unix systems, set the ctime for inodes on a | 348 | * Like most other Unix systems, set the ctime for inodes on a |
| 365 | * rename. | 349 | * rename. |
| 366 | * ext2_dec_count() will mark the inode dirty. | 350 | * inode_dec_link_count() will mark the inode dirty. |
| 367 | */ | 351 | */ |
| 368 | old_inode->i_ctime = CURRENT_TIME_SEC; | 352 | old_inode->i_ctime = CURRENT_TIME_SEC; |
| 369 | 353 | ||
| 370 | ext2_delete_entry (old_de, old_page); | 354 | ext2_delete_entry (old_de, old_page); |
| 371 | ext2_dec_count(old_inode); | 355 | inode_dec_link_count(old_inode); |
| 372 | 356 | ||
| 373 | if (dir_de) { | 357 | if (dir_de) { |
| 374 | ext2_set_link(old_inode, dir_de, dir_page, new_dir); | 358 | ext2_set_link(old_inode, dir_de, dir_page, new_dir); |
| 375 | ext2_dec_count(old_dir); | 359 | inode_dec_link_count(old_dir); |
| 376 | } | 360 | } |
| 377 | return 0; | 361 | return 0; |
| 378 | 362 | ||
