@@ -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]))
@@ -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);
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(-)