diff mbox series

btrfs: ratelimit device path change info on mounted device

Message ID 20190716135910.848-1-anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs: ratelimit device path change info on mounted device | expand

Commit Message

Anand Jain July 16, 2019, 1:59 p.m. UTC
If there are more than one path to a device, the last scanned path
will map to the mounted FS. In some Linux based os there appears to be a
system script (autofs?) which fails to notice that a device's alternative
path is already mounted, and so the change in device-path gets logged
every ~2mins whenever such a script is active.

kernel: [33017.407252] BTRFS info (device sdc3):
device fsid 4d1ba5af-8b89-4cb5-96c6-55d1f028a202 devid 4 moved
old:/dev/mapper/cryptdata4tb--vg-backup new:/dev/dm-13
kernel: [33017.522242] BTRFS info (device sdc3):
device fsid 4d1ba5af-8b89-4cb5-96c6-55d1f028a202 devid 4 moved
old:/dev/dm-13 new:/dev/mapper/cryptdata4tb--vg-backup
kernel: [33018.797161] BTRFS info (device sdc3):
device fsid 4d1ba5af-8b89-4cb5-96c6-55d1f028a202 devid 4 moved
old:/dev/mapper/cryptdata4tb--vg-backup new:/dev/dm-13
kernel: [33019.061631] BTRFS info (device sdc3):
device fsid 4d1ba5af-8b89-4cb5-96c6-55d1f028a202 devid 4 moved
old:/dev/dm-13 new:/dev/mapper/cryptdata4tb--vg-backup

Fix this by using the ratelimit printk.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reported-by: g.btrfs@cobb.uk.net
Reported-by: calestyo@scientia.net
---
 fs/btrfs/volumes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Anand Jain July 16, 2019, 2:08 p.m. UTC | #1
Graham, Chris,

  I am unable to reproduce, would you be able to try this patch and let 
me know if this fixes the problem?

Thanks, Anand


On 16/7/19 9:59 PM, Anand Jain wrote:
> If there are more than one path to a device, the last scanned path
> will map to the mounted FS. In some Linux based os there appears to be a
> system script (autofs?) which fails to notice that a device's alternative
> path is already mounted, and so the change in device-path gets logged
> every ~2mins whenever such a script is active.
> 
> kernel: [33017.407252] BTRFS info (device sdc3):
> device fsid 4d1ba5af-8b89-4cb5-96c6-55d1f028a202 devid 4 moved
> old:/dev/mapper/cryptdata4tb--vg-backup new:/dev/dm-13
> kernel: [33017.522242] BTRFS info (device sdc3):
> device fsid 4d1ba5af-8b89-4cb5-96c6-55d1f028a202 devid 4 moved
> old:/dev/dm-13 new:/dev/mapper/cryptdata4tb--vg-backup
> kernel: [33018.797161] BTRFS info (device sdc3):
> device fsid 4d1ba5af-8b89-4cb5-96c6-55d1f028a202 devid 4 moved
> old:/dev/mapper/cryptdata4tb--vg-backup new:/dev/dm-13
> kernel: [33019.061631] BTRFS info (device sdc3):
> device fsid 4d1ba5af-8b89-4cb5-96c6-55d1f028a202 devid 4 moved
> old:/dev/dm-13 new:/dev/mapper/cryptdata4tb--vg-backup
> 
> Fix this by using the ratelimit printk.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> Reported-by: g.btrfs@cobb.uk.net
> Reported-by: calestyo@scientia.net
> ---
>   fs/btrfs/volumes.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index a13ddba1ebc3..b4c4add7b5e7 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -1086,7 +1086,7 @@ static noinline struct btrfs_device *device_list_add(const char *path,
>   				return ERR_PTR(-EEXIST);
>   			}
>   			bdput(path_bdev);
> -			btrfs_info_in_rcu(device->fs_info,
> +			btrfs_info_rl_in_rcu(device->fs_info,
>   				"device fsid %pU devid %llu moved old:%s new:%s",
>   				disk_super->fsid, devid,
>   				rcu_str_deref(device->name), path);
>
David Sterba July 19, 2019, 2:58 p.m. UTC | #2
On Tue, Jul 16, 2019 at 09:59:10PM +0800, Anand Jain wrote:
> If there are more than one path to a device, the last scanned path
> will map to the mounted FS. In some Linux based os there appears to be a
> system script (autofs?) which fails to notice that a device's alternative
> path is already mounted, and so the change in device-path gets logged
> every ~2mins whenever such a script is active.
> 
> kernel: [33017.407252] BTRFS info (device sdc3):
> device fsid 4d1ba5af-8b89-4cb5-96c6-55d1f028a202 devid 4 moved
> old:/dev/mapper/cryptdata4tb--vg-backup new:/dev/dm-13
> kernel: [33017.522242] BTRFS info (device sdc3):
> device fsid 4d1ba5af-8b89-4cb5-96c6-55d1f028a202 devid 4 moved
> old:/dev/dm-13 new:/dev/mapper/cryptdata4tb--vg-backup
> kernel: [33018.797161] BTRFS info (device sdc3):
> device fsid 4d1ba5af-8b89-4cb5-96c6-55d1f028a202 devid 4 moved
> old:/dev/mapper/cryptdata4tb--vg-backup new:/dev/dm-13
> kernel: [33019.061631] BTRFS info (device sdc3):
> device fsid 4d1ba5af-8b89-4cb5-96c6-55d1f028a202 devid 4 moved
> old:/dev/dm-13 new:/dev/mapper/cryptdata4tb--vg-backup
> 
> Fix this by using the ratelimit printk.

The ratelimiting will most certainly not stop the repeated messages,
btrfs_info_rl_in_rcu uses the default settings which is to limit within
5 seconds and allow burts of 10 messages.
diff mbox series

Patch

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index a13ddba1ebc3..b4c4add7b5e7 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1086,7 +1086,7 @@  static noinline struct btrfs_device *device_list_add(const char *path,
 				return ERR_PTR(-EEXIST);
 			}
 			bdput(path_bdev);
-			btrfs_info_in_rcu(device->fs_info,
+			btrfs_info_rl_in_rcu(device->fs_info,
 				"device fsid %pU devid %llu moved old:%s new:%s",
 				disk_super->fsid, devid,
 				rcu_str_deref(device->name), path);