fs/jfs: Switch to use new generic UUID API
PATCH 1/1 fs/jfs: Switch to use new generic UUID API
There are new types and helpers that are supposed to be used in new code.
As a preparation to get rid of legacy types and API functions do the conversion here.
---
- not tested on real FS
fs/jfs/jfs_incore.h | 6 ++++-- fs/jfs/jfs_logmgr.c | 17 ++++++++--------- fs/jfs/jfs_logmgr.h | 10 +++++----- fs/jfs/jfs_mount.c | 4 ++-- fs/jfs/jfs_superblock.h | 7 ++++--- fs/jfs/super.c | 5 +++-- 6 files changed, 26 insertions(+), 23 deletions(-)
fs/jfs/jfs_incore.h +4 -2
@@ -23,6 +23,8 @@#include <linux/rwsem.h> #include <linux/slab.h> #include <linux/bitops.h> +#include <linux/uuid.h> +#include "jfs_types.h" #include "jfs_xtree.h" #include "jfs_dtree.h"
@@ -178,8 +180,8 @@ struct jfs_sb_info {pxd_t logpxd;/* pxd describing log */ pxd_t fsckpxd;/* pxd describing fsck wkspc */ pxd_t ait2;/* pxd describing AIT copy */ -char uuid[16 ];/* 128-bit uuid for volume */ -char loguuid[16 ];/* 128-bit uuid for log */ +uuid_t uuid;/* 128-bit uuid for volume */ +uuid_t loguuid;/* 128-bit uuid for log */ /* * commit_state is used for synchronization of the jfs_commit * threads. It is protected by LAZY_LOCK().
fs/jfs/jfs_logmgr.c +8 -9
@@ -1092,8 +1092,7 @@ int lmLogOpen(struct super_block *sb)mutex_lock (&jfs_log_mutex);list_for_each_entry (log, &jfs_external_logs, journal_list) {if (log->bdev->bd_dev == sbi->logdev) { -if (memcmp (log->uuid, sbi->loguuid, -sizeof (log->uuid))) { +if (!uuid_equal (&log->uuid, &sbi->loguuid)) {jfs_warn ("wrong uuid on JFS journal" );mutex_unlock (&jfs_log_mutex);return -EINVAL ;
@@ -1130,7 +1129,7 @@ int lmLogOpen(struct super_block *sb) } log->bdev = bdev; -memcpy (log->uuid, sbi->loguuid,sizeof (log->uuid)); +uuid_copy (&log->uuid, &sbi->loguuid);/* * initialize log:
@@ -1336,7 +1335,7 @@ int lmLogInit(struct jfs_log * log)jfs_info ("lmLogInit: inline log:0x%p base:0x%Lx size:0x%x" , log, (unsigned long long )log->base, log->size); }else { -if (memcmp (logsuper->uuid, log->uuid,16 )) { +if (!uuid_equal (&logsuper->uuid, &log->uuid)) {jfs_warn ("wrong uuid on JFS log device" ); goto errout20; }
@@ -1732,7 +1731,7 @@ static int lmLogFileSystem(struct jfs_log * log, struct jfs_sb_info *sbi,int i;struct logsuper *logsuper;struct lbuf *bpsuper; -char *uuid = sbi->uuid; +uuid_t *uuid = &sbi->uuid;/* * insert/remove file system device to log active file system list.
@@ -1743,8 +1742,8 @@ static int lmLogFileSystem(struct jfs_log * log, struct jfs_sb_info *sbi, logsuper = (struct logsuper *) bpsuper->l_ldata;if (activate) {for (i =0 ; i <MAX_ACTIVE ; i++) -if (!memcmp (logsuper->active[i].uuid,NULL_UUID ,16 )) { -memcpy (logsuper->active[i].uuid, uuid,16 ); +if (uuid_is_null (&logsuper->active[i].uuid)) { +uuid_copy (&logsuper->active[i].uuid, uuid); sbi->aggregate = i;break ; }
@@ -1755,8 +1754,8 @@ static int lmLogFileSystem(struct jfs_log * log, struct jfs_sb_info *sbi, } }else {for (i =0 ; i <MAX_ACTIVE ; i++) -if (!memcmp (logsuper->active[i].uuid, uuid,16 )) { -memcpy (logsuper->active[i].uuid,NULL_UUID ,16 ); +if (uuid_equal (&logsuper->active[i].uuid, uuid)) { +uuid_copy (&logsuper->active[i].uuid, &uuid_null);break ; }if (i ==MAX_ACTIVE ) {
fs/jfs/jfs_logmgr.h +5 -5
@@ -19,6 +19,8 @@#ifndef _H_JFS_LOGMGR#define _H_JFS_LOGMGR +#include <linux/uuid.h> +#include "jfs_filsys.h" #include "jfs_lock.h"
@@ -73,15 +75,13 @@ struct logsuper {__le32 state;/* 4: state - see below */ __le32 end;/* 4: addr of last log record set by logredo */ -char uuid[16 ];/* 16: 128-bit journal uuid */ +uuid_t uuid;/* 16: 128-bit journal uuid */ char label[16 ];/* 16: journal label */ struct { -char uuid[16 ]; +uuid_t uuid; } active[MAX_ACTIVE ];/* 2048: active file systems list */ }; -#define NULL_UUID "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" -/* log flag: commit option (see jfs_filsys.h) */ /* log state */
@@ -410,7 +410,7 @@ struct jfs_log {spinlock_t synclock;/* 4: synclist lock */ struct lbuf *wqueue;/* 4: log pageout queue */ int count;/* 4: count */ -char uuid[16 ];/* 16: 128-bit uuid of log device */ +uuid_t uuid;/* 16: 128-bit uuid of log device */ int no_integrity;/* 3: flag to disable journaling to disk */ };
fs/jfs/jfs_mount.c +2 -2
@@ -389,8 +389,8 @@ static int chkSuper(struct super_block *sb) sbi->logpxd = j_sb->s_logpxd; else { sbi->logdev =new_decode_dev (le32_to_cpu (j_sb->s_logdev)); -memcpy (sbi->uuid, j_sb->s_uuid,sizeof (sbi->uuid)); -memcpy (sbi->loguuid, j_sb->s_loguuid,sizeof (sbi->uuid)); +uuid_copy (&sbi->uuid, &j_sb->s_uuid); +uuid_copy (&sbi->loguuid, &j_sb->s_loguuid); } sbi->fsckpxd = j_sb->s_fsckpxd; sbi->ait2 = j_sb->s_ait2;
fs/jfs/jfs_superblock.h +4 -3
@@ -18,6 +18,8 @@#ifndef _H_JFS_SUPERBLOCK#define _H_JFS_SUPERBLOCK +#include <linux/uuid.h> +/* * make the magic number something a human could read */
@@ -100,10 +102,9 @@ struct jfs_superblock {pxd_t s_xlogpxd;/* 8: extendfs logpxd */ /* - 128 byte boundary - */ -char s_uuid[16 ];/* 16: 128-bit uuid for volume */ +uuid_t s_uuid;/* 16: 128-bit uuid for volume */ char s_label[16 ];/* 16: volume label */ -char s_loguuid[16 ];/* 16: 128-bit uuid for log device */ - +uuid_t s_loguuid;/* 16: 128-bit uuid for log device */ };extern int readSuper (struct super_block *,struct buffer_head **);
fs/jfs/super.c +3 -2
@@ -174,8 +174,9 @@ static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf) buf->f_files = maxinodes; buf->f_ffree = maxinodes - (atomic_read (&imap->im_numinos) -atomic_read (&imap->im_numfree)); - buf->f_fsid.val[0 ] = (u32 )crc32_le (0 , sbi->uuid,sizeof (sbi->uuid)/2 ); - buf->f_fsid.val[1 ] = (u32 )crc32_le (0 , sbi->uuid +sizeof (sbi->uuid)/2 , + buf->f_fsid.val[0 ] = (u32 )crc32_le (0 , (char *)&sbi->uuid, +sizeof (sbi->uuid)/2 ); + buf->f_fsid.val[1 ] = (u32 )crc32_le (0 , (char *)&sbi->uuid +sizeof (sbi->uuid)/2 ,sizeof (sbi->uuid)/2 ); buf->f_namelen =JFS_NAME_MAX ;
Signature · 1 line
2.20.1
Quoted 4 lines · Andy Shevchenko
There are new types and helpers that are supposed to be used in new code.
As a preparation to get rid of legacy types and API functions do the conversion here.
Looks good to me. I tweaked it slightly to keep checkpatch from complaining about lines over 80 characters. I'll push it into -next for v5.1.
Shaggy
Quoted 199 lines
Signed-off-by Andy Shevchenko <[email protected]>---
- not tested on real FS
fs/jfs/jfs_incore.h | 6 ++++-- fs/jfs/jfs_logmgr.c | 17 ++++++++--------- fs/jfs/jfs_logmgr.h | 10 +++++----- fs/jfs/jfs_mount.c | 4 ++-- fs/jfs/jfs_superblock.h | 7 ++++--- fs/jfs/super.c | 5 +++-- 6 files changed, 26 insertions(+), 23 deletions(-)fs/jfs/jfs_incore.h +4
-2@@ -23,6 +23,8 @@#include <linux/rwsem.h> #include <linux/slab.h> #include <linux/bitops.h> +#include <linux/uuid.h> +#include "jfs_types.h" #include "jfs_xtree.h" #include "jfs_dtree.h" @@ -178,8 +180,8 @@ struct jfs_sb_info {pxd_t logpxd;/* pxd describing log */ pxd_t fsckpxd;/* pxd describing fsck wkspc */ pxd_t ait2;/* pxd describing AIT copy */ -char uuid[16 ];/* 128-bit uuid for volume */ -char loguuid[16 ];/* 128-bit uuid for log */ +uuid_t uuid;/* 128-bit uuid for volume */ +uuid_t loguuid;/* 128-bit uuid for log */ /* * commit_state is used for synchronization of the jfs_commit * threads. It is protected by LAZY_LOCK(). fs/jfs/jfs_logmgr.c +8
-9@@ -1092,8 +1092,7 @@ int lmLogOpen(struct super_block *sb)mutex_lock (&jfs_log_mutex);list_for_each_entry (log, &jfs_external_logs, journal_list) {if (log->bdev->bd_dev == sbi->logdev) { -if (memcmp (log->uuid, sbi->loguuid, -sizeof (log->uuid))) { +if (!uuid_equal (&log->uuid, &sbi->loguuid)) {jfs_warn ("wrong uuid on JFS journal" );mutex_unlock (&jfs_log_mutex);return -EINVAL ;@@ -1130,7 +1129,7 @@ int lmLogOpen(struct super_block *sb) } log->bdev = bdev; -memcpy (log->uuid, sbi->loguuid,sizeof (log->uuid)); +uuid_copy (&log->uuid, &sbi->loguuid);/* * initialize log: @@ -1336,7 +1335,7 @@ int lmLogInit(struct jfs_log * log)jfs_info ("lmLogInit: inline log:0x%p base:0x%Lx size:0x%x" , log, (unsigned long long )log->base, log->size); }else { -if (memcmp (logsuper->uuid, log->uuid,16 )) { +if (!uuid_equal (&logsuper->uuid, &log->uuid)) {jfs_warn ("wrong uuid on JFS log device" ); goto errout20; }@@ -1732,7 +1731,7 @@ static int lmLogFileSystem(struct jfs_log * log, struct jfs_sb_info *sbi,int i;struct logsuper *logsuper;struct lbuf *bpsuper; -char *uuid = sbi->uuid; +uuid_t *uuid = &sbi->uuid;/* * insert/remove file system device to log active file system list. @@ -1743,8 +1742,8 @@ static int lmLogFileSystem(struct jfs_log * log, struct jfs_sb_info *sbi, logsuper = (struct logsuper *) bpsuper->l_ldata;if (activate) {for (i =0 ; i <MAX_ACTIVE ; i++) -if (!memcmp (logsuper->active[i].uuid,NULL_UUID ,16 )) { -memcpy (logsuper->active[i].uuid, uuid,16 ); +if (uuid_is_null (&logsuper->active[i].uuid)) { +uuid_copy (&logsuper->active[i].uuid, uuid); sbi->aggregate = i;break ; }@@ -1755,8 +1754,8 @@ static int lmLogFileSystem(struct jfs_log * log, struct jfs_sb_info *sbi, } }else {for (i =0 ; i <MAX_ACTIVE ; i++) -if (!memcmp (logsuper->active[i].uuid, uuid,16 )) { -memcpy (logsuper->active[i].uuid,NULL_UUID ,16 ); +if (uuid_equal (&logsuper->active[i].uuid, uuid)) { +uuid_copy (&logsuper->active[i].uuid, &uuid_null);break ; }if (i ==MAX_ACTIVE ) {fs/jfs/jfs_logmgr.h +5
-5@@ -19,6 +19,8 @@#ifndef _H_JFS_LOGMGR#define _H_JFS_LOGMGR +#include <linux/uuid.h> +#include "jfs_filsys.h" #include "jfs_lock.h" @@ -73,15 +75,13 @@ struct logsuper {__le32 state;/* 4: state - see below */ __le32 end;/* 4: addr of last log record set by logredo */ -char uuid[16 ];/* 16: 128-bit journal uuid */ +uuid_t uuid;/* 16: 128-bit journal uuid */ char label[16 ];/* 16: journal label */ struct { -char uuid[16 ]; +uuid_t uuid; } active[MAX_ACTIVE ];/* 2048: active file systems list */ }; -#define NULL_UUID "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" -/* log flag: commit option (see jfs_filsys.h) */ /* log state */ @@ -410,7 +410,7 @@ struct jfs_log {spinlock_t synclock;/* 4: synclist lock */ struct lbuf *wqueue;/* 4: log pageout queue */ int count;/* 4: count */ -char uuid[16 ];/* 16: 128-bit uuid of log device */ +uuid_t uuid;/* 16: 128-bit uuid of log device */ int no_integrity;/* 3: flag to disable journaling to disk */ };fs/jfs/jfs_mount.c +2
-2@@ -389,8 +389,8 @@ static int chkSuper(struct super_block *sb) sbi->logpxd = j_sb->s_logpxd; else { sbi->logdev =new_decode_dev (le32_to_cpu (j_sb->s_logdev)); -memcpy (sbi->uuid, j_sb->s_uuid,sizeof (sbi->uuid)); -memcpy (sbi->loguuid, j_sb->s_loguuid,sizeof (sbi->uuid)); +uuid_copy (&sbi->uuid, &j_sb->s_uuid); +uuid_copy (&sbi->loguuid, &j_sb->s_loguuid); } sbi->fsckpxd = j_sb->s_fsckpxd; sbi->ait2 = j_sb->s_ait2;fs/jfs/jfs_superblock.h +4
-3@@ -18,6 +18,8 @@#ifndef _H_JFS_SUPERBLOCK#define _H_JFS_SUPERBLOCK +#include <linux/uuid.h> +/* * make the magic number something a human could read */ @@ -100,10 +102,9 @@ struct jfs_superblock {pxd_t s_xlogpxd;/* 8: extendfs logpxd */ /* - 128 byte boundary - */ -char s_uuid[16 ];/* 16: 128-bit uuid for volume */ +uuid_t s_uuid;/* 16: 128-bit uuid for volume */ char s_label[16 ];/* 16: volume label */ -char s_loguuid[16 ];/* 16: 128-bit uuid for log device */ - +uuid_t s_loguuid;/* 16: 128-bit uuid for log device */ };extern int readSuper (struct super_block *,struct buffer_head **);fs/jfs/super.c +3
-2@@ -174,8 +174,9 @@ static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf) buf->f_files = maxinodes; buf->f_ffree = maxinodes - (atomic_read (&imap->im_numinos) -atomic_read (&imap->im_numfree)); - buf->f_fsid.val[0 ] = (u32 )crc32_le (0 , sbi->uuid,sizeof (sbi->uuid)/2 ); - buf->f_fsid.val[1 ] = (u32 )crc32_le (0 , sbi->uuid +sizeof (sbi->uuid)/2 , + buf->f_fsid.val[0 ] = (u32 )crc32_le (0 , (char *)&sbi->uuid, +sizeof (sbi->uuid)/2 ); + buf->f_fsid.val[1 ] = (u32 )crc32_le (0 , (char *)&sbi->uuid +sizeof (sbi->uuid)/2 ,sizeof (sbi->uuid)/2 ); buf->f_namelen =JFS_NAME_MAX ;
fs/jfs/super.c static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf) · line 179
Quoted 1 line
fs/jfs/super.c +1
-0+ buf->f_fsid.val[1] = (u32)crc32_le(0, (char *)&sbi->uuid + sizeof(sbi->uuid)/2,
This adds an overly long line, and has weird operator spacing.
In fact given how much deep magic it does it should probably be moved into a helper and properly documented when you touch it anyway.
Quoted 7 lines · Christoph Hellwig
Review
Quoted 1 line
(quoted diff) +1
-0+ buf->f_fsid.val[1] = (u32)crc32_le(0, (char *)&sbi->uuid + sizeof(sbi->uuid)/2,This adds an overly long line, and has weird operator spacing.
In fact given how much deep magic it does it should probably be moved into a helper and properly documented when you touch it anyway.
I cleaned this up a bit when I pushed it to the jfs tree.
https://github.com/kleikamp/linux-shaggy/commit/2e3bc6125154c691e987e2554f2c99ec10f83b73
Here's the relevant part. It's still a bit ugly, but I got rid of an unnecessary cast and kept the lines from exceeding 80 characters.
fs/jfs/super.c +5 -3
@@ -174,9 +174,11 @@ static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf) buf->f_files = maxinodes; buf->f_ffree = maxinodes - (atomic_read (&imap->im_numinos) -atomic_read (&imap->im_numfree)); - buf->f_fsid.val[0 ] = (u32 )crc32_le (0 , sbi->uuid,sizeof (sbi->uuid)/2 ); - buf->f_fsid.val[1 ] = (u32 )crc32_le (0 , sbi->uuid +sizeof (sbi->uuid)/2 , -sizeof (sbi->uuid)/2 ); + buf->f_fsid.val[0 ] =crc32_le (0 , (char *)&sbi->uuid, +sizeof (sbi->uuid)/2 ); + buf->f_fsid.val[1 ] =crc32_le (0 , + (char *)&sbi->uuid +sizeof (sbi->uuid)/2 , +sizeof (sbi->uuid)/2 ); buf->f_namelen =JFS_NAME_MAX ;return 0 ;
Quoted 6 lines · Dave Kleikamp
fs/jfs/super.c +0
-0@@ -174,9 +174,11 @@ static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf) buf->f_files = maxinodes;
fs/jfs/super.c static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf) · line 181
Quoted 10 lines
fs/jfs/super.c +5
-3buf->f_ffree = maxinodes - (atomic_read (&imap->im_numinos) -atomic_read (&imap->im_numfree)); - buf->f_fsid.val[0 ] = (u32 )crc32_le (0 , sbi->uuid,sizeof (sbi->uuid)/2 ); - buf->f_fsid.val[1 ] = (u32 )crc32_le (0 , sbi->uuid +sizeof (sbi->uuid)/2 , -sizeof (sbi->uuid)/2 ); + buf->f_fsid.val[0 ] =crc32_le (0 , (char *)&sbi->uuid, +sizeof (sbi->uuid)/2 ); + buf->f_fsid.val[1 ] =crc32_le (0 , + (char *)&sbi->uuid +sizeof (sbi->uuid)/2 , +sizeof (sbi->uuid)/2 );
I'd really love to see a little helper to calculate the fsid, and a comment on that function documenting the design decision behind it.
Quoted 12 lines · Christoph Hellwig
Quoted 11 lines · Dave Kleikamp
fs/jfs/super.c +0
-3@@ -174,9 +174,11 @@ static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf) buf->f_files = maxinodes; buf->f_ffree = maxinodes - (atomic_read (&imap->im_numinos) -atomic_read (&imap->im_numfree)); - buf->f_fsid.val[0 ] = (u32 )crc32_le (0 , sbi->uuid,sizeof (sbi->uuid)/2 ); - buf->f_fsid.val[1 ] = (u32 )crc32_le (0 , sbi->uuid +sizeof (sbi->uuid)/2 , -sizeof (sbi->uuid)/2 );
Quoted 8 lines
fs/jfs/super.c static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf) · line 181
Quoted 5 lines
fs/jfs/super.c +5
-0+ buf->f_fsid.val[0 ] =crc32_le (0 , (char *)&sbi->uuid, +sizeof (sbi->uuid)/2 ); + buf->f_fsid.val[1 ] =crc32_le (0 , + (char *)&sbi->uuid +sizeof (sbi->uuid)/2 , +sizeof (sbi->uuid)/2 );I'd really love to see a little helper to calculate the fsid, and a comment on that function documenting the design decision behind it.
I can do that. It was a long time ago, but I'm sure the design decision was that I took the idea from another filesystem, possibly reiserfs, but I'll make a better case than that. :-)
Shaggy