Commit 6b388653 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] infrastructure

	* added ->media_changed(disk).  Callers of ->check_media_changed()
are using that one if present
	* added ->revaldiate_disk(disk).  Callers of ->revalidate()
are using that one if present
	* added disk->queue.  do_open() uses it if non-NULL
	* added disk->private_data
	* removed assignments to inode->i_data.backing_... - it belongs to
filesystem that contains device node and we don't care about it;
inode->i_mapping points to ->i_data of bdev inode and there we should
(and do) set that field.
parent 4978a1f0
...@@ -527,15 +527,20 @@ int check_disk_change(struct block_device *bdev) ...@@ -527,15 +527,20 @@ int check_disk_change(struct block_device *bdev)
struct block_device_operations * bdops = bdev->bd_op; struct block_device_operations * bdops = bdev->bd_op;
kdev_t dev = to_kdev_t(bdev->bd_dev); kdev_t dev = to_kdev_t(bdev->bd_dev);
if (!bdops->media_changed) {
if (bdops->check_media_change == NULL) if (bdops->check_media_change == NULL)
return 0; return 0;
if (!bdops->check_media_change(dev)) if (!bdops->check_media_change(dev))
return 0; return 0;
} else if (!bdops->media_changed(bdev->bd_disk))
return 0;
if (invalidate_device(dev, 0)) if (invalidate_device(dev, 0))
printk("VFS: busy inodes on changed media.\n"); printk("VFS: busy inodes on changed media.\n");
if (bdops->revalidate) if (bdops->revalidate_disk)
bdops->revalidate_disk(bdev->bd_disk);
else if (bdops->revalidate)
bdops->revalidate(dev); bdops->revalidate(dev);
if (bdev->bd_disk->minors > 1) if (bdev->bd_disk->minors > 1)
bdev->bd_invalidated = 1; bdev->bd_invalidated = 1;
...@@ -633,11 +638,15 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file * ...@@ -633,11 +638,15 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
if (!bdev->bd_openers) if (!bdev->bd_openers)
bdev->bd_disk = disk; bdev->bd_disk = disk;
if (!bdev->bd_queue) { if (!bdev->bd_queue) {
if (disk->queue)
bdev->bd_queue = disk->queue;
else {
struct blk_dev_struct *p = blk_dev + major(dev); struct blk_dev_struct *p = blk_dev + major(dev);
bdev->bd_queue = &p->request_queue; bdev->bd_queue = &p->request_queue;
if (p->queue) if (p->queue)
bdev->bd_queue = p->queue(dev); bdev->bd_queue = p->queue(dev);
} }
}
if (bdev->bd_op->open) { if (bdev->bd_op->open) {
ret = bdev->bd_op->open(inode, file); ret = bdev->bd_op->open(inode, file);
if (ret) if (ret)
...@@ -650,7 +659,6 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file * ...@@ -650,7 +659,6 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
bdi = blk_get_backing_dev_info(bdev); bdi = blk_get_backing_dev_info(bdev);
if (bdi == NULL) if (bdi == NULL)
bdi = &default_backing_dev_info; bdi = &default_backing_dev_info;
inode->i_data.backing_dev_info = bdi;
bdev->bd_inode->i_data.backing_dev_info = bdi; bdev->bd_inode->i_data.backing_dev_info = bdi;
} }
if (bdev->bd_invalidated) if (bdev->bd_invalidated)
...@@ -661,7 +669,6 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file * ...@@ -661,7 +669,6 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
if (!bdev->bd_openers) { if (!bdev->bd_openers) {
struct hd_struct *p; struct hd_struct *p;
p = disk->part + part - 1; p = disk->part + part - 1;
inode->i_data.backing_dev_info =
bdev->bd_inode->i_data.backing_dev_info = bdev->bd_inode->i_data.backing_dev_info =
bdev->bd_contains->bd_inode->i_data.backing_dev_info; bdev->bd_contains->bd_inode->i_data.backing_dev_info;
if (!(disk->flags & GENHD_FL_UP) || !p->nr_sects) { if (!(disk->flags & GENHD_FL_UP) || !p->nr_sects) {
...@@ -685,6 +692,8 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file * ...@@ -685,6 +692,8 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
out2: out2:
if (!bdev->bd_openers) { if (!bdev->bd_openers) {
bdev->bd_queue = NULL;
bdev->bd_disk = NULL;
bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info; bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
if (bdev != bdev->bd_contains) { if (bdev != bdev->bd_contains) {
blkdev_put(bdev->bd_contains, BDEV_RAW); blkdev_put(bdev->bd_contains, BDEV_RAW);
......
...@@ -511,7 +511,9 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev) ...@@ -511,7 +511,9 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
bdev->bd_invalidated = 0; bdev->bd_invalidated = 0;
for (p = 1; p < disk->minors; p++) for (p = 1; p < disk->minors; p++)
delete_partition(disk, p); delete_partition(disk, p);
if (bdev->bd_op->revalidate) if (bdev->bd_op->revalidate_disk)
bdev->bd_op->revalidate_disk(disk);
else if (bdev->bd_op->revalidate)
bdev->bd_op->revalidate(dev); bdev->bd_op->revalidate(dev);
if (!get_capacity(disk) || !(state = check_partition(disk, bdev))) if (!get_capacity(disk) || !(state = check_partition(disk, bdev)))
return res; return res;
......
...@@ -732,6 +732,8 @@ struct block_device_operations { ...@@ -732,6 +732,8 @@ struct block_device_operations {
int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long); int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
int (*check_media_change) (kdev_t); int (*check_media_change) (kdev_t);
int (*revalidate) (kdev_t); int (*revalidate) (kdev_t);
int (*media_changed) (struct gendisk *);
int (*revalidate_disk) (struct gendisk *);
struct module *owner; struct module *owner;
}; };
......
...@@ -80,6 +80,8 @@ struct gendisk { ...@@ -80,6 +80,8 @@ struct gendisk {
char disk_name[16]; /* name of major driver */ char disk_name[16]; /* name of major driver */
struct hd_struct *part; /* [indexed by minor] */ struct hd_struct *part; /* [indexed by minor] */
struct block_device_operations *fops; struct block_device_operations *fops;
struct request_queue *queue;
void *private_data;
sector_t capacity; sector_t capacity;
struct list_head list; struct list_head list;
struct list_head full_list; struct list_head full_list;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment