aboutsummaryrefslogtreecommitdiffstats
path: root/block/deadline-iosched.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/deadline-iosched.c')
-rw-r--r--block/deadline-iosched.c64
1 files changed, 12 insertions, 52 deletions
diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c
index 27e494b1bf97..a3e3ff1e0c65 100644
--- a/block/deadline-iosched.c
+++ b/block/deadline-iosched.c
@@ -694,11 +694,6 @@ deadline_set_request(request_queue_t *q, struct request *rq, struct bio *bio,
694/* 694/*
695 * sysfs parts below 695 * sysfs parts below
696 */ 696 */
697struct deadline_fs_entry {
698 struct attribute attr;
699 ssize_t (*show)(struct deadline_data *, char *);
700 ssize_t (*store)(struct deadline_data *, const char *, size_t);
701};
702 697
703static ssize_t 698static ssize_t
704deadline_var_show(int var, char *page) 699deadline_var_show(int var, char *page)
@@ -716,9 +711,10 @@ deadline_var_store(int *var, const char *page, size_t count)
716} 711}
717 712
718#define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \ 713#define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \
719static ssize_t __FUNC(struct deadline_data *dd, char *page) \ 714static ssize_t __FUNC(elevator_t *e, char *page) \
720{ \ 715{ \
721 int __data = __VAR; \ 716 struct deadline_data *dd = e->elevator_data; \
717 int __data = __VAR; \
722 if (__CONV) \ 718 if (__CONV) \
723 __data = jiffies_to_msecs(__data); \ 719 __data = jiffies_to_msecs(__data); \
724 return deadline_var_show(__data, (page)); \ 720 return deadline_var_show(__data, (page)); \
@@ -731,8 +727,9 @@ SHOW_FUNCTION(deadline_fifobatch_show, dd->fifo_batch, 0);
731#undef SHOW_FUNCTION 727#undef SHOW_FUNCTION
732 728
733#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \ 729#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \
734static ssize_t __FUNC(struct deadline_data *dd, const char *page, size_t count) \ 730static ssize_t __FUNC(elevator_t *e, const char *page, size_t count) \
735{ \ 731{ \
732 struct deadline_data *dd = e->elevator_data; \
736 int __data; \ 733 int __data; \
737 int ret = deadline_var_store(&__data, (page), count); \ 734 int ret = deadline_var_store(&__data, (page), count); \
738 if (__data < (MIN)) \ 735 if (__data < (MIN)) \
@@ -752,33 +749,33 @@ STORE_FUNCTION(deadline_frontmerges_store, &dd->front_merges, 0, 1, 0);
752STORE_FUNCTION(deadline_fifobatch_store, &dd->fifo_batch, 0, INT_MAX, 0); 749STORE_FUNCTION(deadline_fifobatch_store, &dd->fifo_batch, 0, INT_MAX, 0);
753#undef STORE_FUNCTION 750#undef STORE_FUNCTION
754 751
755static struct deadline_fs_entry deadline_readexpire_entry = { 752static struct elv_fs_entry deadline_readexpire_entry = {
756 .attr = {.name = "read_expire", .mode = S_IRUGO | S_IWUSR }, 753 .attr = {.name = "read_expire", .mode = S_IRUGO | S_IWUSR },
757 .show = deadline_readexpire_show, 754 .show = deadline_readexpire_show,
758 .store = deadline_readexpire_store, 755 .store = deadline_readexpire_store,
759}; 756};
760static struct deadline_fs_entry deadline_writeexpire_entry = { 757static struct elv_fs_entry deadline_writeexpire_entry = {
761 .attr = {.name = "write_expire", .mode = S_IRUGO | S_IWUSR }, 758 .attr = {.name = "write_expire", .mode = S_IRUGO | S_IWUSR },
762 .show = deadline_writeexpire_show, 759 .show = deadline_writeexpire_show,
763 .store = deadline_writeexpire_store, 760 .store = deadline_writeexpire_store,
764}; 761};
765static struct deadline_fs_entry deadline_writesstarved_entry = { 762static struct elv_fs_entry deadline_writesstarved_entry = {
766 .attr = {.name = "writes_starved", .mode = S_IRUGO | S_IWUSR }, 763 .attr = {.name = "writes_starved", .mode = S_IRUGO | S_IWUSR },
767 .show = deadline_writesstarved_show, 764 .show = deadline_writesstarved_show,
768 .store = deadline_writesstarved_store, 765 .store = deadline_writesstarved_store,
769}; 766};
770static struct deadline_fs_entry deadline_frontmerges_entry = { 767static struct elv_fs_entry deadline_frontmerges_entry = {
771 .attr = {.name = "front_merges", .mode = S_IRUGO | S_IWUSR }, 768 .attr = {.name = "front_merges", .mode = S_IRUGO | S_IWUSR },
772 .show = deadline_frontmerges_show, 769 .show = deadline_frontmerges_show,
773 .store = deadline_frontmerges_store, 770 .store = deadline_frontmerges_store,
774}; 771};
775static struct deadline_fs_entry deadline_fifobatch_entry = { 772static struct elv_fs_entry deadline_fifobatch_entry = {
776 .attr = {.name = "fifo_batch", .mode = S_IRUGO | S_IWUSR }, 773 .attr = {.name = "fifo_batch", .mode = S_IRUGO | S_IWUSR },
777 .show = deadline_fifobatch_show, 774 .show = deadline_fifobatch_show,
778 .store = deadline_fifobatch_store, 775 .store = deadline_fifobatch_store,
779}; 776};
780 777
781static struct attribute *default_attrs[] = { 778static struct attribute *deadline_attrs[] = {
782 &deadline_readexpire_entry.attr, 779 &deadline_readexpire_entry.attr,
783 &deadline_writeexpire_entry.attr, 780 &deadline_writeexpire_entry.attr,
784 &deadline_writesstarved_entry.attr, 781 &deadline_writesstarved_entry.attr,
@@ -787,43 +784,6 @@ static struct attribute *default_attrs[] = {
787 NULL, 784 NULL,
788}; 785};
789 786
790#define to_deadline(atr) container_of((atr), struct deadline_fs_entry, attr)
791
792static ssize_t
793deadline_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
794{
795 elevator_t *e = container_of(kobj, elevator_t, kobj);
796 struct deadline_fs_entry *entry = to_deadline(attr);
797
798 if (!entry->show)
799 return -EIO;
800
801 return entry->show(e->elevator_data, page);
802}
803
804static ssize_t
805deadline_attr_store(struct kobject *kobj, struct attribute *attr,
806 const char *page, size_t length)
807{
808 elevator_t *e = container_of(kobj, elevator_t, kobj);
809 struct deadline_fs_entry *entry = to_deadline(attr);
810
811 if (!entry->store)
812 return -EIO;
813
814 return entry->store(e->elevator_data, page, length);
815}
816
817static struct sysfs_ops deadline_sysfs_ops = {
818 .show = deadline_attr_show,
819 .store = deadline_attr_store,
820};
821
822static struct kobj_type deadline_ktype = {
823 .sysfs_ops = &deadline_sysfs_ops,
824 .default_attrs = default_attrs,
825};
826
827static struct elevator_type iosched_deadline = { 787static struct elevator_type iosched_deadline = {
828 .ops = { 788 .ops = {
829 .elevator_merge_fn = deadline_merge, 789 .elevator_merge_fn = deadline_merge,
@@ -840,7 +800,7 @@ static struct elevator_type iosched_deadline = {
840 .elevator_exit_fn = deadline_exit_queue, 800 .elevator_exit_fn = deadline_exit_queue,
841 }, 801 },
842 802
843 .elevator_ktype = &deadline_ktype, 803 .elevator_attrs = deadline_attrs,
844 .elevator_name = "deadline", 804 .elevator_name = "deadline",
845 .elevator_owner = THIS_MODULE, 805 .elevator_owner = THIS_MODULE,
846}; 806};