diff mbox

[1/5] Btrfs: don't abort the current transaction if there is no enough space for inode cache

Message ID 1368453312-7027-1-git-send-email-miaox@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Miao Xie May 13, 2013, 1:55 p.m. UTC
The filesystem with inode cache was forced to be read-only when we umounted it.

Steps to reproduce:
 # mkfs.btrfs -f ${DEV}
 # mount -o inode_cache ${DEV} ${MNT}
 # dd if=/dev/zero of=${MNT}/file1 bs=1M count=8192
 # btrfs fi syn ${MNT}
 # dd if=${MNT}/file1 of=/dev/null bs=1M
 # rm -f ${MNT}/file1
 # btrfs fi syn ${MNT}
 # umount ${MNT}

It is because there was no enough space to do inode cache truncation, and then
we aborted the current transaction.

But no space error is not a serious problem when we write out the inode cache,
and it is safe that we just skip this step if we meet this problem. So we need
not abort the current transaction.

Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
 fs/btrfs/inode-map.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Tsutomu Itoh May 14, 2013, 6:39 a.m. UTC | #1
Hi, Miao,

On 2013/05/13 22:55, Miao Xie wrote:
> The filesystem with inode cache was forced to be read-only when we umounted it.
> 
> Steps to reproduce:
>   # mkfs.btrfs -f ${DEV}
>   # mount -o inode_cache ${DEV} ${MNT}
>   # dd if=/dev/zero of=${MNT}/file1 bs=1M count=8192
>   # btrfs fi syn ${MNT}
>   # dd if=${MNT}/file1 of=/dev/null bs=1M
>   # rm -f ${MNT}/file1
>   # btrfs fi syn ${MNT}
>   # umount ${MNT}
> 
> It is because there was no enough space to do inode cache truncation, and then
> we aborted the current transaction.

The problem has not occurred in my testset after applying your patchset.
Your patchset looks good to me. Thanks.

Tested-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>

> 
> But no space error is not a serious problem when we write out the inode cache,
> and it is safe that we just skip this step if we meet this problem. So we need
> not abort the current transaction.
> 
> Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
> ---
>   fs/btrfs/inode-map.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
> index d26f67a..9818d4a 100644
> --- a/fs/btrfs/inode-map.c
> +++ b/fs/btrfs/inode-map.c
> @@ -468,7 +468,8 @@ again:
>   	if (i_size_read(inode) > 0) {
>   		ret = btrfs_truncate_free_space_cache(root, trans, path, inode);
>   		if (ret) {
> -			btrfs_abort_transaction(trans, root, ret);
> +			if (ret != -ENOSPC)
> +				btrfs_abort_transaction(trans, root, ret);
>   			goto out_put;
>   		}
>   	}
> 


--
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-map.c b/fs/btrfs/inode-map.c
index d26f67a..9818d4a 100644
--- a/fs/btrfs/inode-map.c
+++ b/fs/btrfs/inode-map.c
@@ -468,7 +468,8 @@  again:
 	if (i_size_read(inode) > 0) {
 		ret = btrfs_truncate_free_space_cache(root, trans, path, inode);
 		if (ret) {
-			btrfs_abort_transaction(trans, root, ret);
+			if (ret != -ENOSPC)
+				btrfs_abort_transaction(trans, root, ret);
 			goto out_put;
 		}
 	}