Lines 45-50
struct wb_writeback_args {
Link Here
|
45 |
int for_kupdate:1; |
45 |
int for_kupdate:1; |
46 |
int range_cyclic:1; |
46 |
int range_cyclic:1; |
47 |
int for_background:1; |
47 |
int for_background:1; |
|
|
48 |
int sb_pinned:1; |
48 |
}; |
49 |
}; |
49 |
|
50 |
|
50 |
/* |
51 |
/* |
Lines 230-235
static void bdi_sync_writeback(struct backing_dev_info *bdi,
Link Here
|
230 |
.sync_mode = WB_SYNC_ALL, |
231 |
.sync_mode = WB_SYNC_ALL, |
231 |
.nr_pages = LONG_MAX, |
232 |
.nr_pages = LONG_MAX, |
232 |
.range_cyclic = 0, |
233 |
.range_cyclic = 0, |
|
|
234 |
/* |
235 |
* Setting sb_pinned is not necessary for WB_SYNC_ALL, but |
236 |
* lets make it explicitly clear. |
237 |
*/ |
238 |
.sb_pinned = 1, |
233 |
}; |
239 |
}; |
234 |
struct bdi_work work; |
240 |
struct bdi_work work; |
235 |
|
241 |
|
Lines 245-265
static void bdi_sync_writeback(struct backing_dev_info *bdi,
Link Here
|
245 |
* @bdi: the backing device to write from |
251 |
* @bdi: the backing device to write from |
246 |
* @sb: write inodes from this super_block |
252 |
* @sb: write inodes from this super_block |
247 |
* @nr_pages: the number of pages to write |
253 |
* @nr_pages: the number of pages to write |
|
|
254 |
* @sb_locked: caller already holds sb umount sem. |
248 |
* |
255 |
* |
249 |
* Description: |
256 |
* Description: |
250 |
* This does WB_SYNC_NONE opportunistic writeback. The IO is only |
257 |
* This does WB_SYNC_NONE opportunistic writeback. The IO is only |
251 |
* started when this function returns, we make no guarentees on |
258 |
* started when this function returns, we make no guarentees on |
252 |
* completion. Caller need not hold sb s_umount semaphore. |
259 |
* completion. Caller specifies whether sb umount sem is held already or not. |
253 |
* |
260 |
* |
254 |
*/ |
261 |
*/ |
255 |
void bdi_start_writeback(struct backing_dev_info *bdi, struct super_block *sb, |
262 |
void bdi_start_writeback(struct backing_dev_info *bdi, struct super_block *sb, |
256 |
long nr_pages) |
263 |
long nr_pages, int sb_locked) |
257 |
{ |
264 |
{ |
258 |
struct wb_writeback_args args = { |
265 |
struct wb_writeback_args args = { |
259 |
.sb = sb, |
266 |
.sb = sb, |
260 |
.sync_mode = WB_SYNC_NONE, |
267 |
.sync_mode = WB_SYNC_NONE, |
261 |
.nr_pages = nr_pages, |
268 |
.nr_pages = nr_pages, |
262 |
.range_cyclic = 1, |
269 |
.range_cyclic = 1, |
|
|
270 |
.sb_pinned = sb_locked, |
263 |
}; |
271 |
}; |
264 |
|
272 |
|
265 |
/* |
273 |
/* |
Lines 577-583
static enum sb_pin_state pin_sb_for_writeback(struct writeback_control *wbc,
Link Here
|
577 |
/* |
585 |
/* |
578 |
* Caller must already hold the ref for this |
586 |
* Caller must already hold the ref for this |
579 |
*/ |
587 |
*/ |
580 |
if (wbc->sync_mode == WB_SYNC_ALL) { |
588 |
if (wbc->sync_mode == WB_SYNC_ALL || wbc->sb_pinned) { |
581 |
WARN_ON(!rwsem_is_locked(&sb->s_umount)); |
589 |
WARN_ON(!rwsem_is_locked(&sb->s_umount)); |
582 |
return SB_NOT_PINNED; |
590 |
return SB_NOT_PINNED; |
583 |
} |
591 |
} |
Lines 751-756
static long wb_writeback(struct bdi_writeback *wb,
Link Here
|
751 |
.for_kupdate = args->for_kupdate, |
759 |
.for_kupdate = args->for_kupdate, |
752 |
.for_background = args->for_background, |
760 |
.for_background = args->for_background, |
753 |
.range_cyclic = args->range_cyclic, |
761 |
.range_cyclic = args->range_cyclic, |
|
|
762 |
.sb_pinned = args->sb_pinned, |
754 |
}; |
763 |
}; |
755 |
unsigned long oldest_jif; |
764 |
unsigned long oldest_jif; |
756 |
long wrote = 0; |
765 |
long wrote = 0; |
Lines 1183-1188
static void wait_sb_inodes(struct super_block *sb)
Link Here
|
1183 |
iput(old_inode); |
1192 |
iput(old_inode); |
1184 |
} |
1193 |
} |
1185 |
|
1194 |
|
|
|
1195 |
static void __writeback_inodes_sb(struct super_block *sb, int sb_locked) |
1196 |
{ |
1197 |
unsigned long nr_dirty = global_page_state(NR_FILE_DIRTY); |
1198 |
unsigned long nr_unstable = global_page_state(NR_UNSTABLE_NFS); |
1199 |
long nr_to_write; |
1200 |
|
1201 |
nr_to_write = nr_dirty + nr_unstable + |
1202 |
(inodes_stat.nr_inodes - inodes_stat.nr_unused); |
1203 |
|
1204 |
bdi_start_writeback(sb->s_bdi, sb, nr_to_write, sb_locked); |
1205 |
} |
1206 |
|
1186 |
/** |
1207 |
/** |
1187 |
* writeback_inodes_sb - writeback dirty inodes from given super_block |
1208 |
* writeback_inodes_sb - writeback dirty inodes from given super_block |
1188 |
* @sb: the superblock |
1209 |
* @sb: the superblock |
Lines 1194-1211
static void wait_sb_inodes(struct super_block *sb)
Link Here
|
1194 |
*/ |
1215 |
*/ |
1195 |
void writeback_inodes_sb(struct super_block *sb) |
1216 |
void writeback_inodes_sb(struct super_block *sb) |
1196 |
{ |
1217 |
{ |
1197 |
unsigned long nr_dirty = global_page_state(NR_FILE_DIRTY); |
1218 |
__writeback_inodes_sb(sb, 0); |
1198 |
unsigned long nr_unstable = global_page_state(NR_UNSTABLE_NFS); |
|
|
1199 |
long nr_to_write; |
1200 |
|
1201 |
nr_to_write = nr_dirty + nr_unstable + |
1202 |
(inodes_stat.nr_inodes - inodes_stat.nr_unused); |
1203 |
|
1204 |
bdi_start_writeback(sb->s_bdi, sb, nr_to_write); |
1205 |
} |
1219 |
} |
1206 |
EXPORT_SYMBOL(writeback_inodes_sb); |
1220 |
EXPORT_SYMBOL(writeback_inodes_sb); |
1207 |
|
1221 |
|
1208 |
/** |
1222 |
/** |
|
|
1223 |
* writeback_inodes_sb_locked - writeback dirty inodes from given super_block |
1224 |
* @sb: the superblock |
1225 |
* |
1226 |
* Like writeback_inodes_sb(), except the caller already holds the |
1227 |
* sb umount sem. |
1228 |
*/ |
1229 |
void writeback_inodes_sb_locked(struct super_block *sb) |
1230 |
{ |
1231 |
__writeback_inodes_sb(sb, 1); |
1232 |
} |
1233 |
|
1234 |
/** |
1209 |
* writeback_inodes_sb_if_idle - start writeback if none underway |
1235 |
* writeback_inodes_sb_if_idle - start writeback if none underway |
1210 |
* @sb: the superblock |
1236 |
* @sb: the superblock |
1211 |
* |
1237 |
* |