linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: Remove extra discard_alignment from hd_struct.
@ 2011-04-20  8:17 Tao Ma
  2011-05-06  9:34 ` [PATCH RESEND] block: Remove " Tao Ma
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tao Ma @ 2011-04-20  8:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: axboe

From: Tao Ma <boyu.mt@taobao.com>

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.

Signed-off-by: Tao Ma <boyu.mt@taobao.com>
---
 fs/partitions/check.c |    9 ++++++---
 include/linux/genhd.h |    1 -
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index ac54697..ec4f4ae 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -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);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index d764a42..b4c233f 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -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;
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH RESEND] block: Remove discard_alignment from hd_struct.
  2011-04-20  8:17 [PATCH] block: Remove extra discard_alignment from hd_struct Tao Ma
@ 2011-05-06  9:34 ` Tao Ma
  2011-05-07  1:28 ` [PATCH] block: Remove extra " Jens Axboe
  2011-05-12  0:08 ` Andrew Morton
  2 siblings, 0 replies; 4+ messages in thread
From: Tao Ma @ 2011-05-06  9:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: axboe

From: Tao Ma <boyu.mt@taobao.com>

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.

Signed-off-by: Tao Ma <boyu.mt@taobao.com>
---
 fs/partitions/check.c |    9 ++++++---
 include/linux/genhd.h |    1 -
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index ac54697..ec4f4ae 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -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);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index d764a42..b4c233f 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -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;
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] block: Remove extra discard_alignment from hd_struct.
  2011-04-20  8:17 [PATCH] block: Remove extra discard_alignment from hd_struct Tao Ma
  2011-05-06  9:34 ` [PATCH RESEND] block: Remove " Tao Ma
@ 2011-05-07  1:28 ` Jens Axboe
  2011-05-12  0:08 ` Andrew Morton
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2011-05-07  1:28 UTC (permalink / raw)
  To: Tao Ma; +Cc: linux-kernel

On 2011-04-20 02:17, Tao Ma wrote:
> From: Tao Ma <boyu.mt@taobao.com>
> 
> 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.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] block: Remove extra discard_alignment from hd_struct.
  2011-04-20  8:17 [PATCH] block: Remove extra discard_alignment from hd_struct Tao Ma
  2011-05-06  9:34 ` [PATCH RESEND] block: Remove " Tao Ma
  2011-05-07  1:28 ` [PATCH] block: Remove extra " Jens Axboe
@ 2011-05-12  0:08 ` Andrew Morton
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2011-05-12  0:08 UTC (permalink / raw)
  To: Tao Ma; +Cc: linux-kernel, axboe

On Wed, 20 Apr 2011 16:17:35 +0800
Tao Ma <tm@tao.ma> wrote:

> --- a/fs/partitions/check.c
> +++ b/fs/partitions/check.c
> @@ -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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-12  0:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-20  8:17 [PATCH] block: Remove extra discard_alignment from hd_struct Tao Ma
2011-05-06  9:34 ` [PATCH RESEND] block: Remove " Tao Ma
2011-05-07  1:28 ` [PATCH] block: Remove extra " Jens Axboe
2011-05-12  0:08 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).