block: move the start_sect field to struct block_device
Move the start_sect field to struct block_device in preparation of killing struct hd_struct. 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:
Родитель
15e3d2c5cd
Коммит
29ff57c610
|
@ -757,9 +757,10 @@ static inline int blk_partition_remap(struct bio *bio)
|
|||
if (bio_sectors(bio)) {
|
||||
if (bio_check_eod(bio, bdev_nr_sectors(p->bdev)))
|
||||
goto out;
|
||||
bio->bi_iter.bi_sector += p->start_sect;
|
||||
bio->bi_iter.bi_sector += p->bdev->bd_start_sect;
|
||||
trace_block_bio_remap(bio->bi_disk->queue, bio, part_devt(p),
|
||||
bio->bi_iter.bi_sector - p->start_sect);
|
||||
bio->bi_iter.bi_sector -
|
||||
p->bdev->bd_start_sect);
|
||||
}
|
||||
bio->bi_partno = 0;
|
||||
ret = 0;
|
||||
|
|
|
@ -65,7 +65,7 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
|
|||
|
||||
/* In case the discard request is in a partition */
|
||||
if (bdev_is_partition(bdev))
|
||||
part_offset = bdev->bd_part->start_sect;
|
||||
part_offset = bdev->bd_start_sect;
|
||||
|
||||
while (nr_sects) {
|
||||
sector_t granularity_aligned_lba, req_sects;
|
||||
|
|
|
@ -305,8 +305,8 @@ EXPORT_SYMBOL_GPL(disk_part_iter_exit);
|
|||
|
||||
static inline int sector_in_part(struct hd_struct *part, sector_t sector)
|
||||
{
|
||||
return part->start_sect <= sector &&
|
||||
sector < part->start_sect + bdev_nr_sectors(part->bdev);
|
||||
return part->bdev->bd_start_sect <= sector &&
|
||||
sector < part->bdev->bd_start_sect + bdev_nr_sectors(part->bdev);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -192,7 +192,7 @@ static ssize_t part_start_show(struct device *dev,
|
|||
{
|
||||
struct hd_struct *p = dev_to_part(dev);
|
||||
|
||||
return sprintf(buf, "%llu\n",(unsigned long long)p->start_sect);
|
||||
return sprintf(buf, "%llu\n", p->bdev->bd_start_sect);
|
||||
}
|
||||
|
||||
static ssize_t part_ro_show(struct device *dev,
|
||||
|
@ -209,7 +209,7 @@ static ssize_t part_alignment_offset_show(struct device *dev,
|
|||
|
||||
return sprintf(buf, "%u\n",
|
||||
queue_limit_alignment_offset(&part_to_disk(p)->queue->limits,
|
||||
p->start_sect));
|
||||
p->bdev->bd_start_sect));
|
||||
}
|
||||
|
||||
static ssize_t part_discard_alignment_show(struct device *dev,
|
||||
|
@ -219,7 +219,7 @@ static ssize_t part_discard_alignment_show(struct device *dev,
|
|||
|
||||
return sprintf(buf, "%u\n",
|
||||
queue_limit_discard_alignment(&part_to_disk(p)->queue->limits,
|
||||
p->start_sect));
|
||||
p->bdev->bd_start_sect));
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(partition, 0444, part_partition_show, NULL);
|
||||
|
@ -301,7 +301,7 @@ static void hd_struct_free_work(struct work_struct *work)
|
|||
*/
|
||||
put_device(disk_to_dev(disk));
|
||||
|
||||
part->start_sect = 0;
|
||||
part->bdev->bd_start_sect = 0;
|
||||
bdev_set_nr_sectors(part->bdev, 0);
|
||||
part_stat_set_all(part, 0);
|
||||
put_device(part_to_dev(part));
|
||||
|
@ -416,7 +416,7 @@ static struct hd_struct *add_partition(struct gendisk *disk, int partno,
|
|||
|
||||
pdev = part_to_dev(p);
|
||||
|
||||
p->start_sect = start;
|
||||
bdev->bd_start_sect = start;
|
||||
bdev_set_nr_sectors(bdev, len);
|
||||
p->partno = partno;
|
||||
p->policy = get_disk_ro(disk);
|
||||
|
@ -508,8 +508,9 @@ static bool partition_overlaps(struct gendisk *disk, sector_t start,
|
|||
disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY);
|
||||
while ((part = disk_part_iter_next(&piter))) {
|
||||
if (part->partno == skip_partno ||
|
||||
start >= part->start_sect + bdev_nr_sectors(part->bdev) ||
|
||||
start + length <= part->start_sect)
|
||||
start >= part->bdev->bd_start_sect +
|
||||
bdev_nr_sectors(part->bdev) ||
|
||||
start + length <= part->bdev->bd_start_sect)
|
||||
continue;
|
||||
overlap = true;
|
||||
break;
|
||||
|
@ -592,7 +593,7 @@ int bdev_resize_partition(struct block_device *bdev, int partno,
|
|||
mutex_lock_nested(&bdev->bd_mutex, 1);
|
||||
|
||||
ret = -EINVAL;
|
||||
if (start != part->start_sect)
|
||||
if (start != part->bdev->bd_start_sect)
|
||||
goto out_unlock;
|
||||
|
||||
ret = -EBUSY;
|
||||
|
|
|
@ -20,6 +20,7 @@ typedef void (bio_end_io_t) (struct bio *);
|
|||
struct bio_crypt_ctx;
|
||||
|
||||
struct block_device {
|
||||
sector_t bd_start_sect;
|
||||
struct disk_stats __percpu *bd_stats;
|
||||
unsigned long bd_stamp;
|
||||
dev_t bd_dev;
|
||||
|
|
|
@ -1488,7 +1488,7 @@ static inline int bdev_alignment_offset(struct block_device *bdev)
|
|||
return -1;
|
||||
if (bdev_is_partition(bdev))
|
||||
return queue_limit_alignment_offset(&q->limits,
|
||||
bdev->bd_part->start_sect);
|
||||
bdev->bd_start_sect);
|
||||
return q->limits.alignment_offset;
|
||||
}
|
||||
|
||||
|
@ -1529,7 +1529,7 @@ static inline int bdev_discard_alignment(struct block_device *bdev)
|
|||
|
||||
if (bdev_is_partition(bdev))
|
||||
return queue_limit_discard_alignment(&q->limits,
|
||||
bdev->bd_part->start_sect);
|
||||
bdev->bd_start_sect);
|
||||
return q->limits.discard_alignment;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ struct partition_meta_info {
|
|||
};
|
||||
|
||||
struct hd_struct {
|
||||
sector_t start_sect;
|
||||
struct percpu_ref ref;
|
||||
|
||||
struct block_device *bdev;
|
||||
|
@ -298,7 +297,7 @@ extern void rand_initialize_disk(struct gendisk *disk);
|
|||
|
||||
static inline sector_t get_start_sect(struct block_device *bdev)
|
||||
{
|
||||
return bdev->bd_part->start_sect;
|
||||
return bdev->bd_start_sect;
|
||||
}
|
||||
|
||||
static inline sector_t bdev_nr_sectors(struct block_device *bdev)
|
||||
|
|
|
@ -458,14 +458,9 @@ static struct rchan_callbacks blk_relay_callbacks = {
|
|||
static void blk_trace_setup_lba(struct blk_trace *bt,
|
||||
struct block_device *bdev)
|
||||
{
|
||||
struct hd_struct *part = NULL;
|
||||
|
||||
if (bdev)
|
||||
part = bdev->bd_part;
|
||||
|
||||
if (part) {
|
||||
bt->start_lba = part->start_sect;
|
||||
bt->end_lba = part->start_sect + bdev_nr_sectors(bdev);
|
||||
if (bdev) {
|
||||
bt->start_lba = bdev->bd_start_sect;
|
||||
bt->end_lba = bdev->bd_start_sect + bdev_nr_sectors(bdev);
|
||||
} else {
|
||||
bt->start_lba = 0;
|
||||
bt->end_lba = -1ULL;
|
||||
|
|
Загрузка…
Ссылка в новой задаче