aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);