X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=volumes.h;h=5bcaae7f03d2ef54d249ec0efbd179b049b1f755;hb=30b852cd7e2299ba7795cd302d783724d88e101f;hp=bc3516aa3d782aca029f891720a82a146901cedb;hpb=12becfe1220bb4e45e529d4d2363394431605deb;p=platform%2Fupstream%2Fbtrfs-progs.git diff --git a/volumes.h b/volumes.h index bc3516a..5bcaae7 100644 --- a/volumes.h +++ b/volumes.h @@ -209,6 +209,28 @@ static inline int check_crossing_stripes(struct btrfs_fs_info *fs_info, (bg_offset + len - 1) / BTRFS_STRIPE_LEN); } +static inline u64 calc_stripe_length(u64 type, u64 length, int num_stripes) +{ + u64 stripe_size; + + if (type & BTRFS_BLOCK_GROUP_RAID0) { + stripe_size = length; + stripe_size /= num_stripes; + } else if (type & BTRFS_BLOCK_GROUP_RAID10) { + stripe_size = length * 2; + stripe_size /= num_stripes; + } else if (type & BTRFS_BLOCK_GROUP_RAID5) { + stripe_size = length; + stripe_size /= (num_stripes - 1); + } else if (type & BTRFS_BLOCK_GROUP_RAID6) { + stripe_size = length; + stripe_size /= (num_stripes - 2); + } else { + stripe_size = length; + } + return stripe_size; +} + int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw, u64 logical, u64 *length, u64 *type, struct btrfs_multi_bio **multi_ret, int mirror_num,