aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fs-writeback.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-28 16:21:44 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-28 16:21:44 -0500
commitde1a2262b006220dae2561a299a6ea128c46f4fe (patch)
tree0df7b3686f09a77a000fb63a333237facad3482c /fs/fs-writeback.c
parentf042fea0da78d9dc077a9c736b33b60eb8f35195 (diff)
parented84825b785ceb932af7dd5aa08614801721320b (diff)
Merge tag 'writeback-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/wfg/linux
Pull writeback fixes from Wu Fengguang: "Two writeback fixes - fix negative (setpoint - dirty) in 32bit archs - use down_read_trylock() in writeback_inodes_sb(_nr)_if_idle()" * tag 'writeback-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/wfg/linux: Negative (setpoint-dirty) in bdi_position_ratio() vfs: re-implement writeback_inodes_sb(_nr)_if_idle() and rename them
Diffstat (limited to 'fs/fs-writeback.c')
-rw-r--r--fs/fs-writeback.c44
1 files changed, 20 insertions, 24 deletions
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 359494ea1bde..21f46fb3a101 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -1344,47 +1344,43 @@ void writeback_inodes_sb(struct super_block *sb, enum wb_reason reason)
1344EXPORT_SYMBOL(writeback_inodes_sb); 1344EXPORT_SYMBOL(writeback_inodes_sb);
1345 1345
1346/** 1346/**
1347 * writeback_inodes_sb_if_idle - start writeback if none underway 1347 * try_to_writeback_inodes_sb_nr - try to start writeback if none underway
1348 * @sb: the superblock 1348 * @sb: the superblock
1349 * @reason: reason why some writeback work was initiated 1349 * @nr: the number of pages to write
1350 * @reason: the reason of writeback
1350 * 1351 *
1351 * Invoke writeback_inodes_sb if no writeback is currently underway. 1352 * Invoke writeback_inodes_sb_nr if no writeback is currently underway.
1352 * Returns 1 if writeback was started, 0 if not. 1353 * Returns 1 if writeback was started, 0 if not.
1353 */ 1354 */
1354int writeback_inodes_sb_if_idle(struct super_block *sb, enum wb_reason reason) 1355int try_to_writeback_inodes_sb_nr(struct super_block *sb,
1356 unsigned long nr,
1357 enum wb_reason reason)
1355{ 1358{
1356 if (!writeback_in_progress(sb->s_bdi)) { 1359 if (writeback_in_progress(sb->s_bdi))
1357 down_read(&sb->s_umount);
1358 writeback_inodes_sb(sb, reason);
1359 up_read(&sb->s_umount);
1360 return 1; 1360 return 1;
1361 } else 1361
1362 if (!down_read_trylock(&sb->s_umount))
1362 return 0; 1363 return 0;
1364
1365 writeback_inodes_sb_nr(sb, nr, reason);
1366 up_read(&sb->s_umount);
1367 return 1;
1363} 1368}
1364EXPORT_SYMBOL(writeback_inodes_sb_if_idle); 1369EXPORT_SYMBOL(try_to_writeback_inodes_sb_nr);
1365 1370
1366/** 1371/**
1367 * writeback_inodes_sb_nr_if_idle - start writeback if none underway 1372 * try_to_writeback_inodes_sb - try to start writeback if none underway
1368 * @sb: the superblock 1373 * @sb: the superblock
1369 * @nr: the number of pages to write
1370 * @reason: reason why some writeback work was initiated 1374 * @reason: reason why some writeback work was initiated
1371 * 1375 *
1372 * Invoke writeback_inodes_sb if no writeback is currently underway. 1376 * Implement by try_to_writeback_inodes_sb_nr()
1373 * Returns 1 if writeback was started, 0 if not. 1377 * Returns 1 if writeback was started, 0 if not.
1374 */ 1378 */
1375int writeback_inodes_sb_nr_if_idle(struct super_block *sb, 1379int try_to_writeback_inodes_sb(struct super_block *sb, enum wb_reason reason)
1376 unsigned long nr,
1377 enum wb_reason reason)
1378{ 1380{
1379 if (!writeback_in_progress(sb->s_bdi)) { 1381 return try_to_writeback_inodes_sb_nr(sb, get_nr_dirty_pages(), reason);
1380 down_read(&sb->s_umount);
1381 writeback_inodes_sb_nr(sb, nr, reason);
1382 up_read(&sb->s_umount);
1383 return 1;
1384 } else
1385 return 0;
1386} 1382}
1387EXPORT_SYMBOL(writeback_inodes_sb_nr_if_idle); 1383EXPORT_SYMBOL(try_to_writeback_inodes_sb);
1388 1384
1389/** 1385/**
1390 * sync_inodes_sb - sync sb inode pages 1386 * sync_inodes_sb - sync sb inode pages