aboutsummaryrefslogtreecommitdiffstats
path: root/mm/filemap.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-08-01 13:26:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-08-01 13:26:23 -0400
commita0e881b7c189fa2bd76c024dbff91e79511c971d (patch)
tree0c801918565b08921d21aceee5b326f64d998f5f /mm/filemap.c
parenteff0d13f3823f35d70228cd151d2a2c89288ff32 (diff)
parentdbc6e0222d79e78925fe20733844a796a4b72cf9 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull second vfs pile from Al Viro: "The stuff in there: fsfreeze deadlock fixes by Jan (essentially, the deadlock reproduced by xfstests 068), symlink and hardlink restriction patches, plus assorted cleanups and fixes. Note that another fsfreeze deadlock (emergency thaw one) is *not* dealt with - the series by Fernando conflicts a lot with Jan's, breaks userland ABI (FIFREEZE semantics gets changed) and trades the deadlock for massive vfsmount leak; this is going to be handled next cycle. There probably will be another pull request, but that stuff won't be in it." Fix up trivial conflicts due to unrelated changes next to each other in drivers/{staging/gdm72xx/usb_boot.c, usb/gadget/storage_common.c} * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (54 commits) delousing target_core_file a bit Documentation: Correct s_umount state for freeze_fs/unfreeze_fs fs: Remove old freezing mechanism ext2: Implement freezing btrfs: Convert to new freezing mechanism nilfs2: Convert to new freezing mechanism ntfs: Convert to new freezing mechanism fuse: Convert to new freezing mechanism gfs2: Convert to new freezing mechanism ocfs2: Convert to new freezing mechanism xfs: Convert to new freezing code ext4: Convert to new freezing mechanism fs: Protect write paths by sb_start_write - sb_end_write fs: Skip atime update on frozen filesystem fs: Add freezing handling to mnt_want_write() / mnt_drop_write() fs: Improve filesystem freezing handling switch the protection of percpu_counter list to spinlock nfsd: Push mnt_want_write() outside of i_mutex btrfs: Push mnt_want_write() outside of i_mutex fat: Push mnt_want_write() outside of i_mutex ...
Diffstat (limited to 'mm/filemap.c')
-rw-r--r--mm/filemap.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index a4a5260b0279..fa5ca304148e 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1712,8 +1712,35 @@ page_not_uptodate:
1712} 1712}
1713EXPORT_SYMBOL(filemap_fault); 1713EXPORT_SYMBOL(filemap_fault);
1714 1714
1715int filemap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
1716{
1717 struct page *page = vmf->page;
1718 struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
1719 int ret = VM_FAULT_LOCKED;
1720
1721 sb_start_pagefault(inode->i_sb);
1722 file_update_time(vma->vm_file);
1723 lock_page(page);
1724 if (page->mapping != inode->i_mapping) {
1725 unlock_page(page);
1726 ret = VM_FAULT_NOPAGE;
1727 goto out;
1728 }
1729 /*
1730 * We mark the page dirty already here so that when freeze is in
1731 * progress, we are guaranteed that writeback during freezing will
1732 * see the dirty page and writeprotect it again.
1733 */
1734 set_page_dirty(page);
1735out:
1736 sb_end_pagefault(inode->i_sb);
1737 return ret;
1738}
1739EXPORT_SYMBOL(filemap_page_mkwrite);
1740
1715const struct vm_operations_struct generic_file_vm_ops = { 1741const struct vm_operations_struct generic_file_vm_ops = {
1716 .fault = filemap_fault, 1742 .fault = filemap_fault,
1743 .page_mkwrite = filemap_page_mkwrite,
1717}; 1744};
1718 1745
1719/* This is used for a general mmap of a disk file */ 1746/* This is used for a general mmap of a disk file */
@@ -2407,8 +2434,6 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
2407 count = ocount; 2434 count = ocount;
2408 pos = *ppos; 2435 pos = *ppos;
2409 2436
2410 vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE);
2411
2412 /* We can write back this queue in page reclaim */ 2437 /* We can write back this queue in page reclaim */
2413 current->backing_dev_info = mapping->backing_dev_info; 2438 current->backing_dev_info = mapping->backing_dev_info;
2414 written = 0; 2439 written = 0;
@@ -2507,6 +2532,7 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
2507 2532
2508 BUG_ON(iocb->ki_pos != pos); 2533 BUG_ON(iocb->ki_pos != pos);
2509 2534
2535 sb_start_write(inode->i_sb);
2510 mutex_lock(&inode->i_mutex); 2536 mutex_lock(&inode->i_mutex);
2511 blk_start_plug(&plug); 2537 blk_start_plug(&plug);
2512 ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); 2538 ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos);
@@ -2520,6 +2546,7 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
2520 ret = err; 2546 ret = err;
2521 } 2547 }
2522 blk_finish_plug(&plug); 2548 blk_finish_plug(&plug);
2549 sb_end_write(inode->i_sb);
2523 return ret; 2550 return ret;
2524} 2551}
2525EXPORT_SYMBOL(generic_file_aio_write); 2552EXPORT_SYMBOL(generic_file_aio_write);