From: Lukas Czerner <lczerner@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, tytso@mit.edu, sandeen@redhat.com,
adilger.kernel@dilger.ca, gregkh@suse.de, hch@infradead.org,
axboe@kernel.dk, lczerner@redhat.com
Subject: [PATCH 1/2] blk-sysfs: Clean-up attribute definitions
Date: Thu, 9 Dec 2010 16:25:36 +0100 [thread overview]
Message-ID: <1291908337-18805-2-git-send-email-lczerner@redhat.com> (raw)
In-Reply-To: <1291908337-18805-1-git-send-email-lczerner@redhat.com>
This commit simplifies block queue attribute definitions for sysfs
/sys/block/*/queue by introducing macros instead of defining each
structure of its own.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
block/blk-sysfs.c | 197 +++++++++++++++++------------------------------------
1 files changed, 63 insertions(+), 134 deletions(-)
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 013457f..8ba860e 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -187,14 +187,14 @@ static ssize_t queue_max_hw_sectors_show(struct request_queue *q, char *page)
#define QUEUE_SYSFS_BIT_FNS(name, flag, neg) \
static ssize_t \
-queue_show_##name(struct request_queue *q, char *page) \
+queue_##name##_show(struct request_queue *q, char *page) \
{ \
int bit; \
bit = test_bit(QUEUE_FLAG_##flag, &q->queue_flags); \
return queue_var_show(neg ? !bit : bit, page); \
} \
static ssize_t \
-queue_store_##name(struct request_queue *q, const char *page, size_t count) \
+queue_##name##_store(struct request_queue *q, const char *page, size_t count) \
{ \
unsigned long val; \
ssize_t ret; \
@@ -265,142 +265,71 @@ queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)
return ret;
}
-static struct queue_sysfs_entry queue_requests_entry = {
- .attr = {.name = "nr_requests", .mode = S_IRUGO | S_IWUSR },
- .show = queue_requests_show,
- .store = queue_requests_store,
-};
-
-static struct queue_sysfs_entry queue_ra_entry = {
- .attr = {.name = "read_ahead_kb", .mode = S_IRUGO | S_IWUSR },
- .show = queue_ra_show,
- .store = queue_ra_store,
-};
-
-static struct queue_sysfs_entry queue_max_sectors_entry = {
- .attr = {.name = "max_sectors_kb", .mode = S_IRUGO | S_IWUSR },
- .show = queue_max_sectors_show,
- .store = queue_max_sectors_store,
-};
-
-static struct queue_sysfs_entry queue_max_hw_sectors_entry = {
- .attr = {.name = "max_hw_sectors_kb", .mode = S_IRUGO },
- .show = queue_max_hw_sectors_show,
-};
-
-static struct queue_sysfs_entry queue_max_segments_entry = {
- .attr = {.name = "max_segments", .mode = S_IRUGO },
- .show = queue_max_segments_show,
-};
-
-static struct queue_sysfs_entry queue_max_integrity_segments_entry = {
- .attr = {.name = "max_integrity_segments", .mode = S_IRUGO },
- .show = queue_max_integrity_segments_show,
-};
-
-static struct queue_sysfs_entry queue_max_segment_size_entry = {
- .attr = {.name = "max_segment_size", .mode = S_IRUGO },
- .show = queue_max_segment_size_show,
-};
-
-static struct queue_sysfs_entry queue_iosched_entry = {
- .attr = {.name = "scheduler", .mode = S_IRUGO | S_IWUSR },
- .show = elv_iosched_show,
- .store = elv_iosched_store,
-};
-
-static struct queue_sysfs_entry queue_hw_sector_size_entry = {
- .attr = {.name = "hw_sector_size", .mode = S_IRUGO },
- .show = queue_logical_block_size_show,
-};
-
-static struct queue_sysfs_entry queue_logical_block_size_entry = {
- .attr = {.name = "logical_block_size", .mode = S_IRUGO },
- .show = queue_logical_block_size_show,
-};
-
-static struct queue_sysfs_entry queue_physical_block_size_entry = {
- .attr = {.name = "physical_block_size", .mode = S_IRUGO },
- .show = queue_physical_block_size_show,
-};
-
-static struct queue_sysfs_entry queue_io_min_entry = {
- .attr = {.name = "minimum_io_size", .mode = S_IRUGO },
- .show = queue_io_min_show,
-};
-
-static struct queue_sysfs_entry queue_io_opt_entry = {
- .attr = {.name = "optimal_io_size", .mode = S_IRUGO },
- .show = queue_io_opt_show,
-};
-
-static struct queue_sysfs_entry queue_discard_granularity_entry = {
- .attr = {.name = "discard_granularity", .mode = S_IRUGO },
- .show = queue_discard_granularity_show,
-};
-
-static struct queue_sysfs_entry queue_discard_max_entry = {
- .attr = {.name = "discard_max_bytes", .mode = S_IRUGO },
- .show = queue_discard_max_show,
-};
-
-static struct queue_sysfs_entry queue_discard_zeroes_data_entry = {
- .attr = {.name = "discard_zeroes_data", .mode = S_IRUGO },
- .show = queue_discard_zeroes_data_show,
-};
-
-static struct queue_sysfs_entry queue_nonrot_entry = {
- .attr = {.name = "rotational", .mode = S_IRUGO | S_IWUSR },
- .show = queue_show_nonrot,
- .store = queue_store_nonrot,
-};
-
-static struct queue_sysfs_entry queue_nomerges_entry = {
- .attr = {.name = "nomerges", .mode = S_IRUGO | S_IWUSR },
- .show = queue_nomerges_show,
- .store = queue_nomerges_store,
-};
+#define queue_iosched_store elv_iosched_store
+#define queue_iosched_show elv_iosched_show
+#define queue_hw_sector_size_show queue_logical_block_size_show
-static struct queue_sysfs_entry queue_rq_affinity_entry = {
- .attr = {.name = "rq_affinity", .mode = S_IRUGO | S_IWUSR },
- .show = queue_rq_affinity_show,
- .store = queue_rq_affinity_store,
-};
-
-static struct queue_sysfs_entry queue_iostats_entry = {
- .attr = {.name = "iostats", .mode = S_IRUGO | S_IWUSR },
- .show = queue_show_iostats,
- .store = queue_store_iostats,
-};
+#define QUEUE_ENTRY(_name,_mode,_show,_store) \
+static struct queue_sysfs_entry queue_##_name##_entry = { \
+ .attr = {.name = __stringify(_name), .mode = _mode }, \
+ .show = _show, \
+ .store = _store, \
+}
-static struct queue_sysfs_entry queue_random_entry = {
- .attr = {.name = "add_random", .mode = S_IRUGO | S_IWUSR },
- .show = queue_show_random,
- .store = queue_store_random,
-};
+#define QUEUE_RO_ENTRY(name) \
+ QUEUE_ENTRY(name, S_IRUGO, queue_##name##_show, NULL)
+
+#define QUEUE_RW_ENTRY(name) \
+ QUEUE_ENTRY(name, S_IRUGO | S_IWUSR, \
+ queue_##name##_show, queue_##name##_store)
+
+#define ATTR_LIST(name) &queue_##name##_entry.attr
+
+QUEUE_RO_ENTRY(max_hw_sectors);
+QUEUE_RO_ENTRY(max_segments);
+QUEUE_RO_ENTRY(max_integrity_segments);
+QUEUE_RO_ENTRY(max_segment_size);
+QUEUE_RO_ENTRY(hw_sector_size);
+QUEUE_RO_ENTRY(logical_block_size);
+QUEUE_RO_ENTRY(physical_block_size);
+QUEUE_RO_ENTRY(io_min);
+QUEUE_RO_ENTRY(io_opt);
+QUEUE_RO_ENTRY(discard_granularity);
+QUEUE_RO_ENTRY(discard_max);
+QUEUE_RO_ENTRY(discard_zeroes_data);
+
+QUEUE_RW_ENTRY(requests);
+QUEUE_RW_ENTRY(max_sectors);
+QUEUE_RW_ENTRY(ra);
+QUEUE_RW_ENTRY(iosched);
+QUEUE_RW_ENTRY(nonrot);
+QUEUE_RW_ENTRY(nomerges);
+QUEUE_RW_ENTRY(rq_affinity);
+QUEUE_RW_ENTRY(iostats);
+QUEUE_RW_ENTRY(random);
static struct attribute *default_attrs[] = {
- &queue_requests_entry.attr,
- &queue_ra_entry.attr,
- &queue_max_hw_sectors_entry.attr,
- &queue_max_sectors_entry.attr,
- &queue_max_segments_entry.attr,
- &queue_max_integrity_segments_entry.attr,
- &queue_max_segment_size_entry.attr,
- &queue_iosched_entry.attr,
- &queue_hw_sector_size_entry.attr,
- &queue_logical_block_size_entry.attr,
- &queue_physical_block_size_entry.attr,
- &queue_io_min_entry.attr,
- &queue_io_opt_entry.attr,
- &queue_discard_granularity_entry.attr,
- &queue_discard_max_entry.attr,
- &queue_discard_zeroes_data_entry.attr,
- &queue_nonrot_entry.attr,
- &queue_nomerges_entry.attr,
- &queue_rq_affinity_entry.attr,
- &queue_iostats_entry.attr,
- &queue_random_entry.attr,
+ ATTR_LIST(requests),
+ ATTR_LIST(ra),
+ ATTR_LIST(max_hw_sectors),
+ ATTR_LIST(max_sectors),
+ ATTR_LIST(max_segments),
+ ATTR_LIST(max_integrity_segments),
+ ATTR_LIST(max_segment_size),
+ ATTR_LIST(iosched),
+ ATTR_LIST(hw_sector_size),
+ ATTR_LIST(logical_block_size),
+ ATTR_LIST(physical_block_size),
+ ATTR_LIST(io_min),
+ ATTR_LIST(io_opt),
+ ATTR_LIST(discard_granularity),
+ ATTR_LIST(discard_max),
+ ATTR_LIST(discard_zeroes_data),
+ ATTR_LIST(nonrot),
+ ATTR_LIST(nomerges),
+ ATTR_LIST(rq_affinity),
+ ATTR_LIST(iostats),
+ ATTR_LIST(random),
NULL,
};
--
1.7.2.3
next prev parent reply other threads:[~2010-12-09 15:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-09 15:25 [RFC PATCH 0/2 v1] Ioctl for reading block queue information Lukas Czerner
2010-12-09 15:25 ` Lukas Czerner [this message]
2010-12-09 15:25 ` [PATCH 2/2] Add BLKGETQUEUEINFO for reading block queue attributes Lukas Czerner
2010-12-10 18:39 ` Arnd Bergmann
2010-12-09 19:20 ` [RFC PATCH 0/2 v1] Ioctl for reading block queue information Greg KH
2010-12-09 19:49 ` Andreas Dilger
2010-12-09 19:54 ` Greg KH
2010-12-10 14:07 ` Lukas Czerner
2010-12-10 17:34 ` Greg KH
2010-12-10 17:59 ` Lukas Czerner
2010-12-10 18:25 ` Kay Sievers
2010-12-10 18:38 ` Lukas Czerner
2010-12-10 17:51 ` Kay Sievers
2010-12-10 17:54 ` Lukas Czerner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1291908337-18805-2-git-send-email-lczerner@redhat.com \
--to=lczerner@redhat.com \
--cc=adilger.kernel@dilger.ca \
--cc=axboe@kernel.dk \
--cc=gregkh@suse.de \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sandeen@redhat.com \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).