aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/namei.c')
-rw-r--r--fs/ext4/namei.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index e5a74a5ac261..e7e1d79a7d75 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1616,21 +1616,6 @@ static int ext4_delete_entry (handle_t *handle,
1616 return -ENOENT; 1616 return -ENOENT;
1617} 1617}
1618 1618
1619/*
1620 * ext4_mark_inode_dirty is somewhat expensive, so unlike ext2 we
1621 * do not perform it in these functions. We perform it at the call site,
1622 * if it is needed.
1623 */
1624static inline void ext4_inc_count(handle_t *handle, struct inode *inode)
1625{
1626 inc_nlink(inode);
1627}
1628
1629static inline void ext4_dec_count(handle_t *handle, struct inode *inode)
1630{
1631 drop_nlink(inode);
1632}
1633
1634static int ext4_add_nondir(handle_t *handle, 1619static int ext4_add_nondir(handle_t *handle,
1635 struct dentry *dentry, struct inode *inode) 1620 struct dentry *dentry, struct inode *inode)
1636{ 1621{
@@ -1640,7 +1625,7 @@ static int ext4_add_nondir(handle_t *handle,
1640 d_instantiate(dentry, inode); 1625 d_instantiate(dentry, inode);
1641 return 0; 1626 return 0;
1642 } 1627 }
1643 ext4_dec_count(handle, inode); 1628 drop_nlink(inode);
1644 iput(inode); 1629 iput(inode);
1645 return err; 1630 return err;
1646} 1631}
@@ -2161,7 +2146,7 @@ retry:
2161 err = __page_symlink(inode, symname, l, 2146 err = __page_symlink(inode, symname, l,
2162 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); 2147 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
2163 if (err) { 2148 if (err) {
2164 ext4_dec_count(handle, inode); 2149 drop_nlink(inode);
2165 ext4_mark_inode_dirty(handle, inode); 2150 ext4_mark_inode_dirty(handle, inode);
2166 iput (inode); 2151 iput (inode);
2167 goto out_stop; 2152 goto out_stop;
@@ -2189,6 +2174,12 @@ static int ext4_link (struct dentry * old_dentry,
2189 2174
2190 if (inode->i_nlink >= EXT4_LINK_MAX) 2175 if (inode->i_nlink >= EXT4_LINK_MAX)
2191 return -EMLINK; 2176 return -EMLINK;
2177 /*
2178 * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing
2179 * otherwise has the potential to corrupt the orphan inode list.
2180 */
2181 if (inode->i_nlink == 0)
2182 return -ENOENT;
2192 2183
2193retry: 2184retry:
2194 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 2185 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -2200,7 +2191,7 @@ retry:
2200 handle->h_sync = 1; 2191 handle->h_sync = 1;
2201 2192
2202 inode->i_ctime = CURRENT_TIME_SEC; 2193 inode->i_ctime = CURRENT_TIME_SEC;
2203 ext4_inc_count(handle, inode); 2194 inc_nlink(inode);
2204 atomic_inc(&inode->i_count); 2195 atomic_inc(&inode->i_count);
2205 2196
2206 err = ext4_add_nondir(handle, dentry, inode); 2197 err = ext4_add_nondir(handle, dentry, inode);
@@ -2372,7 +2363,7 @@ end_rename:
2372/* 2363/*
2373 * directories can handle most operations... 2364 * directories can handle most operations...
2374 */ 2365 */
2375struct inode_operations ext4_dir_inode_operations = { 2366const struct inode_operations ext4_dir_inode_operations = {
2376 .create = ext4_create, 2367 .create = ext4_create,
2377 .lookup = ext4_lookup, 2368 .lookup = ext4_lookup,
2378 .link = ext4_link, 2369 .link = ext4_link,
@@ -2392,7 +2383,7 @@ struct inode_operations ext4_dir_inode_operations = {
2392 .permission = ext4_permission, 2383 .permission = ext4_permission,
2393}; 2384};
2394 2385
2395struct inode_operations ext4_special_inode_operations = { 2386const struct inode_operations ext4_special_inode_operations = {
2396 .setattr = ext4_setattr, 2387 .setattr = ext4_setattr,
2397#ifdef CONFIG_EXT4DEV_FS_XATTR 2388#ifdef CONFIG_EXT4DEV_FS_XATTR
2398 .setxattr = generic_setxattr, 2389 .setxattr = generic_setxattr,