md: Make sync_page_io aware of underlying block size.

sync_page_io is sometimes called on to read an object smaller than a
page.  If that happens to be smaller than the physical block size
of the device, the size needs to be rounded up.

This is particularly import for use of sync_page_io by dm-raid.

This is a simple fix for a bug that stops dm-raid from working on 4K
phys-sector devices.  So it seems suitable for -stable at low
priority.

Signed-off-by: NeilBrown  <neilb@suse.de>
Cc: stable@vger.kernel.org (After release of 3.18)
Reported-by: Liuhua Wang <lwang@suse.com>
md/bitmap: always wait for writes on unplug.

If two threads call bitmap_unplug at the same time, then
one might schedule all the writes, and the other might
decide that it doesn't need to wait.  But really it does.

It rarely hurts to wait when it isn't absolutely necessary,
and the current code doesn't really focus on 'absolutely necessary'
anyway.  So just wait always.

This can potentially lead to data corruption if a crash happens
at an awkward time and data was written before the bitmap was
updated.  It is very unlikely, but this should go to -stable
just to be safe.  Appropriate for any -stable.

Signed-off-by: NeilBrown <neilb@suse.de>
Cc: stable@vger.kernel.org (please delay until 3.18 is released)
md/raid1: minor typos and reformatting.

Signed-off-by: NeilBrown <neilb@suse.de>
md: use set_bit/clear_bit instead of shift/mask for bi_flags changes.

Using {set,clear}_bit is more consistent that << and masking.

No functional change.

Signed-off-by: NeilBrown <neilb@suse.de>
md/raid10: another memory leak due to reshape.

Signed-off-by: NeilBrown <neilb@suse.de>
md/raid5: fix init_stripe() inconsistencies

raid5: fix init_stripe() inconsistencies

1) remove_hash() is not necessary. We will only be called right after
   get_free_stripe(). There we have already a call to remove_hash().

2) Tracing prints out the sector of the freed stripe and not the sector
   that we want to initialize.

Signed-off-by: NeilBrown <neilb@suse.de>
md/raid1: process_checks doesn't use its return value.

process_checks() always returns '0', so change it to 'void'.

Signed-off-by: NeilBrown <neilb@suse.de>
md: be more relaxed about stopping an array which isn't started.

In general we don't allow an array to be stopped if it is in use.
However if the array hasn't really been started yet, then any
apparent use is an anomily, probably due to 'udev' or similar
having a look to see what is there.

This means that if something goes wrong while assembling an array
it cannot reliably be un-assembled - STOP_ARRAY could fail.
There is no value here, so change do_md_stop() to succeed
despite concurrent opens if the array has not yet been
activated.  i.e. if ->pers is NULL.

Reported-by: "Baldysiak, Pawel" <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
md: use wait_event() to simplify md_super_wait()

md_super_wait is really just wait_event() open-coded.
So use the macro instead.

Signed-off-by: NeilBrown <neilb@suse.de>
md/bitmap: remove bev_logical_block_size rounding where not needed.

Now that sync_page_io rounds up the size, read_sb_page() doesn't
need too.

Signed-off-by: NeilBrown <neilb@suse.de>