[ENBD] 2.4.32 write & m_r problem
Peter T. Breuer
ptb at it.uc3m.es
Wed Mar 3 14:14:01 MST 2004
OK, just an update on this one.
The problem is localized in enbd-server.c, in the do_srv_write routine.
We have a set of changes that flips the right/wrong behavior, more or
less (i.e. I calculate that it should, via code interpolation
techniques). But the changes are so subtle that I can't see what makes
them right or wrong. So I'll just revert that routine.
I'll also step a few other things backwards, call that "2.4.32" and
release it, and try other things in 2.4.33.
FYI, here is the change that nobody can see what makes it right or
wrong. Looked like only clean-ups to me. This is in the write-align
area. It is likely that the problem is a counting error under unusual
circumstances, causing a skipped write.
In the old code, a loop chipped away at request->len by reading a bit of
it from net and writing a bit of what it got to disk. But it
decremented request->len as soon as a read occurred. In the new code,
the decrement happened at the end of the loop. That's about all the
significant difference I can see!
Weird.
I'm settling 2.4.32 right now.
Peter
--- do_srv_write-working.txt Wed Mar 3 19:59:52 2004
+++ do_srv_write-nonworking.txt Wed Mar 3 19:33:38 2004
@@ -103,11 +103,13 @@
if (rsiz < 0) {
DEBUG ("failed to read %d bytes from net: %m\n", request->len);
- ERROR (reply); // PTB give error reply
+ reply->error = rsiz; // PTB signal media error
return -EINVAL; // PTB die die
}
blen += rsiz;
+ buflen += rsiz;
+ request->len -= rsiz;
DEBUG ("upcoming write sector %Ld-%Ld seqno %d, ondisk seqno %d\n",
request->from >> 9, (request->from + request->len - 1) >> 9,
@@ -115,27 +117,27 @@
// PTB write_to_disk:
- if (blen >= self->blksize) {
+ if (buflen >= self->blksize) {
// PTB write out at least a blksize worth now
- wsiz = blen - blen % self->blksize;
+ wsiz = buflen - buflen % self->blksize;
goto do_write;
}
- if (blen + (request->len - rsiz) >= self->blksize) {
+ if (buflen + request->len >= self->blksize) {
// PTB we expect more, go round and read again
wsiz = 0;
goto skip_write;
}
- if (blen >= 1024) {
+ if (buflen >= 1024) {
// PTB write out at least a KB worth now
- wsiz = (blen >> 10) << 10;
+ wsiz = buflen & ~(1024 - 1);
goto do_write;
}
- if (blen + (request->len - rsiz) >= 1024) {
+ if (buflen + request->len >= 1024) {
// PTB we expect more, go round and read again
wsiz = 0;
goto skip_write;
}
- wsiz = blen;
+ wsiz = buflen;
// PTB just write what we have. We could try and recover later
goto do_write;
@@ -143,16 +145,16 @@
res = server->write (server, self->buffer + boffset, wsiz, request->from);
if (res < wsiz) {
- ERROR (reply); // PTB give error reply
+ // PTB signal remote error
+ reply->error = res < 0 ? -res : EINVAL;
return 0; // PTB ready for next time round
}
-
-skip_write:
request->from += wsiz;
- request->len -= rsiz;
- buflen += rsiz;
boffset += wsiz;
+ buflen -= wsiz;
blen -= wsiz;
+
+skip_write:
}
// PTB tell world we handled it
More information about the ENBD
mailing list