aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-11-04 19:56:02 -0400
committerChris Mason <chris.mason@oracle.com>2011-11-06 03:04:20 -0500
commitc06a0e120a4e381a1c291c1fce3c6155c5791cae (patch)
treea9d1c44610b37c701d25e439b005dacfa0f823c1 /fs/btrfs/ctree.h
parentbf0da8c183a15656eee63c54f334c3794320872a (diff)
Btrfs: fix delayed insertion reservation
We all keep getting those stupid warnings from use_block_rsv when running stress.sh, and it's because the delayed insertion stuff is being stupid. It's not the delayed insertion stuffs fault, it's all just stupid. When marking an inode dirty for oh say updating the time on it, we just do a btrfs_join_transaction, which doesn't reserve any space. This is stupid because we're going to have to have space reserve to make this change, but we do it because it's fast because chances are we're going to call it over and over again and it doesn't matter. Well thanks to the delayed insertion stuff this is mostly the case, so we do actually need to make this reservation. So if trans->bytes_reserved is 0 then try to do a normal reservation. If not return ENOSPC which will make the btrfs_dirty_inode start a proper transaction which will let it do the whole ENOSPC dance and reserve enough space for the delayed insertion to steal the reservation from the transaction. The other stupid thing we do is not reserve space for the inode when writing to the thing. Usually this is ok since we have to update the time so we'd have already done all this work before we get to the endio stuff, so it doesn't matter. But this is stupid because we could write the data after the transaction commits where we changed the mtime of the inode so we have to cow all the way down to the inode anyway. This used to be masked by the delalloc reservation stuff, but because we delay the update it doesn't get masked in this case. So again the delayed insertion stuff bites us in the ass. So if our trans->block_rsv is delalloc, just steal the reservation from the delalloc reserve. Hopefully this won't bite us in the ass, but I've said that before. With this patch stress.sh no longer spits out those stupid warnings (famous last words). Thanks, Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 3002e5d4da0b..6bb34fc1ff22 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2353,6 +2353,9 @@ void btrfs_free_block_rsv(struct btrfs_root *root,
2353int btrfs_block_rsv_add(struct btrfs_root *root, 2353int btrfs_block_rsv_add(struct btrfs_root *root,
2354 struct btrfs_block_rsv *block_rsv, 2354 struct btrfs_block_rsv *block_rsv,
2355 u64 num_bytes); 2355 u64 num_bytes);
2356int btrfs_block_rsv_add_noflush(struct btrfs_root *root,
2357 struct btrfs_block_rsv *block_rsv,
2358 u64 num_bytes);
2356int btrfs_block_rsv_check(struct btrfs_root *root, 2359int btrfs_block_rsv_check(struct btrfs_root *root,
2357 struct btrfs_block_rsv *block_rsv, int min_factor); 2360 struct btrfs_block_rsv *block_rsv, int min_factor);
2358int btrfs_block_rsv_refill(struct btrfs_root *root, 2361int btrfs_block_rsv_refill(struct btrfs_root *root,