diff options
Diffstat (limited to 'include/linux/writeback.h')
| -rw-r--r-- | include/linux/writeback.h | 74 |
1 files changed, 57 insertions, 17 deletions
diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 3f6542ca619..a378c295851 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h | |||
| @@ -7,9 +7,28 @@ | |||
| 7 | #include <linux/sched.h> | 7 | #include <linux/sched.h> |
| 8 | #include <linux/fs.h> | 8 | #include <linux/fs.h> |
| 9 | 9 | ||
| 10 | struct backing_dev_info; | 10 | /* |
| 11 | * The 1/4 region under the global dirty thresh is for smooth dirty throttling: | ||
| 12 | * | ||
| 13 | * (thresh - thresh/DIRTY_FULL_SCOPE, thresh) | ||
| 14 | * | ||
| 15 | * Further beyond, all dirtier tasks will enter a loop waiting (possibly long | ||
| 16 | * time) for the dirty pages to drop, unless written enough pages. | ||
| 17 | * | ||
| 18 | * The global dirty threshold is normally equal to the global dirty limit, | ||
| 19 | * except when the system suddenly allocates a lot of anonymous memory and | ||
| 20 | * knocks down the global dirty threshold quickly, in which case the global | ||
| 21 | * dirty limit will follow down slowly to prevent livelocking all dirtier tasks. | ||
| 22 | */ | ||
| 23 | #define DIRTY_SCOPE 8 | ||
| 24 | #define DIRTY_FULL_SCOPE (DIRTY_SCOPE / 2) | ||
| 11 | 25 | ||
| 12 | extern spinlock_t inode_wb_list_lock; | 26 | /* |
| 27 | * 4MB minimal write chunk size | ||
| 28 | */ | ||
| 29 | #define MIN_WRITEBACK_PAGES (4096UL >> (PAGE_CACHE_SHIFT - 10)) | ||
| 30 | |||
| 31 | struct backing_dev_info; | ||
| 13 | 32 | ||
| 14 | /* | 33 | /* |
| 15 | * fs/fs-writeback.c | 34 | * fs/fs-writeback.c |
| @@ -20,17 +39,29 @@ enum writeback_sync_modes { | |||
| 20 | }; | 39 | }; |
| 21 | 40 | ||
| 22 | /* | 41 | /* |
| 42 | * why some writeback work was initiated | ||
| 43 | */ | ||
| 44 | enum wb_reason { | ||
| 45 | WB_REASON_BACKGROUND, | ||
| 46 | WB_REASON_TRY_TO_FREE_PAGES, | ||
| 47 | WB_REASON_SYNC, | ||
| 48 | WB_REASON_PERIODIC, | ||
| 49 | WB_REASON_LAPTOP_TIMER, | ||
| 50 | WB_REASON_FREE_MORE_MEM, | ||
| 51 | WB_REASON_FS_FREE_SPACE, | ||
| 52 | WB_REASON_FORKER_THREAD, | ||
| 53 | |||
| 54 | WB_REASON_MAX, | ||
| 55 | }; | ||
| 56 | extern const char *wb_reason_name[]; | ||
| 57 | |||
| 58 | /* | ||
| 23 | * A control structure which tells the writeback code what to do. These are | 59 | * A control structure which tells the writeback code what to do. These are |
| 24 | * always on the stack, and hence need no locking. They are always initialised | 60 | * always on the stack, and hence need no locking. They are always initialised |
| 25 | * in a manner such that unspecified fields are set to zero. | 61 | * in a manner such that unspecified fields are set to zero. |
| 26 | */ | 62 | */ |
| 27 | struct writeback_control { | 63 | struct writeback_control { |
| 28 | enum writeback_sync_modes sync_mode; | 64 | enum writeback_sync_modes sync_mode; |
| 29 | unsigned long *older_than_this; /* If !NULL, only write back inodes | ||
| 30 | older than this */ | ||
| 31 | unsigned long wb_start; /* Time writeback_inodes_wb was | ||
| 32 | called. This is needed to avoid | ||
| 33 | extra jobs and livelock */ | ||
| 34 | long nr_to_write; /* Write this many pages, and decrement | 65 | long nr_to_write; /* Write this many pages, and decrement |
| 35 | this for each page written */ | 66 | this for each page written */ |
| 36 | long pages_skipped; /* Pages which were not written */ | 67 | long pages_skipped; /* Pages which were not written */ |
| @@ -43,14 +74,11 @@ struct writeback_control { | |||
| 43 | loff_t range_start; | 74 | loff_t range_start; |
| 44 | loff_t range_end; | 75 | loff_t range_end; |
| 45 | 76 | ||
| 46 | unsigned nonblocking:1; /* Don't get stuck on request queues */ | ||
| 47 | unsigned encountered_congestion:1; /* An output: a queue is full */ | ||
| 48 | unsigned for_kupdate:1; /* A kupdate writeback */ | 77 | unsigned for_kupdate:1; /* A kupdate writeback */ |
| 49 | unsigned for_background:1; /* A background writeback */ | 78 | unsigned for_background:1; /* A background writeback */ |
| 50 | unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */ | 79 | unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */ |
| 51 | unsigned for_reclaim:1; /* Invoked from the page allocator */ | 80 | unsigned for_reclaim:1; /* Invoked from the page allocator */ |
| 52 | unsigned range_cyclic:1; /* range_start is cyclic */ | 81 | unsigned range_cyclic:1; /* range_start is cyclic */ |
| 53 | unsigned more_io:1; /* more io to be dispatched */ | ||
| 54 | }; | 82 | }; |
| 55 | 83 | ||
| 56 | /* | 84 | /* |
| @@ -58,15 +86,17 @@ struct writeback_control { | |||
| 58 | */ | 86 | */ |
| 59 | struct bdi_writeback; | 87 | struct bdi_writeback; |
| 60 | int inode_wait(void *); | 88 | int inode_wait(void *); |
| 61 | void writeback_inodes_sb(struct super_block *); | 89 | void writeback_inodes_sb(struct super_block *, enum wb_reason reason); |
| 62 | void writeback_inodes_sb_nr(struct super_block *, unsigned long nr); | 90 | void writeback_inodes_sb_nr(struct super_block *, unsigned long nr, |
| 63 | int writeback_inodes_sb_if_idle(struct super_block *); | 91 | enum wb_reason reason); |
| 64 | int writeback_inodes_sb_nr_if_idle(struct super_block *, unsigned long nr); | 92 | int writeback_inodes_sb_if_idle(struct super_block *, enum wb_reason reason); |
| 93 | int writeback_inodes_sb_nr_if_idle(struct super_block *, unsigned long nr, | ||
| 94 | enum wb_reason reason); | ||
| 65 | void sync_inodes_sb(struct super_block *); | 95 | void sync_inodes_sb(struct super_block *); |
| 66 | void writeback_inodes_wb(struct bdi_writeback *wb, | 96 | long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages, |
| 67 | struct writeback_control *wbc); | 97 | enum wb_reason reason); |
| 68 | long wb_do_writeback(struct bdi_writeback *wb, int force_wait); | 98 | long wb_do_writeback(struct bdi_writeback *wb, int force_wait); |
| 69 | void wakeup_flusher_threads(long nr_pages); | 99 | void wakeup_flusher_threads(long nr_pages, enum wb_reason reason); |
| 70 | 100 | ||
| 71 | /* writeback.h requires fs.h; it, too, is not included from here. */ | 101 | /* writeback.h requires fs.h; it, too, is not included from here. */ |
| 72 | static inline void wait_on_inode(struct inode *inode) | 102 | static inline void wait_on_inode(struct inode *inode) |
| @@ -95,6 +125,8 @@ static inline void laptop_sync_completion(void) { } | |||
| 95 | #endif | 125 | #endif |
| 96 | void throttle_vm_writeout(gfp_t gfp_mask); | 126 | void throttle_vm_writeout(gfp_t gfp_mask); |
| 97 | 127 | ||
| 128 | extern unsigned long global_dirty_limit; | ||
| 129 | |||
| 98 | /* These are exported to sysctl. */ | 130 | /* These are exported to sysctl. */ |
| 99 | extern int dirty_background_ratio; | 131 | extern int dirty_background_ratio; |
| 100 | extern unsigned long dirty_background_bytes; | 132 | extern unsigned long dirty_background_bytes; |
| @@ -129,6 +161,14 @@ void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty); | |||
| 129 | unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, | 161 | unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, |
| 130 | unsigned long dirty); | 162 | unsigned long dirty); |
| 131 | 163 | ||
| 164 | void __bdi_update_bandwidth(struct backing_dev_info *bdi, | ||
| 165 | unsigned long thresh, | ||
| 166 | unsigned long bg_thresh, | ||
| 167 | unsigned long dirty, | ||
| 168 | unsigned long bdi_thresh, | ||
| 169 | unsigned long bdi_dirty, | ||
| 170 | unsigned long start_time); | ||
| 171 | |||
| 132 | void page_writeback_init(void); | 172 | void page_writeback_init(void); |
| 133 | void balance_dirty_pages_ratelimited_nr(struct address_space *mapping, | 173 | void balance_dirty_pages_ratelimited_nr(struct address_space *mapping, |
| 134 | unsigned long nr_pages_dirtied); | 174 | unsigned long nr_pages_dirtied); |
