aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/blkdev.h5
-rw-r--r--include/linux/cdrom.h6
-rw-r--r--include/linux/fs.h26
-rw-r--r--include/linux/genhd.h45
4 files changed, 66 insertions, 16 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 36ab42c9bb99..4d18ff34670a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -115,6 +115,7 @@ struct request {
115 void *elevator_private3; 115 void *elevator_private3;
116 116
117 struct gendisk *rq_disk; 117 struct gendisk *rq_disk;
118 struct hd_struct *part;
118 unsigned long start_time; 119 unsigned long start_time;
119#ifdef CONFIG_BLK_CGROUP 120#ifdef CONFIG_BLK_CGROUP
120 unsigned long long start_time_ns; 121 unsigned long long start_time_ns;
@@ -646,7 +647,6 @@ static inline void rq_flush_dcache_pages(struct request *rq)
646 647
647extern int blk_register_queue(struct gendisk *disk); 648extern int blk_register_queue(struct gendisk *disk);
648extern void blk_unregister_queue(struct gendisk *disk); 649extern void blk_unregister_queue(struct gendisk *disk);
649extern void register_disk(struct gendisk *dev);
650extern void generic_make_request(struct bio *bio); 650extern void generic_make_request(struct bio *bio);
651extern void blk_rq_init(struct request_queue *q, struct request *rq); 651extern void blk_rq_init(struct request_queue *q, struct request *rq);
652extern void blk_put_request(struct request *); 652extern void blk_put_request(struct request *);
@@ -1256,6 +1256,9 @@ struct block_device_operations {
1256 int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); 1256 int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
1257 int (*direct_access) (struct block_device *, sector_t, 1257 int (*direct_access) (struct block_device *, sector_t,
1258 void **, unsigned long *); 1258 void **, unsigned long *);
1259 unsigned int (*check_events) (struct gendisk *disk,
1260 unsigned int clearing);
1261 /* ->media_changed() is DEPRECATED, use ->check_events() instead */
1259 int (*media_changed) (struct gendisk *); 1262 int (*media_changed) (struct gendisk *);
1260 void (*unlock_native_capacity) (struct gendisk *); 1263 void (*unlock_native_capacity) (struct gendisk *);
1261 int (*revalidate_disk) (struct gendisk *); 1264 int (*revalidate_disk) (struct gendisk *);
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
index 78e904796622..35eae4b67503 100644
--- a/include/linux/cdrom.h
+++ b/include/linux/cdrom.h
@@ -946,6 +946,8 @@ struct cdrom_device_info {
946/* device-related storage */ 946/* device-related storage */
947 unsigned int options : 30; /* options flags */ 947 unsigned int options : 30; /* options flags */
948 unsigned mc_flags : 2; /* media change buffer flags */ 948 unsigned mc_flags : 2; /* media change buffer flags */
949 unsigned int vfs_events; /* cached events for vfs path */
950 unsigned int ioctl_events; /* cached events for ioctl path */
949 int use_count; /* number of times device opened */ 951 int use_count; /* number of times device opened */
950 char name[20]; /* name of the device type */ 952 char name[20]; /* name of the device type */
951/* per-device flags */ 953/* per-device flags */
@@ -965,6 +967,8 @@ struct cdrom_device_ops {
965 int (*open) (struct cdrom_device_info *, int); 967 int (*open) (struct cdrom_device_info *, int);
966 void (*release) (struct cdrom_device_info *); 968 void (*release) (struct cdrom_device_info *);
967 int (*drive_status) (struct cdrom_device_info *, int); 969 int (*drive_status) (struct cdrom_device_info *, int);
970 unsigned int (*check_events) (struct cdrom_device_info *cdi,
971 unsigned int clearing, int slot);
968 int (*media_changed) (struct cdrom_device_info *, int); 972 int (*media_changed) (struct cdrom_device_info *, int);
969 int (*tray_move) (struct cdrom_device_info *, int); 973 int (*tray_move) (struct cdrom_device_info *, int);
970 int (*lock_door) (struct cdrom_device_info *, int); 974 int (*lock_door) (struct cdrom_device_info *, int);
@@ -993,6 +997,8 @@ extern int cdrom_open(struct cdrom_device_info *cdi, struct block_device *bdev,
993extern void cdrom_release(struct cdrom_device_info *cdi, fmode_t mode); 997extern void cdrom_release(struct cdrom_device_info *cdi, fmode_t mode);
994extern int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev, 998extern int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev,
995 fmode_t mode, unsigned int cmd, unsigned long arg); 999 fmode_t mode, unsigned int cmd, unsigned long arg);
1000extern unsigned int cdrom_check_events(struct cdrom_device_info *cdi,
1001 unsigned int clearing);
996extern int cdrom_media_changed(struct cdrom_device_info *); 1002extern int cdrom_media_changed(struct cdrom_device_info *);
997 1003
998extern int register_cdrom(struct cdrom_device_info *cdi); 1004extern int register_cdrom(struct cdrom_device_info *cdi);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c0701288d204..3984f2358d1f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -664,8 +664,9 @@ struct block_device {
664 void * bd_claiming; 664 void * bd_claiming;
665 void * bd_holder; 665 void * bd_holder;
666 int bd_holders; 666 int bd_holders;
667 bool bd_write_holder;
667#ifdef CONFIG_SYSFS 668#ifdef CONFIG_SYSFS
668 struct list_head bd_holder_list; 669 struct gendisk * bd_holder_disk; /* for sysfs slave linkng */
669#endif 670#endif
670 struct block_device * bd_contains; 671 struct block_device * bd_contains;
671 unsigned bd_block_size; 672 unsigned bd_block_size;
@@ -2019,7 +2020,6 @@ extern struct block_device *bdgrab(struct block_device *bdev);
2019extern void bd_set_size(struct block_device *, loff_t size); 2020extern void bd_set_size(struct block_device *, loff_t size);
2020extern void bd_forget(struct inode *inode); 2021extern void bd_forget(struct inode *inode);
2021extern void bdput(struct block_device *); 2022extern void bdput(struct block_device *);
2022extern struct block_device *open_by_devnum(dev_t, fmode_t);
2023extern void invalidate_bdev(struct block_device *); 2023extern void invalidate_bdev(struct block_device *);
2024extern int sync_blockdev(struct block_device *bdev); 2024extern int sync_blockdev(struct block_device *bdev);
2025extern struct super_block *freeze_bdev(struct block_device *); 2025extern struct super_block *freeze_bdev(struct block_device *);
@@ -2050,16 +2050,20 @@ extern const struct file_operations def_fifo_fops;
2050extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); 2050extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
2051extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long); 2051extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long);
2052extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); 2052extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
2053extern int blkdev_get(struct block_device *, fmode_t); 2053extern int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder);
2054extern int blkdev_put(struct block_device *, fmode_t); 2054extern struct block_device *blkdev_get_by_path(const char *path, fmode_t mode,
2055extern int bd_claim(struct block_device *, void *); 2055 void *holder);
2056extern void bd_release(struct block_device *); 2056extern struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode,
2057 void *holder);
2058extern int blkdev_put(struct block_device *bdev, fmode_t mode);
2057#ifdef CONFIG_SYSFS 2059#ifdef CONFIG_SYSFS
2058extern int bd_claim_by_disk(struct block_device *, void *, struct gendisk *); 2060extern int bd_link_disk_holder(struct block_device *bdev, struct gendisk *disk);
2059extern void bd_release_from_disk(struct block_device *, struct gendisk *);
2060#else 2061#else
2061#define bd_claim_by_disk(bdev, holder, disk) bd_claim(bdev, holder) 2062static inline int bd_link_disk_holder(struct block_device *bdev,
2062#define bd_release_from_disk(bdev, disk) bd_release(bdev) 2063 struct gendisk *disk)
2064{
2065 return 0;
2066}
2063#endif 2067#endif
2064#endif 2068#endif
2065 2069
@@ -2095,8 +2099,6 @@ static inline void unregister_chrdev(unsigned int major, const char *name)
2095extern const char *__bdevname(dev_t, char *buffer); 2099extern const char *__bdevname(dev_t, char *buffer);
2096extern const char *bdevname(struct block_device *bdev, char *buffer); 2100extern const char *bdevname(struct block_device *bdev, char *buffer);
2097extern struct block_device *lookup_bdev(const char *); 2101extern struct block_device *lookup_bdev(const char *);
2098extern struct block_device *open_bdev_exclusive(const char *, fmode_t, void *);
2099extern void close_bdev_exclusive(struct block_device *, fmode_t);
2100extern void blkdev_show(struct seq_file *,off_t); 2102extern void blkdev_show(struct seq_file *,off_t);
2101 2103
2102#else 2104#else
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 7a7b9c1644e4..c0d5f6945c1e 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -115,6 +115,7 @@ struct hd_struct {
115#else 115#else
116 struct disk_stats dkstats; 116 struct disk_stats dkstats;
117#endif 117#endif
118 atomic_t ref;
118 struct rcu_head rcu_head; 119 struct rcu_head rcu_head;
119}; 120};
120 121
@@ -127,6 +128,11 @@ struct hd_struct {
127#define GENHD_FL_EXT_DEVT 64 /* allow extended devt */ 128#define GENHD_FL_EXT_DEVT 64 /* allow extended devt */
128#define GENHD_FL_NATIVE_CAPACITY 128 129#define GENHD_FL_NATIVE_CAPACITY 128
129 130
131enum {
132 DISK_EVENT_MEDIA_CHANGE = 1 << 0, /* media changed */
133 DISK_EVENT_EJECT_REQUEST = 1 << 1, /* eject requested */
134};
135
130#define BLK_SCSI_MAX_CMDS (256) 136#define BLK_SCSI_MAX_CMDS (256)
131#define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) 137#define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8))
132 138
@@ -143,6 +149,8 @@ struct disk_part_tbl {
143 struct hd_struct __rcu *part[]; 149 struct hd_struct __rcu *part[];
144}; 150};
145 151
152struct disk_events;
153
146struct gendisk { 154struct gendisk {
147 /* major, first_minor and minors are input parameters only, 155 /* major, first_minor and minors are input parameters only,
148 * don't use directly. Use disk_devt() and disk_max_parts(). 156 * don't use directly. Use disk_devt() and disk_max_parts().
@@ -154,6 +162,10 @@ struct gendisk {
154 162
155 char disk_name[DISK_NAME_LEN]; /* name of major driver */ 163 char disk_name[DISK_NAME_LEN]; /* name of major driver */
156 char *(*devnode)(struct gendisk *gd, mode_t *mode); 164 char *(*devnode)(struct gendisk *gd, mode_t *mode);
165
166 unsigned int events; /* supported events */
167 unsigned int async_events; /* async events, subset of all */
168
157 /* Array of pointers to partitions indexed by partno. 169 /* Array of pointers to partitions indexed by partno.
158 * Protected with matching bdev lock but stat and other 170 * Protected with matching bdev lock but stat and other
159 * non-critical accesses use RCU. Always access through 171 * non-critical accesses use RCU. Always access through
@@ -171,9 +183,8 @@ struct gendisk {
171 struct kobject *slave_dir; 183 struct kobject *slave_dir;
172 184
173 struct timer_rand_state *random; 185 struct timer_rand_state *random;
174
175 atomic_t sync_io; /* RAID */ 186 atomic_t sync_io; /* RAID */
176 struct work_struct async_notify; 187 struct disk_events *ev;
177#ifdef CONFIG_BLK_DEV_INTEGRITY 188#ifdef CONFIG_BLK_DEV_INTEGRITY
178 struct blk_integrity *integrity; 189 struct blk_integrity *integrity;
179#endif 190#endif
@@ -395,7 +406,6 @@ extern void part_round_stats(int cpu, struct hd_struct *part);
395/* block/genhd.c */ 406/* block/genhd.c */
396extern void add_disk(struct gendisk *disk); 407extern void add_disk(struct gendisk *disk);
397extern void del_gendisk(struct gendisk *gp); 408extern void del_gendisk(struct gendisk *gp);
398extern void unlink_gendisk(struct gendisk *gp);
399extern struct gendisk *get_gendisk(dev_t dev, int *partno); 409extern struct gendisk *get_gendisk(dev_t dev, int *partno);
400extern struct block_device *bdget_disk(struct gendisk *disk, int partno); 410extern struct block_device *bdget_disk(struct gendisk *disk, int partno);
401 411
@@ -407,6 +417,11 @@ static inline int get_disk_ro(struct gendisk *disk)
407 return disk->part0.policy; 417 return disk->part0.policy;
408} 418}
409 419
420extern void disk_block_events(struct gendisk *disk);
421extern void disk_unblock_events(struct gendisk *disk);
422extern void disk_check_events(struct gendisk *disk);
423extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
424
410/* drivers/char/random.c */ 425/* drivers/char/random.c */
411extern void add_disk_randomness(struct gendisk *disk); 426extern void add_disk_randomness(struct gendisk *disk);
412extern void rand_initialize_disk(struct gendisk *disk); 427extern void rand_initialize_disk(struct gendisk *disk);
@@ -583,6 +598,7 @@ extern struct hd_struct * __must_check add_partition(struct gendisk *disk,
583 sector_t len, int flags, 598 sector_t len, int flags,
584 struct partition_meta_info 599 struct partition_meta_info
585 *info); 600 *info);
601extern void __delete_partition(struct hd_struct *);
586extern void delete_partition(struct gendisk *, int); 602extern void delete_partition(struct gendisk *, int);
587extern void printk_all_partitions(void); 603extern void printk_all_partitions(void);
588 604
@@ -611,6 +627,29 @@ extern ssize_t part_fail_store(struct device *dev,
611 const char *buf, size_t count); 627 const char *buf, size_t count);
612#endif /* CONFIG_FAIL_MAKE_REQUEST */ 628#endif /* CONFIG_FAIL_MAKE_REQUEST */
613 629
630static inline void hd_ref_init(struct hd_struct *part)
631{
632 atomic_set(&part->ref, 1);
633 smp_mb();
634}
635
636static inline void hd_struct_get(struct hd_struct *part)
637{
638 atomic_inc(&part->ref);
639 smp_mb__after_atomic_inc();
640}
641
642static inline int hd_struct_try_get(struct hd_struct *part)
643{
644 return atomic_inc_not_zero(&part->ref);
645}
646
647static inline void hd_struct_put(struct hd_struct *part)
648{
649 if (atomic_dec_and_test(&part->ref))
650 __delete_partition(part);
651}
652
614#else /* CONFIG_BLOCK */ 653#else /* CONFIG_BLOCK */
615 654
616static inline void printk_all_partitions(void) { } 655static inline void printk_all_partitions(void) { }