aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-sysfs.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-01-07 06:22:39 -0500
committerJens Axboe <jens.axboe@oracle.com>2009-01-30 06:34:37 -0500
commit1308835ffffe6d61ad1f48c5c381c9cc47f683ec (patch)
tree5430cde36604537fdc3c597f53f65cba990f08fd /block/blk-sysfs.c
parent16642eb68216d8e0e136a99e514e9166e7125838 (diff)
block: export SSD/non-rotational queue flag through sysfs
For some devices (i.e. CFA ATA) we can't reliably detect whether the device is of rotational or non-rotational type so we need to leave the final decision about this setting to the user-space. As a bonus do a minor CodingStyle fixup in queue_nomerges_store(). Suggested-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/blk-sysfs.c')
-rw-r--r--block/blk-sysfs.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index a29cb788e408..b538ab8dbbd1 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -130,6 +130,27 @@ static ssize_t queue_max_hw_sectors_show(struct request_queue *q, char *page)
130 return queue_var_show(max_hw_sectors_kb, (page)); 130 return queue_var_show(max_hw_sectors_kb, (page));
131} 131}
132 132
133static ssize_t queue_nonrot_show(struct request_queue *q, char *page)
134{
135 return queue_var_show(!blk_queue_nonrot(q), page);
136}
137
138static ssize_t queue_nonrot_store(struct request_queue *q, const char *page,
139 size_t count)
140{
141 unsigned long nm;
142 ssize_t ret = queue_var_store(&nm, page, count);
143
144 spin_lock_irq(q->queue_lock);
145 if (nm)
146 queue_flag_clear(QUEUE_FLAG_NONROT, q);
147 else
148 queue_flag_set(QUEUE_FLAG_NONROT, q);
149 spin_unlock_irq(q->queue_lock);
150
151 return ret;
152}
153
133static ssize_t queue_nomerges_show(struct request_queue *q, char *page) 154static ssize_t queue_nomerges_show(struct request_queue *q, char *page)
134{ 155{
135 return queue_var_show(blk_queue_nomerges(q), page); 156 return queue_var_show(blk_queue_nomerges(q), page);
@@ -146,8 +167,8 @@ static ssize_t queue_nomerges_store(struct request_queue *q, const char *page,
146 queue_flag_set(QUEUE_FLAG_NOMERGES, q); 167 queue_flag_set(QUEUE_FLAG_NOMERGES, q);
147 else 168 else
148 queue_flag_clear(QUEUE_FLAG_NOMERGES, q); 169 queue_flag_clear(QUEUE_FLAG_NOMERGES, q);
149
150 spin_unlock_irq(q->queue_lock); 170 spin_unlock_irq(q->queue_lock);
171
151 return ret; 172 return ret;
152} 173}
153 174
@@ -210,6 +231,12 @@ static struct queue_sysfs_entry queue_hw_sector_size_entry = {
210 .show = queue_hw_sector_size_show, 231 .show = queue_hw_sector_size_show,
211}; 232};
212 233
234static struct queue_sysfs_entry queue_nonrot_entry = {
235 .attr = {.name = "rotational", .mode = S_IRUGO | S_IWUSR },
236 .show = queue_nonrot_show,
237 .store = queue_nonrot_store,
238};
239
213static struct queue_sysfs_entry queue_nomerges_entry = { 240static struct queue_sysfs_entry queue_nomerges_entry = {
214 .attr = {.name = "nomerges", .mode = S_IRUGO | S_IWUSR }, 241 .attr = {.name = "nomerges", .mode = S_IRUGO | S_IWUSR },
215 .show = queue_nomerges_show, 242 .show = queue_nomerges_show,
@@ -229,6 +256,7 @@ static struct attribute *default_attrs[] = {
229 &queue_max_sectors_entry.attr, 256 &queue_max_sectors_entry.attr,
230 &queue_iosched_entry.attr, 257 &queue_iosched_entry.attr,
231 &queue_hw_sector_size_entry.attr, 258 &queue_hw_sector_size_entry.attr,
259 &queue_nonrot_entry.attr,
232 &queue_nomerges_entry.attr, 260 &queue_nomerges_entry.attr,
233 &queue_rq_affinity_entry.attr, 261 &queue_rq_affinity_entry.attr,
234 NULL, 262 NULL,