introduce a nr_pages function to make the dirty mapping code clearer

Also, change the 'every other page' routines to work sometimes
on the odd pages, sometimes on the even.