Date: Wed, 3 Oct 2012 11:49:33 +0300 From: Boris Astardzhiev <boris.astardzhiev@gmail.com> To: Grzegorz Bernacki <gber@freebsd.org> Cc: freebsd-fs@freebsd.org, stanislav_galabov@smartcom.bg Subject: Re: libstand's NANDFS superblock detection fix Message-ID: <CAP=KkTwmpz-%2BffS7RPwH=CyMmNeT8ccO0wEjT4tF4D1ATG9H0Q@mail.gmail.com> In-Reply-To: <506C082B.8000207@freebsd.org> References: <CAP=KkTzMeWVh=NavOOgzytyOf_Qjr2S3tSYZNmFxEZWg%2Bn0GOA@mail.gmail.com> <506C082B.8000207@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hello,
About the checkpoint numbers - we have noticed that
libstand-nandfs' judgement is by sb->s_wtime whereas kernelspace
does it by sb->s_last_cno (sys/fs/nandfs/nandfs_vfsops.c:1590).
The patch is attached without the #if 0 part and is ready
to be submitted. I don't have commit privileges and I don't know
the right procedure further. Do I need to send a PR or something else?
I'll anticipate your reply.
Greetings,
Boris
On Wed, Oct 3, 2012 at 12:40 PM, Grzegorz Bernacki <gber@freebsd.org> wrote:
> On 10/02/12 17:00, Boris Astardzhiev wrote:
>
>> 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
>>
>
> Hello Boris,
>
> Patch looks fine. Just remove code under #if 0 and it can be submitted.
> Please let me know if you want to do it or you can do it yourself.
> Give me some more time and I will check checkpoint number differs you
> mentioned.
>
> thanks a lot for you contribution,
> grzesiek
>
[-- Attachment #2 --]
diff --git a/lib/libstand/nandfs.c b/lib/libstand/nandfs.c
index 67e2fea..d5fcb9d 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,22 @@ 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 {
- sb += (sizeof(struct nandfs_fsdata) /
- sizeof(struct nandfs_super_block));
- n -= (sizeof(struct nandfs_fsdata) /
+ s += (sizeof(struct nandfs_fsdata) /
sizeof(struct nandfs_super_block));
}
}
- 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=KkTwmpz-%2BffS7RPwH=CyMmNeT8ccO0wEjT4tF4D1ATG9H0Q>
