diff mbox

[12/14] btrfs-progs: Issue warnings if ioctls fail in sigint handlers

Message ID 1362436804-16766-13-git-send-email-sandeen@redhat.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Eric Sandeen March 4, 2013, 10:40 p.m. UTC
The two sigint handlers issue ioctls to clean up, but if
they fail, noone would know.  I'm not sure there is
any other error handling to be done at this point, but a
notification seems wise.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 cmds-replace.c |    5 ++++-
 cmds-scrub.c   |    6 +++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

Comments

Zach Brown March 4, 2013, 9:57 p.m. UTC | #1
> +	ret = ioctl(cancel_fd, BTRFS_IOC_SCRUB_CANCEL, NULL);
> +	if (ret < 0)
> +		perror("Scrub cancel failed\n");

Probably don't want the extra newline.

- z
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Sandeen March 4, 2013, 10:34 p.m. UTC | #2
On 3/4/13 3:57 PM, Zach Brown wrote:
>> +	ret = ioctl(cancel_fd, BTRFS_IOC_SCRUB_CANCEL, NULL);
>> +	if (ret < 0)
>> +		perror("Scrub cancel failed\n");
> 
> Probably don't want the extra newline.
> 
> - z
> 

Doh, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/cmds-replace.c b/cmds-replace.c
index 4cc32df..10030f6 100644
--- a/cmds-replace.c
+++ b/cmds-replace.c
@@ -77,10 +77,13 @@  static int is_numerical(const char *str)
 static int dev_replace_cancel_fd = -1;
 static void dev_replace_sigint_handler(int signal)
 {
+	int ret;
 	struct btrfs_ioctl_dev_replace_args args = {0};
 
 	args.cmd = BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL;
-	ioctl(dev_replace_cancel_fd, BTRFS_IOC_DEV_REPLACE, &args);
+	ret = ioctl(dev_replace_cancel_fd, BTRFS_IOC_DEV_REPLACE, &args);
+	if (ret < 0)
+		perror("Device replace cancel failed");
 }
 
 static int dev_replace_handle_sigint(int fd)
diff --git a/cmds-scrub.c b/cmds-scrub.c
index da4120f..f73b3c6 100644
--- a/cmds-scrub.c
+++ b/cmds-scrub.c
@@ -287,7 +287,11 @@  static void free_history(struct scrub_file_record **last_scrubs)
 static int cancel_fd = -1;
 static void scrub_sigint_record_progress(int signal)
 {
-	ioctl(cancel_fd, BTRFS_IOC_SCRUB_CANCEL, NULL);
+	int ret;
+
+	ret = ioctl(cancel_fd, BTRFS_IOC_SCRUB_CANCEL, NULL);
+	if (ret < 0)
+		perror("Scrub cancel failed\n");
 }
 
 static int scrub_handle_sigint_parent(void)