block: merge struct block_device and struct hd_struct
Instead of having two structures that represent each block device with different life time rules, merge them into a single one. This also greatly simplifies the reference counting rules, as we can use the inode reference count as the main reference count for the new struct block_device, with the device model reference front ending it for device model interaction. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
9499ffc752
commit
0d02129e76
+8
-35
@@ -1810,30 +1810,15 @@ static ssize_t blk_trace_mask2str(char *buf, int mask)
|
||||
return p - buf;
|
||||
}
|
||||
|
||||
static struct request_queue *blk_trace_get_queue(struct block_device *bdev)
|
||||
{
|
||||
if (bdev->bd_disk == NULL)
|
||||
return NULL;
|
||||
|
||||
return bdev_get_queue(bdev);
|
||||
}
|
||||
|
||||
static ssize_t sysfs_blk_trace_attr_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct block_device *bdev = bdget_part(dev_to_part(dev));
|
||||
struct request_queue *q;
|
||||
struct block_device *bdev = dev_to_bdev(dev);
|
||||
struct request_queue *q = bdev_get_queue(bdev);
|
||||
struct blk_trace *bt;
|
||||
ssize_t ret = -ENXIO;
|
||||
|
||||
if (bdev == NULL)
|
||||
goto out;
|
||||
|
||||
q = blk_trace_get_queue(bdev);
|
||||
if (q == NULL)
|
||||
goto out_bdput;
|
||||
|
||||
mutex_lock(&q->debugfs_mutex);
|
||||
|
||||
bt = rcu_dereference_protected(q->blk_trace,
|
||||
@@ -1856,9 +1841,6 @@ static ssize_t sysfs_blk_trace_attr_show(struct device *dev,
|
||||
|
||||
out_unlock_bdev:
|
||||
mutex_unlock(&q->debugfs_mutex);
|
||||
out_bdput:
|
||||
bdput(bdev);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1866,8 +1848,8 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct block_device *bdev;
|
||||
struct request_queue *q;
|
||||
struct block_device *bdev = dev_to_bdev(dev);
|
||||
struct request_queue *q = bdev_get_queue(bdev);
|
||||
struct blk_trace *bt;
|
||||
u64 value;
|
||||
ssize_t ret = -EINVAL;
|
||||
@@ -1883,17 +1865,10 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
|
||||
goto out;
|
||||
value = ret;
|
||||
}
|
||||
} else if (kstrtoull(buf, 0, &value))
|
||||
goto out;
|
||||
|
||||
ret = -ENXIO;
|
||||
bdev = bdget_part(dev_to_part(dev));
|
||||
if (bdev == NULL)
|
||||
goto out;
|
||||
|
||||
q = blk_trace_get_queue(bdev);
|
||||
if (q == NULL)
|
||||
goto out_bdput;
|
||||
} else {
|
||||
if (kstrtoull(buf, 0, &value))
|
||||
goto out;
|
||||
}
|
||||
|
||||
mutex_lock(&q->debugfs_mutex);
|
||||
|
||||
@@ -1931,8 +1906,6 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
|
||||
|
||||
out_unlock_bdev:
|
||||
mutex_unlock(&q->debugfs_mutex);
|
||||
out_bdput:
|
||||
bdput(bdev);
|
||||
out:
|
||||
return ret ? ret : count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user