]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - platform-intel.h
imsm: enforce "all member disks must be members of all arrays"
[thirdparty/mdadm.git] / platform-intel.h
index c1264825d930af4bd375971f5cfb33486db7be40..bbdc9f9508b4c95e6322b6ac5e8f776e4c939780 100644 (file)
@@ -17,6 +17,7 @@
  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  */
 #include <asm/types.h>
+#include <strings.h>
 
 /* The IMSM OROM Version Table definition */
 struct imsm_orom {
@@ -78,6 +79,42 @@ struct imsm_orom {
        __u32 reserved2;
 } __attribute__((packed));
 
+static inline int imsm_orom_has_raid0(const struct imsm_orom *orom)
+{
+       return !!(orom->rlc & IMSM_OROM_RLC_RAID0);
+}
+static inline int imsm_orom_has_raid1(const struct imsm_orom *orom)
+{
+       return !!(orom->rlc & IMSM_OROM_RLC_RAID1);
+}
+static inline int imsm_orom_has_raid1e(const struct imsm_orom *orom)
+{
+       return !!(orom->rlc & IMSM_OROM_RLC_RAID1E);
+}
+static inline int imsm_orom_has_raid10(const struct imsm_orom *orom)
+{
+       return !!(orom->rlc & IMSM_OROM_RLC_RAID10);
+}
+static inline int imsm_orom_has_raid5(const struct imsm_orom *orom)
+{
+       return !!(orom->rlc & IMSM_OROM_RLC_RAID5);
+}
+
+/**
+ * imsm_orom_has_chunk - check if the orom supports the given chunk size
+ * @orom: orom pointer from find_imsm_orom
+ * @chunk: chunk size in kibibytes
+ */
+static inline int imsm_orom_has_chunk(const struct imsm_orom *orom, int chunk)
+{
+       int fs = ffs(chunk);
+
+       if (!fs)
+               return 0;
+       fs--; /* bit num to bit index */
+       return !!(orom->sss & (1 << (fs - 1)));
+}
+
 struct sys_dev {
        char *path;
        struct sys_dev *next;