lib/cleaner_exec.c: get process ID of cleanerd through pipe

After applying commit 8ce4b524a1654ece478f54fce772cc0c16e3c559
"cleanerd: call _exit(2) twice for ensuring not being a session
leader", the mount helper program of nilfs2 no longer gets proper
process ID (pid) of cleaner daemon, and umount.nilfs2 fails to kill
cleanerd.

This fixes the issue by letting cleanerd print out the pid of spawned
daemon and letting nilfs_launch_cleanerd() function read it through
pipe.

Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
mount.nilfs2: ensure gcpid option is dropped if the value is zero

Legacy version of mount.nilfs2 and umount.nilfs2 may leave invalid
mount option string "gcpid=0" in /etc/mtab.  This adds a new macro
replace_drop_opt() which replaces or drops mount option based on the
given condition, and uses the macro to ensure the gcpid option will be
deleted when its value equals zero.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
lib/nilfs.c: add missing comments of API functions

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
nilfs-utils: cldconfig add an option to set minimal free blocks

With this option the user can specify the minimal number of free/dead
blocks before a segment can be cleaned. This is a threshold for the GC
to prevent needless moving of data. If there are less free blocks
to gain from cleaning a segment than the specified number, the GC will
abort and try again with a different segment.

By setting it to 0 this feature is effectively disabled.

Signed-off-by: Andreas Rohner <andreas.rohner@gmx.net>
nilfs-utils: cleanerd: add custom error value to enable fast retry

This patch adds the custom error value EGCTRYAGAIN, which signals to
cleanerd to retry the GC process as soon as possible with no timeout.

If the GC decides not to do any real work and only changes a few
metadata bytes, there is no need for a timeout. Furthermore if the GC is
running, there is probably not enough free space on the device and it is
crucial to retry quickly.

Signed-off-by: Andreas Rohner <andreas.rohner@gmx.net>
nilfs-utils: refactoring of nilfs_reclaim_segment to add minblocks param

nilfs_reclaim_segment gathers all the necessary information to decide,
how many reclaimable blocks there are in the segments that are to be
cleaned.

By enabling the passing of the threshold value
minblocks, nilfs_reclaim_segment can check the actual value against the
threshold.

Signed-off-by: Andreas Rohner <andreas.rohner@gmx.net>
nilfs-utils: add support for NILFS_IOCTL_SET_SUINFO ioctl

With this ioctl the segment usage information in the SUFILE can be
updated from userspace.

This is useful, because it allows the GC to modify and update segment
usage entries for specific segments, which enables it to avoid
unnecessary write operations.

If a segment needs to be cleaned, but there is no or very little free
space to be gained, the cleaning operation basically degrades to
needless expensive copying of data. In the end the only thing that
changes is the location of the data and a timestamp in the segment
usage info. With this ioctl the GC can skip the copying and update the
segment usage entries directly instead.

Additionally this patch implements a simple check in
nilfs_reclaim_segment. If the number of free blocks that can be gained
by cleaning the segments is below the threshold of minblocks, it simply
updates the segment usage information instead.

Signed-off-by: Andreas Rohner <andreas.rohner@gmx.net>
nilfs-utils: man: add description of min_free_blocks_threshold

Adds a description of the new min_free_blocks_threshold and
mc_min_free_blocks_threshold options in the config file and the new
command line parameter -t for nilfs-clean.

Signed-off-by: Andreas Rohner <andreas.rohner@gmx.net>
temporary commit
add logging