aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext3/namei.c')
-rw-r--r--fs/ext3/namei.c54
1 files changed, 48 insertions, 6 deletions
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 692de13e3596..998ea111e537 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -576,11 +576,8 @@ static int htree_dirblock_to_tree(struct file *dir_file,
576 if (!ext3_check_dir_entry("htree_dirblock_to_tree", dir, de, bh, 576 if (!ext3_check_dir_entry("htree_dirblock_to_tree", dir, de, bh,
577 (block<<EXT3_BLOCK_SIZE_BITS(dir->i_sb)) 577 (block<<EXT3_BLOCK_SIZE_BITS(dir->i_sb))
578 +((char *)de - bh->b_data))) { 578 +((char *)de - bh->b_data))) {
579 /* On error, skip the f_pos to the next block. */ 579 /* silently ignore the rest of the block */
580 dir_file->f_pos = (dir_file->f_pos | 580 break;
581 (dir->i_sb->s_blocksize - 1)) + 1;
582 brelse (bh);
583 return count;
584 } 581 }
585 ext3fs_dirhash(de->name, de->name_len, hinfo); 582 ext3fs_dirhash(de->name, de->name_len, hinfo);
586 if ((hinfo->hash < start_hash) || 583 if ((hinfo->hash < start_hash) ||
@@ -1762,6 +1759,45 @@ retry:
1762 return err; 1759 return err;
1763} 1760}
1764 1761
1762static int ext3_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
1763{
1764 handle_t *handle;
1765 struct inode *inode;
1766 int err, retries = 0;
1767
1768 dquot_initialize(dir);
1769
1770retry:
1771 handle = ext3_journal_start(dir, EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) +
1772 4 + EXT3_XATTR_TRANS_BLOCKS);
1773
1774 if (IS_ERR(handle))
1775 return PTR_ERR(handle);
1776
1777 inode = ext3_new_inode (handle, dir, NULL, mode);
1778 err = PTR_ERR(inode);
1779 if (!IS_ERR(inode)) {
1780 inode->i_op = &ext3_file_inode_operations;
1781 inode->i_fop = &ext3_file_operations;
1782 ext3_set_aops(inode);
1783 err = ext3_orphan_add(handle, inode);
1784 if (err)
1785 goto err_drop_inode;
1786 mark_inode_dirty(inode);
1787 d_tmpfile(dentry, inode);
1788 unlock_new_inode(inode);
1789 }
1790 ext3_journal_stop(handle);
1791 if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries))
1792 goto retry;
1793 return err;
1794err_drop_inode:
1795 ext3_journal_stop(handle);
1796 unlock_new_inode(inode);
1797 iput(inode);
1798 return err;
1799}
1800
1765static int ext3_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode) 1801static int ext3_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode)
1766{ 1802{
1767 handle_t *handle; 1803 handle_t *handle;
@@ -2303,7 +2339,7 @@ static int ext3_link (struct dentry * old_dentry,
2303 2339
2304retry: 2340retry:
2305 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + 2341 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
2306 EXT3_INDEX_EXTRA_TRANS_BLOCKS); 2342 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 1);
2307 if (IS_ERR(handle)) 2343 if (IS_ERR(handle))
2308 return PTR_ERR(handle); 2344 return PTR_ERR(handle);
2309 2345
@@ -2317,6 +2353,11 @@ retry:
2317 err = ext3_add_entry(handle, dentry, inode); 2353 err = ext3_add_entry(handle, dentry, inode);
2318 if (!err) { 2354 if (!err) {
2319 ext3_mark_inode_dirty(handle, inode); 2355 ext3_mark_inode_dirty(handle, inode);
2356 /* this can happen only for tmpfile being
2357 * linked the first time
2358 */
2359 if (inode->i_nlink == 1)
2360 ext3_orphan_del(handle, inode);
2320 d_instantiate(dentry, inode); 2361 d_instantiate(dentry, inode);
2321 } else { 2362 } else {
2322 drop_nlink(inode); 2363 drop_nlink(inode);
@@ -2519,6 +2560,7 @@ const struct inode_operations ext3_dir_inode_operations = {
2519 .mkdir = ext3_mkdir, 2560 .mkdir = ext3_mkdir,
2520 .rmdir = ext3_rmdir, 2561 .rmdir = ext3_rmdir,
2521 .mknod = ext3_mknod, 2562 .mknod = ext3_mknod,
2563 .tmpfile = ext3_tmpfile,
2522 .rename = ext3_rename, 2564 .rename = ext3_rename,
2523 .setattr = ext3_setattr, 2565 .setattr = ext3_setattr,
2524#ifdef CONFIG_EXT3_FS_XATTR 2566#ifdef CONFIG_EXT3_FS_XATTR