History

btrfs: device delete to get errors from the kernel

when user runs command btrfs dev del the raid requisite error if any goes to the /var/log/messages, its not good idea to clutter messages with these user (knowledge) errors, further user don't have to review the system messages to know problem with the cli it should be dropped to the user as part of the cli return. to bring this feature created a set of the ERROR defined BTRFS_ERROR_DEV* error codes and created their error string. I expect this enum to be added with other error which we might want to communicate to the user land v3: moved the code with in the file no logical change v1->v2: introduce error codes for the device mgmt usage v1: adds a parameter in the ioctl arg struct to carry the error string

Anand Jain committed 13 years ago

Commit 183860f1 parent c73e2933 files · +58 −31Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/btrfs.h+40−1
@@ -447,6 +447,46 @@ struct btrfs_ioctl_send_args { · 446 unmodified lines
447447 __u64 reserved[4]; /* in */
448448 };
449449
450+/* Error codes as returned by the kernel */
451+enum btrfs_err_code {
452+ notused,
453+ BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET,
454+ BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET,
455+ BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET,
456+ BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET,
457+ BTRFS_ERROR_DEV_TGT_REPLACE,
458+ BTRFS_ERROR_DEV_MISSING_NOT_FOUND,
459+ BTRFS_ERROR_DEV_ONLY_WRITABLE,
460+ BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS
461+};
462+/* An error code to error string mapping for the kernel
463+* error codes
464+*/
465+static inline char *btrfs_err_str(enum btrfs_err_code err_code)
466+{
467+ switch (err_code) {
468+ case BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET:
469+ return "unable to go below two devices on raid1";
470+ case BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET:
471+ return "unable to go below four devices on raid10";
472+ case BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET:
473+ return "unable to go below two devices on raid5";
474+ case BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET:
475+ return "unable to go below three devices on raid6";
476+ case BTRFS_ERROR_DEV_TGT_REPLACE:
477+ return "unable to remove the dev_replace target dev";
478+ case BTRFS_ERROR_DEV_MISSING_NOT_FOUND:
479+ return "no missing devices found to remove";
480+ case BTRFS_ERROR_DEV_ONLY_WRITABLE:
481+ return "unable to remove the only writeable device";
482+ case BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS:
483+ return "add/delete/balance/replace/resize operation "\
484+ "in progress";
485+ default:
486+ return NULL;
487+ }
488+}
489+
450490 #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
451491 struct btrfs_ioctl_vol_args)
452492 #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
@@ -539,5 +579,4 @@ struct btrfs_ioctl_send_args { · 86 unmodified lines
539579 struct btrfs_ioctl_get_dev_stats)
540580 #define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, \
541581 struct btrfs_ioctl_dev_replace_args)
542−
543582 #endif /* _UAPI_LINUX_BTRFS_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t