caches-queues-lists: Rearrange struct file_buffer

Move long longs to the start of the structure, on 32-bit
nachines these are, obviously, longer than pointers.
Making them first avoids the necessity of the compiler to insert
4-bytes of padding between the pointers and the long longs to get
8 byte alignment.

The reduction of the structure size from 68 bytes to 64 bytes,
also means the compiler doesn't have to pad the structure out to
72 bytes to get an 8 byte multiple (again to ensure 8 byte
alignment of long longs).

This makes a saving of 8 bytes on 32-bit machines.  On
64-bit machines there is no difference.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
caches-queues-lists: Merge sequence and index in struct file_buffer

Now that the deflator thread(s) do not hash the writer block, the index
and sequence fields are never in use at the same time.

The sequence field is needed to correctly order the blocks output by the
seq_queue, but at this time, none of the blocks are hashed and index is
unused.  Once the blocks are obtained from the seq_queue they are either
discarded (uncompressed fragment blocks and empty file blocks) and never
hashed, or they are hashed by the main thread later.  But when this happens
the sequence field is no longer in use.

So we can merge the two fields which saves 8 bytes.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: write_file() only set status if read buffer errored

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Mksquashfs: write_file(), read_size is now largely redundant

eigned-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: write_file_frag() no longer needs the size argument

It is now (and has been for quite a few years) stored in the
file_buffer which is also passed in.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: write_file_blocks_dup() no longer needs the read_size argument

It is now (and has been for quite a few years) stored in the                    file_buffer which is also passed in.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: write_file_blocks() no longer needs the read_size argument

It is now (and has been for quite a few years) stored in the
file_buffer which is also passed in.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: tidy up code in write_file() by shrinking variable names

Plus eliminate the unnecessary jump to file_err.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: pass reader_buffer to write_file_empty()

Make the behaviour of write_file_empty() match the
other write_file_*() functions, where it deletes the
reader_buffer.

This removes the messy special handling of write_file_empty()
in write_file() where it has to delete the reader_buffer
but only for write_file_empty().

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: reader_read_process(), remove file_buffer->block = count

Remove the setting of file_buffer->block to the file block count.
This value is never used.

A little bit of Squashfs archaeology shows this was in the earliest version
of parallel Mksquashfs from 2006, and the value wasn't used then either!
It is high time it was removed.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: reader_read_file(), remove file_buffer->block = count

Remove the setting of file_buffer->block to the file block count.
This value is never used.

A little bit of Squashfs archaeology shows this was in the earliest version
of parallel Mksquashfs from 2006, and the value wasn't used then either!
It is high time it was removed.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: reader_read_file(), get rid of count

Get of rid of count now it is no longer used.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: write_file_blocks_dup(), bring into line with write_file_frag_dup()

Write_file_frag() does pre duplicate checking, and calls
write_file_frag_dup().

Make the behaviour of write_file_blocks() the same.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: write_file_frag_dup() no longer needs the size argument

It is now (and has been for quite a few years) stored in the
file_buffer which is also passed in.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: reader_read_file(), optimise expected away

This also fixes a bug in handling files of an exact multiple
of the block size, introduced in the recent commit to remove
count.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: reader_read_file(), optimise byte away

Plus re-organise some code to make flow cleaner, and to
take advantage of the fact that we are now using blocks
as a decrementing counter, so we easily know if this is
the last iteration.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
process_fragments: move fragment checksumming to the process fragment threads

Move fragment checksumming to the process fragment threads, and away
from the main thread.

This has a couple of minor side effects:

1. Tail end fragments (fragments belonging to files larger than the
block size) are now checksummed up front.

2. This means add_non_dup() gains an extra checksum_frag_flag,
because we now have a combination of True/False statuses for
the block checksum and the fragment checksum.  Previously, we
either had both the block checksum and fragment checksum, or neither.
(fragments pre-existing on disk on append are not checksummed up front).

3. duplicate() no longer needs the fragment checksum to be passed,
because it is contained within the file_buffer structure which
is always passed.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: initialise pos_mutex

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: statically initialise fragment_mutex

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
xattr: Rename dupl[] to dupl_value[]

Rename dupl[] to dupl_value[] to match dup_id[]

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>