aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorJiro SEKIBA <jir@unicus.jp>2009-11-27 05:41:08 -0500
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-11-27 06:05:15 -0500
commit565de406e7bfa92ffec6315e89857986da657192 (patch)
tree43ac1b59a748a91e2d22505843823fbae5e63c50 /fs/nilfs2
parent43f8bc262fcfadc7583b2353d2708e6eb77788ff (diff)
nilfs2: expand inode_inc_link_count and inode_dec_link_count
This is an intermidiate patch to reduce redandunt mark_inode_dirty() calls by calling inode_inc_link_count() and inode_dec_link_count() functions. Signed-off-by: Jiro SEKIBA <jir@unicus.jp> Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r--fs/nilfs2/namei.c49
1 files changed, 32 insertions, 17 deletions
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index 4616f96be700..f952439d2702 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -200,7 +200,8 @@ out:
200 return err; 200 return err;
201 201
202out_fail: 202out_fail:
203 inode_dec_link_count(inode); 203 drop_nlink(inode);
204 mark_inode_dirty(inode);
204 iput(inode); 205 iput(inode);
205 goto out; 206 goto out;
206} 207}
@@ -245,7 +246,8 @@ static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
245 if (err) 246 if (err)
246 return err; 247 return err;
247 248
248 inode_inc_link_count(dir); 249 inc_nlink(dir);
250 mark_inode_dirty(dir);
249 251
250 inode = nilfs_new_inode(dir, S_IFDIR | mode); 252 inode = nilfs_new_inode(dir, S_IFDIR | mode);
251 err = PTR_ERR(inode); 253 err = PTR_ERR(inode);
@@ -256,7 +258,8 @@ static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
256 inode->i_fop = &nilfs_dir_operations; 258 inode->i_fop = &nilfs_dir_operations;
257 inode->i_mapping->a_ops = &nilfs_aops; 259 inode->i_mapping->a_ops = &nilfs_aops;
258 260
259 inode_inc_link_count(inode); 261 inc_nlink(inode);
262 mark_inode_dirty(inode);
260 263
261 err = nilfs_make_empty(inode, dir); 264 err = nilfs_make_empty(inode, dir);
262 if (err) 265 if (err)
@@ -276,11 +279,14 @@ out:
276 return err; 279 return err;
277 280
278out_fail: 281out_fail:
279 inode_dec_link_count(inode); 282 drop_nlink(inode);
280 inode_dec_link_count(inode); 283 mark_inode_dirty(inode);
284 drop_nlink(inode);
285 mark_inode_dirty(inode);
281 iput(inode); 286 iput(inode);
282out_dir: 287out_dir:
283 inode_dec_link_count(dir); 288 drop_nlink(dir);
289 mark_inode_dirty(dir);
284 goto out; 290 goto out;
285} 291}
286 292
@@ -317,7 +323,8 @@ static int nilfs_unlink(struct inode *dir, struct dentry *dentry)
317 goto out; 323 goto out;
318 324
319 inode->i_ctime = dir->i_ctime; 325 inode->i_ctime = dir->i_ctime;
320 inode_dec_link_count(inode); 326 drop_nlink(inode);
327 mark_inode_dirty(inode);
321 err = 0; 328 err = 0;
322out: 329out:
323 if (!err) 330 if (!err)
@@ -343,8 +350,10 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry)
343 err = nilfs_unlink(dir, dentry); 350 err = nilfs_unlink(dir, dentry);
344 if (!err) { 351 if (!err) {
345 inode->i_size = 0; 352 inode->i_size = 0;
346 inode_dec_link_count(inode); 353 drop_nlink(inode);
347 inode_dec_link_count(dir); 354 mark_inode_dirty(inode);
355 drop_nlink(dir);
356 mark_inode_dirty(dir);
348 } 357 }
349 } 358 }
350 if (!err) 359 if (!err)
@@ -395,33 +404,38 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
395 new_de = nilfs_find_entry(new_dir, new_dentry, &new_page); 404 new_de = nilfs_find_entry(new_dir, new_dentry, &new_page);
396 if (!new_de) 405 if (!new_de)
397 goto out_dir; 406 goto out_dir;
398 inode_inc_link_count(old_inode); 407 inc_nlink(old_inode);
408 mark_inode_dirty(old_inode);
399 nilfs_set_link(new_dir, new_de, new_page, old_inode); 409 nilfs_set_link(new_dir, new_de, new_page, old_inode);
400 mark_inode_dirty(new_dir); 410 mark_inode_dirty(new_dir);
401 new_inode->i_ctime = CURRENT_TIME; 411 new_inode->i_ctime = CURRENT_TIME;
402 if (dir_de) 412 if (dir_de)
403 drop_nlink(new_inode); 413 drop_nlink(new_inode);
404 inode_dec_link_count(new_inode); 414 drop_nlink(new_inode);
415 mark_inode_dirty(new_inode);
405 } else { 416 } else {
406 if (dir_de) { 417 if (dir_de) {
407 err = -EMLINK; 418 err = -EMLINK;
408 if (new_dir->i_nlink >= NILFS_LINK_MAX) 419 if (new_dir->i_nlink >= NILFS_LINK_MAX)
409 goto out_dir; 420 goto out_dir;
410 } 421 }
411 inode_inc_link_count(old_inode); 422 inc_nlink(old_inode);
423 mark_inode_dirty(old_inode);
412 err = nilfs_add_link(new_dentry, old_inode); 424 err = nilfs_add_link(new_dentry, old_inode);
413 if (err) { 425 if (err) {
414 inode_dec_link_count(old_inode); 426 drop_nlink(old_inode);
427 mark_inode_dirty(old_inode);
415 goto out_dir; 428 goto out_dir;
416 } 429 }
417 if (dir_de) 430 if (dir_de) {
418 inode_inc_link_count(new_dir); 431 inc_nlink(new_dir);
432 mark_inode_dirty(new_dir);
433 }
419 } 434 }
420 435
421 /* 436 /*
422 * Like most other Unix systems, set the ctime for inodes on a 437 * Like most other Unix systems, set the ctime for inodes on a
423 * rename. 438 * rename.
424 * inode_dec_link_count() will mark the inode dirty.
425 */ 439 */
426 old_inode->i_ctime = CURRENT_TIME; 440 old_inode->i_ctime = CURRENT_TIME;
427 441
@@ -430,7 +444,8 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
430 444
431 if (dir_de) { 445 if (dir_de) {
432 nilfs_set_link(old_inode, dir_de, dir_page, new_dir); 446 nilfs_set_link(old_inode, dir_de, dir_page, new_dir);
433 inode_dec_link_count(old_dir); 447 drop_nlink(old_dir);
448 mark_inode_dirty(old_dir);
434 } 449 }
435 mark_inode_dirty(old_inode); 450 mark_inode_dirty(old_inode);
436 451