提交 a1706ac4 编写于 作者: J Jens Axboe

Revert "block: Remove extra discard_alignment from hd_struct."

It was not a good idea to start dereferencing disk->queue from
the fs sysfs strategy for displaying discard alignment. We ran
into first a NULL pointer deref, and after fixing that we sometimes
see unvalid disk->queue pointer values.

Since discard is the only one of the bunch actually looking into
the queue, just revert the change.

This reverts commit 23ceb5b7.

Conflicts:
	fs/partitions/check.c
上级 5988ce23
...@@ -255,13 +255,7 @@ ssize_t part_discard_alignment_show(struct device *dev, ...@@ -255,13 +255,7 @@ ssize_t part_discard_alignment_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct hd_struct *p = dev_to_part(dev); struct hd_struct *p = dev_to_part(dev);
struct gendisk *disk = dev_to_disk(dev); return sprintf(buf, "%u\n", p->discard_alignment);
unsigned int alignment = 0;
if (disk->queue)
alignment = queue_limit_discard_alignment(&disk->queue->limits,
p->start_sect);
return sprintf(buf, "%u\n", alignment);
} }
ssize_t part_stat_show(struct device *dev, ssize_t part_stat_show(struct device *dev,
...@@ -455,6 +449,8 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, ...@@ -455,6 +449,8 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
p->start_sect = start; p->start_sect = start;
p->alignment_offset = p->alignment_offset =
queue_limit_alignment_offset(&disk->queue->limits, start); queue_limit_alignment_offset(&disk->queue->limits, start);
p->discard_alignment =
queue_limit_discard_alignment(&disk->queue->limits, start);
p->nr_sects = len; p->nr_sects = len;
p->partno = partno; p->partno = partno;
p->policy = get_disk_ro(disk); p->policy = get_disk_ro(disk);
......
...@@ -100,6 +100,7 @@ struct hd_struct { ...@@ -100,6 +100,7 @@ struct hd_struct {
sector_t start_sect; sector_t start_sect;
sector_t nr_sects; sector_t nr_sects;
sector_t alignment_offset; sector_t alignment_offset;
unsigned int discard_alignment;
struct device __dev; struct device __dev;
struct kobject *holder_dir; struct kobject *holder_dir;
int policy, partno; int policy, partno;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册