Commit Graph

12 Commits

Author SHA1 Message Date
Kyle Evans
6966ac055c Drop "All Rights Reserved" from all libbe/bectl files
I sent out an e-mail on 2020/01/21 with a plan to do this to Kyle, Rob, and
Wes; all parties have responded in the affirmative that it's OK to drop it
from these files.
2020-01-24 02:18:09 +00:00
Kyle Evans
8f5c6c31ae libbe(3): promote dependent clones when destroying an environment
When removing a boot environment iterate over the dependents and process the
snapshots by grabbing any clones. Promote the clones we found and then
remove the target environment.

This fixes the ability to destroy a boot environment when it has been used
to spawn one or more other boot environments.

PR:		242592
Submitted by:	Wes Maag <jwmaag gmail com> (with changes by myself)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D22953
2020-01-02 18:46:33 +00:00
Kyle Evans
be7dd42376 libbe(3): Fix be_destroy behavior w.r.t. deep BE snapshots and -o
be_destroy is documented to recursively destroy a boot environment.  In the
case of snapshots, one would take this to mean that these are also
recursively destroyed.  However, this was previously not the case.
be_destroy would descend into the be_destroy callback and attempt to
zfs_iter_children on the top-level snapshot, which is bogus.

Our alternative approach is to take note of the snapshot name and iterate
through all of fs children of the BE to try destruction in the children.

The -o option is also fixed to work properly with deep BEs.  If the BE was
created with `bectl create -e otherDeepBE newDeepBE`, for instance, then a
recursive snapshot of otherDeepBE would have been taken for construction of
newDeepBE but a subsequent destroy with BE_DESTROY_ORIGIN set would only
clean up the snapshot at the root of otherDeepBE: ${BEROOT}/otherDeepBE@...

The most recent iteration instead pretends not to know how these things
work, verifies that the origin is another BE and then passes that back
through be_destroy to DTRT when snapshots and deep BEs may be in play.

MFC after:	1 week
2019-02-13 04:19:08 +00:00
Kyle Evans
162ec56949 libbe(3): Fix error handling with respect to be_exists
Some paths through be_exists will set the error state, others will not
There are multiple reasons that a call can fail, so clean it up a bit: all
paths now return an appropriate error code so the caller can attempt to
distinguish between a BE legitimately not existing and just having the wrong
mountpoint. The caller is expected to bubble the error through to the
internal error handler as needed.

This fixes some unfriendliness with bectl(8)'s activate subcommand, where
it might fail due to a bad mountpoint but the only message output is a
generic "failed to activate" message.

Approved by:	re (gjb)
2018-09-01 02:22:26 +00:00
Kyle Evans
c65a211146 libbe(3): More error handling bits
be_add_child functionality gets split out into separate places as a bonus.
A lot of places here we'll gloss over libzfs errors, because they shouldn't
be happening given the conditions that we're operating under. "Unknown
error" is what I'm intending to use for the moment to indicate an
exceptional circumstance- exceptional enough that we can't tell the consumer
did because we're not so certain that they did anything.
2018-08-10 21:23:56 +00:00
Kyle Evans
2989df090a libbe(3): Clarify some errors
While here, fix a bug with 'rename' that checked the wrong name for being
the active BE.
2018-08-08 03:25:10 +00:00
Kyle Evans
50a1972ed8 Catch up on BE_ERR messages 2018-08-08 03:11:13 +00:00
Kyle Evans
b6e7c421b7 libbe(3)/bectl(8): Standardize $FreeBSD$ IDs 2018-08-07 14:02:41 +00:00
Kyle Evans
b179da0111 libbe(3)/bectl(8): Standardize copyright headers
- File names don't necessarily need to be repeated
- Add SPDX tags
- Add a missing copyright for Kyle Kneitinger in bectl.8, originally written
  by him in GSoC 2017; his standard copyright notice has been copied from
  other files within the same directory to remain consistent with how he
  clearly wished to portray it
2018-08-07 13:46:06 +00:00
Kyle Evans
20b7b8d86c libbe(3): Document that we'll clobber previous errors set by set_error 2018-08-07 03:26:32 +00:00
Kyle Evans
bfe0869c7f libbe(3): make style consistent with what I'll use going forward 2018-07-25 03:50:01 +00:00
Kyle Evans
28f16a0f19 Import libbe(3)/be(1) from socsvn/soc2017/kneitinger/libbe-head 2018-07-24 13:17:40 +00:00