|
@@ -5641,6 +5641,13 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ * O_TMPFILE, set link count to 0, so that after this point,
|
|
|
+ * we fill in an inode item with the correct link count.
|
|
|
+ */
|
|
|
+ if (!name)
|
|
|
+ set_nlink(inode, 0);
|
|
|
+
|
|
|
/*
|
|
|
* we have to initialize this early, so we can reclaim the inode
|
|
|
* number if we fail afterwards in this function.
|
|
@@ -9007,6 +9014,14 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
|
|
|
if (ret)
|
|
|
goto out;
|
|
|
|
|
|
+ /*
|
|
|
+ * We set number of links to 0 in btrfs_new_inode(), and here we set
|
|
|
+ * it to 1 because d_tmpfile() will issue a warning if the count is 0,
|
|
|
+ * through:
|
|
|
+ *
|
|
|
+ * d_tmpfile() -> inode_dec_link_count() -> drop_nlink()
|
|
|
+ */
|
|
|
+ set_nlink(inode, 1);
|
|
|
d_tmpfile(dentry, inode);
|
|
|
mark_inode_dirty(inode);
|
|
|
|