diff options
Diffstat (limited to 'fs/ocfs2/namei.c')
| -rw-r--r-- | fs/ocfs2/namei.c | 100 |
1 files changed, 37 insertions, 63 deletions
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 4cbb18f26c5f..f171b51a74f7 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
| @@ -204,14 +204,7 @@ static struct inode *ocfs2_get_init_inode(struct inode *dir, int mode) | |||
| 204 | inode->i_nlink = 2; | 204 | inode->i_nlink = 2; |
| 205 | else | 205 | else |
| 206 | inode->i_nlink = 1; | 206 | inode->i_nlink = 1; |
| 207 | inode->i_uid = current_fsuid(); | 207 | inode_init_owner(inode, dir, mode); |
| 208 | if (dir->i_mode & S_ISGID) { | ||
| 209 | inode->i_gid = dir->i_gid; | ||
| 210 | if (S_ISDIR(mode)) | ||
| 211 | mode |= S_ISGID; | ||
| 212 | } else | ||
| 213 | inode->i_gid = current_fsgid(); | ||
| 214 | inode->i_mode = mode; | ||
| 215 | dquot_initialize(inode); | 208 | dquot_initialize(inode); |
| 216 | return inode; | 209 | return inode; |
| 217 | } | 210 | } |
| @@ -239,6 +232,8 @@ static int ocfs2_mknod(struct inode *dir, | |||
| 239 | }; | 232 | }; |
| 240 | int did_quota_inode = 0; | 233 | int did_quota_inode = 0; |
| 241 | struct ocfs2_dir_lookup_result lookup = { NULL, }; | 234 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
| 235 | sigset_t oldset; | ||
| 236 | int did_block_signals = 0; | ||
| 242 | 237 | ||
| 243 | mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode, | 238 | mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode, |
| 244 | (unsigned long)dev, dentry->d_name.len, | 239 | (unsigned long)dev, dentry->d_name.len, |
| @@ -350,6 +345,10 @@ static int ocfs2_mknod(struct inode *dir, | |||
| 350 | goto leave; | 345 | goto leave; |
| 351 | } | 346 | } |
| 352 | 347 | ||
| 348 | /* Starting to change things, restart is no longer possible. */ | ||
| 349 | ocfs2_block_signals(&oldset); | ||
| 350 | did_block_signals = 1; | ||
| 351 | |||
| 353 | status = dquot_alloc_inode(inode); | 352 | status = dquot_alloc_inode(inode); |
| 354 | if (status) | 353 | if (status) |
| 355 | goto leave; | 354 | goto leave; |
| @@ -384,11 +383,7 @@ static int ocfs2_mknod(struct inode *dir, | |||
| 384 | goto leave; | 383 | goto leave; |
| 385 | } | 384 | } |
| 386 | ocfs2_add_links_count(dirfe, 1); | 385 | ocfs2_add_links_count(dirfe, 1); |
| 387 | status = ocfs2_journal_dirty(handle, parent_fe_bh); | 386 | ocfs2_journal_dirty(handle, parent_fe_bh); |
| 388 | if (status < 0) { | ||
| 389 | mlog_errno(status); | ||
| 390 | goto leave; | ||
| 391 | } | ||
| 392 | inc_nlink(dir); | 387 | inc_nlink(dir); |
| 393 | } | 388 | } |
| 394 | 389 | ||
| @@ -439,6 +434,8 @@ leave: | |||
| 439 | ocfs2_commit_trans(osb, handle); | 434 | ocfs2_commit_trans(osb, handle); |
| 440 | 435 | ||
| 441 | ocfs2_inode_unlock(dir, 1); | 436 | ocfs2_inode_unlock(dir, 1); |
| 437 | if (did_block_signals) | ||
| 438 | ocfs2_unblock_signals(&oldset); | ||
| 442 | 439 | ||
| 443 | if (status == -ENOSPC) | 440 | if (status == -ENOSPC) |
| 444 | mlog(0, "Disk is full\n"); | 441 | mlog(0, "Disk is full\n"); |
| @@ -487,14 +484,15 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb, | |||
| 487 | int status = 0; | 484 | int status = 0; |
| 488 | struct ocfs2_dinode *fe = NULL; | 485 | struct ocfs2_dinode *fe = NULL; |
| 489 | struct ocfs2_extent_list *fel; | 486 | struct ocfs2_extent_list *fel; |
| 490 | u64 fe_blkno = 0; | 487 | u64 suballoc_loc, fe_blkno = 0; |
| 491 | u16 suballoc_bit; | 488 | u16 suballoc_bit; |
| 492 | u16 feat; | 489 | u16 feat; |
| 493 | 490 | ||
| 494 | *new_fe_bh = NULL; | 491 | *new_fe_bh = NULL; |
| 495 | 492 | ||
| 496 | status = ocfs2_claim_new_inode(osb, handle, dir, parent_fe_bh, | 493 | status = ocfs2_claim_new_inode(handle, dir, parent_fe_bh, |
| 497 | inode_ac, &suballoc_bit, &fe_blkno); | 494 | inode_ac, &suballoc_loc, |
| 495 | &suballoc_bit, &fe_blkno); | ||
| 498 | if (status < 0) { | 496 | if (status < 0) { |
| 499 | mlog_errno(status); | 497 | mlog_errno(status); |
| 500 | goto leave; | 498 | goto leave; |
| @@ -531,6 +529,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb, | |||
| 531 | fe->i_generation = cpu_to_le32(inode->i_generation); | 529 | fe->i_generation = cpu_to_le32(inode->i_generation); |
| 532 | fe->i_fs_generation = cpu_to_le32(osb->fs_generation); | 530 | fe->i_fs_generation = cpu_to_le32(osb->fs_generation); |
| 533 | fe->i_blkno = cpu_to_le64(fe_blkno); | 531 | fe->i_blkno = cpu_to_le64(fe_blkno); |
| 532 | fe->i_suballoc_loc = cpu_to_le64(suballoc_loc); | ||
| 534 | fe->i_suballoc_bit = cpu_to_le16(suballoc_bit); | 533 | fe->i_suballoc_bit = cpu_to_le16(suballoc_bit); |
| 535 | fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot); | 534 | fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot); |
| 536 | fe->i_uid = cpu_to_le32(inode->i_uid); | 535 | fe->i_uid = cpu_to_le32(inode->i_uid); |
| @@ -567,11 +566,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb, | |||
| 567 | fel->l_count = cpu_to_le16(ocfs2_extent_recs_per_inode(osb->sb)); | 566 | fel->l_count = cpu_to_le16(ocfs2_extent_recs_per_inode(osb->sb)); |
| 568 | } | 567 | } |
| 569 | 568 | ||
| 570 | status = ocfs2_journal_dirty(handle, *new_fe_bh); | 569 | ocfs2_journal_dirty(handle, *new_fe_bh); |
| 571 | if (status < 0) { | ||
| 572 | mlog_errno(status); | ||
| 573 | goto leave; | ||
| 574 | } | ||
| 575 | 570 | ||
| 576 | ocfs2_populate_inode(inode, fe, 1); | 571 | ocfs2_populate_inode(inode, fe, 1); |
| 577 | ocfs2_ci_set_new(osb, INODE_CACHE(inode)); | 572 | ocfs2_ci_set_new(osb, INODE_CACHE(inode)); |
| @@ -637,6 +632,7 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
| 637 | struct ocfs2_dinode *fe = NULL; | 632 | struct ocfs2_dinode *fe = NULL; |
| 638 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); | 633 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); |
| 639 | struct ocfs2_dir_lookup_result lookup = { NULL, }; | 634 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
| 635 | sigset_t oldset; | ||
| 640 | 636 | ||
| 641 | mlog_entry("(inode=%lu, old='%.*s' new='%.*s')\n", inode->i_ino, | 637 | mlog_entry("(inode=%lu, old='%.*s' new='%.*s')\n", inode->i_ino, |
| 642 | old_dentry->d_name.len, old_dentry->d_name.name, | 638 | old_dentry->d_name.len, old_dentry->d_name.name, |
| @@ -693,6 +689,9 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
| 693 | goto out_unlock_inode; | 689 | goto out_unlock_inode; |
| 694 | } | 690 | } |
| 695 | 691 | ||
| 692 | /* Starting to change things, restart is no longer possible. */ | ||
| 693 | ocfs2_block_signals(&oldset); | ||
| 694 | |||
| 696 | err = ocfs2_journal_access_di(handle, INODE_CACHE(inode), fe_bh, | 695 | err = ocfs2_journal_access_di(handle, INODE_CACHE(inode), fe_bh, |
| 697 | OCFS2_JOURNAL_ACCESS_WRITE); | 696 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 698 | if (err < 0) { | 697 | if (err < 0) { |
| @@ -705,14 +704,7 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
| 705 | ocfs2_set_links_count(fe, inode->i_nlink); | 704 | ocfs2_set_links_count(fe, inode->i_nlink); |
| 706 | fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec); | 705 | fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec); |
| 707 | fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec); | 706 | fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec); |
| 708 | 707 | 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 | 708 | ||
| 717 | err = ocfs2_add_entry(handle, dentry, inode, | 709 | err = ocfs2_add_entry(handle, dentry, inode, |
| 718 | OCFS2_I(inode)->ip_blkno, | 710 | OCFS2_I(inode)->ip_blkno, |
| @@ -736,6 +728,7 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
| 736 | 728 | ||
| 737 | out_commit: | 729 | out_commit: |
| 738 | ocfs2_commit_trans(osb, handle); | 730 | ocfs2_commit_trans(osb, handle); |
| 731 | ocfs2_unblock_signals(&oldset); | ||
| 739 | out_unlock_inode: | 732 | out_unlock_inode: |
| 740 | ocfs2_inode_unlock(inode, 1); | 733 | ocfs2_inode_unlock(inode, 1); |
| 741 | 734 | ||
| @@ -909,12 +902,7 @@ static int ocfs2_unlink(struct inode *dir, | |||
| 909 | drop_nlink(inode); | 902 | drop_nlink(inode); |
| 910 | drop_nlink(inode); | 903 | drop_nlink(inode); |
| 911 | ocfs2_set_links_count(fe, inode->i_nlink); | 904 | ocfs2_set_links_count(fe, inode->i_nlink); |
| 912 | 905 | 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 | 906 | ||
| 919 | dir->i_ctime = dir->i_mtime = CURRENT_TIME; | 907 | dir->i_ctime = dir->i_mtime = CURRENT_TIME; |
| 920 | if (S_ISDIR(inode->i_mode)) | 908 | if (S_ISDIR(inode->i_mode)) |
| @@ -1332,12 +1320,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
| 1332 | ocfs2_set_links_count(newfe, 0); | 1320 | ocfs2_set_links_count(newfe, 0); |
| 1333 | else | 1321 | else |
| 1334 | ocfs2_add_links_count(newfe, -1); | 1322 | ocfs2_add_links_count(newfe, -1); |
| 1335 | 1323 | 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 { | 1324 | } else { |
| 1342 | /* if the name was not found in new_dir, add it now */ | 1325 | /* if the name was not found in new_dir, add it now */ |
| 1343 | status = ocfs2_add_entry(handle, new_dentry, old_inode, | 1326 | status = ocfs2_add_entry(handle, new_dentry, old_inode, |
| @@ -1356,10 +1339,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
| 1356 | 1339 | ||
| 1357 | old_di->i_ctime = cpu_to_le64(old_inode->i_ctime.tv_sec); | 1340 | 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); | 1341 | old_di->i_ctime_nsec = cpu_to_le32(old_inode->i_ctime.tv_nsec); |
| 1359 | 1342 | 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 | 1343 | } else |
| 1364 | mlog_errno(status); | 1344 | mlog_errno(status); |
| 1365 | 1345 | ||
| @@ -1431,7 +1411,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
| 1431 | OCFS2_JOURNAL_ACCESS_WRITE); | 1411 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 1432 | fe = (struct ocfs2_dinode *) old_dir_bh->b_data; | 1412 | fe = (struct ocfs2_dinode *) old_dir_bh->b_data; |
| 1433 | ocfs2_set_links_count(fe, old_dir->i_nlink); | 1413 | ocfs2_set_links_count(fe, old_dir->i_nlink); |
| 1434 | status = ocfs2_journal_dirty(handle, old_dir_bh); | 1414 | ocfs2_journal_dirty(handle, old_dir_bh); |
| 1435 | } | 1415 | } |
| 1436 | } | 1416 | } |
| 1437 | ocfs2_dentry_move(old_dentry, new_dentry, old_dir, new_dir); | 1417 | ocfs2_dentry_move(old_dentry, new_dentry, old_dir, new_dir); |
| @@ -1563,11 +1543,7 @@ static int ocfs2_create_symlink_data(struct ocfs2_super *osb, | |||
| 1563 | (bytes_left > sb->s_blocksize) ? sb->s_blocksize : | 1543 | (bytes_left > sb->s_blocksize) ? sb->s_blocksize : |
| 1564 | bytes_left); | 1544 | bytes_left); |
| 1565 | 1545 | ||
| 1566 | status = ocfs2_journal_dirty(handle, bhs[virtual]); | 1546 | ocfs2_journal_dirty(handle, bhs[virtual]); |
| 1567 | if (status < 0) { | ||
| 1568 | mlog_errno(status); | ||
| 1569 | goto bail; | ||
| 1570 | } | ||
| 1571 | 1547 | ||
| 1572 | virtual++; | 1548 | virtual++; |
| 1573 | p_blkno++; | 1549 | p_blkno++; |
| @@ -1611,6 +1587,8 @@ static int ocfs2_symlink(struct inode *dir, | |||
| 1611 | }; | 1587 | }; |
| 1612 | int did_quota = 0, did_quota_inode = 0; | 1588 | int did_quota = 0, did_quota_inode = 0; |
| 1613 | struct ocfs2_dir_lookup_result lookup = { NULL, }; | 1589 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
| 1590 | sigset_t oldset; | ||
| 1591 | int did_block_signals = 0; | ||
| 1614 | 1592 | ||
| 1615 | mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir, | 1593 | mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir, |
| 1616 | dentry, symname, dentry->d_name.len, dentry->d_name.name); | 1594 | dentry, symname, dentry->d_name.len, dentry->d_name.name); |
| @@ -1706,6 +1684,10 @@ static int ocfs2_symlink(struct inode *dir, | |||
| 1706 | goto bail; | 1684 | goto bail; |
| 1707 | } | 1685 | } |
| 1708 | 1686 | ||
| 1687 | /* Starting to change things, restart is no longer possible. */ | ||
| 1688 | ocfs2_block_signals(&oldset); | ||
| 1689 | did_block_signals = 1; | ||
| 1690 | |||
| 1709 | status = dquot_alloc_inode(inode); | 1691 | status = dquot_alloc_inode(inode); |
| 1710 | if (status) | 1692 | if (status) |
| 1711 | goto bail; | 1693 | goto bail; |
| @@ -1814,6 +1796,8 @@ bail: | |||
| 1814 | ocfs2_commit_trans(osb, handle); | 1796 | ocfs2_commit_trans(osb, handle); |
| 1815 | 1797 | ||
| 1816 | ocfs2_inode_unlock(dir, 1); | 1798 | ocfs2_inode_unlock(dir, 1); |
| 1799 | if (did_block_signals) | ||
| 1800 | ocfs2_unblock_signals(&oldset); | ||
| 1817 | 1801 | ||
| 1818 | brelse(new_fe_bh); | 1802 | brelse(new_fe_bh); |
| 1819 | brelse(parent_fe_bh); | 1803 | brelse(parent_fe_bh); |
| @@ -1961,12 +1945,7 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb, | |||
| 1961 | if (S_ISDIR(inode->i_mode)) | 1945 | if (S_ISDIR(inode->i_mode)) |
| 1962 | ocfs2_add_links_count(orphan_fe, 1); | 1946 | ocfs2_add_links_count(orphan_fe, 1); |
| 1963 | orphan_dir_inode->i_nlink = ocfs2_read_links_count(orphan_fe); | 1947 | orphan_dir_inode->i_nlink = ocfs2_read_links_count(orphan_fe); |
| 1964 | 1948 | 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 | 1949 | ||
| 1971 | status = __ocfs2_add_entry(handle, orphan_dir_inode, name, | 1950 | status = __ocfs2_add_entry(handle, orphan_dir_inode, name, |
| 1972 | OCFS2_ORPHAN_NAMELEN, inode, | 1951 | OCFS2_ORPHAN_NAMELEN, inode, |
| @@ -2065,12 +2044,7 @@ int ocfs2_orphan_del(struct ocfs2_super *osb, | |||
| 2065 | if (S_ISDIR(inode->i_mode)) | 2044 | if (S_ISDIR(inode->i_mode)) |
| 2066 | ocfs2_add_links_count(orphan_fe, -1); | 2045 | ocfs2_add_links_count(orphan_fe, -1); |
| 2067 | orphan_dir_inode->i_nlink = ocfs2_read_links_count(orphan_fe); | 2046 | orphan_dir_inode->i_nlink = ocfs2_read_links_count(orphan_fe); |
| 2068 | 2047 | 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 | 2048 | ||
| 2075 | leave: | 2049 | leave: |
| 2076 | ocfs2_free_dir_lookup_result(&lookup); | 2050 | ocfs2_free_dir_lookup_result(&lookup); |
