* Two questions about update_global_block_rsv()
@ 2012-06-07 14:46 WeiFeng Liu
2012-06-11 4:05 ` Liu Bo
0 siblings, 1 reply; 3+ messages in thread
From: WeiFeng Liu @ 2012-06-07 14:46 UTC (permalink / raw)
To: linux-btrfs
Help two questions about update_global_block_rsv()
update_global_block_rsv(fs_info) {
...
block_rsv = &fs_info->global_block_rsv;
sinfo = block_rsv->space_info;
num_bytes = sinfo->bytes_used + sinfo->bytes_pinned +
sinfo->bytes_reserved + sinfo->bytes_readonly +
sinfo->bytes_may_use;
if (sinfo->total_bytes > num_bytes) {
num_bytes = sinfo->total_bytes - num_bytes;
block_rsv->reserved += num_bytes;
sinfo->bytes_may_use += num_bytes;
}
...
}
1. I don't quite understand the lines:
block_rsv->reserved += num_bytes;
sinfo->bytes_may_use += num_bytes;
why aren't they like these?
block_rsv->reserved = num_bytes;
sinfo->bytes_may_use = num_bytes;
assuming that nothing else is changed, and we just call
update_global_block_rsv() for several times, then block_rsv->reserved will
increase constantly, and so sinfo->bytes_may_use; can anyone tell me what it
means? I mean if nothing else is changed the two variables should keep their
values unchanged also, is that right? a bit puzzlement to me.
2. Is the meaning of sinfo->bytes_may_use that bytes which is available for use
or that bytes which will likely/unlikely be used?
thanks
WeiFeng Liu
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Two questions about update_global_block_rsv()
2012-06-07 14:46 Two questions about update_global_block_rsv() WeiFeng Liu
@ 2012-06-11 4:05 ` Liu Bo
0 siblings, 0 replies; 3+ messages in thread
From: Liu Bo @ 2012-06-11 4:05 UTC (permalink / raw)
To: WeiFeng Liu; +Cc: linux-btrfs
On 06/07/2012 10:46 PM, WeiFeng Liu wrote:
> Help two questions about update_global_block_rsv()
>
> update_global_block_rsv(fs_info) {
>
> ...
> block_rsv = &fs_info->global_block_rsv;
> sinfo = block_rsv->space_info;
>
> num_bytes = sinfo->bytes_used + sinfo->bytes_pinned +
> sinfo->bytes_reserved + sinfo->bytes_readonly +
> sinfo->bytes_may_use;
>
> if (sinfo->total_bytes > num_bytes) {
> num_bytes = sinfo->total_bytes - num_bytes;
> block_rsv->reserved += num_bytes;
> sinfo->bytes_may_use += num_bytes;
> }
> ...
> }
>
> 1. I don't quite understand the lines:
> block_rsv->reserved += num_bytes;
> sinfo->bytes_may_use += num_bytes;
>
> why aren't they like these?
> block_rsv->reserved = num_bytes;
> sinfo->bytes_may_use = num_bytes;
>
> assuming that nothing else is changed, and we just call
> update_global_block_rsv() for several times, then block_rsv->reserved will
> increase constantly, and so sinfo->bytes_may_use; can anyone tell me what it
> means? I mean if nothing else is changed the two variables should keep their
> values unchanged also, is that right? a bit puzzlement to me.
>
the following if-statement tells the truth:
if (block_rsv->reserved >= block_rsv->size) {
...
}
> 2. Is the meaning of sinfo->bytes_may_use that bytes which is available for use
> or that bytes which will likely/unlikely be used?
>
You need to understand how a block_rsv works,
both block_rsv and space_info are a kind of _container_:
Introducing metadata reseravtion contexts has two major advantages.
First, it makes metadata reservation more traceable.
Second, it can reclaim freed space and re-add them to the itself after transaction committed.
here is a basic model:
+--+--->size +--+--->size +--------------+
| | | | | |
| | | | | |
+--+--->reserved +--+--->reserved +--------------+-->may_used
| | | | | |
| | | | | |
| | | | | |
+--+ +--+ +--------------+
block_rsv + block_rsv + ... = space_info(flag=4)
A B |
|
+--> reserved meta bytes
Hope that this helps.
thanks,
liubo
> thanks
>
> WeiFeng Liu
>
> --
> 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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Two questions about update_global_block_rsv()
@ 2012-06-21 12:57 WeiFeng Liu
0 siblings, 0 replies; 3+ messages in thread
From: WeiFeng Liu @ 2012-06-21 12:57 UTC (permalink / raw)
To: Liu Bo; +Cc: linux-btrfs
>
>You need to understand how a block_rsv works,
>
>both block_rsv and space_info are a kind of _container_:
>
> Introducing metadata reseravtion contexts has two major
>advantages.
> First, it makes metadata reservation more traceable.
> Second, it can reclaim freed space and re-add them to the
>itself after transaction committed.
>
>
>here is a basic model:
>
> +--+--->size +--+--->size +---
>-----------+
> | | | | |
> |
> | | | | |
> |
> +--+--->reserved +--+--->reserved +---
>-----------+-->may_used
> | | | | |
> |
> | | | | |
> |
> | | | | |
> |
> +--+ +--+ +---
>-----------+
> block_rsv + block_rsv + ... =
>space_info(flag=4)
> A B |
> |
> +--> reserved
>meta bytes
>
>
>Hope that this helps.
>
>thanks,
>liubo
I'm afraid it's a bit late to say thanks, LiuBo.
I saw your June 11 replay yesterday, I have not touched my mail account for nearly
ten days since my original post, I thought it would have been burried by time after
I kept watching someone's replay for 2, 3 days and failed to get one.
your illustration is usefull for me, I will re-browse some rsv code with it.
thank you very much,
WeiFeng Liu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-06-21 12:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-07 14:46 Two questions about update_global_block_rsv() WeiFeng Liu
2012-06-11 4:05 ` Liu Bo
-- strict thread matches above, loose matches on Subject: below --
2012-06-21 12:57 WeiFeng Liu
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).