Skip to content

Added a more descriptive error message due the destroy failure #17234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025

Conversation

ghost
Copy link

@ghost ghost commented Apr 10, 2025

Motivation and Context

Change improves interaction with the user. Makes an error message more understandable and descriptive.

Fixes #14538

Description

Previously, the destroy failure due to a long hold returned a standard error message: dataset is busy
This could cause misunderstanding and confusion among users.
The change makes the error message more understandable and definite, displaying the presence of the holder.

This is implemented by performing an additional check for the presence of holders.
If any, displayed: held by "holder" instead of dataset is busy

Before:

sudo zfs snapshot rpool@test
sudo zfs hold example rpool@test
sudo zfs destroy rpool@test
cannot destroy snapshot rpool@test: dataset is busy
sudo zfs release example rpool@test
sudo zfs destroy rpool@test

After:

sudo zfs snapshot rpool@test
sudo zfs hold example rpool@test
sudo zfs destroy rpool@test
cannot destroy snapshot rpool@test: held by example
sudo zfs release example rpool@test
sudo zfs destroy rpool@test

How Has This Been Tested?

Run the commands in the different combinations.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

Copy link
Member

@amotin amotin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More detailed errors are always great, but I don't very like that additional details are not obtained atomically from the original error, but fetched separately, so they might be out of sync, theoretically confusing.

@amotin
Copy link
Member

amotin commented Apr 10, 2025

Also seems it failed to build:

   CC       lib/libzfs/libzfs_la-libzfs_import.lo
  lib/libzfs/libzfs_dataset.c: In function 'zfs_destroy_snaps_nvl':
  lib/libzfs/libzfs_dataset.c:4032:4: error: a label can only be part of a statement and a declaration is not a statement
      nvlist_t *existing_holds;
      ^~~~~~~~

Or in Clang:

  lib/libzfs/libzfs_dataset.c:4032:4: error: label followed by a declaration is a C23 extension [-Werror,-Wc23-extensions]
   4032 |                         nvlist_t *existing_holds;
        |                         ^
  1 error generated.

@ghost
Copy link
Author

ghost commented Apr 10, 2025

Sorry, I did not notice this problem. Everything went smoothly on my device.
build_libzfs_dataset lo

Perhaps other compiler requires that the nvlist_t *existing_holds declaration should be outside switch...case or something. I'll try to figure it out.

@amotin amotin added the Status: Code Review Needed Ready for review and testing label Apr 11, 2025
Copy link
Contributor

@AttilaFueloep AttilaFueloep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with amotin about the non-atomicity of the change. Still I think this is a nice improvement, pointing at the hold will benefit users. On the net you'll find a lot of question asked by users confused by the fact they couldn't delete seemingly unused datasets.

As a side note, in this case I think it's OK not to indent the block contents since that would harm readability. What does checkstyle say, by the way?

@ghost
Copy link
Author

ghost commented Apr 11, 2025

On my side, the checkstyle was successful.
If indent the block, then it will not fit into the permissible length of the line.

@amotin
Copy link
Member

amotin commented Apr 11, 2025

@Artem-OSSRevival If you search for other examples, more typical is to open the braces at the end of case line and close on the line after break, aligned to the next case. This way you don't need additional indentation.

@amotin
Copy link
Member

amotin commented Apr 11, 2025

Not exactly. Just search for ': {'.

@ghost
Copy link
Author

ghost commented Apr 11, 2025

I understood correctly? I can now fix the commit.
braces2

@AttilaFueloep
Copy link
Contributor

Yeah, I think this is the best solution.

@AttilaFueloep
Copy link
Contributor

Still looks good.

@AttilaFueloep
Copy link
Contributor

To summarize, as initially written it required C23, starting with C99 case X:; would do the trick, and as it is now, it works from C89 onwards.

Copy link
Contributor

@mcmilk mcmilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two commits should be merged.

@ghost ghost closed this Apr 13, 2025
@ghost ghost reopened this Apr 13, 2025
@ghost ghost closed this Apr 14, 2025
@ghost ghost reopened this Apr 14, 2025
@ghost ghost closed this Apr 14, 2025
@ghost ghost reopened this Apr 14, 2025
@amotin amotin added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Apr 15, 2025
@amotin amotin added Status: Code Review Needed Ready for review and testing and removed Status: Accepted Ready to integrate (reviewed, tested) labels Apr 15, 2025
@ghost ghost closed this Apr 15, 2025
@amotin
Copy link
Member

amotin commented Apr 15, 2025

@Artem-OSSRevival I really wonder what is your workflow that includes PR closing/reopen?

@ghost
Copy link
Author

ghost commented Apr 15, 2025

To remove the current commit and there were no several ones.

@ghost ghost reopened this Apr 15, 2025
@amotin
Copy link
Member

amotin commented Apr 15, 2025

@Artem-OSSRevival Everybody else just force-push updated and possibly rebased commits. You don't need to remove the old one, just amend it and force-push.

@tonyhutter tonyhutter added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Apr 23, 2025
@amotin amotin merged commit 37a3e26 into openzfs:master Apr 24, 2025
18 of 24 checks passed
snajpa pushed a commit to vpsfreecz/zfs that referenced this pull request May 2, 2025
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Tino Reichardt <[email protected]>
Reviewed by: Attila Fülöp <[email protected]>
Signed-off-by: Artem-OSSRevival <[email protected]>
Fixes: openzfs#14538
Closes: openzfs#17234
robn pushed a commit to robn/zfs that referenced this pull request May 23, 2025
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Tino Reichardt <[email protected]>
Reviewed by: Attila Fülöp <[email protected]>
Signed-off-by: Artem-OSSRevival <[email protected]>
Fixes: openzfs#14538
Closes: openzfs#17234
(cherry picked from commit 37a3e26)
@robn robn mentioned this pull request May 23, 2025
14 tasks
robn pushed a commit to robn/zfs that referenced this pull request May 24, 2025
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Tino Reichardt <[email protected]>
Reviewed by: Attila Fülöp <[email protected]>
Signed-off-by: Artem-OSSRevival <[email protected]>
Fixes: openzfs#14538
Closes: openzfs#17234
(cherry picked from commit 37a3e26)
tonyhutter pushed a commit that referenced this pull request May 28, 2025
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Tino Reichardt <[email protected]>
Reviewed by: Attila Fülöp <[email protected]>
Signed-off-by: Artem-OSSRevival <[email protected]>
Fixes: #14538
Closes: #17234
(cherry picked from commit 37a3e26)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zfs destroy failure due to a long hold should return a more descriptive error message
4 participants