btrfs: Cleanup for btrfs_calc_num_tolerated_disk_barrier_failures
authorZhao Lei <zhaolei@cn.fujitsu.com>
Thu, 16 Jul 2015 07:00:46 +0000 (15:00 +0800)
committerChris Mason <clm@fb.com>
Mon, 31 Aug 2015 18:45:47 +0000 (11:45 -0700)
commit2c4580454fffbf184fdb9292aa19ab1ffc224add
treea9857994347042ae7d1709697fcde157ffcb0a38
parent8c204c9657c32ec5a259ebf852a767afe7efdafa
btrfs: Cleanup for btrfs_calc_num_tolerated_disk_barrier_failures

1: Use ARRAY_SIZE(types) to replace a static-value variant:
   int num_types = 4;

2: Use 'continue' on condition to reduce one level tab
   if (!XXX) {
       code;
       ...
   }
   ->
   if (XXX)
       continue;
   code;
   ...

3: Put setting 'num_tolerated_disk_barrier_failures = 2' to
   (num_tolerated_disk_barrier_failures > 2) condition to make
   make logic neat.
   if (num_tolerated_disk_barrier_failures > 0 && XXX)
       num_tolerated_disk_barrier_failures = 0;
   else if (num_tolerated_disk_barrier_failures > 1) {
       if (XXX)
           num_tolerated_disk_barrier_failures = 1;
       else if (XXX)
           num_tolerated_disk_barrier_failures = 2;
   ->
   if (num_tolerated_disk_barrier_failures > 0 && XXX)
       num_tolerated_disk_barrier_failures = 0;
   if (num_tolerated_disk_barrier_failures > 1 && XXX)
       num_tolerated_disk_barrier_failures = ;
   if (num_tolerated_disk_barrier_failures > 2 && XXX)
       num_tolerated_disk_barrier_failures = 2;

4: Remove comment of:
   num_mirrors - 1: if RAID1 or RAID10 is configured and more
   than 2 mirrors are used.
   which is not fit with code.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/disk-io.c