diff mbox

Btrfs: handle quota reserve failure properly

Message ID 1473965868-9675-1-git-send-email-jbacik@fb.com (mailing list archive)
State Accepted
Headers show

Commit Message

Josef Bacik Sept. 15, 2016, 6:57 p.m. UTC
btrfs/022 was spitting a warning for the case that we exceed the quota.  If we
fail to make our quota reservation we need to clean up our data space
reservation.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 fs/btrfs/extent-tree.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Holger Hoffstätte Sept. 16, 2016, 9:02 a.m. UTC | #1
On Thu, 15 Sep 2016 14:57:48 -0400, Josef Bacik wrote:

> btrfs/022 was spitting a warning for the case that we exceed the quota.  If we
> fail to make our quota reservation we need to clean up our data space
> reservation.  Thanks,
> 
> Signed-off-by: Josef Bacik <jbacik@fb.com>
> ---
>  fs/btrfs/extent-tree.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 03da2f6..d72eaae 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -4286,13 +4286,10 @@ int btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len)
>  	if (ret < 0)
>  		return ret;
>  
> -	/*
> -	 * Use new btrfs_qgroup_reserve_data to reserve precious data space
> -	 *
> -	 * TODO: Find a good method to avoid reserve data space for NOCOW
> -	 * range, but don't impact performance on quota disable case.
> -	 */
> +	/* Use new btrfs_qgroup_reserve_data to reserve precious data space. */
>  	ret = btrfs_qgroup_reserve_data(inode, start, len);
> +	if (ret)
> +		btrfs_free_reserved_data_space_noquota(inode, start, len);
>  	return ret;
>  }
>  
> -- 
> 2.7.4

This came up before, though slightly different:
http://www.spinics.net/lists/linux-btrfs/msg56644.html

Which version is correct - with or without _noquota ?

-h

--
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
David Sterba Sept. 19, 2016, 6:08 p.m. UTC | #2
On Fri, Sep 16, 2016 at 09:02:22AM +0000, Holger Hoffstätte wrote:
> On Thu, 15 Sep 2016 14:57:48 -0400, Josef Bacik wrote:
> 
> > btrfs/022 was spitting a warning for the case that we exceed the quota.  If we
> > fail to make our quota reservation we need to clean up our data space
> > reservation.  Thanks,
> > 
> > Signed-off-by: Josef Bacik <jbacik@fb.com>
> > ---
> >  fs/btrfs/extent-tree.c | 9 +++------
> >  1 file changed, 3 insertions(+), 6 deletions(-)
> > 
> > diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> > index 03da2f6..d72eaae 100644
> > --- a/fs/btrfs/extent-tree.c
> > +++ b/fs/btrfs/extent-tree.c
> > @@ -4286,13 +4286,10 @@ int btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len)
> >  	if (ret < 0)
> >  		return ret;
> >  
> > -	/*
> > -	 * Use new btrfs_qgroup_reserve_data to reserve precious data space
> > -	 *
> > -	 * TODO: Find a good method to avoid reserve data space for NOCOW
> > -	 * range, but don't impact performance on quota disable case.
> > -	 */
> > +	/* Use new btrfs_qgroup_reserve_data to reserve precious data space. */
> >  	ret = btrfs_qgroup_reserve_data(inode, start, len);
> > +	if (ret)
> > +		btrfs_free_reserved_data_space_noquota(inode, start, len);
> >  	return ret;
> >  }
> >  
> > -- 
> > 2.7.4
> 
> This came up before, though slightly different:
> http://www.spinics.net/lists/linux-btrfs/msg56644.html
> 
> Which version is correct - with or without _noquota ?

Seems that it's the _noquota variant.
--
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
Jeff Mahoney Sept. 19, 2016, 6:50 p.m. UTC | #3
On 9/15/16 2:57 PM, Josef Bacik wrote:
> btrfs/022 was spitting a warning for the case that we exceed the quota.  If we
> fail to make our quota reservation we need to clean up our data space
> reservation.  Thanks,
> 
> Signed-off-by: Josef Bacik <jbacik@fb.com>
> ---
>  fs/btrfs/extent-tree.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 03da2f6..d72eaae 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -4286,13 +4286,10 @@ int btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len)
>  	if (ret < 0)
>  		return ret;
>  
> -	/*
> -	 * Use new btrfs_qgroup_reserve_data to reserve precious data space
> -	 *
> -	 * TODO: Find a good method to avoid reserve data space for NOCOW
> -	 * range, but don't impact performance on quota disable case.
> -	 */
> +	/* Use new btrfs_qgroup_reserve_data to reserve precious data space. */
>  	ret = btrfs_qgroup_reserve_data(inode, start, len);
> +	if (ret)
> +		btrfs_free_reserved_data_space_noquota(inode, start, len);
>  	return ret;
>  }
>  
> 

Tested-by: Jeff Mahoney <jeffm@suse.com>

btrfs/022 passes now.

Thanks,

-Jeff
Qu Wenruo Sept. 20, 2016, 12:33 a.m. UTC | #4
At 09/20/2016 02:08 AM, David Sterba wrote:
> On Fri, Sep 16, 2016 at 09:02:22AM +0000, Holger Hoffstätte wrote:
>> On Thu, 15 Sep 2016 14:57:48 -0400, Josef Bacik wrote:
>>
>>> btrfs/022 was spitting a warning for the case that we exceed the quota.  If we
>>> fail to make our quota reservation we need to clean up our data space
>>> reservation.  Thanks,
>>>
>>> Signed-off-by: Josef Bacik <jbacik@fb.com>
>>> ---
>>>  fs/btrfs/extent-tree.c | 9 +++------
>>>  1 file changed, 3 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
>>> index 03da2f6..d72eaae 100644
>>> --- a/fs/btrfs/extent-tree.c
>>> +++ b/fs/btrfs/extent-tree.c
>>> @@ -4286,13 +4286,10 @@ int btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len)
>>>  	if (ret < 0)
>>>  		return ret;
>>>
>>> -	/*
>>> -	 * Use new btrfs_qgroup_reserve_data to reserve precious data space
>>> -	 *
>>> -	 * TODO: Find a good method to avoid reserve data space for NOCOW
>>> -	 * range, but don't impact performance on quota disable case.
>>> -	 */
>>> +	/* Use new btrfs_qgroup_reserve_data to reserve precious data space. */
>>>  	ret = btrfs_qgroup_reserve_data(inode, start, len);
>>> +	if (ret)
>>> +		btrfs_free_reserved_data_space_noquota(inode, start, len);
>>>  	return ret;
>>>  }
>>>
>>> --
>>> 2.7.4
>>
>> This came up before, though slightly different:
>> http://www.spinics.net/lists/linux-btrfs/msg56644.html
>>
>> Which version is correct - with or without _noquota ?
>
> Seems that it's the _noquota variant.

Josef and David is right, _noquota variant is more proper.

The case is, if the start, len range covers some already reserved range, 
then such free will also free such range.

Causing the reserved range being freed too early.

Thanks,
Qu

> --
> 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
>
>


--
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
Chris Mason Sept. 20, 2016, 12:35 a.m. UTC | #5
On 09/19/2016 02:50 PM, Jeff Mahoney wrote:
> On 9/15/16 2:57 PM, Josef Bacik wrote:
>> btrfs/022 was spitting a warning for the case that we exceed the quota.  If we
>> fail to make our quota reservation we need to clean up our data space
>> reservation.  Thanks,
>>
>> Signed-off-by: Josef Bacik <jbacik@fb.com>
>> ---
>>  fs/btrfs/extent-tree.c | 9 +++------
>>  1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
>> index 03da2f6..d72eaae 100644
>> --- a/fs/btrfs/extent-tree.c
>> +++ b/fs/btrfs/extent-tree.c
>> @@ -4286,13 +4286,10 @@ int btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len)
>>  	if (ret < 0)
>>  		return ret;
>>
>> -	/*
>> -	 * Use new btrfs_qgroup_reserve_data to reserve precious data space
>> -	 *
>> -	 * TODO: Find a good method to avoid reserve data space for NOCOW
>> -	 * range, but don't impact performance on quota disable case.
>> -	 */
>> +	/* Use new btrfs_qgroup_reserve_data to reserve precious data space. */
>>  	ret = btrfs_qgroup_reserve_data(inode, start, len);
>> +	if (ret)
>> +		btrfs_free_reserved_data_space_noquota(inode, start, len);
>>  	return ret;
>>  }
>>
>>
>
> Tested-by: Jeff Mahoney <jeffm@suse.com>
>
> btrfs/022 passes now.
>

Thanks guys, I'll get this in for -final.

-chris

--
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/extent-tree.c b/fs/btrfs/extent-tree.c
index 03da2f6..d72eaae 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4286,13 +4286,10 @@  int btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len)
 	if (ret < 0)
 		return ret;
 
-	/*
-	 * Use new btrfs_qgroup_reserve_data to reserve precious data space
-	 *
-	 * TODO: Find a good method to avoid reserve data space for NOCOW
-	 * range, but don't impact performance on quota disable case.
-	 */
+	/* Use new btrfs_qgroup_reserve_data to reserve precious data space. */
 	ret = btrfs_qgroup_reserve_data(inode, start, len);
+	if (ret)
+		btrfs_free_reserved_data_space_noquota(inode, start, len);
 	return ret;
 }