aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorJiro SEKIBA <jir@unicus.jp>2009-11-27 05:41:10 -0500
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-11-27 06:05:15 -0500
commit4cd76c3c930993cf70657775bb521cad006e37b4 (patch)
treef29b80420e2214d08785580f11e400728750d10a /fs/nilfs2
parent17491472769abbf4dac694d96c65eed5a7e1c81c (diff)
nilfs2: split nilfs_unlink as nilfs_do_unlink and nilfs_unlink
Split nilfs_unlink() to reduce nested transaction and duplicate mark_inode_dirty() calls when calling nilfs_unlink() from nilfs_rmdir(). nilfs_do_unlink() is an actual unlink functionality which is not in transaction and does not call mark_inode_dirty() for dentry argument. nilfs_unlink() is a wrapper function for do_nilfs_unlink() with transaction and mark_inode_dirty() for dentry argument. 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.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index 35f59da16bbf..d92e83905f01 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -288,18 +288,13 @@ out_dir:
288 goto out; 288 goto out;
289} 289}
290 290
291static int nilfs_unlink(struct inode *dir, struct dentry *dentry) 291static int nilfs_do_unlink(struct inode *dir, struct dentry *dentry)
292{ 292{
293 struct inode *inode; 293 struct inode *inode;
294 struct nilfs_dir_entry *de; 294 struct nilfs_dir_entry *de;
295 struct page *page; 295 struct page *page;
296 struct nilfs_transaction_info ti;
297 int err; 296 int err;
298 297
299 err = nilfs_transaction_begin(dir->i_sb, &ti, 0);
300 if (err)
301 return err;
302
303 err = -ENOENT; 298 err = -ENOENT;
304 de = nilfs_find_entry(dir, dentry, &page); 299 de = nilfs_find_entry(dir, dentry, &page);
305 if (!de) 300 if (!de)
@@ -322,12 +317,26 @@ static int nilfs_unlink(struct inode *dir, struct dentry *dentry)
322 317
323 inode->i_ctime = dir->i_ctime; 318 inode->i_ctime = dir->i_ctime;
324 drop_nlink(inode); 319 drop_nlink(inode);
325 mark_inode_dirty(inode);
326 err = 0; 320 err = 0;
327out: 321out:
328 if (!err) 322 return err;
323}
324
325static int nilfs_unlink(struct inode *dir, struct dentry *dentry)
326{
327 struct nilfs_transaction_info ti;
328 int err;
329
330 err = nilfs_transaction_begin(dir->i_sb, &ti, 0);
331 if (err)
332 return err;
333
334 err = nilfs_do_unlink(dir, dentry);
335
336 if (!err) {
337 mark_inode_dirty(dentry->d_inode);
329 err = nilfs_transaction_commit(dir->i_sb); 338 err = nilfs_transaction_commit(dir->i_sb);
330 else 339 } else
331 nilfs_transaction_abort(dir->i_sb); 340 nilfs_transaction_abort(dir->i_sb);
332 341
333 return err; 342 return err;
@@ -345,7 +354,7 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry)
345 354
346 err = -ENOTEMPTY; 355 err = -ENOTEMPTY;
347 if (nilfs_empty_dir(inode)) { 356 if (nilfs_empty_dir(inode)) {
348 err = nilfs_unlink(dir, dentry); 357 err = nilfs_do_unlink(dir, dentry);
349 if (!err) { 358 if (!err) {
350 inode->i_size = 0; 359 inode->i_size = 0;
351 drop_nlink(inode); 360 drop_nlink(inode);