diff options
-rw-r--r-- | fs/nfs/write.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 75adb8e78db9..b3c5f5db73a4 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -1325,21 +1325,14 @@ long nfs_sync_mapping_wait(struct address_space *mapping, struct writeback_contr | |||
1325 | return ret; | 1325 | return ret; |
1326 | } | 1326 | } |
1327 | 1327 | ||
1328 | static int nfs_write_mapping(struct address_space *mapping, int how) | 1328 | static int __nfs_write_mapping(struct address_space *mapping, struct writeback_control *wbc, int how) |
1329 | { | 1329 | { |
1330 | struct writeback_control wbc = { | ||
1331 | .bdi = mapping->backing_dev_info, | ||
1332 | .sync_mode = WB_SYNC_ALL, | ||
1333 | .nr_to_write = LONG_MAX, | ||
1334 | .for_writepages = 1, | ||
1335 | .range_cyclic = 1, | ||
1336 | }; | ||
1337 | int ret; | 1330 | int ret; |
1338 | 1331 | ||
1339 | ret = nfs_writepages(mapping, &wbc); | 1332 | ret = nfs_writepages(mapping, wbc); |
1340 | if (ret < 0) | 1333 | if (ret < 0) |
1341 | goto out; | 1334 | goto out; |
1342 | ret = nfs_sync_mapping_wait(mapping, &wbc, how); | 1335 | ret = nfs_sync_mapping_wait(mapping, wbc, how); |
1343 | if (ret < 0) | 1336 | if (ret < 0) |
1344 | goto out; | 1337 | goto out; |
1345 | return 0; | 1338 | return 0; |
@@ -1348,6 +1341,25 @@ out: | |||
1348 | return ret; | 1341 | return ret; |
1349 | } | 1342 | } |
1350 | 1343 | ||
1344 | /* Two pass sync: first using WB_SYNC_NONE, then WB_SYNC_ALL */ | ||
1345 | static int nfs_write_mapping(struct address_space *mapping, int how) | ||
1346 | { | ||
1347 | struct writeback_control wbc = { | ||
1348 | .bdi = mapping->backing_dev_info, | ||
1349 | .sync_mode = WB_SYNC_NONE, | ||
1350 | .nr_to_write = LONG_MAX, | ||
1351 | .for_writepages = 1, | ||
1352 | .range_cyclic = 1, | ||
1353 | }; | ||
1354 | int ret; | ||
1355 | |||
1356 | ret = __nfs_write_mapping(mapping, &wbc, how); | ||
1357 | if (ret < 0) | ||
1358 | return ret; | ||
1359 | wbc.sync_mode = WB_SYNC_ALL; | ||
1360 | return __nfs_write_mapping(mapping, &wbc, how); | ||
1361 | } | ||
1362 | |||
1351 | /* | 1363 | /* |
1352 | * flush the inode to disk. | 1364 | * flush the inode to disk. |
1353 | */ | 1365 | */ |