diff mbox

[2/2,v2] btrfs: device delete must be sysloged

Message ID 1404265052-29424-2-git-send-email-Anand.Jain@oracle.com (mailing list archive)
State Accepted
Headers show

Commit Message

Anand Jain July 2, 2014, 1:37 a.m. UTC
as in the disk add patch, disk detached from the volume must be
recorded in the syslog as well for the same reason.

Signed-off-by: Anand Jain <Anand.Jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
---
 v2: Accepts David's review comments, thanks

 fs/btrfs/ioctl.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Satoru Takeuchi July 2, 2014, 7:03 a.m. UTC | #1
(2014/07/02 10:37), Anand Jain wrote:
> as in the disk add patch, disk detached from the volume must be
> recorded in the syslog as well for the same reason.
> 
> Signed-off-by: Anand Jain <Anand.Jain@oracle.com>
> Reviewed-by: David Sterba <dsterba@suse.cz>

Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Tested-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>

test result:
  3.16-rc3: failed
  3.16-rc3 with these patches: success

===============================================================================
#!/bin/sh

TEST_DEV1=/dev/vdb
TEST_DEV2=/dev/vdc
TEST_MNT=/home/sat/mnt

umount $TEST_MNT
mkfs.btrfs -f $TEST_DEV1
dmesg >dmesg.old

mount $TEST_DEV1 $TEST_MNT
btrfs dev add -f $TEST_DEV2 $TEST_MNT
if [ $? -ne 0 ] ; then
    echo "[ERROR] failed to btrfs dev add." >&2
    exit 1
fi

btrfs dev del $TEST_DEV2 $TEST_MNT
if [ $? -ne 0 ] ; then
    echo "[ERROR] failed to btrfs dev delete" >&2
    exit 1
fi

dmesg >dmesg.new
diff dmesg.old dmesg.new | grep '^>' >dmesg.diff

RET=0
TEST_DEV1_BASE=$(basename $TEST_DEV1)
if grep -q "BTRFS info (device $TEST_DEV1_BASE): device added $TEST_DEV2" dmesg.diff ; then
    echo "[PASS] btrfs device add is logged." >&2
else
    echo "[FAIL] btrfs device add is not logged." >&2
    RET=1
fi
    
if grep -q "BTRFS info (device $TEST_DEV1_BASE): device deleted $TEST_DEV2" dmesg.diff ; then
    echo "[PASS] btrfs device delete is logged." >&2
else
    echo "[FAIL] btrfs device delete is not logged." >&2
    RET=1
fi

rm dmesg.{new,old,diff}
umount $TEST_MNT

exit $RET
===============================================================================

Thanks,
Satoru



> ---
>   v2: Accepts David's review comments, thanks
> 
>   fs/btrfs/ioctl.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 4e10259..016a5eb 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -2531,6 +2531,10 @@ static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg)
>   	mutex_unlock(&root->fs_info->volume_mutex);
>   	atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0);
>   
> +	if (!ret)
> +		btrfs_info(root->fs_info, "device deleted %s",
> +							vol_args->name);
> +
>   out:
>   	kfree(vol_args);
>   	mnt_drop_write_file(file);
> 

--
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/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 4e10259..016a5eb 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2531,6 +2531,10 @@  static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg)
 	mutex_unlock(&root->fs_info->volume_mutex);
 	atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0);
 
+	if (!ret)
+		btrfs_info(root->fs_info, "device deleted %s",
+							vol_args->name);
+
 out:
 	kfree(vol_args);
 	mnt_drop_write_file(file);