View | Details | Raw Unified | Return to bug 15906
Collapse All | Expand All

(-)a/fs/fs-writeback.c (-11 / +37 lines)
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
 *
(-)a/fs/sync.c (-1 / +1 lines)
Lines 42-48 static int __sync_filesystem(struct super_block *sb, int wait) Link Here
42
	if (wait)
42
	if (wait)
43
		sync_inodes_sb(sb);
43
		sync_inodes_sb(sb);
44
	else
44
	else
45
		writeback_inodes_sb(sb);
45
		writeback_inodes_sb_locked(sb);
46
46
47
	if (sb->s_op->sync_fs)
47
	if (sb->s_op->sync_fs)
48
		sb->s_op->sync_fs(sb, wait);
48
		sb->s_op->sync_fs(sb, wait);
(-)a/include/linux/backing-dev.h (-1 / +1 lines)
Lines 103-109 int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); Link Here
103
void bdi_unregister(struct backing_dev_info *bdi);
103
void bdi_unregister(struct backing_dev_info *bdi);
104
int bdi_setup_and_register(struct backing_dev_info *, char *, unsigned int);
104
int bdi_setup_and_register(struct backing_dev_info *, char *, unsigned int);
105
void bdi_start_writeback(struct backing_dev_info *bdi, struct super_block *sb,
105
void bdi_start_writeback(struct backing_dev_info *bdi, struct super_block *sb,
106
				long nr_pages);
106
				long nr_pages, int sb_locked);
107
int bdi_writeback_task(struct bdi_writeback *wb);
107
int bdi_writeback_task(struct bdi_writeback *wb);
108
int bdi_has_dirty_io(struct backing_dev_info *bdi);
108
int bdi_has_dirty_io(struct backing_dev_info *bdi);
109
109
(-)a/include/linux/writeback.h (+10 lines)
Lines 65-70 struct writeback_control { Link Here
65
	 * so we use a single control to update them
65
	 * so we use a single control to update them
66
	 */
66
	 */
67
	unsigned no_nrwrite_index_update:1;
67
	unsigned no_nrwrite_index_update:1;
68
69
	/*
70
	 * For WB_SYNC_ALL, the sb must always be pinned. For WB_SYNC_NONE,
71
	 * the writeback code will pin the sb for the caller. However,
72
	 * for eg umount, the caller does WB_SYNC_NONE but already has
73
	 * the sb pinned. If the below is set, caller already has the
74
	 * sb pinned.
75
	 */
76
	unsigned sb_pinned:1;
68
};
77
};
69
78
70
/*
79
/*
Lines 73-78 struct writeback_control { Link Here
73
struct bdi_writeback;
82
struct bdi_writeback;
74
int inode_wait(void *);
83
int inode_wait(void *);
75
void writeback_inodes_sb(struct super_block *);
84
void writeback_inodes_sb(struct super_block *);
85
void writeback_inodes_sb_locked(struct super_block *);
76
int writeback_inodes_sb_if_idle(struct super_block *);
86
int writeback_inodes_sb_if_idle(struct super_block *);
77
void sync_inodes_sb(struct super_block *);
87
void sync_inodes_sb(struct super_block *);
78
void writeback_inodes_wbc(struct writeback_control *wbc);
88
void writeback_inodes_wbc(struct writeback_control *wbc);
(-)a/mm/page-writeback.c (-1 / +1 lines)
Lines 597-603 static void balance_dirty_pages(struct address_space *mapping, Link Here
597
	    (!laptop_mode && ((global_page_state(NR_FILE_DIRTY)
597
	    (!laptop_mode && ((global_page_state(NR_FILE_DIRTY)
598
			       + global_page_state(NR_UNSTABLE_NFS))
598
			       + global_page_state(NR_UNSTABLE_NFS))
599
					  > background_thresh)))
599
					  > background_thresh)))
600
		bdi_start_writeback(bdi, NULL, 0);
600
		bdi_start_writeback(bdi, NULL, 0, 0);
601
}
601
}
602
602
603
void set_page_dirty_balance(struct page *page, int page_mkwrite)
603
void set_page_dirty_balance(struct page *page, int page_mkwrite)

Return to bug 15906