From: "Darrick J. Wong" <djwong@kernel.org>
To: Andrey Albershteyn <aalbersh@redhat.com>,
Christoph Hellwig <hch@infradead.org>
Cc: xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH] xfs_healer: update weakhandle mountpoint when reconnecting
Date: Sun, 12 Apr 2026 20:56:50 -0700 [thread overview]
Message-ID: <20260413035650.GG1048989@frogsfrogsfrogs> (raw)
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);
}
next reply other threads:[~2026-04-13 3:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 3:56 Darrick J. Wong [this message]
2026-04-13 9:56 ` [PATCH] xfs_healer: update weakhandle mountpoint when reconnecting Andrey Albershteyn
2026-04-15 5:35 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260413035650.GG1048989@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=aalbersh@redhat.com \
--cc=hch@infradead.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox