dedupe_extent_list() cleanups

- move code to open file + put on list into filerec_open_once()

- use list_is_last to detect end of list rather than count

- assert on some end-cases that shouldn't happen

Code flow is still tricky but hopefully more readable at least now.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
dedupe_extent_list() fixes

We could exit the loop with a live context if there was exactly
MAX_DEDUPES_PER_IOCTL + 1 extents. The context gets cleaned up but that
means we might not dedupe that extent. Fix this by adding a previous extent
to the context and forcing a dedupe in that situation.

We also weren't bubbling up ENOMEM in case of error from
add_extent_to_dedupe().

Also, don't try dedupe if we ever only got one extent to succesfully be
added.

This patch also adds some asserts to help catch loop errors in the future.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Print the correct extent filename in case of error adding it to dedupe
context.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Import unlikely() from linux kernel source and use it for abort_on().

This is the only place where unlikely makes sense in the current code.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Merge branch 'dedupe_extent_list_fixes'
Obey --lookup-extents when loading from a hashfile.

Normally the block flags aren't set if --lookup-extents=no is specified, so
the block flags check always comes out negative. However, we'll get the
block flags set if the user loads from a hashfile. To fix this, explicitely
ignore them during the extent search.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>