Date: Thu, 13 Dec 2001 16:55:48 -0800 (PST) From: Matthew Dillon <dillon@apollo.backplane.com> To: Terry Lambert <tlambert2@mindspring.com> Cc: David Greenman <dg@root.com>, Jordan Hubbard <jkh@winston.freebsd.org>, Peter Wemm <peter@wemm.org>, Mike Smith <msmith@FreeBSD.ORG>, hackers@FreeBSD.ORG, msmith@mass.dis.org Subject: Re: NFS Patch #4 -- survived overnight test. (was Re: Found NFS data corruption bug... (was Re:...)) Message-ID: <200112140055.fBE0tmA61806@apollo.backplane.com> References: <58885.1008217148@winston.freebsd.org> <200112130608.fBD689K49906@apollo.backplane.com> <20011212224927.A73226@nexus.root.com> <200112131835.fBDIZuL70031@apollo.backplane.com> <3C18FAC9.E743DAA5@mindspring.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Terry's interest prompted me to redo my algorithm a bit and write a program to test it with various combinations of base and size. I've included the program below. My fixed algorithm appears to produce the correct results, which is to generate the DEV_BSIZE aligned range that is fully enclosed within the supplied range. So, for example, a base of 0x0020 and a size of 0x0040 will produce a range of 0x0200 to 0x0200 (i.e. a null range, meaning we can't clear any dirty bits at all for that particular case). I am going to re-test with the new algorithm. Terry, or anyone... if you are interesting in trying out your own algorithm fill it into algorithm2() below and enable the comparison code. Thanks for the comments, Terry! -Matt #include <stdio.h> #include <stdlib.h> #include <unistd.h> static void algorithm1(int *base, int *size); static void algorithm2(int *base, int *size); int main(int ac, char **av) { int base; int size; for (base = 0; base <= 4096; base += 32) { for (size = 0; size <= 4096 - base; size += 32) { int nbase1 = base, nsize1 = size; int nbase2 = base, nsize2 = size; algorithm1(&nbase1, &nsize1); printf("%04x-%04x -> %04x-%04x\n", base, base + size, nbase1, nbase1 + nsize1); #if 0 algorithm2(&nbase2, &nsize2); if (nbase1 != nbase2 || nsize1 != nsize2) { printf("%04x-%04x mismatch %04x-%04x vs %04x-%04x\n", base, base + size, nbase1, nbase1 + nsize1, nbase2, nbase2 + nsize2 ); } #endif } } } #define DEV_BSIZE 512 static void algorithm1(int *base, int *size) { int frag; if ((frag = *base & (DEV_BSIZE - 1)) != 0) { frag = DEV_BSIZE - frag; *base += frag; *size -= frag; if (*size < 0) *size = 0; } *size = *size & ~(DEV_BSIZE - 1); } #if 0 static void algorithm2(int *base, int *size) { ... } #endif To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200112140055.fBE0tmA61806>