]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
fs: switch ->s_uuid to uuid_t
authorChristoph Hellwig <hch@lst.de>
Wed, 10 May 2017 13:06:33 +0000 (15:06 +0200)
committerChristoph Hellwig <hch@lst.de>
Mon, 5 Jun 2017 14:59:12 +0000 (16:59 +0200)
For some file systems we still memcpy into it, but in various places this
already allows us to use the proper uuid helpers.  More to come..

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Acked-by: Mimi Zohar <zohar@linux.vnet.ibm.com> (Changes to IMA/EVM)
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
14 files changed:
drivers/xen/tmem.c
fs/ext4/super.c
fs/f2fs/super.c
fs/gfs2/ops_fstype.c
fs/gfs2/sys.c
fs/ocfs2/super.c
fs/overlayfs/copy_up.c
fs/overlayfs/namei.c
fs/xfs/xfs_mount.c
include/linux/cleancache.h
include/linux/fs.h
mm/cleancache.c
security/integrity/evm/evm_crypto.c
security/integrity/ima/ima_policy.c

index 4ac2ca8a76561952798f7c49bdd292719d0439a8..bf13d1ec51f3bee0c92e9f9c968c21c13bd72173 100644 (file)
@@ -233,12 +233,12 @@ static int tmem_cleancache_init_fs(size_t pagesize)
        return xen_tmem_new_pool(uuid_private, 0, pagesize);
 }
 
-static int tmem_cleancache_init_shared_fs(char *uuid, size_t pagesize)
+static int tmem_cleancache_init_shared_fs(uuid_t *uuid, size_t pagesize)
 {
        struct tmem_pool_uuid shared_uuid;
 
-       shared_uuid.uuid_lo = *(u64 *)uuid;
-       shared_uuid.uuid_hi = *(u64 *)(&uuid[8]);
+       shared_uuid.uuid_lo = *(u64 *)&uuid->b[0];
+       shared_uuid.uuid_hi = *(u64 *)&uuid->b[8];
        return xen_tmem_new_pool(shared_uuid, TMEM_POOL_SHARED, pagesize);
 }
 
index 0b177da9ea8271f4a46208937d3c43fd20c0e9b7..6e3b4186a22fad11eb58ce26171c243c0b2a6705 100644 (file)
@@ -3952,7 +3952,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
                sb->s_qcop = &ext4_qctl_operations;
        sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
 #endif
-       memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
+       memcpy(&sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
 
        INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
        mutex_init(&sbi->s_orphan_lock);
index 83355ec4a92cdeb86d4be8d4630e01e7b0c96a28..0b89b0b7b9f75701e3a5f85680761181ce64f3df 100644 (file)
@@ -1937,7 +1937,7 @@ try_onemore:
        sb->s_time_gran = 1;
        sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
                (test_opt(sbi, POSIX_ACL) ? MS_POSIXACL : 0);
-       memcpy(sb->s_uuid, raw_super->uuid, sizeof(raw_super->uuid));
+       memcpy(&sb->s_uuid, raw_super->uuid, sizeof(raw_super->uuid));
 
        /* init f2fs-specific super block info */
        sbi->valid_super_block = valid_super_block;
index ed67548b286ccc58d84732d00af5ca281772bd39..b92135c202c25cc409812d095ac5b7ea4936d5dc 100644 (file)
@@ -203,7 +203,7 @@ static void gfs2_sb_in(struct gfs2_sbd *sdp, const void *buf)
 
        memcpy(sb->sb_lockproto, str->sb_lockproto, GFS2_LOCKNAME_LEN);
        memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN);
-       memcpy(s->s_uuid, str->sb_uuid, 16);
+       memcpy(&s->s_uuid, str->sb_uuid, 16);
 }
 
 /**
index 7a515345610c28dc4b35e8aa15f4b5061754c060..e77bc52b468f24b407bb19a4783959ce981be163 100644 (file)
@@ -71,25 +71,14 @@ static ssize_t fsname_show(struct gfs2_sbd *sdp, char *buf)
        return snprintf(buf, PAGE_SIZE, "%s\n", sdp->sd_fsname);
 }
 
-static int gfs2_uuid_valid(const u8 *uuid)
-{
-       int i;
-
-       for (i = 0; i < 16; i++) {
-               if (uuid[i])
-                       return 1;
-       }
-       return 0;
-}
-
 static ssize_t uuid_show(struct gfs2_sbd *sdp, char *buf)
 {
        struct super_block *s = sdp->sd_vfs;
-       const u8 *uuid = s->s_uuid;
+
        buf[0] = '\0';
-       if (!gfs2_uuid_valid(uuid))
+       if (uuid_is_null(&s->s_uuid))
                return 0;
-       return snprintf(buf, PAGE_SIZE, "%pUB\n", uuid);
+       return snprintf(buf, PAGE_SIZE, "%pUB\n", &s->s_uuid);
 }
 
 static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
@@ -712,14 +701,13 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,
 {
        struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
        struct super_block *s = sdp->sd_vfs;
-       const u8 *uuid = s->s_uuid;
 
        add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name);
        add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name);
        if (!test_bit(SDF_NOJOURNALID, &sdp->sd_flags))
                add_uevent_var(env, "JOURNALID=%d", sdp->sd_lockstruct.ls_jid);
-       if (gfs2_uuid_valid(uuid))
-               add_uevent_var(env, "UUID=%pUB", uuid);
+       if (!uuid_is_null(&s->s_uuid))
+               add_uevent_var(env, "UUID=%pUB", &s->s_uuid);
        return 0;
 }
 
index ca1646fbcaefe7daf0e205620ca3344a4cf2a44a..83005f486451eaaa211614f22247fb885f24d229 100644 (file)
@@ -2062,7 +2062,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
        cbits = le32_to_cpu(di->id2.i_super.s_clustersize_bits);
        bbits = le32_to_cpu(di->id2.i_super.s_blocksize_bits);
        sb->s_maxbytes = ocfs2_max_file_offset(bbits, cbits);
-       memcpy(sb->s_uuid, di->id2.i_super.s_uuid,
+       memcpy(&sb->s_uuid, di->id2.i_super.s_uuid,
               sizeof(di->id2.i_super.s_uuid));
 
        osb->osb_dx_mask = (1 << (cbits - bbits)) - 1;
index 7a44533f4bbf24134a95bdc030bde5779f28457a..d55fceb4e414f0e322c60f1841fb9c157f956c8e 100644 (file)
@@ -284,7 +284,6 @@ static int ovl_set_origin(struct dentry *dentry, struct dentry *lower,
                          struct dentry *upper)
 {
        struct super_block *sb = lower->d_sb;
-       uuid_be *uuid = (uuid_be *) &sb->s_uuid;
        const struct ovl_fh *fh = NULL;
        int err;
 
@@ -294,8 +293,8 @@ static int ovl_set_origin(struct dentry *dentry, struct dentry *lower,
         * up and a pure upper inode.
         */
        if (sb->s_export_op && sb->s_export_op->fh_to_dentry &&
-           uuid_be_cmp(*uuid, NULL_UUID_BE)) {
-               fh = ovl_encode_fh(lower, uuid);
+           !uuid_is_null(&sb->s_uuid)) {
+               fh = ovl_encode_fh(lower, &sb->s_uuid);
                if (IS_ERR(fh))
                        return PTR_ERR(fh);
        }
index f3136c31e72af24cbb9949449a12d292fc3bf11b..de0d4f742f36eb67ce84456be47bbef977fe1320 100644 (file)
@@ -135,7 +135,7 @@ static struct dentry *ovl_get_origin(struct dentry *dentry,
         * Make sure that the stored uuid matches the uuid of the lower
         * layer where file handle will be decoded.
         */
-       if (uuid_be_cmp(fh->uuid, *(uuid_be *) &mnt->mnt_sb->s_uuid))
+       if (!uuid_equal(&fh->uuid, &mnt->mnt_sb->s_uuid))
                goto out;
 
        origin = exportfs_decode_fh(mnt, (struct fid *)fh->fid,
index 54452967e35e96e6331ab2489f78bcb2642e9ad7..d249546da15ef0b2e847f8a2a6c354c94d4600b6 100644 (file)
@@ -74,8 +74,7 @@ xfs_uuid_mount(
        int                     hole, i;
 
        /* Publish UUID in struct super_block */
-       BUILD_BUG_ON(sizeof(mp->m_super->s_uuid) != sizeof(uuid_t));
-       memcpy(&mp->m_super->s_uuid, uuid, sizeof(uuid_t));
+       uuid_copy(&mp->m_super->s_uuid, uuid);
 
        if (mp->m_flags & XFS_MOUNT_NOUUID)
                return 0;
index fccf7f44139dd67c2bae6db1799e2517bcd9cd00..bbb3712dd8923feca7e8239cf044ef5ef041d7c0 100644 (file)
@@ -27,7 +27,7 @@ struct cleancache_filekey {
 
 struct cleancache_ops {
        int (*init_fs)(size_t);
-       int (*init_shared_fs)(char *uuid, size_t);
+       int (*init_shared_fs)(uuid_t *uuid, size_t);
        int (*get_page)(int, struct cleancache_filekey,
                        pgoff_t, struct page *);
        void (*put_page)(int, struct cleancache_filekey,
index 803e5a9b265422d2c2034678331b6d4dd353d1de..3e68cabb8457e5a9ae5b53bd9d7aa0f844ee99fa 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/percpu-rwsem.h>
 #include <linux/workqueue.h>
 #include <linux/delayed_call.h>
+#include <linux/uuid.h>
 
 #include <asm/byteorder.h>
 #include <uapi/linux/fs.h>
@@ -1328,8 +1329,8 @@ struct super_block {
 
        struct sb_writers       s_writers;
 
-       char s_id[32];                          /* Informational name */
-       u8 s_uuid[16];                          /* UUID */
+       char                    s_id[32];       /* Informational name */
+       uuid_t                  s_uuid;         /* UUID */
 
        void                    *s_fs_info;     /* Filesystem private info */
        unsigned int            s_max_links;
index ba5d8f3e6d68a3769589c372adc3183b4addfb40..f7b9fdc79d97c15cc6790566469b6614c686aa90 100644 (file)
@@ -130,7 +130,7 @@ void __cleancache_init_shared_fs(struct super_block *sb)
        int pool_id = CLEANCACHE_NO_BACKEND_SHARED;
 
        if (cleancache_ops) {
-               pool_id = cleancache_ops->init_shared_fs(sb->s_uuid, PAGE_SIZE);
+               pool_id = cleancache_ops->init_shared_fs(&sb->s_uuid, PAGE_SIZE);
                if (pool_id < 0)
                        pool_id = CLEANCACHE_NO_POOL;
        }
index d7f282d75cc16efa1d21274e42145280a2f69468..1d32cd20009a3bd35cf77bc11027354c00eb8812 100644 (file)
@@ -164,7 +164,7 @@ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode,
        hmac_misc.mode = inode->i_mode;
        crypto_shash_update(desc, (const u8 *)&hmac_misc, sizeof(hmac_misc));
        if (evm_hmac_attrs & EVM_ATTR_FSUUID)
-               crypto_shash_update(desc, inode->i_sb->s_uuid,
+               crypto_shash_update(desc, &inode->i_sb->s_uuid.b[0],
                                    sizeof(inode->i_sb->s_uuid));
        crypto_shash_final(desc, digest);
 }
index 9a7c7cbdbe7ce1d39e038d2cf0e0b10e67bcd4ef..6f885fab9d84a1476eacaf5d1905b4546d964fd6 100644 (file)
@@ -244,7 +244,7 @@ static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode,
            && rule->fsmagic != inode->i_sb->s_magic)
                return false;
        if ((rule->flags & IMA_FSUUID) &&
-           memcmp(&rule->fsuuid, inode->i_sb->s_uuid, sizeof(rule->fsuuid)))
+           !uuid_equal(&rule->fsuuid, &inode->i_sb->s_uuid))
                return false;
        if ((rule->flags & IMA_UID) && !rule->uid_op(cred->uid, rule->uid))
                return false;