Commit 425fff9f authored by Dave Kleikamp's avatar Dave Kleikamp Committed by Linus Torvalds

[PATCH] JFS external journal support

Additional support for external journal.  We're basically adding uuid's
to both the file system and the journal to tie the two together.
parent b24c4e67
...@@ -122,8 +122,11 @@ struct jfs_sb_info { ...@@ -122,8 +122,11 @@ struct jfs_sb_info {
short l2nbperpage; /* 2: log2 blocks per page */ short l2nbperpage; /* 2: log2 blocks per page */
short l2niperblk; /* 2: log2 inodes per page */ short l2niperblk; /* 2: log2 inodes per page */
kdev_t logdev; /* 2: external log device */ kdev_t logdev; /* 2: external log device */
uint aggregate; /* volume identifier in log record */
pxd_t logpxd; /* 8: pxd describing log */ pxd_t logpxd; /* 8: pxd describing log */
pxd_t ait2; /* 8: pxd describing AIT copy */ pxd_t ait2; /* 8: pxd describing AIT copy */
char uuid[16]; /* 16: 128-bit uuid for volume */
char loguuid[16]; /* 16: 128-bit uuid for log */
/* Formerly in ipimap */ /* Formerly in ipimap */
uint gengen; /* 4: inode generation generator*/ uint gengen; /* 4: inode generation generator*/
uint inostamp; /* 4: shows inode belongs to fileset*/ uint inostamp; /* 4: shows inode belongs to fileset*/
......
...@@ -168,7 +168,7 @@ static int lmWriteRecord(log_t * log, tblock_t * tblk, lrd_t * lrd, ...@@ -168,7 +168,7 @@ static int lmWriteRecord(log_t * log, tblock_t * tblk, lrd_t * lrd,
tlock_t * tlck); tlock_t * tlck);
static int lmNextPage(log_t * log); static int lmNextPage(log_t * log);
static int lmLogFileSystem(log_t * log, kdev_t fsdev, int activate); static int lmLogFileSystem(log_t * log, char *uuid, int activate);
static int lmLogInit(log_t * log); static int lmLogInit(log_t * log);
static int lmLogShutdown(log_t * log); static int lmLogShutdown(log_t * log);
...@@ -1098,6 +1098,11 @@ int lmLogOpen(struct super_block *sb, log_t ** logptr) ...@@ -1098,6 +1098,11 @@ int lmLogOpen(struct super_block *sb, log_t ** logptr)
* file systems to log may have n-to-1 relationship; * file systems to log may have n-to-1 relationship;
*/ */
externalLog: externalLog:
/*
* TODO: Check for already opened log devices
*/
if (!(bdev = bdget(kdev_t_to_nr(JFS_SBI(sb)->logdev)))) { if (!(bdev = bdget(kdev_t_to_nr(JFS_SBI(sb)->logdev)))) {
rc = ENODEV; rc = ENODEV;
goto errout10; goto errout10;
...@@ -1110,6 +1115,7 @@ int lmLogOpen(struct super_block *sb, log_t ** logptr) ...@@ -1110,6 +1115,7 @@ int lmLogOpen(struct super_block *sb, log_t ** logptr)
log->sb = sb; /* This should be a list */ log->sb = sb; /* This should be a list */
log->bdev = bdev; log->bdev = bdev;
memcpy(log->uuid, JFS_SBI(sb)->loguuid, sizeof(log->uuid));
/* /*
* initialize log: * initialize log:
...@@ -1120,7 +1126,7 @@ int lmLogOpen(struct super_block *sb, log_t ** logptr) ...@@ -1120,7 +1126,7 @@ int lmLogOpen(struct super_block *sb, log_t ** logptr)
/* /*
* add file system to log active file system list * add file system to log active file system list
*/ */
if ((rc = lmLogFileSystem(log, sb->s_dev, 1))) if ((rc = lmLogFileSystem(log, JFS_SBI(sb)->uuid, 1)))
goto errout30; goto errout30;
out: out:
...@@ -1221,6 +1227,10 @@ static int lmLogInit(log_t * log) ...@@ -1221,6 +1227,10 @@ static int lmLogInit(log_t * log)
("lmLogInit: inline log:0x%p base:0x%Lx size:0x%x\n", ("lmLogInit: inline log:0x%p base:0x%Lx size:0x%x\n",
log, (unsigned long long) log->base, log->size)); log, (unsigned long long) log->base, log->size));
} else { } else {
if (memcmp(logsuper->uuid, log->uuid, 16)) {
jERROR(1,("wrong uuid on JFS log device\n"));
goto errout20;
}
log->size = le32_to_cpu(logsuper->size); log->size = le32_to_cpu(logsuper->size);
log->l2bsize = le32_to_cpu(logsuper->l2bsize); log->l2bsize = le32_to_cpu(logsuper->l2bsize);
jFYI(0, jFYI(0,
...@@ -1317,7 +1327,6 @@ static int lmLogInit(log_t * log) ...@@ -1317,7 +1327,6 @@ static int lmLogInit(log_t * log)
logsuper->state = cpu_to_le32(LOGMOUNT); logsuper->state = cpu_to_le32(LOGMOUNT);
log->serial = le32_to_cpu(logsuper->serial) + 1; log->serial = le32_to_cpu(logsuper->serial) + 1;
logsuper->serial = cpu_to_le32(log->serial); logsuper->serial = cpu_to_le32(log->serial);
logsuper->device = cpu_to_le32(log->bdev->bd_dev);
lbmDirectWrite(log, bpsuper, lbmWRITE | lbmRELEASE | lbmSYNC); lbmDirectWrite(log, bpsuper, lbmWRITE | lbmRELEASE | lbmSYNC);
if ((rc = lbmIOWait(bpsuper, lbmFREE))) if ((rc = lbmIOWait(bpsuper, lbmFREE)))
goto errout30; goto errout30;
...@@ -1374,7 +1383,7 @@ int lmLogClose(struct super_block *sb, log_t * log) ...@@ -1374,7 +1383,7 @@ int lmLogClose(struct super_block *sb, log_t * log)
* external log as separate logical volume * external log as separate logical volume
*/ */
externalLog: externalLog:
lmLogFileSystem(log, sb->s_dev, 0); lmLogFileSystem(log, JFS_SBI(sb)->uuid, 0);
rc = lmLogShutdown(log); rc = lmLogShutdown(log);
blkdev_put(log->bdev, BDEV_FS); blkdev_put(log->bdev, BDEV_FS);
...@@ -1509,11 +1518,10 @@ static int lmLogShutdown(log_t * log) ...@@ -1509,11 +1518,10 @@ static int lmLogShutdown(log_t * log)
* *
* serialization: IWRITE_LOCK(log inode) held on entry/exit * serialization: IWRITE_LOCK(log inode) held on entry/exit
*/ */
static int lmLogFileSystem(log_t * log, kdev_t fsdev, int activate) static int lmLogFileSystem(log_t * log, char *uuid, int activate)
{ {
int rc = 0; int rc = 0;
int i; int i;
u32 dev_le = cpu_to_le32(kdev_t_to_nr(fsdev));
logsuper_t *logsuper; logsuper_t *logsuper;
lbuf_t *bpsuper; lbuf_t *bpsuper;
...@@ -1526,8 +1534,8 @@ static int lmLogFileSystem(log_t * log, kdev_t fsdev, int activate) ...@@ -1526,8 +1534,8 @@ static int lmLogFileSystem(log_t * log, kdev_t fsdev, int activate)
logsuper = (logsuper_t *) bpsuper->l_ldata; logsuper = (logsuper_t *) bpsuper->l_ldata;
if (activate) { if (activate) {
for (i = 0; i < MAX_ACTIVE; i++) for (i = 0; i < MAX_ACTIVE; i++)
if (logsuper->active[i] == 0) { if (!memcmp(logsuper->active[i].uuid, NULL_UUID, 16)) {
logsuper->active[i] = dev_le; memcpy(logsuper->active[i].uuid, uuid, 16);
break; break;
} }
if (i == MAX_ACTIVE) { if (i == MAX_ACTIVE) {
...@@ -1537,8 +1545,8 @@ static int lmLogFileSystem(log_t * log, kdev_t fsdev, int activate) ...@@ -1537,8 +1545,8 @@ static int lmLogFileSystem(log_t * log, kdev_t fsdev, int activate)
} }
} else { } else {
for (i = 0; i < MAX_ACTIVE; i++) for (i = 0; i < MAX_ACTIVE; i++)
if (logsuper->active[i] == dev_le) { if (!memcmp(logsuper->active[i].uuid, uuid, 16)) {
logsuper->active[i] = 0; memcpy(logsuper->active[i].uuid, NULL_UUID, 16);
break; break;
} }
assert(i < MAX_ACTIVE); assert(i < MAX_ACTIVE);
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
#define LOGMAGIC 0x87654321 #define LOGMAGIC 0x87654321
#define LOGVERSION 1 #define LOGVERSION 1
#define MAX_ACTIVE 512 /* Max active file systems sharing log */ #define MAX_ACTIVE 128 /* Max active file systems sharing log */
typedef struct { typedef struct {
u32 magic; /* 4: log lv identifier */ u32 magic; /* 4: log lv identifier */
...@@ -72,10 +72,15 @@ typedef struct { ...@@ -72,10 +72,15 @@ typedef struct {
u32 state; /* 4: state - see below */ u32 state; /* 4: state - see below */
s32 end; /* 4: addr of last log record set by logredo */ s32 end; /* 4: addr of last log record set by logredo */
u32 device; /* 4: save device in case location changes */ char uuid[16]; /* 16: 128-bit journal uuid */
u32 active[MAX_ACTIVE]; /* 2048: active file systems list */ char label[16]; /* 16: journal label */
struct {
char uuid[16];
} active[MAX_ACTIVE]; /* 2048: active file systems list */
} logsuper_t; } logsuper_t;
#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 flag: commit option (see jfs_filsys.h) */
/* log state */ /* log state */
...@@ -411,6 +416,7 @@ typedef struct jfs_log { ...@@ -411,6 +416,7 @@ typedef struct jfs_log {
spinlock_t synclock; /* 4: synclist lock */ spinlock_t synclock; /* 4: synclist lock */
struct lbuf *wqueue; /* 4: log pageout queue */ struct lbuf *wqueue; /* 4: log pageout queue */
int count; /* 4: count */ int count; /* 4: count */
char uuid[16]; /* 16: 128-bit uuid of log device */
} log_t; } log_t;
/* /*
......
...@@ -405,8 +405,11 @@ static int chkSuper(struct super_block *sb) ...@@ -405,8 +405,11 @@ static int chkSuper(struct super_block *sb)
sbi->l2niperblk = sbi->l2bsize - L2DISIZE; sbi->l2niperblk = sbi->l2bsize - L2DISIZE;
if (sbi->mntflag & JFS_INLINELOG) if (sbi->mntflag & JFS_INLINELOG)
sbi->logpxd = j_sb->s_logpxd; sbi->logpxd = j_sb->s_logpxd;
else else {
sbi->logdev = to_kdev_t(le32_to_cpu(j_sb->s_logdev)); sbi->logdev = to_kdev_t(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));
}
sbi->ait2 = j_sb->s_ait2; sbi->ait2 = j_sb->s_ait2;
out: out:
...@@ -446,10 +449,6 @@ int updateSuper(struct super_block *sb, uint state) ...@@ -446,10 +449,6 @@ int updateSuper(struct super_block *sb, uint state)
j_sb->s_logdev = j_sb->s_logdev =
cpu_to_le32(JFS_SBI(sb)->log->bdev->bd_dev); cpu_to_le32(JFS_SBI(sb)->log->bdev->bd_dev);
j_sb->s_logserial = cpu_to_le32(JFS_SBI(sb)->log->serial); j_sb->s_logserial = cpu_to_le32(JFS_SBI(sb)->log->serial);
/* record our own device number in case the location
* changes after a reboot
*/
j_sb->s_device = cpu_to_le32(kdev_t_to_nr(sb->s_dev));
} else if (state == FM_CLEAN) { } else if (state == FM_CLEAN) {
/* /*
* If this volume is shared with OS/2, OS/2 will need to * If this volume is shared with OS/2, OS/2 will need to
......
...@@ -91,6 +91,7 @@ struct jfs_superblock { ...@@ -91,6 +91,7 @@ struct jfs_superblock {
* N.B. This must be 11 bytes to * N.B. This must be 11 bytes to
* conform with the OS/2 BootSector * conform with the OS/2 BootSector
* requirements * requirements
* Only used when s_version is 1
*/ */
/* extendfs() parameter under s_state & FM_EXTENDFS */ /* extendfs() parameter under s_state & FM_EXTENDFS */
...@@ -99,9 +100,9 @@ struct jfs_superblock { ...@@ -99,9 +100,9 @@ struct jfs_superblock {
pxd_t s_xlogpxd; /* 8: extendfs logpxd */ pxd_t s_xlogpxd; /* 8: extendfs logpxd */
/* - 128 byte boundary - */ /* - 128 byte boundary - */
u32 s_device; /* Store device in case location changes char s_uuid[16]; /* 16: 128-bit uuid for volume */
* between reboots char s_label[16]; /* 16: volume label */
*/ char s_loguuid[16]; /* 16: 128-bit uuid for log device */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment