Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added FSync Control version 1.

  • Loading branch information...
commit 751c44aa88e41d911844d252a663ba5f1e28769c 1 parent 6fb96c9
Ezekeel authored
6 drivers/misc/Kconfig
@@ -579,4 +579,10 @@ source "drivers/misc/lis3lv02d/Kconfig"
579 579 source "drivers/misc/carma/Kconfig"
580 580 source "drivers/misc/modem_if/Kconfig"
581 581
  582 +config FSYNC_CONTROL
  583 + bool "Support for FSync Control"
  584 + default y
  585 + help
  586 + Say Y here to enable FSync Control
  587 +
582 588 endif # MISC_DEVICES
1  drivers/misc/Makefile
@@ -57,3 +57,4 @@ obj-$(CONFIG_SEC_MODEM) += modem_if/
57 57 obj-$(CONFIG_USB_SWITCH_FSA9480) += fsa9480.o
58 58 obj-$(CONFIG_OMAP_DIE_TEMP_SENSOR) += omap_temp_sensor.o
59 59 obj-$(CONFIG_LEDS_AN30259A) += leds-an30259a.o
  60 +obj-$(CONFIG_FSYNC_CONTROL) += fsync_control.o
110 drivers/misc/fsync_control.c
... ... @@ -0,0 +1,110 @@
  1 +/* drivers/misc/fsync_control.c
  2 + *
  3 + * Copyright 2012 Ezekeel
  4 + *
  5 + * This program is free software; you can redistribute it and/or modify
  6 + * it under the terms of the GNU General Public License version 2 as
  7 + * published by the Free Software Foundation.
  8 + */
  9 +
  10 +#include <linux/init.h>
  11 +#include <linux/device.h>
  12 +#include <linux/miscdevice.h>
  13 +
  14 +#define FSYNCCONTROL_VERSION 1
  15 +
  16 +static bool fsync_enabled = true;
  17 +
  18 +bool fsynccontrol_fsync_enabled()
  19 +{
  20 + return fsync_enabled;
  21 +}
  22 +EXPORT_SYMBOL(fsynccontrol_fsync_enabled);
  23 +
  24 +static ssize_t fsynccontrol_status_read(struct device * dev, struct device_attribute * attr, char * buf)
  25 +{
  26 + return sprintf(buf, "%u\n", (fsync_enabled ? 1 : 0));
  27 +}
  28 +
  29 +static ssize_t fsynccontrol_status_write(struct device * dev, struct device_attribute * attr, const char * buf, size_t size)
  30 +{
  31 + unsigned int data;
  32 +
  33 + if(sscanf(buf, "%u\n", &data) == 1)
  34 + {
  35 + if (data == 1)
  36 + {
  37 + pr_info("%s: FSYNCCONTROL fsync enabled\n", __FUNCTION__);
  38 +
  39 + fsync_enabled = true;
  40 +
  41 + }
  42 + else if (data == 0)
  43 + {
  44 + pr_info("%s: FSYNCCONTROL fsync disabled\n", __FUNCTION__);
  45 +
  46 + fsync_enabled = false;
  47 + }
  48 + else
  49 + {
  50 + pr_info("%s: invalid input range %u\n", __FUNCTION__, data);
  51 + }
  52 + }
  53 + else
  54 + {
  55 + pr_info("%s: invalid input\n", __FUNCTION__);
  56 + }
  57 +
  58 + return size;
  59 +}
  60 +
  61 +static ssize_t fsynccontrol_version(struct device * dev, struct device_attribute * attr, char * buf)
  62 +{
  63 + return sprintf(buf, "%u\n", FSYNCCONTROL_VERSION);
  64 +}
  65 +
  66 +static DEVICE_ATTR(fsync_enabled, S_IRUGO | S_IWUGO, fsynccontrol_status_read, fsynccontrol_status_write);
  67 +static DEVICE_ATTR(version, S_IRUGO , fsynccontrol_version, NULL);
  68 +
  69 +static struct attribute *fsynccontrol_attributes[] =
  70 + {
  71 + &dev_attr_fsync_enabled.attr,
  72 + &dev_attr_version.attr,
  73 + NULL
  74 + };
  75 +
  76 +static struct attribute_group fsynccontrol_group =
  77 + {
  78 + .attrs = fsynccontrol_attributes,
  79 + };
  80 +
  81 +static struct miscdevice fsynccontrol_device =
  82 + {
  83 + .minor = MISC_DYNAMIC_MINOR,
  84 + .name = "fsynccontrol",
  85 + };
  86 +
  87 +static int __init fsynccontrol_init(void)
  88 +{
  89 + int ret;
  90 +
  91 + pr_info("%s misc_register(%s)\n", __FUNCTION__, fsynccontrol_device.name);
  92 +
  93 + ret = misc_register(&fsynccontrol_device);
  94 +
  95 + if (ret)
  96 + {
  97 + pr_err("%s misc_register(%s) fail\n", __FUNCTION__, fsynccontrol_device.name);
  98 + return 1;
  99 + }
  100 +
  101 + if (sysfs_create_group(&fsynccontrol_device.this_device->kobj, &fsynccontrol_group) < 0)
  102 + {
  103 + pr_err("%s sysfs_create_group fail\n", __FUNCTION__);
  104 + pr_err("Failed to create sysfs group for device (%s)!\n", fsynccontrol_device.name);
  105 + }
  106 +
  107 + return 0;
  108 +}
  109 +
  110 +device_initcall(fsynccontrol_init);
44 fs/sync.c
@@ -21,6 +21,10 @@
21 21 #define VALID_FLAGS (SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| \
22 22 SYNC_FILE_RANGE_WAIT_AFTER)
23 23
  24 +#ifdef CONFIG_FSYNC_CONTROL
  25 +extern bool fsynccontrol_fsync_enabled();
  26 +#endif
  27 +
24 28 /*
25 29 * Do the filesystem syncing work. For simple filesystems
26 30 * writeback_inodes_sb(sb) just dirties buffers with inodes so we have to
@@ -139,6 +143,11 @@ SYSCALL_DEFINE1(syncfs, int, fd)
139 143 int ret;
140 144 int fput_needed;
141 145
  146 +#ifdef CONFIG_FSYNC_CONTROL
  147 + if (!fsynccontrol_fsync_enabled())
  148 + return 0;
  149 +#endif
  150 +
142 151 file = fget_light(fd, &fput_needed);
143 152 if (!file)
144 153 return -EBADF;
@@ -168,6 +177,11 @@ int vfs_fsync_range(struct file *file, loff_t start, loff_t end, int datasync)
168 177 struct address_space *mapping = file->f_mapping;
169 178 int err, ret;
170 179
  180 +#ifdef CONFIG_FSYNC_CONTROL
  181 + if (!fsynccontrol_fsync_enabled())
  182 + return 0;
  183 +#endif
  184 +
171 185 if (!file->f_op || !file->f_op->fsync) {
172 186 ret = -EINVAL;
173 187 goto out;
@@ -200,6 +214,11 @@ EXPORT_SYMBOL(vfs_fsync_range);
200 214 */
201 215 int vfs_fsync(struct file *file, int datasync)
202 216 {
  217 +#ifdef CONFIG_FSYNC_CONTROL
  218 + if (!fsynccontrol_fsync_enabled())
  219 + return 0;
  220 +#endif
  221 +
203 222 return vfs_fsync_range(file, 0, LLONG_MAX, datasync);
204 223 }
205 224 EXPORT_SYMBOL(vfs_fsync);
@@ -209,6 +228,11 @@ static int do_fsync(unsigned int fd, int datasync)
209 228 struct file *file;
210 229 int ret = -EBADF;
211 230
  231 +#ifdef CONFIG_FSYNC_CONTROL
  232 + if (!fsynccontrol_fsync_enabled())
  233 + return 0;
  234 +#endif
  235 +
212 236 file = fget(fd);
213 237 if (file) {
214 238 ret = vfs_fsync(file, datasync);
@@ -219,11 +243,21 @@ static int do_fsync(unsigned int fd, int datasync)
219 243
220 244 SYSCALL_DEFINE1(fsync, unsigned int, fd)
221 245 {
  246 +#ifdef CONFIG_FSYNC_CONTROL
  247 + if (!fsynccontrol_fsync_enabled())
  248 + return 0;
  249 +#endif
  250 +
222 251 return do_fsync(fd, 0);
223 252 }
224 253
225 254 SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
226 255 {
  256 +#ifdef CONFIG_FSYNC_CONTROL
  257 + if (!fsynccontrol_fsync_enabled())
  258 + return 0;
  259 +#endif
  260 +
227 261 return do_fsync(fd, 1);
228 262 }
229 263
@@ -237,6 +271,11 @@ SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
237 271 */
238 272 int generic_write_sync(struct file *file, loff_t pos, loff_t count)
239 273 {
  274 +#ifdef CONFIG_FSYNC_CONTROL
  275 + if (!fsynccontrol_fsync_enabled())
  276 + return 0;
  277 +#endif
  278 +
240 279 if (!(file->f_flags & O_DSYNC) && !IS_SYNC(file->f_mapping->host))
241 280 return 0;
242 281 return vfs_fsync_range(file, pos, pos + count - 1,
@@ -301,6 +340,11 @@ SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes,
301 340 int fput_needed;
302 341 umode_t i_mode;
303 342
  343 +#ifdef CONFIG_FSYNC_CONTROL
  344 + if (!fsynccontrol_fsync_enabled())
  345 + return 0;
  346 +#endif
  347 +
304 348 ret = -EINVAL;
305 349 if (flags & ~VALID_FLAGS)
306 350 goto out;

3 comments on commit 751c44a

For the life of me I can't find the /sys file to enable this. I added to my skyrocket kernel. Sorry for being dense.

Javier Vazquez

It's on /sys/devices/virtual/misc/fsynccontrol

or /sys/class/misc/fsynccontrol

The question is: Using RL Benchmark: SQlite I cannot see any differente in performance, while on the same solution on 2.6.35 kernel improved that a lot.

Is this stuff working?

Moved onto SGS3, but now that you reminded me I'll take a look at adding. I'll get back to you on this.

Please sign in to comment.
Something went wrong with that request. Please try again.