diff options
Diffstat (limited to 'mm/backing-dev.c')
| -rw-r--r-- | mm/backing-dev.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 8e8587444132..493b468a5035 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c | |||
| @@ -2,11 +2,24 @@ | |||
| 2 | #include <linux/wait.h> | 2 | #include <linux/wait.h> |
| 3 | #include <linux/backing-dev.h> | 3 | #include <linux/backing-dev.h> |
| 4 | #include <linux/fs.h> | 4 | #include <linux/fs.h> |
| 5 | #include <linux/pagemap.h> | ||
| 5 | #include <linux/sched.h> | 6 | #include <linux/sched.h> |
| 6 | #include <linux/module.h> | 7 | #include <linux/module.h> |
| 7 | #include <linux/writeback.h> | 8 | #include <linux/writeback.h> |
| 8 | #include <linux/device.h> | 9 | #include <linux/device.h> |
| 9 | 10 | ||
| 11 | void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page) | ||
| 12 | { | ||
| 13 | } | ||
| 14 | EXPORT_SYMBOL(default_unplug_io_fn); | ||
| 15 | |||
| 16 | struct backing_dev_info default_backing_dev_info = { | ||
| 17 | .ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_CACHE_SIZE, | ||
| 18 | .state = 0, | ||
| 19 | .capabilities = BDI_CAP_MAP_COPY, | ||
| 20 | .unplug_io_fn = default_unplug_io_fn, | ||
| 21 | }; | ||
| 22 | EXPORT_SYMBOL_GPL(default_backing_dev_info); | ||
| 10 | 23 | ||
| 11 | static struct class *bdi_class; | 24 | static struct class *bdi_class; |
| 12 | 25 | ||
| @@ -166,9 +179,20 @@ static __init int bdi_class_init(void) | |||
| 166 | bdi_debug_init(); | 179 | bdi_debug_init(); |
| 167 | return 0; | 180 | return 0; |
| 168 | } | 181 | } |
| 169 | |||
| 170 | postcore_initcall(bdi_class_init); | 182 | postcore_initcall(bdi_class_init); |
| 171 | 183 | ||
| 184 | static int __init default_bdi_init(void) | ||
| 185 | { | ||
| 186 | int err; | ||
| 187 | |||
| 188 | err = bdi_init(&default_backing_dev_info); | ||
| 189 | if (!err) | ||
| 190 | bdi_register(&default_backing_dev_info, NULL, "default"); | ||
| 191 | |||
| 192 | return err; | ||
| 193 | } | ||
| 194 | subsys_initcall(default_bdi_init); | ||
| 195 | |||
| 172 | int bdi_register(struct backing_dev_info *bdi, struct device *parent, | 196 | int bdi_register(struct backing_dev_info *bdi, struct device *parent, |
| 173 | const char *fmt, ...) | 197 | const char *fmt, ...) |
| 174 | { | 198 | { |
| @@ -260,12 +284,12 @@ static wait_queue_head_t congestion_wqh[2] = { | |||
| 260 | }; | 284 | }; |
| 261 | 285 | ||
| 262 | 286 | ||
| 263 | void clear_bdi_congested(struct backing_dev_info *bdi, int rw) | 287 | void clear_bdi_congested(struct backing_dev_info *bdi, int sync) |
| 264 | { | 288 | { |
| 265 | enum bdi_state bit; | 289 | enum bdi_state bit; |
| 266 | wait_queue_head_t *wqh = &congestion_wqh[rw]; | 290 | wait_queue_head_t *wqh = &congestion_wqh[sync]; |
| 267 | 291 | ||
| 268 | bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested; | 292 | bit = sync ? BDI_sync_congested : BDI_async_congested; |
| 269 | clear_bit(bit, &bdi->state); | 293 | clear_bit(bit, &bdi->state); |
| 270 | smp_mb__after_clear_bit(); | 294 | smp_mb__after_clear_bit(); |
| 271 | if (waitqueue_active(wqh)) | 295 | if (waitqueue_active(wqh)) |
| @@ -273,11 +297,11 @@ void clear_bdi_congested(struct backing_dev_info *bdi, int rw) | |||
| 273 | } | 297 | } |
| 274 | EXPORT_SYMBOL(clear_bdi_congested); | 298 | EXPORT_SYMBOL(clear_bdi_congested); |
| 275 | 299 | ||
| 276 | void set_bdi_congested(struct backing_dev_info *bdi, int rw) | 300 | void set_bdi_congested(struct backing_dev_info *bdi, int sync) |
| 277 | { | 301 | { |
| 278 | enum bdi_state bit; | 302 | enum bdi_state bit; |
| 279 | 303 | ||
| 280 | bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested; | 304 | bit = sync ? BDI_sync_congested : BDI_async_congested; |
| 281 | set_bit(bit, &bdi->state); | 305 | set_bit(bit, &bdi->state); |
| 282 | } | 306 | } |
| 283 | EXPORT_SYMBOL(set_bdi_congested); | 307 | EXPORT_SYMBOL(set_bdi_congested); |
