These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / include / linux / genhd.h
index ec274e0..847cc1d 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/kdev_t.h>
 #include <linux/rcupdate.h>
 #include <linux/slab.h>
+#include <linux/percpu-refcount.h>
 
 #ifdef CONFIG_BLOCK
 
@@ -124,7 +125,7 @@ struct hd_struct {
 #else
        struct disk_stats dkstats;
 #endif
-       atomic_t ref;
+       struct percpu_ref ref;
        struct rcu_head rcu_head;
 };
 
@@ -162,6 +163,18 @@ struct disk_part_tbl {
 
 struct disk_events;
 
+#if defined(CONFIG_BLK_DEV_INTEGRITY)
+
+struct blk_integrity {
+       struct blk_integrity_profile    *profile;
+       unsigned char                   flags;
+       unsigned char                   tuple_size;
+       unsigned char                   interval_exp;
+       unsigned char                   tag_size;
+};
+
+#endif /* CONFIG_BLK_DEV_INTEGRITY */
+
 struct gendisk {
        /* major, first_minor and minors are input parameters only,
         * don't use directly.  Use disk_devt() and disk_max_parts().
@@ -197,8 +210,8 @@ struct gendisk {
        atomic_t sync_io;               /* RAID */
        struct disk_events *ev;
 #ifdef  CONFIG_BLK_DEV_INTEGRITY
-       struct blk_integrity *integrity;
-#endif
+       struct kobject integrity_kobj;
+#endif /* CONFIG_BLK_DEV_INTEGRITY */
        int node_id;
 };
 
@@ -611,7 +624,7 @@ extern struct hd_struct * __must_check add_partition(struct gendisk *disk,
                                                     sector_t len, int flags,
                                                     struct partition_meta_info
                                                       *info);
-extern void __delete_partition(struct hd_struct *);
+extern void __delete_partition(struct percpu_ref *);
 extern void delete_partition(struct gendisk *, int);
 extern void printk_all_partitions(void);
 
@@ -640,27 +653,39 @@ extern ssize_t part_fail_store(struct device *dev,
                               const char *buf, size_t count);
 #endif /* CONFIG_FAIL_MAKE_REQUEST */
 
-static inline void hd_ref_init(struct hd_struct *part)
+static inline int hd_ref_init(struct hd_struct *part)
 {
-       atomic_set(&part->ref, 1);
-       smp_mb();
+       if (percpu_ref_init(&part->ref, __delete_partition, 0,
+                               GFP_KERNEL))
+               return -ENOMEM;
+       return 0;
 }
 
 static inline void hd_struct_get(struct hd_struct *part)
 {
-       atomic_inc(&part->ref);
-       smp_mb__after_atomic();
+       percpu_ref_get(&part->ref);
 }
 
 static inline int hd_struct_try_get(struct hd_struct *part)
 {
-       return atomic_inc_not_zero(&part->ref);
+       return percpu_ref_tryget_live(&part->ref);
 }
 
 static inline void hd_struct_put(struct hd_struct *part)
 {
-       if (atomic_dec_and_test(&part->ref))
-               __delete_partition(part);
+       percpu_ref_put(&part->ref);
+}
+
+static inline void hd_struct_kill(struct hd_struct *part)
+{
+       percpu_ref_kill(&part->ref);
+}
+
+static inline void hd_free_part(struct hd_struct *part)
+{
+       free_part_stats(part);
+       free_part_info(part);
+       percpu_ref_exit(&part->ref);
 }
 
 /*
@@ -714,6 +739,16 @@ static inline void part_nr_sects_write(struct hd_struct *part, sector_t size)
 #endif
 }
 
+#if defined(CONFIG_BLK_DEV_INTEGRITY)
+extern void blk_integrity_add(struct gendisk *);
+extern void blk_integrity_del(struct gendisk *);
+extern void blk_integrity_revalidate(struct gendisk *);
+#else  /* CONFIG_BLK_DEV_INTEGRITY */
+static inline void blk_integrity_add(struct gendisk *disk) { }
+static inline void blk_integrity_del(struct gendisk *disk) { }
+static inline void blk_integrity_revalidate(struct gendisk *disk) { }
+#endif /* CONFIG_BLK_DEV_INTEGRITY */
+
 #else /* CONFIG_BLOCK */
 
 static inline void printk_all_partitions(void) { }