diff options
Diffstat (limited to 'fs/ocfs2/namei.c')
-rw-r--r-- | fs/ocfs2/namei.c | 91 |
1 files changed, 36 insertions, 55 deletions
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 4cbb18f26c5..db5dd3ed4df 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
@@ -239,6 +239,8 @@ static int ocfs2_mknod(struct inode *dir, | |||
239 | }; | 239 | }; |
240 | int did_quota_inode = 0; | 240 | int did_quota_inode = 0; |
241 | struct ocfs2_dir_lookup_result lookup = { NULL, }; | 241 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
242 | sigset_t oldset; | ||
243 | int did_block_signals = 0; | ||
242 | 244 | ||
243 | mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode, | 245 | mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode, |
244 | (unsigned long)dev, dentry->d_name.len, | 246 | (unsigned long)dev, dentry->d_name.len, |
@@ -350,6 +352,10 @@ static int ocfs2_mknod(struct inode *dir, | |||
350 | goto leave; | 352 | goto leave; |
351 | } | 353 | } |
352 | 354 | ||
355 | /* Starting to change things, restart is no longer possible. */ | ||
356 | ocfs2_block_signals(&oldset); | ||
357 | did_block_signals = 1; | ||
358 | |||
353 | status = dquot_alloc_inode(inode); | 359 | status = dquot_alloc_inode(inode); |
354 | if (status) | 360 | if (status) |
355 | goto leave; | 361 | goto leave; |
@@ -384,11 +390,7 @@ static int ocfs2_mknod(struct inode *dir, | |||
384 | goto leave; | 390 | goto leave; |
385 | } | 391 | } |
386 | ocfs2_add_links_count(dirfe, 1); | 392 | ocfs2_add_links_count(dirfe, 1); |
387 | status = ocfs2_journal_dirty(handle, parent_fe_bh); | 393 | ocfs2_journal_dirty(handle, parent_fe_bh); |
388 | if (status < 0) { | ||
389 | mlog_errno(status); | ||
390 | goto leave; | ||
391 | } | ||
392 | inc_nlink(dir); | 394 | inc_nlink(dir); |
393 | } | 395 | } |
394 | 396 | ||
@@ -439,6 +441,8 @@ leave: | |||
439 | ocfs2_commit_trans(osb, handle); | 441 | ocfs2_commit_trans(osb, handle); |
440 | 442 | ||
441 | ocfs2_inode_unlock(dir, 1); | 443 | ocfs2_inode_unlock(dir, 1); |
444 | if (did_block_signals) | ||
445 | ocfs2_unblock_signals(&oldset); | ||
442 | 446 | ||
443 | if (status == -ENOSPC) | 447 | if (status == -ENOSPC) |
444 | mlog(0, "Disk is full\n"); | 448 | mlog(0, "Disk is full\n"); |
@@ -487,14 +491,15 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb, | |||
487 | int status = 0; | 491 | int status = 0; |
488 | struct ocfs2_dinode *fe = NULL; | 492 | struct ocfs2_dinode *fe = NULL; |
489 | struct ocfs2_extent_list *fel; | 493 | struct ocfs2_extent_list *fel; |
490 | u64 fe_blkno = 0; | 494 | u64 suballoc_loc, fe_blkno = 0; |
491 | u16 suballoc_bit; | 495 | u16 suballoc_bit; |
492 | u16 feat; | 496 | u16 feat; |
493 | 497 | ||
494 | *new_fe_bh = NULL; | 498 | *new_fe_bh = NULL; |
495 | 499 | ||
496 | status = ocfs2_claim_new_inode(osb, handle, dir, parent_fe_bh, | 500 | status = ocfs2_claim_new_inode(handle, dir, parent_fe_bh, |
497 | inode_ac, &suballoc_bit, &fe_blkno); | 501 | inode_ac, &suballoc_loc, |
502 | &suballoc_bit, &fe_blkno); | ||
498 | if (status < 0) { | 503 | if (status < 0) { |
499 | mlog_errno(status); | 504 | mlog_errno(status); |
500 | goto leave; | 505 | goto leave; |
@@ -531,6 +536,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb, | |||
531 | fe->i_generation = cpu_to_le32(inode->i_generation); | 536 | fe->i_generation = cpu_to_le32(inode->i_generation); |
532 | fe->i_fs_generation = cpu_to_le32(osb->fs_generation); | 537 | fe->i_fs_generation = cpu_to_le32(osb->fs_generation); |
533 | fe->i_blkno = cpu_to_le64(fe_blkno); | 538 | fe->i_blkno = cpu_to_le64(fe_blkno); |
539 | fe->i_suballoc_loc = cpu_to_le64(suballoc_loc); | ||
534 | fe->i_suballoc_bit = cpu_to_le16(suballoc_bit); | 540 | fe->i_suballoc_bit = cpu_to_le16(suballoc_bit); |
535 | fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot); | 541 | fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot); |
536 | fe->i_uid = cpu_to_le32(inode->i_uid); | 542 | fe->i_uid = cpu_to_le32(inode->i_uid); |
@@ -567,11 +573,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb, | |||
567 | fel->l_count = cpu_to_le16(ocfs2_extent_recs_per_inode(osb->sb)); | 573 | fel->l_count = cpu_to_le16(ocfs2_extent_recs_per_inode(osb->sb)); |
568 | } | 574 | } |
569 | 575 | ||
570 | status = ocfs2_journal_dirty(handle, *new_fe_bh); | 576 | ocfs2_journal_dirty(handle, *new_fe_bh); |
571 | if (status < 0) { | ||
572 | mlog_errno(status); | ||
573 | goto leave; | ||
574 | } | ||
575 | 577 | ||
576 | ocfs2_populate_inode(inode, fe, 1); | 578 | ocfs2_populate_inode(inode, fe, 1); |
577 | ocfs2_ci_set_new(osb, INODE_CACHE(inode)); | 579 | ocfs2_ci_set_new(osb, INODE_CACHE(inode)); |
@@ -637,6 +639,7 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
637 | struct ocfs2_dinode *fe = NULL; | 639 | struct ocfs2_dinode *fe = NULL; |
638 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); | 640 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); |
639 | struct ocfs2_dir_lookup_result lookup = { NULL, }; | 641 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
642 | sigset_t oldset; | ||
640 | 643 | ||
641 | mlog_entry("(inode=%lu, old='%.*s' new='%.*s')\n", inode->i_ino, | 644 | mlog_entry("(inode=%lu, old='%.*s' new='%.*s')\n", inode->i_ino, |
642 | old_dentry->d_name.len, old_dentry->d_name.name, | 645 | old_dentry->d_name.len, old_dentry->d_name.name, |
@@ -693,6 +696,9 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
693 | goto out_unlock_inode; | 696 | goto out_unlock_inode; |
694 | } | 697 | } |
695 | 698 | ||
699 | /* Starting to change things, restart is no longer possible. */ | ||
700 | ocfs2_block_signals(&oldset); | ||
701 | |||
696 | err = ocfs2_journal_access_di(handle, INODE_CACHE(inode), fe_bh, | 702 | err = ocfs2_journal_access_di(handle, INODE_CACHE(inode), fe_bh, |
697 | OCFS2_JOURNAL_ACCESS_WRITE); | 703 | OCFS2_JOURNAL_ACCESS_WRITE); |
698 | if (err < 0) { | 704 | if (err < 0) { |
@@ -705,14 +711,7 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
705 | ocfs2_set_links_count(fe, inode->i_nlink); | 711 | ocfs2_set_links_count(fe, inode->i_nlink); |
706 | fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec); | 712 | fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec); |
707 | fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec); | 713 | fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec); |
708 | 714 | ocfs2_journal_dirty(handle, fe_bh); | |
709 | err = ocfs2_journal_dirty(handle, fe_bh); | ||
710 | if (err < 0) { | ||
711 | ocfs2_add_links_count(fe, -1); | ||
712 | drop_nlink(inode); | ||
713 | mlog_errno(err); | ||
714 | goto out_commit; | ||
715 | } | ||
716 | 715 | ||
717 | err = ocfs2_add_entry(handle, dentry, inode, | 716 | err = ocfs2_add_entry(handle, dentry, inode, |
718 | OCFS2_I(inode)->ip_blkno, | 717 | OCFS2_I(inode)->ip_blkno, |
@@ -736,6 +735,7 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
736 | 735 | ||
737 | out_commit: | 736 | out_commit: |
738 | ocfs2_commit_trans(osb, handle); | 737 | ocfs2_commit_trans(osb, handle); |
738 | ocfs2_unblock_signals(&oldset); | ||
739 | out_unlock_inode: | 739 | out_unlock_inode: |
740 | ocfs2_inode_unlock(inode, 1); | 740 | ocfs2_inode_unlock(inode, 1); |
741 | 741 | ||
@@ -909,12 +909,7 @@ static int ocfs2_unlink(struct inode *dir, | |||
909 | drop_nlink(inode); | 909 | drop_nlink(inode); |
910 | drop_nlink(inode); | 910 | drop_nlink(inode); |
911 | ocfs2_set_links_count(fe, inode->i_nlink); | 911 | ocfs2_set_links_count(fe, inode->i_nlink); |
912 | 912 | ocfs2_journal_dirty(handle, fe_bh); | |
913 | status = ocfs2_journal_dirty(handle, fe_bh); | ||
914 | if (status < 0) { | ||
915 | mlog_errno(status); | ||
916 | goto leave; | ||
917 | } | ||
918 | 913 | ||
919 | dir->i_ctime = dir->i_mtime = CURRENT_TIME; | 914 | dir->i_ctime = dir->i_mtime = CURRENT_TIME; |
920 | if (S_ISDIR(inode->i_mode)) | 915 | if (S_ISDIR(inode->i_mode)) |
@@ -1332,12 +1327,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1332 | ocfs2_set_links_count(newfe, 0); | 1327 | ocfs2_set_links_count(newfe, 0); |
1333 | else | 1328 | else |
1334 | ocfs2_add_links_count(newfe, -1); | 1329 | ocfs2_add_links_count(newfe, -1); |
1335 | 1330 | ocfs2_journal_dirty(handle, newfe_bh); | |
1336 | status = ocfs2_journal_dirty(handle, newfe_bh); | ||
1337 | if (status < 0) { | ||
1338 | mlog_errno(status); | ||
1339 | goto bail; | ||
1340 | } | ||
1341 | } else { | 1331 | } else { |
1342 | /* if the name was not found in new_dir, add it now */ | 1332 | /* if the name was not found in new_dir, add it now */ |
1343 | status = ocfs2_add_entry(handle, new_dentry, old_inode, | 1333 | status = ocfs2_add_entry(handle, new_dentry, old_inode, |
@@ -1356,10 +1346,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1356 | 1346 | ||
1357 | old_di->i_ctime = cpu_to_le64(old_inode->i_ctime.tv_sec); | 1347 | old_di->i_ctime = cpu_to_le64(old_inode->i_ctime.tv_sec); |
1358 | old_di->i_ctime_nsec = cpu_to_le32(old_inode->i_ctime.tv_nsec); | 1348 | old_di->i_ctime_nsec = cpu_to_le32(old_inode->i_ctime.tv_nsec); |
1359 | 1349 | ocfs2_journal_dirty(handle, old_inode_bh); | |
1360 | status = ocfs2_journal_dirty(handle, old_inode_bh); | ||
1361 | if (status < 0) | ||
1362 | mlog_errno(status); | ||
1363 | } else | 1350 | } else |
1364 | mlog_errno(status); | 1351 | mlog_errno(status); |
1365 | 1352 | ||
@@ -1431,7 +1418,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1431 | OCFS2_JOURNAL_ACCESS_WRITE); | 1418 | OCFS2_JOURNAL_ACCESS_WRITE); |
1432 | fe = (struct ocfs2_dinode *) old_dir_bh->b_data; | 1419 | fe = (struct ocfs2_dinode *) old_dir_bh->b_data; |
1433 | ocfs2_set_links_count(fe, old_dir->i_nlink); | 1420 | ocfs2_set_links_count(fe, old_dir->i_nlink); |
1434 | status = ocfs2_journal_dirty(handle, old_dir_bh); | 1421 | ocfs2_journal_dirty(handle, old_dir_bh); |
1435 | } | 1422 | } |
1436 | } | 1423 | } |
1437 | ocfs2_dentry_move(old_dentry, new_dentry, old_dir, new_dir); | 1424 | ocfs2_dentry_move(old_dentry, new_dentry, old_dir, new_dir); |
@@ -1563,11 +1550,7 @@ static int ocfs2_create_symlink_data(struct ocfs2_super *osb, | |||
1563 | (bytes_left > sb->s_blocksize) ? sb->s_blocksize : | 1550 | (bytes_left > sb->s_blocksize) ? sb->s_blocksize : |
1564 | bytes_left); | 1551 | bytes_left); |
1565 | 1552 | ||
1566 | status = ocfs2_journal_dirty(handle, bhs[virtual]); | 1553 | ocfs2_journal_dirty(handle, bhs[virtual]); |
1567 | if (status < 0) { | ||
1568 | mlog_errno(status); | ||
1569 | goto bail; | ||
1570 | } | ||
1571 | 1554 | ||
1572 | virtual++; | 1555 | virtual++; |
1573 | p_blkno++; | 1556 | p_blkno++; |
@@ -1611,6 +1594,8 @@ static int ocfs2_symlink(struct inode *dir, | |||
1611 | }; | 1594 | }; |
1612 | int did_quota = 0, did_quota_inode = 0; | 1595 | int did_quota = 0, did_quota_inode = 0; |
1613 | struct ocfs2_dir_lookup_result lookup = { NULL, }; | 1596 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
1597 | sigset_t oldset; | ||
1598 | int did_block_signals = 0; | ||
1614 | 1599 | ||
1615 | mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir, | 1600 | mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir, |
1616 | dentry, symname, dentry->d_name.len, dentry->d_name.name); | 1601 | dentry, symname, dentry->d_name.len, dentry->d_name.name); |
@@ -1706,6 +1691,10 @@ static int ocfs2_symlink(struct inode *dir, | |||
1706 | goto bail; | 1691 | goto bail; |
1707 | } | 1692 | } |
1708 | 1693 | ||
1694 | /* Starting to change things, restart is no longer possible. */ | ||
1695 | ocfs2_block_signals(&oldset); | ||
1696 | did_block_signals = 1; | ||
1697 | |||
1709 | status = dquot_alloc_inode(inode); | 1698 | status = dquot_alloc_inode(inode); |
1710 | if (status) | 1699 | if (status) |
1711 | goto bail; | 1700 | goto bail; |
@@ -1814,6 +1803,8 @@ bail: | |||
1814 | ocfs2_commit_trans(osb, handle); | 1803 | ocfs2_commit_trans(osb, handle); |
1815 | 1804 | ||
1816 | ocfs2_inode_unlock(dir, 1); | 1805 | ocfs2_inode_unlock(dir, 1); |
1806 | if (did_block_signals) | ||
1807 | ocfs2_unblock_signals(&oldset); | ||
1817 | 1808 | ||
1818 | brelse(new_fe_bh); | 1809 | brelse(new_fe_bh); |
1819 | brelse(parent_fe_bh); | 1810 | brelse(parent_fe_bh); |
@@ -1961,12 +1952,7 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb, | |||
1961 | if (S_ISDIR(inode->i_mode)) | 1952 | if (S_ISDIR(inode->i_mode)) |
1962 | ocfs2_add_links_count(orphan_fe, 1); | 1953 | ocfs2_add_links_count(orphan_fe, 1); |
1963 | orphan_dir_inode->i_nlink = ocfs2_read_links_count(orphan_fe); | 1954 | orphan_dir_inode->i_nlink = ocfs2_read_links_count(orphan_fe); |
1964 | 1955 | ocfs2_journal_dirty(handle, orphan_dir_bh); | |
1965 | status = ocfs2_journal_dirty(handle, orphan_dir_bh); | ||
1966 | if (status < 0) { | ||
1967 | mlog_errno(status); | ||
1968 | goto leave; | ||
1969 | } | ||
1970 | 1956 | ||
1971 | status = __ocfs2_add_entry(handle, orphan_dir_inode, name, | 1957 | status = __ocfs2_add_entry(handle, orphan_dir_inode, name, |
1972 | OCFS2_ORPHAN_NAMELEN, inode, | 1958 | OCFS2_ORPHAN_NAMELEN, inode, |
@@ -2065,12 +2051,7 @@ int ocfs2_orphan_del(struct ocfs2_super *osb, | |||
2065 | if (S_ISDIR(inode->i_mode)) | 2051 | if (S_ISDIR(inode->i_mode)) |
2066 | ocfs2_add_links_count(orphan_fe, -1); | 2052 | ocfs2_add_links_count(orphan_fe, -1); |
2067 | orphan_dir_inode->i_nlink = ocfs2_read_links_count(orphan_fe); | 2053 | orphan_dir_inode->i_nlink = ocfs2_read_links_count(orphan_fe); |
2068 | 2054 | ocfs2_journal_dirty(handle, orphan_dir_bh); | |
2069 | status = ocfs2_journal_dirty(handle, orphan_dir_bh); | ||
2070 | if (status < 0) { | ||
2071 | mlog_errno(status); | ||
2072 | goto leave; | ||
2073 | } | ||
2074 | 2055 | ||
2075 | leave: | 2056 | leave: |
2076 | ocfs2_free_dir_lookup_result(&lookup); | 2057 | ocfs2_free_dir_lookup_result(&lookup); |