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.c52
1 files changed, 36 insertions, 16 deletions
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index aad6400c9b77..ee184084ca42 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -1696,10 +1696,12 @@ static int ext3_create (struct inode * dir, struct dentry * dentry, int mode,
1696 struct inode * inode; 1696 struct inode * inode;
1697 int err, retries = 0; 1697 int err, retries = 0;
1698 1698
1699 dquot_initialize(dir);
1700
1699retry: 1701retry:
1700 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + 1702 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
1701 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + 1703 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
1702 2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb)); 1704 EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
1703 if (IS_ERR(handle)) 1705 if (IS_ERR(handle))
1704 return PTR_ERR(handle); 1706 return PTR_ERR(handle);
1705 1707
@@ -1730,10 +1732,12 @@ static int ext3_mknod (struct inode * dir, struct dentry *dentry,
1730 if (!new_valid_dev(rdev)) 1732 if (!new_valid_dev(rdev))
1731 return -EINVAL; 1733 return -EINVAL;
1732 1734
1735 dquot_initialize(dir);
1736
1733retry: 1737retry:
1734 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + 1738 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
1735 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + 1739 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
1736 2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb)); 1740 EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
1737 if (IS_ERR(handle)) 1741 if (IS_ERR(handle))
1738 return PTR_ERR(handle); 1742 return PTR_ERR(handle);
1739 1743
@@ -1766,10 +1770,12 @@ static int ext3_mkdir(struct inode * dir, struct dentry * dentry, int mode)
1766 if (dir->i_nlink >= EXT3_LINK_MAX) 1770 if (dir->i_nlink >= EXT3_LINK_MAX)
1767 return -EMLINK; 1771 return -EMLINK;
1768 1772
1773 dquot_initialize(dir);
1774
1769retry: 1775retry:
1770 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + 1776 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
1771 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + 1777 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
1772 2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb)); 1778 EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
1773 if (IS_ERR(handle)) 1779 if (IS_ERR(handle))
1774 return PTR_ERR(handle); 1780 return PTR_ERR(handle);
1775 1781
@@ -1920,7 +1926,7 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode)
1920 struct ext3_iloc iloc; 1926 struct ext3_iloc iloc;
1921 int err = 0, rc; 1927 int err = 0, rc;
1922 1928
1923 lock_super(sb); 1929 mutex_lock(&EXT3_SB(sb)->s_orphan_lock);
1924 if (!list_empty(&EXT3_I(inode)->i_orphan)) 1930 if (!list_empty(&EXT3_I(inode)->i_orphan))
1925 goto out_unlock; 1931 goto out_unlock;
1926 1932
@@ -1929,9 +1935,13 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode)
1929 1935
1930 /* @@@ FIXME: Observation from aviro: 1936 /* @@@ FIXME: Observation from aviro:
1931 * I think I can trigger J_ASSERT in ext3_orphan_add(). We block 1937 * I think I can trigger J_ASSERT in ext3_orphan_add(). We block
1932 * here (on lock_super()), so race with ext3_link() which might bump 1938 * here (on s_orphan_lock), so race with ext3_link() which might bump
1933 * ->i_nlink. For, say it, character device. Not a regular file, 1939 * ->i_nlink. For, say it, character device. Not a regular file,
1934 * not a directory, not a symlink and ->i_nlink > 0. 1940 * not a directory, not a symlink and ->i_nlink > 0.
1941 *
1942 * tytso, 4/25/2009: I'm not sure how that could happen;
1943 * shouldn't the fs core protect us from these sort of
1944 * unlink()/link() races?
1935 */ 1945 */
1936 J_ASSERT ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || 1946 J_ASSERT ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
1937 S_ISLNK(inode->i_mode)) || inode->i_nlink == 0); 1947 S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
@@ -1968,7 +1978,7 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode)
1968 jbd_debug(4, "orphan inode %lu will point to %d\n", 1978 jbd_debug(4, "orphan inode %lu will point to %d\n",
1969 inode->i_ino, NEXT_ORPHAN(inode)); 1979 inode->i_ino, NEXT_ORPHAN(inode));
1970out_unlock: 1980out_unlock:
1971 unlock_super(sb); 1981 mutex_unlock(&EXT3_SB(sb)->s_orphan_lock);
1972 ext3_std_error(inode->i_sb, err); 1982 ext3_std_error(inode->i_sb, err);
1973 return err; 1983 return err;
1974} 1984}
@@ -1986,11 +1996,9 @@ int ext3_orphan_del(handle_t *handle, struct inode *inode)
1986 struct ext3_iloc iloc; 1996 struct ext3_iloc iloc;
1987 int err = 0; 1997 int err = 0;
1988 1998
1989 lock_super(inode->i_sb); 1999 mutex_lock(&EXT3_SB(inode->i_sb)->s_orphan_lock);
1990 if (list_empty(&ei->i_orphan)) { 2000 if (list_empty(&ei->i_orphan))
1991 unlock_super(inode->i_sb); 2001 goto out;
1992 return 0;
1993 }
1994 2002
1995 ino_next = NEXT_ORPHAN(inode); 2003 ino_next = NEXT_ORPHAN(inode);
1996 prev = ei->i_orphan.prev; 2004 prev = ei->i_orphan.prev;
@@ -2040,7 +2048,7 @@ int ext3_orphan_del(handle_t *handle, struct inode *inode)
2040out_err: 2048out_err:
2041 ext3_std_error(inode->i_sb, err); 2049 ext3_std_error(inode->i_sb, err);
2042out: 2050out:
2043 unlock_super(inode->i_sb); 2051 mutex_unlock(&EXT3_SB(inode->i_sb)->s_orphan_lock);
2044 return err; 2052 return err;
2045 2053
2046out_brelse: 2054out_brelse:
@@ -2058,7 +2066,9 @@ static int ext3_rmdir (struct inode * dir, struct dentry *dentry)
2058 2066
2059 /* Initialize quotas before so that eventual writes go in 2067 /* Initialize quotas before so that eventual writes go in
2060 * separate transaction */ 2068 * separate transaction */
2061 vfs_dq_init(dentry->d_inode); 2069 dquot_initialize(dir);
2070 dquot_initialize(dentry->d_inode);
2071
2062 handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); 2072 handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb));
2063 if (IS_ERR(handle)) 2073 if (IS_ERR(handle))
2064 return PTR_ERR(handle); 2074 return PTR_ERR(handle);
@@ -2117,7 +2127,9 @@ static int ext3_unlink(struct inode * dir, struct dentry *dentry)
2117 2127
2118 /* Initialize quotas before so that eventual writes go 2128 /* Initialize quotas before so that eventual writes go
2119 * in separate transaction */ 2129 * in separate transaction */
2120 vfs_dq_init(dentry->d_inode); 2130 dquot_initialize(dir);
2131 dquot_initialize(dentry->d_inode);
2132
2121 handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); 2133 handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb));
2122 if (IS_ERR(handle)) 2134 if (IS_ERR(handle))
2123 return PTR_ERR(handle); 2135 return PTR_ERR(handle);
@@ -2172,10 +2184,12 @@ static int ext3_symlink (struct inode * dir,
2172 if (l > dir->i_sb->s_blocksize) 2184 if (l > dir->i_sb->s_blocksize)
2173 return -ENAMETOOLONG; 2185 return -ENAMETOOLONG;
2174 2186
2187 dquot_initialize(dir);
2188
2175retry: 2189retry:
2176 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + 2190 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
2177 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 + 2191 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 +
2178 2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb)); 2192 EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
2179 if (IS_ERR(handle)) 2193 if (IS_ERR(handle))
2180 return PTR_ERR(handle); 2194 return PTR_ERR(handle);
2181 2195
@@ -2226,6 +2240,9 @@ static int ext3_link (struct dentry * old_dentry,
2226 2240
2227 if (inode->i_nlink >= EXT3_LINK_MAX) 2241 if (inode->i_nlink >= EXT3_LINK_MAX)
2228 return -EMLINK; 2242 return -EMLINK;
2243
2244 dquot_initialize(dir);
2245
2229 /* 2246 /*
2230 * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing 2247 * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing
2231 * otherwise has the potential to corrupt the orphan inode list. 2248 * otherwise has the potential to corrupt the orphan inode list.
@@ -2276,12 +2293,15 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
2276 struct ext3_dir_entry_2 * old_de, * new_de; 2293 struct ext3_dir_entry_2 * old_de, * new_de;
2277 int retval, flush_file = 0; 2294 int retval, flush_file = 0;
2278 2295
2296 dquot_initialize(old_dir);
2297 dquot_initialize(new_dir);
2298
2279 old_bh = new_bh = dir_bh = NULL; 2299 old_bh = new_bh = dir_bh = NULL;
2280 2300
2281 /* Initialize quotas before so that eventual writes go 2301 /* Initialize quotas before so that eventual writes go
2282 * in separate transaction */ 2302 * in separate transaction */
2283 if (new_dentry->d_inode) 2303 if (new_dentry->d_inode)
2284 vfs_dq_init(new_dentry->d_inode); 2304 dquot_initialize(new_dentry->d_inode);
2285 handle = ext3_journal_start(old_dir, 2 * 2305 handle = ext3_journal_start(old_dir, 2 *
2286 EXT3_DATA_TRANS_BLOCKS(old_dir->i_sb) + 2306 EXT3_DATA_TRANS_BLOCKS(old_dir->i_sb) +
2287 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2); 2307 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2);