diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/inode.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 6dd6e50d143a..57c3129ee2a2 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -5642,6 +5642,13 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
5642 | } | 5642 | } |
5643 | 5643 | ||
5644 | /* | 5644 | /* |
5645 | * O_TMPFILE, set link count to 0, so that after this point, | ||
5646 | * we fill in an inode item with the correct link count. | ||
5647 | */ | ||
5648 | if (!name) | ||
5649 | set_nlink(inode, 0); | ||
5650 | |||
5651 | /* | ||
5645 | * we have to initialize this early, so we can reclaim the inode | 5652 | * we have to initialize this early, so we can reclaim the inode |
5646 | * number if we fail afterwards in this function. | 5653 | * number if we fail afterwards in this function. |
5647 | */ | 5654 | */ |
@@ -9007,6 +9014,14 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
9007 | if (ret) | 9014 | if (ret) |
9008 | goto out; | 9015 | goto out; |
9009 | 9016 | ||
9017 | /* | ||
9018 | * We set number of links to 0 in btrfs_new_inode(), and here we set | ||
9019 | * it to 1 because d_tmpfile() will issue a warning if the count is 0, | ||
9020 | * through: | ||
9021 | * | ||
9022 | * d_tmpfile() -> inode_dec_link_count() -> drop_nlink() | ||
9023 | */ | ||
9024 | set_nlink(inode, 1); | ||
9010 | d_tmpfile(dentry, inode); | 9025 | d_tmpfile(dentry, inode); |
9011 | mark_inode_dirty(inode); | 9026 | mark_inode_dirty(inode); |
9012 | 9027 | ||