* [PATCH] xfs_healer: update weakhandle mountpoint when reconnecting
@ 2026-04-13 3:56 Darrick J. Wong
2026-04-13 9:56 ` Andrey Albershteyn
2026-04-15 5:35 ` Christoph Hellwig
0 siblings, 2 replies; 3+ messages in thread
From: Darrick J. Wong @ 2026-04-13 3:56 UTC (permalink / raw)
To: Andrey Albershteyn, Christoph Hellwig; +Cc: xfs
From: Darrick J. Wong <djwong@kernel.org>
If we have to reconnect a weakhandle to a different mount point, we
should update the internal mountpoint string to that new value so we
don't have to keep reconnecting it.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
healer/weakhandle.c | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/healer/weakhandle.c b/healer/weakhandle.c
index 7b8cef0a63f971..d659cbd63b5176 100644
--- a/healer/weakhandle.c
+++ b/healer/weakhandle.c
@@ -18,8 +18,8 @@
#include "xfs_healer.h"
struct weakhandle {
- /* Shared reference to the user's mountpoint for logging */
- const char *mntpoint;
+ /* Owned reference to the user's mountpoint for logging */
+ char *mntpoint;
/* Shared reference to the getmntent fsname for reconnecting */
const char *fsname;
@@ -55,7 +55,9 @@ weakhandle_alloc(
if (!wh)
return -1;
- wh->mntpoint = mountpoint;
+ wh->mntpoint = strdup(mountpoint);
+ if (!wh->mntpoint)
+ goto out_wh;
wh->mnt_id = mnt_id;
wh->fsname = fsname;
@@ -71,6 +73,28 @@ weakhandle_alloc(
return -1;
}
+static void
+try_update_mntpoint(
+ struct weakhandle *wh,
+ const char *path)
+{
+ static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+ char *s = strdup(path);
+
+ if (!s)
+ return;
+
+ pthread_mutex_lock(&lock);
+ if (path != wh->mntpoint) {
+ free(wh->mntpoint);
+ wh->mntpoint = s;
+ s = NULL;
+ }
+ pthread_mutex_unlock(&lock);
+
+ free(s);
+}
+
/*
* Reopen a file handle obtained via weak reference, using the given path to a
* mount point.
@@ -108,6 +132,9 @@ weakhandle_reopen_from(
goto out_handle;
}
+ if (path != wh->mntpoint)
+ try_update_mntpoint(wh, path);
+
free_handle(hanp, hlen);
*fd = mnt_fd;
return 0;
@@ -193,6 +220,7 @@ weakhandle_free(
if (wh) {
free_handle(wh->hanp, wh->hlen);
+ free(wh->mntpoint);
free(wh);
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-15 5:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-13 3:56 [PATCH] xfs_healer: update weakhandle mountpoint when reconnecting Darrick J. Wong
2026-04-13 9:56 ` Andrey Albershteyn
2026-04-15 5:35 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox