@@ -760,13 +760,14 @@ bool ovl_init_uuid_xattr(struct super_block *sb, struct ovl_fs *ofs,
760
760
const struct path * upperpath )
761
761
{
762
762
bool set = false;
763
+ uuid_t uuid ;
763
764
int res ;
764
765
765
766
/* Try to load existing persistent uuid */
766
- res = ovl_path_getxattr (ofs , upperpath , OVL_XATTR_UUID , sb -> s_uuid .b ,
767
+ res = ovl_path_getxattr (ofs , upperpath , OVL_XATTR_UUID , uuid .b ,
767
768
UUID_SIZE );
768
769
if (res == UUID_SIZE )
769
- return true ;
770
+ goto set_uuid ;
770
771
771
772
if (res != - ENODATA )
772
773
goto fail ;
@@ -794,17 +795,20 @@ bool ovl_init_uuid_xattr(struct super_block *sb, struct ovl_fs *ofs,
794
795
}
795
796
796
797
/* Generate overlay instance uuid */
797
- uuid_gen (& sb -> s_uuid );
798
+ uuid_gen (& uuid );
798
799
799
800
/* Try to store persistent uuid */
800
801
set = true;
801
- res = ovl_setxattr (ofs , upperpath -> dentry , OVL_XATTR_UUID , sb -> s_uuid .b ,
802
+ res = ovl_setxattr (ofs , upperpath -> dentry , OVL_XATTR_UUID , uuid .b ,
802
803
UUID_SIZE );
803
- if (res == 0 )
804
- return true;
804
+ if (res )
805
+ goto fail ;
806
+
807
+ set_uuid :
808
+ super_set_uuid (sb , uuid .b , sizeof (uuid ));
809
+ return true;
805
810
806
811
fail :
807
- memset (sb -> s_uuid .b , 0 , UUID_SIZE );
808
812
ofs -> config .uuid = OVL_UUID_NULL ;
809
813
pr_warn ("failed to %s uuid (%pd2, err=%i); falling back to uuid=null.\n" ,
810
814
set ? "set" : "get" , upperpath -> dentry , res );
0 commit comments