Skip to contentSkip to conversation

block: Remove extra discard_alignment from hd_struct.

PATCH Applied Tao Ma 3 participants 4 messages Apr 20, 2011 – May 12, 2011

lore
Share & tools
lore

Tao Ma

author
#0 lore raw

PATCH 1/1 block: Remove extra discard_alignment from hd_struct.

From: Tao Ma <[email protected]>

Currently, hd_struct.discard_alignment is only used when we show /sys/block/sdx/sdx/discard_alignment. So remove it and calculate when it is asked to show.

---
 fs/partitions/check.c |    9 ++++++---
 include/linux/genhd.h |    1 -
 2 files changed, 6 insertions(+), 4 deletions(-)
fs/partitions/check.c +6 -3
index ac54697..ec4f4ae 100644
@@ -255,7 +255,12 @@ ssize_t part_discard_alignment_show(struct device *dev,
 				   struct device_attribute *attr, char *buf)
 {
 	struct hd_struct *p = dev_to_part(dev);
-	return sprintf(buf, "%u\n", p->discard_alignment);
+	struct gendisk *disk = dev_to_disk(dev);
+
+	return sprintf(buf, "%u\n",
+		       (unsigned long long)queue_limit_discard_alignment(
+							&disk->queue->limits,
+							p->start_sect));
 }
 
 ssize_t part_stat_show(struct device *dev,
@@ -449,8 +454,6 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
 	p->start_sect = start;
 	p->alignment_offset =
 		queue_limit_alignment_offset(&disk->queue->limits, start);
-	p->discard_alignment =
-		queue_limit_discard_alignment(&disk->queue->limits, start);
 	p->nr_sects = len;
 	p->partno = partno;
 	p->policy = get_disk_ro(disk);
include/linux/genhd.h +0 -1
index d764a42..b4c233f 100644
@@ -100,7 +100,6 @@ struct hd_struct {
 	sector_t start_sect;
 	sector_t nr_sects;
 	sector_t alignment_offset;
-	unsigned int discard_alignment;
 	struct device __dev;
 	struct kobject *holder_dir;
 	int policy, partno;
Signature · 1 line
1.7.4
author
#1 lore raw

PATCH RESEND 1/1 block: Remove discard_alignment from hd_struct.

From: Tao Ma <[email protected]>

Currently, hd_struct.discard_alignment is only used when we show /sys/block/sdx/sdx/discard_alignment. So remove it and calculate when it shows.

---
 fs/partitions/check.c |    9 ++++++---
 include/linux/genhd.h |    1 -
 2 files changed, 6 insertions(+), 4 deletions(-)
fs/partitions/check.c +6 -3
index ac54697..ec4f4ae 100644
@@ -255,7 +255,12 @@ ssize_t part_discard_alignment_show(struct device *dev,
 				   struct device_attribute *attr, char *buf)
 {
 	struct hd_struct *p = dev_to_part(dev);
-	return sprintf(buf, "%u\n", p->discard_alignment);
+	struct gendisk *disk = dev_to_disk(dev);
+
+	return sprintf(buf, "%u\n",
+		       (unsigned long long)queue_limit_discard_alignment(
+							&disk->queue->limits,
+							p->start_sect));
 }
 
 ssize_t part_stat_show(struct device *dev,
@@ -449,8 +454,6 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
 	p->start_sect = start;
 	p->alignment_offset =
 		queue_limit_alignment_offset(&disk->queue->limits, start);
-	p->discard_alignment =
-		queue_limit_discard_alignment(&disk->queue->limits, start);
 	p->nr_sects = len;
 	p->partno = partno;
 	p->policy = get_disk_ro(disk);
include/linux/genhd.h +0 -1
index d764a42..b4c233f 100644
@@ -100,7 +100,6 @@ struct hd_struct {
 	sector_t start_sect;
 	sector_t nr_sects;
 	sector_t alignment_offset;
-	unsigned int discard_alignment;
 	struct device __dev;
 	struct kobject *holder_dir;
 	int policy, partno;
Signature · 1 line
1.7.4
Applied
#2 lore raw
In reply to Tao Ma
Quoted 5 lines · Tao Ma

From: Tao Ma <[email protected]>

Currently, hd_struct.discard_alignment is only used when we show /sys/block/sdx/sdx/discard_alignment. So remove it and calculate when it is asked to show.

Thanks, applied.

Signature · 1 line
Jens Axboe
#3 lore raw
In reply to Tao Ma

fs/partitions/check.c ssize_t part_discard_alignment_show(struct device *dev, · line 263

Quoted 13 lines · On Wed, 20 Apr 2011 16:17:35 +0800 Tao Ma <[email protected]> wrote:
fs/partitions/check.c +6 -1
@@ -255,7 +255,12 @@ ssize_t part_discard_alignment_show(struct device *dev,
 				   struct device_attribute *attr, char *buf)
 {
 	struct hd_struct *p = dev_to_part(dev);
-	return sprintf(buf, "%u\n", p->discard_alignment);
+	struct gendisk *disk = dev_to_disk(dev);
+
+	return sprintf(buf, "%u\n",
+		       (unsigned long long)queue_limit_discard_alignment(
+							&disk->queue->limits,
+							p->start_sect));

fs/partitions/check.c: In function 'part_discard_alignment_show':
fs/partitions/check.c:263: warning: format '%u' expects type 'unsigned int', but argument 3 has type 'long long unsigned int'

um, that should have been apparent from cursory review, let alone compile testing. And it will fail runtime testing on little-endian machines if the third arg is passed on the stack.