diff mbox

[10/10] Btrfs: reserve space for O_TMPFILE orphan item deletion

Message ID 35b9fda73e091d42845d5bbf34607c052da1147f.1525932796.git.osandov@fb.com (mailing list archive)
State New, archived
Headers show

Commit Message

Omar Sandoval May 10, 2018, 6:21 a.m. UTC
From: Omar Sandoval <osandov@fb.com>

btrfs_link() calls btrfs_orphan_del() if it's linking an O_TMPFILE but
it doesn't reserve space to do so. Even before the removal of the
orphan_block_rsv it wasn't using it.

Fixes: ef3b9af50bfa ("Btrfs: implement inode_operations callback tmpfile")
Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 fs/btrfs/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Filipe Manana May 10, 2018, 3:25 p.m. UTC | #1
On Thu, May 10, 2018 at 7:21 AM, Omar Sandoval <osandov@osandov.com> wrote:
> From: Omar Sandoval <osandov@fb.com>
>
> btrfs_link() calls btrfs_orphan_del() if it's linking an O_TMPFILE but
> it doesn't reserve space to do so. Even before the removal of the
> orphan_block_rsv it wasn't using it.
>
> Fixes: ef3b9af50bfa ("Btrfs: implement inode_operations callback tmpfile")
> Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>

> ---
>  fs/btrfs/inode.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 88b89a48b66f..2a610a8d30c4 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -6535,8 +6535,9 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
>          * 2 items for inode and inode ref
>          * 2 items for dir items
>          * 1 item for parent inode
> +        * 1 item for orphan item deletion if O_TMPFILE
>          */
> -       trans = btrfs_start_transaction(root, 5);
> +       trans = btrfs_start_transaction(root, inode->i_nlink ? 5 : 6);
>         if (IS_ERR(trans)) {
>                 err = PTR_ERR(trans);
>                 trans = NULL;
> --
> 2.17.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 88b89a48b66f..2a610a8d30c4 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6535,8 +6535,9 @@  static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
 	 * 2 items for inode and inode ref
 	 * 2 items for dir items
 	 * 1 item for parent inode
+	 * 1 item for orphan item deletion if O_TMPFILE
 	 */
-	trans = btrfs_start_transaction(root, 5);
+	trans = btrfs_start_transaction(root, inode->i_nlink ? 5 : 6);
 	if (IS_ERR(trans)) {
 		err = PTR_ERR(trans);
 		trans = NULL;