Re: [PATCH take2 1/5] dio: centralize completion in dio_complete()
- From: Zach Brown <zach.brown@xxxxxxxxxx>
- Date: Tue, 03 Oct 2006 16:05:12 -0700
-static void dio_complete(struct dio *dio, loff_t offset, ssize_t bytes)
+static int dio_complete(struct dio *dio, loff_t offset, int ret)
{
+ ssize_t transferred = 0;
+
+ if (dio->result) {
+ transferred = dio->result;
+
+ /* Check for short read case */
+ if ((dio->rw == READ) && ((offset + transferred) > dio->i_size))
+ transferred = dio->i_size - offset;
On 32-bit machines ssize_t is `int' and loff_t is `long long'. I guess
`transferred' cannot overflow because you can't write >4G. And I guess
`transferred' cannot go negative because you cannot write >=2G. Can you
confirm that thinking?
Well, I think this ssize_t mirrors the return types for the read and
write syscalls and match the ssize_t wrapping checks on input by
rw_verify_area() and do_readv_writev(). I *think* that covers it,
though I haven't really audited all the ways to get to this code.
- z
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- References:
- [PATCH take2 0/5] dio: clean up completion phase of direct_io_worker()
- From: Zach Brown
- [PATCH take2 1/5] dio: centralize completion in dio_complete()
- From: Zach Brown
- Re: [PATCH take2 1/5] dio: centralize completion in dio_complete()
- From: Andrew Morton
- [PATCH take2 0/5] dio: clean up completion phase of direct_io_worker()
- Prev by Date: Re: [PATCH take2 0/5] dio: clean up completion phase of direct_io_worker()
- Next by Date: please pull from the trivial tree
- Previous by thread: Re: [PATCH take2 1/5] dio: centralize completion in dio_complete()
- Next by thread: [PATCH take2 3/5] dio: formalize bio counters as a dio reference count
- Index(es):
Relevant Pages
|