All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe de Dinechin <dinechin@redhat.com>
To: Btrfs BTRFS <linux-btrfs@vger.kernel.org>
Cc: Roman Mamedov <rm@romanrm.net>
Subject: [PATCH 2/3 v2] Prevent attempt to insert extent record with max_size==0
Date: Fri, 28 Apr 2017 11:50:23 +0200	[thread overview]
Message-ID: <74CAC383-4C3A-4C68-9B56-2AB28947E3E3@redhat.com> (raw)
In-Reply-To: <20170428141640.12429352@natsu>

When this happens, we will trip a BUG_ON(end < start) in insert_state
because in check_extent_refs, we use this max_size expecting it's not zero:

  set_extent_dirty(root->fs_info->excluded_extents,
                   rec->start,
                   rec->start + rec->max_size - 1);

See https://bugzilla.redhat.com/show_bug.cgi?id=1435567
for an example where this scenario occurs.

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
---
 cmds-check.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cmds-check.c b/cmds-check.c
index 2d3ebc1..c13f900 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -6029,6 +6029,7 @@ static int add_extent_rec_nolookup(struct cache_tree *extent_cache,
 	struct extent_record *rec;
 	int ret = 0;
 
+	BUG_ON(tmpl->max_size == 0);
 	rec = malloc(sizeof(*rec));
 	if (!rec)
 		return -ENOMEM;
-- 
2.9.3


  reply	other threads:[~2017-04-28  9:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28  9:13 [PATCH 3/3] Make max_size consistent with nr Christophe de Dinechin
2017-04-28  9:16 ` Roman Mamedov
2017-04-28  9:50   ` Christophe de Dinechin [this message]
2017-05-02 16:46     ` [PATCH 2/3 v2] Prevent attempt to insert extent record with max_size==0 David Sterba
2017-04-28  9:51   ` [PATCH 3/3 v2] Make max_size consistent with nr Christophe de Dinechin
2017-05-02 16:53     ` David Sterba

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=74CAC383-4C3A-4C68-9B56-2AB28947E3E3@redhat.com \
    --to=dinechin@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=rm@romanrm.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.