On Sat, 2 Sep 2000, Linus Torvalds wrote:
> You don't actually have to be smart.
> There's a really simple way to avoid this: compare the thing you're going
> to zero out against zero before you memset() it to zero. If it was already
> zero, you just unlock the page and release.
> Downside: you have to read the page in, in order to compare. However, this
> turns out to be a non-issue: if there were no blocks on that page (like a
> forward truncate) this ends up generating no IO anyway. If there _were_
> blocks on the page, it's likely that one of them was the one we're going
> to partially clear anyway, so the "prepare_write()" would have had to read
> it in anyway.
> Upside: you don't need to mark it dirty unnecessarily, assuming you just
> extended the file. No extra allocation, and no extra write to disk.
> Comments? Basically the "grab_cache_page()" would be a "read_cache_page()"
> instead with all the wait-on-page etc stuff.
Works for me. However, that way it looks like a fs/buffer.c fodder.
Mind if I just call it block_zero_page(page, from, to) and export it?
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to firstname.lastname@example.org
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Thu Sep 07 2000 - 21:00:15 EST