Attempt to fix #84 by releasing per-chunk lock and acquiring generation lock before re-acquiring the per-chunk lock if generation is necessary.

Signed-off-by: Ross Allan <rallanpcl@gmail.com>