From: Catherine Hoang <catherine.hoang@oracle.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH v1 1/4] xfs: refactor xfs_uuid_mount and xfs_uuid_unmount
Date: Mon, 13 Mar 2023 21:21:06 -0700 [thread overview]
Message-ID: <20230314042109.82161-2-catherine.hoang@oracle.com> (raw)
In-Reply-To: <20230314042109.82161-1-catherine.hoang@oracle.com>
Separate out the code that adds and removes a uuid from the uuid table. The
next patch uses these helpers to set the uuid of a mounted filesystem.
Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
---
fs/xfs/xfs_mount.c | 30 +++++++++++++++++++++++++-----
fs/xfs/xfs_mount.h | 2 ++
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index fb87ffb48f7f..434a67235fc9 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -58,7 +58,7 @@ xfs_uuid_mount(
struct xfs_mount *mp)
{
uuid_t *uuid = &mp->m_sb.sb_uuid;
- int hole, i;
+ int error;
/* Publish UUID in struct super_block */
uuid_copy(&mp->m_super->s_uuid, uuid);
@@ -71,6 +71,21 @@ xfs_uuid_mount(
return -EINVAL;
}
+ error = xfs_uuid_remember(uuid);
+ if (error) {
+ xfs_warn(mp, "Filesystem has duplicate UUID %pU - can't mount", uuid);
+ return error;
+ }
+
+ return 0;
+}
+
+int
+xfs_uuid_remember(
+ const uuid_t *uuid)
+{
+ int hole, i;
+
mutex_lock(&xfs_uuid_table_mutex);
for (i = 0, hole = -1; i < xfs_uuid_table_size; i++) {
if (uuid_is_null(&xfs_uuid_table[i])) {
@@ -94,7 +109,6 @@ xfs_uuid_mount(
out_duplicate:
mutex_unlock(&xfs_uuid_table_mutex);
- xfs_warn(mp, "Filesystem has duplicate UUID %pU - can't mount", uuid);
return -EINVAL;
}
@@ -102,12 +116,18 @@ STATIC void
xfs_uuid_unmount(
struct xfs_mount *mp)
{
- uuid_t *uuid = &mp->m_sb.sb_uuid;
- int i;
-
if (xfs_has_nouuid(mp))
return;
+ xfs_uuid_forget(&mp->m_sb.sb_uuid);
+}
+
+void
+xfs_uuid_forget(
+ const uuid_t *uuid)
+{
+ int i;
+
mutex_lock(&xfs_uuid_table_mutex);
for (i = 0; i < xfs_uuid_table_size; i++) {
if (uuid_is_null(&xfs_uuid_table[i]))
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index f3269c0626f0..ee08aeaf5430 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -484,6 +484,8 @@ xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d)
int xfs_buf_hash_init(struct xfs_perag *pag);
void xfs_buf_hash_destroy(struct xfs_perag *pag);
+int xfs_uuid_remember(const uuid_t *uuid);
+void xfs_uuid_forget(const uuid_t *uuid);
extern void xfs_uuid_table_free(void);
extern uint64_t xfs_default_resblks(xfs_mount_t *mp);
extern int xfs_mountfs(xfs_mount_t *mp);
--
2.34.1
next prev parent reply other threads:[~2023-03-14 4:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-14 4:21 [PATCH v1 0/4] setting uuid of online filesystems Catherine Hoang
2023-03-14 4:21 ` Catherine Hoang [this message]
2023-03-14 4:21 ` [PATCH v1 2/4] xfs: implement custom freeze/thaw functions Catherine Hoang
2023-03-14 5:11 ` Amir Goldstein
2023-03-14 5:25 ` Darrick J. Wong
2023-03-14 6:00 ` Amir Goldstein
2023-03-16 5:16 ` Darrick J. Wong
2023-03-14 4:21 ` [PATCH v1 3/4] xfs: add XFS_IOC_SETFSUUID ioctl Catherine Hoang
2023-03-14 5:50 ` Amir Goldstein
2023-03-15 23:12 ` Catherine Hoang
2023-03-16 8:09 ` Amir Goldstein
2023-03-18 0:39 ` Darrick J. Wong
2023-03-18 9:31 ` Amir Goldstein
2023-03-14 4:21 ` [PATCH v1 4/4] xfs: export meta uuid via xfs_fsop_geom Catherine Hoang
2023-03-14 6:28 ` [PATCH v1 0/4] setting uuid of online filesystems Dave Chinner
2023-03-16 20:41 ` Catherine Hoang
2023-03-19 0:16 ` Dave Chinner
2023-03-28 1:38 ` Darrick J. Wong
2023-03-18 0:11 ` Darrick J. Wong
2023-03-18 9:04 ` Amir Goldstein
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=20230314042109.82161-2-catherine.hoang@oracle.com \
--to=catherine.hoang@oracle.com \
--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