diff options
Diffstat (limited to 'fs/xfs/xfs_file.c')
-rw-r--r-- | fs/xfs/xfs_file.c | 70 |
1 files changed, 54 insertions, 16 deletions
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index a2e1cb8a568b..b101e80f2862 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c | |||
@@ -847,6 +847,9 @@ xfs_file_fallocate( | |||
847 | if (error) | 847 | if (error) |
848 | goto out_unlock; | 848 | goto out_unlock; |
849 | 849 | ||
850 | xfs_ilock(ip, XFS_MMAPLOCK_EXCL); | ||
851 | iolock |= XFS_MMAPLOCK_EXCL; | ||
852 | |||
850 | if (mode & FALLOC_FL_PUNCH_HOLE) { | 853 | if (mode & FALLOC_FL_PUNCH_HOLE) { |
851 | error = xfs_free_file_space(ip, offset, len); | 854 | error = xfs_free_file_space(ip, offset, len); |
852 | if (error) | 855 | if (error) |
@@ -997,20 +1000,6 @@ xfs_file_mmap( | |||
997 | } | 1000 | } |
998 | 1001 | ||
999 | /* | 1002 | /* |
1000 | * mmap()d file has taken write protection fault and is being made | ||
1001 | * writable. We can set the page state up correctly for a writable | ||
1002 | * page, which means we can do correct delalloc accounting (ENOSPC | ||
1003 | * checking!) and unwritten extent mapping. | ||
1004 | */ | ||
1005 | STATIC int | ||
1006 | xfs_vm_page_mkwrite( | ||
1007 | struct vm_area_struct *vma, | ||
1008 | struct vm_fault *vmf) | ||
1009 | { | ||
1010 | return block_page_mkwrite(vma, vmf, xfs_get_blocks); | ||
1011 | } | ||
1012 | |||
1013 | /* | ||
1014 | * This type is designed to indicate the type of offset we would like | 1003 | * This type is designed to indicate the type of offset we would like |
1015 | * to search from page cache for xfs_seek_hole_data(). | 1004 | * to search from page cache for xfs_seek_hole_data(). |
1016 | */ | 1005 | */ |
@@ -1385,6 +1374,55 @@ xfs_file_llseek( | |||
1385 | } | 1374 | } |
1386 | } | 1375 | } |
1387 | 1376 | ||
1377 | /* | ||
1378 | * Locking for serialisation of IO during page faults. This results in a lock | ||
1379 | * ordering of: | ||
1380 | * | ||
1381 | * mmap_sem (MM) | ||
1382 | * i_mmap_lock (XFS - truncate serialisation) | ||
1383 | * page_lock (MM) | ||
1384 | * i_lock (XFS - extent map serialisation) | ||
1385 | */ | ||
1386 | STATIC int | ||
1387 | xfs_filemap_fault( | ||
1388 | struct vm_area_struct *vma, | ||
1389 | struct vm_fault *vmf) | ||
1390 | { | ||
1391 | struct xfs_inode *ip = XFS_I(vma->vm_file->f_mapping->host); | ||
1392 | int error; | ||
1393 | |||
1394 | trace_xfs_filemap_fault(ip); | ||
1395 | |||
1396 | xfs_ilock(ip, XFS_MMAPLOCK_SHARED); | ||
1397 | error = filemap_fault(vma, vmf); | ||
1398 | xfs_iunlock(ip, XFS_MMAPLOCK_SHARED); | ||
1399 | |||
1400 | return error; | ||
1401 | } | ||
1402 | |||
1403 | /* | ||
1404 | * mmap()d file has taken write protection fault and is being made writable. We | ||
1405 | * can set the page state up correctly for a writable page, which means we can | ||
1406 | * do correct delalloc accounting (ENOSPC checking!) and unwritten extent | ||
1407 | * mapping. | ||
1408 | */ | ||
1409 | STATIC int | ||
1410 | xfs_filemap_page_mkwrite( | ||
1411 | struct vm_area_struct *vma, | ||
1412 | struct vm_fault *vmf) | ||
1413 | { | ||
1414 | struct xfs_inode *ip = XFS_I(vma->vm_file->f_mapping->host); | ||
1415 | int error; | ||
1416 | |||
1417 | trace_xfs_filemap_page_mkwrite(ip); | ||
1418 | |||
1419 | xfs_ilock(ip, XFS_MMAPLOCK_SHARED); | ||
1420 | error = block_page_mkwrite(vma, vmf, xfs_get_blocks); | ||
1421 | xfs_iunlock(ip, XFS_MMAPLOCK_SHARED); | ||
1422 | |||
1423 | return error; | ||
1424 | } | ||
1425 | |||
1388 | const struct file_operations xfs_file_operations = { | 1426 | const struct file_operations xfs_file_operations = { |
1389 | .llseek = xfs_file_llseek, | 1427 | .llseek = xfs_file_llseek, |
1390 | .read = new_sync_read, | 1428 | .read = new_sync_read, |
@@ -1417,7 +1455,7 @@ const struct file_operations xfs_dir_file_operations = { | |||
1417 | }; | 1455 | }; |
1418 | 1456 | ||
1419 | static const struct vm_operations_struct xfs_file_vm_ops = { | 1457 | static const struct vm_operations_struct xfs_file_vm_ops = { |
1420 | .fault = filemap_fault, | 1458 | .fault = xfs_filemap_fault, |
1421 | .map_pages = filemap_map_pages, | 1459 | .map_pages = filemap_map_pages, |
1422 | .page_mkwrite = xfs_vm_page_mkwrite, | 1460 | .page_mkwrite = xfs_filemap_page_mkwrite, |
1423 | }; | 1461 | }; |