Date: Tue, 2 Oct 2012 18:00:06 +0300 From: Boris Astardzhiev <boris.astardzhiev@gmail.com> To: freebsd-fs@freebsd.org Cc: gjb@semihalf.com, Grzegorz Bernacki <gber@freebsd.org>, stanislav_galabov@smartcom.bg Subject: libstand's NANDFS superblock detection fix Message-ID: <CAP=KkTzMeWVh=NavOOgzytyOf_Qjr2S3tSYZNmFxEZWg%2Bn0GOA@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hello,
On behalf of Smartcom Bulgaria AD I would like to contribute a patch for
libstand's NANDFS support in FreeBSD.
It is related to the correct detection of a superblock when accessing the
filesystem. It's also been noticed that
the election of a superblock between kernelspace and libstand's one differs
regarding the checkpoint number.
The patch is attached.
Comments will be appreciated.
Greetings,
Boris Astardzhiev / Smartcom Bulgaria AD
[-- Attachment #2 --]
diff --git a/lib/libstand/nandfs.c b/lib/libstand/nandfs.c
index 67e2fea..ef6e6fc 100644
--- a/lib/libstand/nandfs.c
+++ b/lib/libstand/nandfs.c
@@ -175,7 +175,7 @@ static int
nandfs_find_super_block(struct nandfs *fs, struct open_file *f)
{
struct nandfs_super_block *sb;
- int i, j, n;
+ int i, j, n, s;
int sectors_to_read, error;
sb = malloc(fs->nf_sectorsize);
@@ -196,23 +196,28 @@ nandfs_find_super_block(struct nandfs *fs, struct open_file *f)
continue;
}
n = fs->nf_sectorsize / sizeof(struct nandfs_super_block);
+ s = 0;
if ((i * fs->nf_sectorsize) % fs->nf_fsdata->f_erasesize == 0) {
if (fs->nf_sectorsize == sizeof(struct nandfs_fsdata))
continue;
else {
+ s += (sizeof(struct nandfs_fsdata) /
+ sizeof(struct nandfs_super_block));
+#if 0
sb += (sizeof(struct nandfs_fsdata) /
sizeof(struct nandfs_super_block));
n -= (sizeof(struct nandfs_fsdata) /
sizeof(struct nandfs_super_block));
+#endif
}
}
- for (j = 0; j < n; j++) {
+ for (j = s; j < n; j++) {
if (!nandfs_check_superblock_crc(fs->nf_fsdata, &sb[j]))
continue;
- NANDFS_DEBUG("magic %x wtime %jd\n", sb->s_magic,
- sb->s_wtime);
- if (sb[j].s_wtime > fs->nf_sb->s_wtime)
+ NANDFS_DEBUG("magic %x wtime %jd, lastcp 0x%jx\n",
+ sb[j].s_magic, sb[j].s_wtime, sb[j].s_last_cno);
+ if (sb[j].s_last_cno > fs->nf_sb->s_last_cno)
memcpy(fs->nf_sb, &sb[j], sizeof(*fs->nf_sb));
}
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAP=KkTzMeWVh=NavOOgzytyOf_Qjr2S3tSYZNmFxEZWg%2Bn0GOA>
