diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-03-13 09:53:04 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:57 -0400 |
commit | aebe7a679cbdd827769e85f632562a66d2a2b9f3 (patch) | |
tree | 5a2e4efe759480e4e8b473d9c43899b20a62fe3e | |
parent | ae1f56238d55ad6d16564455559d1fa9a8cea2f6 (diff) | |
download | lwn-aebe7a679cbdd827769e85f632562a66d2a2b9f3.tar.gz lwn-aebe7a679cbdd827769e85f632562a66d2a2b9f3.zip |
bcachefs: Fix stripe create error path
If we errored out on a new stripe before fully allocating it, we
shouldn't be zeroing out unwritten data.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/ec.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 9ee29dac48ba..74cfd9edd680 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -1078,13 +1078,15 @@ static void ec_stripe_create(struct ec_stripe_new *s) closure_sync(&s->iodone); - for (i = 0; i < nr_data; i++) - if (s->blocks[i]) { - ob = c->open_buckets + s->blocks[i]; + if (!s->err) { + for (i = 0; i < nr_data; i++) + if (s->blocks[i]) { + ob = c->open_buckets + s->blocks[i]; - if (ob->sectors_free) - zero_out_rest_of_ec_bucket(c, s, i, ob); - } + if (ob->sectors_free) + zero_out_rest_of_ec_bucket(c, s, i, ob); + } + } if (s->err) { if (!bch2_err_matches(s->err, EROFS)) |