* [PATCH] btrfs-progs: mkfs: skip failed mount check
@ 2024-05-06 8:46 Qu Wenruo
2024-05-17 16:24 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Qu Wenruo @ 2024-05-06 8:46 UTC (permalink / raw)
To: linux-btrfs; +Cc: Jiri Belka
[BUG]
There is a bug report that, with very weird mount status, there can be
some mount source which can not be accessed:
/hana/shared/QD2/global/hdb/security/ssfs secfs2 500G 57G 444G 12% /hana/shared/QD2/global/hdb/security/ssfs
Strace shows we can not access the above mount source:
131065 stat("/hana/shared/QD2/global/hdb/security/ssfs", 0x7ffed17b8e20) = -1 EACCES (Permission denied)
And lead to failed mount check:
131065 write(2, "ERROR: ", 7) = 7
131065 write(2, "cannot check mount status of /de"..., 56) = 56
131065 write(2, "\n", 1) = 1
[CAUSE]
The mounted check is based on libblid, which gives the mount source, and
for non-btrfs mounts, we call path_is_reg_or_block_device() to check if
we even need to continue checking.
But in above case, the mount source is secfs2, and we can not access the
source.
So we error out causing the check_mounted() to return error.
[FIX]
There is never any guarantee we can access the mount source, but on the
other hand, I do not want to ignore all access failure for the mount
source.
So this patch would let test_status_for_mkfs() to only skip
check_mounted() error if @force_overwrite is true.
This would still keep the old strict checks on whether the target is
already mounted, but if the end user really knows that certain mount
source do not need to be checked, they can always pass "-f" option to
skip the false alerts.
Link: https://bugzilla.suse.com/show_bug.cgi?id=1223799
Reported-by: Jiri Belka <jiri.belka@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
mkfs/common.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mkfs/common.c b/mkfs/common.c
index 3c48a6c120e7..314520397662 100644
--- a/mkfs/common.c
+++ b/mkfs/common.c
@@ -1129,6 +1129,12 @@ bool test_status_for_mkfs(const char *file, bool force_overwrite)
ret = check_mounted(file);
if (ret < 0) {
errno = -ret;
+ if (force_overwrite) {
+ error(
+ "cannot check mount status of %s (%m), skipping the check.",
+ file);
+ return false;
+ }
error("cannot check mount status of %s: %m", file);
return true;
}
--
2.45.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] btrfs-progs: mkfs: skip failed mount check
2024-05-06 8:46 [PATCH] btrfs-progs: mkfs: skip failed mount check Qu Wenruo
@ 2024-05-17 16:24 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2024-05-17 16:24 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs, Jiri Belka
On Mon, May 06, 2024 at 06:16:27PM +0930, Qu Wenruo wrote:
> [BUG]
> There is a bug report that, with very weird mount status, there can be
> some mount source which can not be accessed:
>
> /hana/shared/QD2/global/hdb/security/ssfs secfs2 500G 57G 444G 12% /hana/shared/QD2/global/hdb/security/ssfs
>
> Strace shows we can not access the above mount source:
>
> 131065 stat("/hana/shared/QD2/global/hdb/security/ssfs", 0x7ffed17b8e20) = -1 EACCES (Permission denied)
>
> And lead to failed mount check:
>
> 131065 write(2, "ERROR: ", 7) = 7
> 131065 write(2, "cannot check mount status of /de"..., 56) = 56
> 131065 write(2, "\n", 1) = 1
>
> [CAUSE]
> The mounted check is based on libblid, which gives the mount source, and
> for non-btrfs mounts, we call path_is_reg_or_block_device() to check if
> we even need to continue checking.
>
> But in above case, the mount source is secfs2, and we can not access the
> source.
>
> So we error out causing the check_mounted() to return error.
>
> [FIX]
> There is never any guarantee we can access the mount source, but on the
> other hand, I do not want to ignore all access failure for the mount
> source.
>
> So this patch would let test_status_for_mkfs() to only skip
> check_mounted() error if @force_overwrite is true.
>
> This would still keep the old strict checks on whether the target is
> already mounted, but if the end user really knows that certain mount
> source do not need to be checked, they can always pass "-f" option to
> skip the false alerts.
>
> Link: https://bugzilla.suse.com/show_bug.cgi?id=1223799
> Reported-by: Jiri Belka <jiri.belka@suse.com>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Added to devel, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-17 16:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-06 8:46 [PATCH] btrfs-progs: mkfs: skip failed mount check Qu Wenruo
2024-05-17 16:24 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox