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.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 4df39c4315e1..49159f13cc1f 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -1618,21 +1618,6 @@ static int ext3_delete_entry (handle_t *handle,
1618 return -ENOENT; 1618 return -ENOENT;
1619} 1619}
1620 1620
1621/*
1622 * ext3_mark_inode_dirty is somewhat expensive, so unlike ext2 we
1623 * do not perform it in these functions. We perform it at the call site,
1624 * if it is needed.
1625 */
1626static inline void ext3_inc_count(handle_t *handle, struct inode *inode)
1627{
1628 inc_nlink(inode);
1629}
1630
1631static inline void ext3_dec_count(handle_t *handle, struct inode *inode)
1632{
1633 drop_nlink(inode);
1634}
1635
1636static int ext3_add_nondir(handle_t *handle, 1621static int ext3_add_nondir(handle_t *handle,
1637 struct dentry *dentry, struct inode *inode) 1622 struct dentry *dentry, struct inode *inode)
1638{ 1623{
@@ -1642,7 +1627,7 @@ static int ext3_add_nondir(handle_t *handle,
1642 d_instantiate(dentry, inode); 1627 d_instantiate(dentry, inode);
1643 return 0; 1628 return 0;
1644 } 1629 }
1645 ext3_dec_count(handle, inode); 1630 drop_nlink(inode);
1646 iput(inode); 1631 iput(inode);
1647 return err; 1632 return err;
1648} 1633}
@@ -2163,7 +2148,7 @@ retry:
2163 err = __page_symlink(inode, symname, l, 2148 err = __page_symlink(inode, symname, l,
2164 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); 2149 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
2165 if (err) { 2150 if (err) {
2166 ext3_dec_count(handle, inode); 2151 drop_nlink(inode);
2167 ext3_mark_inode_dirty(handle, inode); 2152 ext3_mark_inode_dirty(handle, inode);
2168 iput (inode); 2153 iput (inode);
2169 goto out_stop; 2154 goto out_stop;
@@ -2191,6 +2176,12 @@ static int ext3_link (struct dentry * old_dentry,
2191 2176
2192 if (inode->i_nlink >= EXT3_LINK_MAX) 2177 if (inode->i_nlink >= EXT3_LINK_MAX)
2193 return -EMLINK; 2178 return -EMLINK;
2179 /*
2180 * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing
2181 * otherwise has the potential to corrupt the orphan inode list.
2182 */
2183 if (inode->i_nlink == 0)
2184 return -ENOENT;
2194 2185
2195retry: 2186retry:
2196 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + 2187 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -2202,7 +2193,7 @@ retry:
2202 handle->h_sync = 1; 2193 handle->h_sync = 1;
2203 2194
2204 inode->i_ctime = CURRENT_TIME_SEC; 2195 inode->i_ctime = CURRENT_TIME_SEC;
2205 ext3_inc_count(handle, inode); 2196 inc_nlink(inode);
2206 atomic_inc(&inode->i_count); 2197 atomic_inc(&inode->i_count);
2207 2198
2208 err = ext3_add_nondir(handle, dentry, inode); 2199 err = ext3_add_nondir(handle, dentry, inode);
@@ -2374,7 +2365,7 @@ end_rename:
2374/* 2365/*
2375 * directories can handle most operations... 2366 * directories can handle most operations...
2376 */ 2367 */
2377struct inode_operations ext3_dir_inode_operations = { 2368const struct inode_operations ext3_dir_inode_operations = {
2378 .create = ext3_create, 2369 .create = ext3_create,
2379 .lookup = ext3_lookup, 2370 .lookup = ext3_lookup,
2380 .link = ext3_link, 2371 .link = ext3_link,
@@ -2394,7 +2385,7 @@ struct inode_operations ext3_dir_inode_operations = {
2394 .permission = ext3_permission, 2385 .permission = ext3_permission,
2395}; 2386};
2396 2387
2397struct inode_operations ext3_special_inode_operations = { 2388const struct inode_operations ext3_special_inode_operations = {
2398 .setattr = ext3_setattr, 2389 .setattr = ext3_setattr,
2399#ifdef CONFIG_EXT3_FS_XATTR 2390#ifdef CONFIG_EXT3_FS_XATTR
2400 .setxattr = generic_setxattr, 2391 .setxattr = generic_setxattr,