* PATCH [2.4.0test10]: Kiobuf#01, expand IO return codes from iobufs
@ 2000-11-02 12:34 Stephen C. Tweedie
2000-11-02 13:42 ` Malcolm Beattie
0 siblings, 1 reply; 2+ messages in thread
From: Stephen C. Tweedie @ 2000-11-02 12:34 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Rik van Riel, Ingo Molnar, Stephen Tweedie, linux-mm
[-- Attachment #1: Type: text/plain, Size: 334 bytes --]
Hi,
Kiobuf diff 01: allow for both the errno and the number of bytes
transferred to be returned in a kiobuf after IO. We need both in
order to know how many pages have been dirtied after a failed IO.
Also includes a fix to the brw_kiovec code to make sure that EIO is
returned if no bytes were transferred successfully.
--Stephen
[-- Attachment #2: 01-retval.diff --]
[-- Type: text/plain, Size: 1791 bytes --]
diff -ru linux-2.4.0-test10.kio.00/drivers/char/raw.c linux-2.4.0-test10.kio.01/drivers/char/raw.c
--- linux-2.4.0-test10.kio.00/drivers/char/raw.c Wed Nov 1 22:25:30 2000
+++ linux-2.4.0-test10.kio.01/drivers/char/raw.c Thu Nov 2 12:00:35 2000
@@ -321,10 +321,10 @@
err = brw_kiovec(rw, 1, &iobuf, dev, b, sector_size);
+ transferred += iobuf->retval;
if (err >= 0) {
- transferred += err;
- size -= err;
- buf += err;
+ size -= iobuf->retval;
+ buf += iobuf->retval;
}
unmap_kiobuf(iobuf); /* The unlock_kiobuf is implicit here */
diff -ru linux-2.4.0-test10.kio.00/fs/buffer.c linux-2.4.0-test10.kio.01/fs/buffer.c
--- linux-2.4.0-test10.kio.00/fs/buffer.c Wed Nov 1 22:25:34 2000
+++ linux-2.4.0-test10.kio.01/fs/buffer.c Thu Nov 2 12:01:14 2000
@@ -1924,6 +1924,8 @@
spin_unlock(&unused_list_lock);
+ if (!iosize)
+ return -EIO;
return iosize;
}
@@ -2049,6 +2051,11 @@
}
finished:
+
+ iobuf->retval = transferred;
+ if (err < 0)
+ iobuf->errno = err;
+
if (transferred)
return transferred;
return err;
diff -ru linux-2.4.0-test10.kio.00/include/linux/iobuf.h linux-2.4.0-test10.kio.01/include/linux/iobuf.h
--- linux-2.4.0-test10.kio.00/include/linux/iobuf.h Thu Nov 2 12:02:43 2000
+++ linux-2.4.0-test10.kio.01/include/linux/iobuf.h Thu Nov 2 12:07:27 2000
@@ -52,7 +52,12 @@
/* Dynamic state for IO completion: */
atomic_t io_count; /* IOs still in progress */
- int errno; /* Status of completed IO */
+
+ /* Equivalent to the return value and "errno" after a syscall: */
+ int errno; /* Error from completed IO (usual
+ kernel negative values) */
+ int retval; /* Return value of completed IO */
+
void (*end_io) (struct kiobuf *); /* Completion callback */
wait_queue_head_t wait_queue;
};
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: PATCH [2.4.0test10]: Kiobuf#01, expand IO return codes from iobufs
2000-11-02 12:34 PATCH [2.4.0test10]: Kiobuf#01, expand IO return codes from iobufs Stephen C. Tweedie
@ 2000-11-02 13:42 ` Malcolm Beattie
0 siblings, 0 replies; 2+ messages in thread
From: Malcolm Beattie @ 2000-11-02 13:42 UTC (permalink / raw)
To: Stephen C. Tweedie; +Cc: Linus Torvalds, Rik van Riel, Ingo Molnar, linux-mm
Stephen C. Tweedie writes:
> Kiobuf diff 01: allow for both the errno and the number of bytes
> transferred to be returned in a kiobuf after IO. We need both in
> order to know how many pages have been dirtied after a failed IO.
[...]
> - int errno; /* Status of completed IO */
> +
> + /* Equivalent to the return value and "errno" after a syscall: */
> + int errno; /* Error from completed IO (usual
> + kernel negative values) */
Although it's nicely commented that errno holds a negative value,
wouldn't it be better to use the usual kernel convention that "err"
holds negative error numbers and "errno" holds positive userland-like
ones? (There are a few places in the kernel which use things called
errno to hold negative numbers but very few). It would just be one
extra little way to help the brain distinguish between the conventions
when using kiobuf and maybe prevent someone beating their head against
a brick wall for a day or two because "if (foo.errno == EIO)" looked
too normal.
--Malcolm
--
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Unix Systems Programmer
Oxford University Computing Services
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-11-02 13:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-11-02 12:34 PATCH [2.4.0test10]: Kiobuf#01, expand IO return codes from iobufs Stephen C. Tweedie
2000-11-02 13:42 ` Malcolm Beattie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox