ovl: convert to super_set_uuid()
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 7 Feb 2024 02:56:16 +0000 (21:56 -0500)
committerChristian Brauner <brauner@kernel.org>
Thu, 8 Feb 2024 20:20:11 +0000 (21:20 +0100)
We don't want to be settingc sb->s_uuid directly anymore, as there's a
length field that also has to be set, and this conversion was not
completely trivial.

Acked-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Link: https://lore.kernel.org/r/20240207025624.1019754-3-kent.overstreet@linux.dev
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-unionfs@vger.kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/overlayfs/util.c

index 0217094c23ea6ae8905c7cb0c44c3ba969345200..ed71480d8adbe0266697367ca9780a6f851e4f0a 100644 (file)
@@ -760,13 +760,14 @@ bool ovl_init_uuid_xattr(struct super_block *sb, struct ovl_fs *ofs,
                         const struct path *upperpath)
 {
        bool set = false;
+       uuid_t uuid;
        int res;
 
        /* Try to load existing persistent uuid */
-       res = ovl_path_getxattr(ofs, upperpath, OVL_XATTR_UUID, sb->s_uuid.b,
+       res = ovl_path_getxattr(ofs, upperpath, OVL_XATTR_UUID, uuid.b,
                                UUID_SIZE);
        if (res == UUID_SIZE)
-               return true;
+               goto set_uuid;
 
        if (res != -ENODATA)
                goto fail;
@@ -794,17 +795,20 @@ bool ovl_init_uuid_xattr(struct super_block *sb, struct ovl_fs *ofs,
        }
 
        /* Generate overlay instance uuid */
-       uuid_gen(&sb->s_uuid);
+       uuid_gen(&uuid);
 
        /* Try to store persistent uuid */
        set = true;
-       res = ovl_setxattr(ofs, upperpath->dentry, OVL_XATTR_UUID, sb->s_uuid.b,
+       res = ovl_setxattr(ofs, upperpath->dentry, OVL_XATTR_UUID, uuid.b,
                           UUID_SIZE);
-       if (res == 0)
-               return true;
+       if (res)
+               goto fail;
+
+set_uuid:
+       super_set_uuid(sb, uuid.b, sizeof(uuid));
+       return true;
 
 fail:
-       memset(sb->s_uuid.b, 0, UUID_SIZE);
        ofs->config.uuid = OVL_UUID_NULL;
        pr_warn("failed to %s uuid (%pd2, err=%i); falling back to uuid=null.\n",
                set ? "set" : "get", upperpath->dentry, res);