reiser4: implement ->remount_fs() super operation

Add ->remount_fs() super option, which performs sync_filesystem()
needed when when transitioning from read-write to read-only, see
http://marc.info/?l=samba-technical&m=139550798721412&w=2 for details.

Panic when flushing read-only file system.

Signed-off-by: Edward Shishkin <edward.shishkin@gmail.com>
reiser4: block_alloc: add BA_SOME_SPACE flag for grabbing a fixed amount of space.

This is used for FITRIM ioctl which will iteratively grab, allocate and trim disk space
bit by bit to avoid starving the rest of system.

Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
reiser4: block_alloc: add a "forward" parameter to reiser4_blocknr_hint to allocate blocks only in forward direction.

Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
reiser4: txnmgr: free allocated but unneeded atom in atom_begin_and_assign_to_txnh().

It is unclear why it hasn't been done before, as there was a
corresponding notice, and such change apparently does not carry any side
effects.

Do this to avoid duplicating code in the next commit.

Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
reiser4: txnmgr: add reiser4_create_atom() which creates an empty atom without capturing any nodes.

Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
reiser4: txnmgr: call reiser4_post_write_back_hook() also for empty atoms.

The atoms generated by reiser4_trim_fs(), despite being empty (zero
capture_count), still have non-empty delete sets which have to be
processed.

Also the empty atom check has been moved after changing atom stage
to ASTAGE_PRE_COMMIT, because reiser4_post_write_back_hook() requires
atom to be unlocked.

Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
reiser4: batch discard support: add a dummy FITRIM ioctl handler for directories.

Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
reiser4: batch discard support: actually implement the FITRIM ioctl handler.

It works in an iterative way, grabbing some fixed amount of space and allocating
blocks until grabbed space is exhausted or partition's end is reached.

Blocks are scheduled for discard by allocating them and immediately adding them
to the atom's delete set, which is read and processed at atom commit time.

After reaching the allocation stop condition, the atom is force-committed and,
if the allocation has been stopped due to grabbed space exhaustion (not due to
reaching end of partition), another iteration happens.

Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
reiser4: block_alloc: add a "min_len" parameter to reiser4_blocknr_hint to limit allocated extent length from below.

The default has been 1, that is, the first encountered free extent with any length
from 1 to requested is allocated and returned.

So, allow changing minimal extent length to allocate.

Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
reiser4: batch discard support: honor minimal extent length passed from the userspace.