diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-11-25 18:29:36 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:47 -0400 |
commit | e2fcf7f6306f12c50ad2ec655fdb8d1918c23bdd (patch) | |
tree | 197a7cf7d6abb1c77cd1b805fe99836dfc29387d /fs/bcachefs/chardev.c | |
parent | 447e92274af6c7e8dcdc7921a6af238afcc87a0a (diff) | |
download | linux-stable-e2fcf7f6306f12c50ad2ec655fdb8d1918c23bdd.tar.gz linux-stable-e2fcf7f6306f12c50ad2ec655fdb8d1918c23bdd.tar.bz2 linux-stable-e2fcf7f6306f12c50ad2ec655fdb8d1918c23bdd.zip |
bcachefs: Fix BCH_IOCTL_DISK_SET_STATE
- Ensure we print an error message if necessary.
Ideally we'd return the precise error code to userspace and leave
printing the error message to the userspace tool, but we haven't
decided to make our private error codes ABI-stable yet.
- Return standard error code to userspace
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/chardev.c')
-rw-r--r-- | fs/bcachefs/chardev.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c index 7b448b9551b6..28854a6c31b9 100644 --- a/fs/bcachefs/chardev.c +++ b/fs/bcachefs/chardev.c @@ -284,6 +284,8 @@ static long bch2_ioctl_disk_set_state(struct bch_fs *c, return PTR_ERR(ca); ret = bch2_dev_set_state(c, ca, arg.new_state, arg.flags); + if (ret) + bch_err(c, "Error setting device state: %s", bch2_err_str(ret)); percpu_ref_put(&ca->ref); return ret; @@ -631,11 +633,14 @@ do { \ \ if (copy_from_user(&i, arg, sizeof(i))) \ return -EFAULT; \ - return bch2_ioctl_##_name(c, i); \ + ret = bch2_ioctl_##_name(c, i); \ + goto out; \ } while (0) long bch2_fs_ioctl(struct bch_fs *c, unsigned cmd, void __user *arg) { + long ret; + switch (cmd) { case BCH_IOCTL_QUERY_UUID: return bch2_ioctl_query_uuid(c, arg); @@ -679,6 +684,10 @@ long bch2_fs_ioctl(struct bch_fs *c, unsigned cmd, void __user *arg) default: return -ENOTTY; } +out: + if (ret < 0) + ret = bch2_err_class(ret); + return ret; } static DEFINE_IDR(bch_chardev_minor); |