* [PATCH 1/1] btrfs: log, when replace, is canceled by the user
@ 2018-02-12 15:36 Anand Jain
2018-02-13 1:47 ` Qu Wenruo
2018-02-13 3:53 ` [PATCH v2] " Anand Jain
0 siblings, 2 replies; 8+ messages in thread
From: Anand Jain @ 2018-02-12 15:36 UTC (permalink / raw)
To: linux-btrfs
For forensic investigations of issues, we would want to know
if and when the user cancels the replace.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/dev-replace.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 197be3fe307b..83eb2d32b477 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -711,6 +711,7 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
{
struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
struct btrfs_device *tgt_device = NULL;
+ struct btrfs_device *src_device = NULL;
struct btrfs_trans_handle *trans;
struct btrfs_root *root = fs_info->tree_root;
u64 result;
@@ -732,6 +733,7 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED:
result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
tgt_device = dev_replace->tgtdev;
+ src_device = dev_replace->srcdev;
dev_replace->tgtdev = NULL;
dev_replace->srcdev = NULL;
break;
@@ -749,6 +751,11 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
}
ret = btrfs_commit_transaction(trans);
WARN_ON(ret);
+
+ btrfs_info(fs_info, "dev_replace from %s (devid %llu) to %s canceled",
+ btrfs_dev_name(src_device), src_device->devid,
+ rcu_str_deref(tgt_device->name));
+
if (tgt_device)
btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device);
--
2.15.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] btrfs: log, when replace, is canceled by the user
2018-02-12 15:36 [PATCH 1/1] btrfs: log, when replace, is canceled by the user Anand Jain
@ 2018-02-13 1:47 ` Qu Wenruo
2018-02-13 3:50 ` Anand Jain
2018-02-13 3:53 ` [PATCH v2] " Anand Jain
1 sibling, 1 reply; 8+ messages in thread
From: Qu Wenruo @ 2018-02-13 1:47 UTC (permalink / raw)
To: Anand Jain, linux-btrfs
[-- Attachment #1.1: Type: text/plain, Size: 1796 bytes --]
On 2018年02月12日 23:36, Anand Jain wrote:
> For forensic investigations of issues, we would want to know
> if and when the user cancels the replace.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> fs/btrfs/dev-replace.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
> index 197be3fe307b..83eb2d32b477 100644
> --- a/fs/btrfs/dev-replace.c
> +++ b/fs/btrfs/dev-replace.c
> @@ -711,6 +711,7 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
> {
> struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
> struct btrfs_device *tgt_device = NULL;
> + struct btrfs_device *src_device = NULL;
> struct btrfs_trans_handle *trans;
> struct btrfs_root *root = fs_info->tree_root;
> u64 result;
> @@ -732,6 +733,7 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
> case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED:
> result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
> tgt_device = dev_replace->tgtdev;
> + src_device = dev_replace->srcdev;
> dev_replace->tgtdev = NULL;
> dev_replace->srcdev = NULL;
> break;
> @@ -749,6 +751,11 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
> }
> ret = btrfs_commit_transaction(trans);
> WARN_ON(ret);
> +
> + btrfs_info(fs_info, "dev_replace from %s (devid %llu) to %s canceled",
> + btrfs_dev_name(src_device), src_device->devid,
> + rcu_str_deref(tgt_device->name));
The behavior is quite good.
Although I'm wondering why for @src_device we use btrfs_dev_name() but
rcu_str_deref() for @tgt_device?
Thanks,
Qu
> +
> if (tgt_device)
> btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device);
>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 520 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] btrfs: log, when replace, is canceled by the user
2018-02-13 1:47 ` Qu Wenruo
@ 2018-02-13 3:50 ` Anand Jain
0 siblings, 0 replies; 8+ messages in thread
From: Anand Jain @ 2018-02-13 3:50 UTC (permalink / raw)
To: Qu Wenruo, linux-btrfs
>> +
>> + btrfs_info(fs_info, "dev_replace from %s (devid %llu) to %s canceled",
>> + btrfs_dev_name(src_device), src_device->devid,
>> + rcu_str_deref(tgt_device->name));
>
> The behavior is quite good.
>
> Although I'm wondering why for @src_device we use btrfs_dev_name() but
> rcu_str_deref() for @tgt_device?
Thanks for the comments.
My bad. In fact, I must use btrfs_dev_name() for tgt_device since
the tgt_device can be missing (-o degraded) when the user decides
to cancel.
Thanks, Anand
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] btrfs: log, when replace, is canceled by the user
2018-02-12 15:36 [PATCH 1/1] btrfs: log, when replace, is canceled by the user Anand Jain
2018-02-13 1:47 ` Qu Wenruo
@ 2018-02-13 3:53 ` Anand Jain
2018-02-13 9:05 ` Qu Wenruo
2018-02-13 17:04 ` David Sterba
1 sibling, 2 replies; 8+ messages in thread
From: Anand Jain @ 2018-02-13 3:53 UTC (permalink / raw)
To: linux-btrfs
For forensic investigations of issues, we would want to know
if and when the user cancels the replace.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v1->v2: use btrfs_dev_name() instead of rcu_str_deref()
as btrfs_dev_name() also provides "missing" string,
if needed.
fs/btrfs/dev-replace.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index dd717e204b5e..3b0760f7ec8a 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -703,6 +703,7 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
{
struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
struct btrfs_device *tgt_device = NULL;
+ struct btrfs_device *src_device = NULL;
struct btrfs_trans_handle *trans;
struct btrfs_root *root = fs_info->tree_root;
int result;
@@ -724,6 +725,7 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED:
result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
tgt_device = dev_replace->tgtdev;
+ src_device = dev_replace->srcdev;
dev_replace->tgtdev = NULL;
dev_replace->srcdev = NULL;
break;
@@ -741,6 +743,11 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
}
ret = btrfs_commit_transaction(trans);
WARN_ON(ret);
+
+ btrfs_info(fs_info, "dev_replace from %s (devid %llu) to %s canceled",
+ btrfs_dev_name(src_device), src_device->devid,
+ btrfs_dev_name(tgt_device));
+
if (tgt_device)
btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device);
--
2.15.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] btrfs: log, when replace, is canceled by the user
2018-02-13 3:53 ` [PATCH v2] " Anand Jain
@ 2018-02-13 9:05 ` Qu Wenruo
2018-02-13 9:08 ` Nikolay Borisov
2018-02-13 17:04 ` David Sterba
1 sibling, 1 reply; 8+ messages in thread
From: Qu Wenruo @ 2018-02-13 9:05 UTC (permalink / raw)
To: Anand Jain, linux-btrfs
[-- Attachment #1.1: Type: text/plain, Size: 1886 bytes --]
On 2018年02月13日 11:53, Anand Jain wrote:
> For forensic investigations of issues, we would want to know
> if and when the user cancels the replace.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>> ---
> v1->v2: use btrfs_dev_name() instead of rcu_str_deref()
> as btrfs_dev_name() also provides "missing" string,
> if needed.
Would you please provide the branch you're using?
As I couldn't find the function or macro of btrfs_dev_name()
Thanks,
Qu
>
> fs/btrfs/dev-replace.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
> index dd717e204b5e..3b0760f7ec8a 100644
> --- a/fs/btrfs/dev-replace.c
> +++ b/fs/btrfs/dev-replace.c
> @@ -703,6 +703,7 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
> {
> struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
> struct btrfs_device *tgt_device = NULL;
> + struct btrfs_device *src_device = NULL;
> struct btrfs_trans_handle *trans;
> struct btrfs_root *root = fs_info->tree_root;
> int result;
> @@ -724,6 +725,7 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
> case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED:
> result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
> tgt_device = dev_replace->tgtdev;
> + src_device = dev_replace->srcdev;
> dev_replace->tgtdev = NULL;
> dev_replace->srcdev = NULL;
> break;
> @@ -741,6 +743,11 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
> }
> ret = btrfs_commit_transaction(trans);
> WARN_ON(ret);
> +
> + btrfs_info(fs_info, "dev_replace from %s (devid %llu) to %s canceled",
> + btrfs_dev_name(src_device), src_device->devid,
> + btrfs_dev_name(tgt_device));
> +
> if (tgt_device)
> btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device);
>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 520 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] btrfs: log, when replace, is canceled by the user
2018-02-13 9:05 ` Qu Wenruo
@ 2018-02-13 9:08 ` Nikolay Borisov
2018-02-13 9:10 ` Qu Wenruo
0 siblings, 1 reply; 8+ messages in thread
From: Nikolay Borisov @ 2018-02-13 9:08 UTC (permalink / raw)
To: Qu Wenruo, Anand Jain, linux-btrfs
On 13.02.2018 11:05, Qu Wenruo wrote:
>
>
> On 2018年02月13日 11:53, Anand Jain wrote:
>> For forensic investigations of issues, we would want to know
>> if and when the user cancels the replace.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>> ---
>> v1->v2: use btrfs_dev_name() instead of rcu_str_deref()
>> as btrfs_dev_name() also provides "missing" string,
>> if needed.
>
> Would you please provide the branch you're using?
>
> As I couldn't find the function or macro of btrfs_dev_name()
I have it in my misc-next checkout. I got introduced by
3c958bd23b60 ("btrfs: add helper for device path or missing")
which is in 4.16-rc1 so pretty recent.
>
> Thanks,
> Qu
>
>>
>> fs/btrfs/dev-replace.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
>> index dd717e204b5e..3b0760f7ec8a 100644
>> --- a/fs/btrfs/dev-replace.c
>> +++ b/fs/btrfs/dev-replace.c
>> @@ -703,6 +703,7 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
>> {
>> struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
>> struct btrfs_device *tgt_device = NULL;
>> + struct btrfs_device *src_device = NULL;
>> struct btrfs_trans_handle *trans;
>> struct btrfs_root *root = fs_info->tree_root;
>> int result;
>> @@ -724,6 +725,7 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
>> case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED:
>> result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
>> tgt_device = dev_replace->tgtdev;
>> + src_device = dev_replace->srcdev;
>> dev_replace->tgtdev = NULL;
>> dev_replace->srcdev = NULL;
>> break;
>> @@ -741,6 +743,11 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
>> }
>> ret = btrfs_commit_transaction(trans);
>> WARN_ON(ret);
>> +
>> + btrfs_info(fs_info, "dev_replace from %s (devid %llu) to %s canceled",
>> + btrfs_dev_name(src_device), src_device->devid,
>> + btrfs_dev_name(tgt_device));
>> +
>> if (tgt_device)
>> btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device);
>>
>>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] btrfs: log, when replace, is canceled by the user
2018-02-13 9:08 ` Nikolay Borisov
@ 2018-02-13 9:10 ` Qu Wenruo
0 siblings, 0 replies; 8+ messages in thread
From: Qu Wenruo @ 2018-02-13 9:10 UTC (permalink / raw)
To: Nikolay Borisov, Anand Jain, linux-btrfs
[-- Attachment #1.1: Type: text/plain, Size: 2580 bytes --]
On 2018年02月13日 17:08, Nikolay Borisov wrote:
>
>
> On 13.02.2018 11:05, Qu Wenruo wrote:
>>
>>
>> On 2018年02月13日 11:53, Anand Jain wrote:
>>> For forensic investigations of issues, we would want to know
>>> if and when the user cancels the replace.
>>>
>>> Signed-off-by: Anand Jain <anand.jain@oracle.com>> ---
>>> v1->v2: use btrfs_dev_name() instead of rcu_str_deref()
>>> as btrfs_dev_name() also provides "missing" string,
>>> if needed.
>>
>> Would you please provide the branch you're using?
>>
>> As I couldn't find the function or macro of btrfs_dev_name()
>
>
> I have it in my misc-next checkout. I got introduced by
> 3c958bd23b60 ("btrfs: add helper for device path or missing")
>
> which is in 4.16-rc1 so pretty recent.
I was on v4.15, no wonder no such function.
Thank you very much,
Qu
>
>
>>
>> Thanks,
>> Qu
>>
>>>
>>> fs/btrfs/dev-replace.c | 7 +++++++
>>> 1 file changed, 7 insertions(+)
>>>
>>> diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
>>> index dd717e204b5e..3b0760f7ec8a 100644
>>> --- a/fs/btrfs/dev-replace.c
>>> +++ b/fs/btrfs/dev-replace.c
>>> @@ -703,6 +703,7 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
>>> {
>>> struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
>>> struct btrfs_device *tgt_device = NULL;
>>> + struct btrfs_device *src_device = NULL;
>>> struct btrfs_trans_handle *trans;
>>> struct btrfs_root *root = fs_info->tree_root;
>>> int result;
>>> @@ -724,6 +725,7 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
>>> case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED:
>>> result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
>>> tgt_device = dev_replace->tgtdev;
>>> + src_device = dev_replace->srcdev;
>>> dev_replace->tgtdev = NULL;
>>> dev_replace->srcdev = NULL;
>>> break;
>>> @@ -741,6 +743,11 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
>>> }
>>> ret = btrfs_commit_transaction(trans);
>>> WARN_ON(ret);
>>> +
>>> + btrfs_info(fs_info, "dev_replace from %s (devid %llu) to %s canceled",
>>> + btrfs_dev_name(src_device), src_device->devid,
>>> + btrfs_dev_name(tgt_device));
>>> +
>>> if (tgt_device)
>>> btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device);
>>>
>>>
>>
> --
> 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
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 520 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] btrfs: log, when replace, is canceled by the user
2018-02-13 3:53 ` [PATCH v2] " Anand Jain
2018-02-13 9:05 ` Qu Wenruo
@ 2018-02-13 17:04 ` David Sterba
1 sibling, 0 replies; 8+ messages in thread
From: David Sterba @ 2018-02-13 17:04 UTC (permalink / raw)
To: Anand Jain; +Cc: linux-btrfs
On Tue, Feb 13, 2018 at 11:53:43AM +0800, Anand Jain wrote:
> For forensic investigations of issues, we would want to know
> if and when the user cancels the replace.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
I've updated the changelog a bit.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-02-13 17:06 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-12 15:36 [PATCH 1/1] btrfs: log, when replace, is canceled by the user Anand Jain
2018-02-13 1:47 ` Qu Wenruo
2018-02-13 3:50 ` Anand Jain
2018-02-13 3:53 ` [PATCH v2] " Anand Jain
2018-02-13 9:05 ` Qu Wenruo
2018-02-13 9:08 ` Nikolay Borisov
2018-02-13 9:10 ` Qu Wenruo
2018-02-13 17:04 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).