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)
struct block_device_operations * bdops = bdev->bd_op;
kdev_t dev = to_kdev_t(bdev->bd_dev);
if (bdops->check_media_change == NULL)
return 0;
if (!bdops->check_media_change(dev))
if (!bdops->media_changed) {
if (bdops->check_media_change == NULL)
return 0;
if (!bdops->check_media_change(dev))
return 0;
} else if (!bdops->media_changed(bdev->bd_disk))
return 0;
if (invalidate_device(dev, 0))
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);
if (bdev->bd_disk->minors > 1)
bdev->bd_invalidated = 1;
......@@ -633,10 +638,14 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
if (!bdev->bd_openers)
bdev->bd_disk = disk;
if (!bdev->bd_queue) {
struct blk_dev_struct *p = blk_dev + major(dev);
bdev->bd_queue = &p->request_queue;
if (p->queue)
bdev->bd_queue = p->queue(dev);
if (disk->queue)
bdev->bd_queue = disk->queue;
else {
struct blk_dev_struct *p = blk_dev + major(dev);
bdev->bd_queue = &p->request_queue;
if (p->queue)
bdev->bd_queue = p->queue(dev);
}
}
if (bdev->bd_op->open) {
ret = bdev->bd_op->open(inode, 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);
if (bdi == NULL)
bdi = &default_backing_dev_info;
inode->i_data.backing_dev_info = bdi;
bdev->bd_inode->i_data.backing_dev_info = bdi;
}
if (bdev->bd_invalidated)
......@@ -661,8 +669,7 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
if (!bdev->bd_openers) {
struct hd_struct *p;
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;
if (!(disk->flags & GENHD_FL_UP) || !p->nr_sects) {
bdev->bd_contains->bd_part_count--;
......@@ -685,6 +692,8 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
out2:
if (!bdev->bd_openers) {
bdev->bd_queue = NULL;
bdev->bd_disk = NULL;
bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
if (bdev != bdev->bd_contains) {
blkdev_put(bdev->bd_contains, BDEV_RAW);
......
......@@ -511,7 +511,9 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
bdev->bd_invalidated = 0;
for (p = 1; p < disk->minors; 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);
if (!get_capacity(disk) || !(state = check_partition(disk, bdev)))
return res;
......
......@@ -732,6 +732,8 @@ struct block_device_operations {
int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
int (*check_media_change) (kdev_t);
int (*revalidate) (kdev_t);
int (*media_changed) (struct gendisk *);
int (*revalidate_disk) (struct gendisk *);
struct module *owner;
};
......
......@@ -80,6 +80,8 @@ struct gendisk {
char disk_name[16]; /* name of major driver */
struct hd_struct *part; /* [indexed by minor] */
struct block_device_operations *fops;
struct request_queue *queue;
void *private_data;
sector_t capacity;
struct list_head 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