* [PATCH] Btrfs: do not ignore errors when truncating the free space cache inode
@ 2013-06-18 21:57 Djalal Harouni
2013-06-19 1:57 ` Miao Xie
0 siblings, 1 reply; 2+ messages in thread
From: Djalal Harouni @ 2013-06-18 21:57 UTC (permalink / raw)
To: Chris Mason, Miao Xie, Josef Bacik, linux-btrfs, linux-kernel
Cc: Djalal Harouni
btrfs_check_trunc_cache_free_space() tries to check if there is enough
space for cache inode truncation but it fails.
Currently this function always returns success even if there is no
enough space. Fix this by returning the -ENOSPC error code.
Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
---
Totally untested code.
fs/btrfs/free-space-cache.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 2750b50..9629830 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -201,7 +201,7 @@ int btrfs_check_trunc_cache_free_space(struct btrfs_root *root,
struct btrfs_block_rsv *rsv)
{
u64 needed_bytes;
- int ret;
+ int ret = 0;
/* 1 for slack space, 1 for updating the inode */
needed_bytes = btrfs_calc_trunc_metadata_size(root, 1) +
@@ -210,10 +210,10 @@ int btrfs_check_trunc_cache_free_space(struct btrfs_root *root,
spin_lock(&rsv->lock);
if (rsv->reserved < needed_bytes)
ret = -ENOSPC;
- else
- ret = 0;
+
spin_unlock(&rsv->lock);
- return 0;
+
+ return ret;
}
int btrfs_truncate_free_space_cache(struct btrfs_root *root,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Btrfs: do not ignore errors when truncating the free space cache inode
2013-06-18 21:57 [PATCH] Btrfs: do not ignore errors when truncating the free space cache inode Djalal Harouni
@ 2013-06-19 1:57 ` Miao Xie
0 siblings, 0 replies; 2+ messages in thread
From: Miao Xie @ 2013-06-19 1:57 UTC (permalink / raw)
To: Djalal Harouni; +Cc: Chris Mason, Josef Bacik, linux-btrfs, linux-kernel
It was fixed by Wei Yongjun
http://marc.info/?l=linux-btrfs&m=136910396606489&w=2
Thanks
Miao
On tue, 18 Jun 2013 22:57:41 +0100, Djalal Harouni wrote:
> btrfs_check_trunc_cache_free_space() tries to check if there is enough
> space for cache inode truncation but it fails.
>
> Currently this function always returns success even if there is no
> enough space. Fix this by returning the -ENOSPC error code.
>
> Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
> ---
> Totally untested code.
>
> fs/btrfs/free-space-cache.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index 2750b50..9629830 100644
> --- a/fs/btrfs/free-space-cache.c
> +++ b/fs/btrfs/free-space-cache.c
> @@ -201,7 +201,7 @@ int btrfs_check_trunc_cache_free_space(struct btrfs_root *root,
> struct btrfs_block_rsv *rsv)
> {
> u64 needed_bytes;
> - int ret;
> + int ret = 0;
>
> /* 1 for slack space, 1 for updating the inode */
> needed_bytes = btrfs_calc_trunc_metadata_size(root, 1) +
> @@ -210,10 +210,10 @@ int btrfs_check_trunc_cache_free_space(struct btrfs_root *root,
> spin_lock(&rsv->lock);
> if (rsv->reserved < needed_bytes)
> ret = -ENOSPC;
> - else
> - ret = 0;
> +
> spin_unlock(&rsv->lock);
> - return 0;
> +
> + return ret;
> }
>
> int btrfs_truncate_free_space_cache(struct btrfs_root *root,
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-19 1:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-18 21:57 [PATCH] Btrfs: do not ignore errors when truncating the free space cache inode Djalal Harouni
2013-06-19 1:57 ` Miao Xie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).