From: Liu Bo <bo.li.liu@oracle.com>
To: Zhaolei <zhaolei@cn.fujitsu.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/9] btrfs: Fix tail space processing in find_free_dev_extent()
Date: Tue, 7 Apr 2015 19:14:31 +0800 [thread overview]
Message-ID: <20150407111329.GA30844@localhost.localdomain> (raw)
In-Reply-To: <5493abf5d0e08b335de6a5a15f0e72019062b80d.1428062473.git.zhaolei@cn.fujitsu.com>
On Fri, Apr 03, 2015 at 08:11:57PM +0800, Zhaolei wrote:
> From: Zhao Lei <zhaolei@cn.fujitsu.com>
>
> It is another reason for NO_SPACE case.
>
> When we found enough free space in loop and saved them to
> max_hole_start/size before, and tail space contains pending extent,
> origional innocent max_hole_start/size are reset in retry.
>
> As a result, find_free_dev_extent() returns less space than it can,
> and cause NO_SPACE in user program.
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
>
> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
> ---
> fs/btrfs/volumes.c | 24 +++++++++++++-----------
> 1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 8222f6f..586824a 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -1136,11 +1136,11 @@ int find_free_dev_extent(struct btrfs_trans_handle *trans,
> path = btrfs_alloc_path();
> if (!path)
> return -ENOMEM;
> -again:
> +
> max_hole_start = search_start;
> max_hole_size = 0;
> - hole_size = 0;
>
> +again:
> if (search_start >= search_end || device->is_tgtdev_for_dev_replace) {
> ret = -ENOSPC;
> goto out;
> @@ -1233,21 +1233,23 @@ next:
> * allocated dev extents, and when shrinking the device,
> * search_end may be smaller than search_start.
> */
> - if (search_end > search_start)
> + if (search_end > search_start) {
> hole_size = search_end - search_start;
>
> - if (hole_size > max_hole_size) {
> - max_hole_start = search_start;
> - max_hole_size = hole_size;
> - }
> + if (contains_pending_extent(trans, device, &search_start,
> + hole_size)) {
> + btrfs_release_path(path);
> + goto again;
> + }
>
> - if (contains_pending_extent(trans, device, &search_start, hole_size)) {
> - btrfs_release_path(path);
> - goto again;
> + if (hole_size > max_hole_size) {
> + max_hole_start = search_start;
> + max_hole_size = hole_size;
> + }
> }
>
> /* See above. */
> - if (hole_size < num_bytes)
> + if (max_hole_size < num_bytes)
> ret = -ENOSPC;
> else
> ret = 0;
> --
> 1.8.5.1
>
> --
> 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
next prev parent reply other threads:[~2015-04-07 11:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-03 12:11 [PATCH 0/9] btrfs: Fix no_space on dd and rm loop Zhaolei
2015-04-03 12:11 ` [PATCH 1/9] btrfs: fix condition of commit transaction Zhaolei
2015-04-03 12:11 ` [PATCH 2/9] btrfs: Fix tail space processing in find_free_dev_extent() Zhaolei
2015-04-07 11:14 ` Liu Bo [this message]
2015-04-03 12:11 ` [PATCH 3/9] btrfs: Adjust commit-transaction condition to avoid NO_SPACE more Zhaolei
2015-04-03 12:11 ` [PATCH 4/9] btrfs: Set relative data on clear btrfs_block_group_cache->pinned Zhaolei
2015-04-03 12:12 ` [PATCH 5/9] btrfs: add WARN_ON() to check is space_info op current Zhaolei
2015-04-03 12:12 ` [PATCH 6/9] btrfs: Fix NO_SPACE bug caused by delayed-iput Zhaolei
2015-04-03 12:12 ` [PATCH 7/9] btrfs: Support busy loop of write and delete Zhaolei
2015-04-03 12:12 ` [PATCH 8/9] btrfs: wait for delayed iputs on no space Zhaolei
2015-04-03 12:12 ` [PATCH 9/9] btrfs: cleanup unused alloc_chunk varible Zhaolei
-- strict thread matches above, loose matches on Subject: below --
2015-04-09 4:34 [PATCH v2 0/9] btrfs: Fix no_space on dd and rm loop Zhaolei
2015-04-09 4:34 ` [PATCH 2/9] btrfs: Fix tail space processing in find_free_dev_extent() Zhaolei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150407111329.GA30844@localhost.localdomain \
--to=bo.li.liu@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=zhaolei@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).