diff options
-rw-r--r-- | fs/buffer.c | 22 | ||||
-rw-r--r-- | fs/open.c | 7 | ||||
-rw-r--r-- | fs/splice.c | 3 | ||||
-rw-r--r-- | mm/filemap.c | 12 | ||||
-rw-r--r-- | mm/filemap_xip.c | 5 |
5 files changed, 26 insertions, 23 deletions
diff --git a/fs/buffer.c b/fs/buffer.c index d5ec360e332d..9f6d2e41281d 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -2306,8 +2306,8 @@ EXPORT_SYMBOL(block_commit_write); | |||
2306 | * beyond EOF, then the page is guaranteed safe against truncation until we | 2306 | * beyond EOF, then the page is guaranteed safe against truncation until we |
2307 | * unlock the page. | 2307 | * unlock the page. |
2308 | * | 2308 | * |
2309 | * Direct callers of this function should call vfs_check_frozen() so that page | 2309 | * Direct callers of this function should protect against filesystem freezing |
2310 | * fault does not busyloop until the fs is thawed. | 2310 | * using sb_start_write() - sb_end_write() functions. |
2311 | */ | 2311 | */ |
2312 | int __block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf, | 2312 | int __block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf, |
2313 | get_block_t get_block) | 2313 | get_block_t get_block) |
@@ -2345,18 +2345,7 @@ int __block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf, | |||
2345 | 2345 | ||
2346 | if (unlikely(ret < 0)) | 2346 | if (unlikely(ret < 0)) |
2347 | goto out_unlock; | 2347 | goto out_unlock; |
2348 | /* | ||
2349 | * Freezing in progress? We check after the page is marked dirty and | ||
2350 | * with page lock held so if the test here fails, we are sure freezing | ||
2351 | * code will wait during syncing until the page fault is done - at that | ||
2352 | * point page will be dirty and unlocked so freezing code will write it | ||
2353 | * and writeprotect it again. | ||
2354 | */ | ||
2355 | set_page_dirty(page); | 2348 | set_page_dirty(page); |
2356 | if (inode->i_sb->s_frozen != SB_UNFROZEN) { | ||
2357 | ret = -EAGAIN; | ||
2358 | goto out_unlock; | ||
2359 | } | ||
2360 | wait_on_page_writeback(page); | 2349 | wait_on_page_writeback(page); |
2361 | return 0; | 2350 | return 0; |
2362 | out_unlock: | 2351 | out_unlock: |
@@ -2371,12 +2360,9 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf, | |||
2371 | int ret; | 2360 | int ret; |
2372 | struct super_block *sb = vma->vm_file->f_path.dentry->d_inode->i_sb; | 2361 | struct super_block *sb = vma->vm_file->f_path.dentry->d_inode->i_sb; |
2373 | 2362 | ||
2374 | /* | 2363 | sb_start_pagefault(sb); |
2375 | * This check is racy but catches the common case. The check in | ||
2376 | * __block_page_mkwrite() is reliable. | ||
2377 | */ | ||
2378 | vfs_check_frozen(sb, SB_FREEZE_WRITE); | ||
2379 | ret = __block_page_mkwrite(vma, vmf, get_block); | 2364 | ret = __block_page_mkwrite(vma, vmf, get_block); |
2365 | sb_end_pagefault(sb); | ||
2380 | return block_page_mkwrite_return(ret); | 2366 | return block_page_mkwrite_return(ret); |
2381 | } | 2367 | } |
2382 | EXPORT_SYMBOL(block_page_mkwrite); | 2368 | EXPORT_SYMBOL(block_page_mkwrite); |
@@ -164,11 +164,13 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small) | |||
164 | if (IS_APPEND(inode)) | 164 | if (IS_APPEND(inode)) |
165 | goto out_putf; | 165 | goto out_putf; |
166 | 166 | ||
167 | sb_start_write(inode->i_sb); | ||
167 | error = locks_verify_truncate(inode, file, length); | 168 | error = locks_verify_truncate(inode, file, length); |
168 | if (!error) | 169 | if (!error) |
169 | error = security_path_truncate(&file->f_path); | 170 | error = security_path_truncate(&file->f_path); |
170 | if (!error) | 171 | if (!error) |
171 | error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); | 172 | error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); |
173 | sb_end_write(inode->i_sb); | ||
172 | out_putf: | 174 | out_putf: |
173 | fput(file); | 175 | fput(file); |
174 | out: | 176 | out: |
@@ -266,7 +268,10 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len) | |||
266 | if (!file->f_op->fallocate) | 268 | if (!file->f_op->fallocate) |
267 | return -EOPNOTSUPP; | 269 | return -EOPNOTSUPP; |
268 | 270 | ||
269 | return file->f_op->fallocate(file, mode, offset, len); | 271 | sb_start_write(inode->i_sb); |
272 | ret = file->f_op->fallocate(file, mode, offset, len); | ||
273 | sb_end_write(inode->i_sb); | ||
274 | return ret; | ||
270 | } | 275 | } |
271 | 276 | ||
272 | SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len) | 277 | SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len) |
diff --git a/fs/splice.c b/fs/splice.c index 7bf08fa22ec9..41514dd89462 100644 --- a/fs/splice.c +++ b/fs/splice.c | |||
@@ -996,6 +996,8 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out, | |||
996 | }; | 996 | }; |
997 | ssize_t ret; | 997 | ssize_t ret; |
998 | 998 | ||
999 | sb_start_write(inode->i_sb); | ||
1000 | |||
999 | pipe_lock(pipe); | 1001 | pipe_lock(pipe); |
1000 | 1002 | ||
1001 | splice_from_pipe_begin(&sd); | 1003 | splice_from_pipe_begin(&sd); |
@@ -1034,6 +1036,7 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out, | |||
1034 | *ppos += ret; | 1036 | *ppos += ret; |
1035 | balance_dirty_pages_ratelimited_nr(mapping, nr_pages); | 1037 | balance_dirty_pages_ratelimited_nr(mapping, nr_pages); |
1036 | } | 1038 | } |
1039 | sb_end_write(inode->i_sb); | ||
1037 | 1040 | ||
1038 | return ret; | 1041 | return ret; |
1039 | } | 1042 | } |
diff --git a/mm/filemap.c b/mm/filemap.c index 51efee65c2cc..fa5ca304148e 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -1718,6 +1718,7 @@ int filemap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1718 | struct inode *inode = vma->vm_file->f_path.dentry->d_inode; | 1718 | struct inode *inode = vma->vm_file->f_path.dentry->d_inode; |
1719 | int ret = VM_FAULT_LOCKED; | 1719 | int ret = VM_FAULT_LOCKED; |
1720 | 1720 | ||
1721 | sb_start_pagefault(inode->i_sb); | ||
1721 | file_update_time(vma->vm_file); | 1722 | file_update_time(vma->vm_file); |
1722 | lock_page(page); | 1723 | lock_page(page); |
1723 | if (page->mapping != inode->i_mapping) { | 1724 | if (page->mapping != inode->i_mapping) { |
@@ -1725,7 +1726,14 @@ int filemap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1725 | ret = VM_FAULT_NOPAGE; | 1726 | ret = VM_FAULT_NOPAGE; |
1726 | goto out; | 1727 | goto out; |
1727 | } | 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); | ||
1728 | out: | 1735 | out: |
1736 | sb_end_pagefault(inode->i_sb); | ||
1729 | return ret; | 1737 | return ret; |
1730 | } | 1738 | } |
1731 | EXPORT_SYMBOL(filemap_page_mkwrite); | 1739 | EXPORT_SYMBOL(filemap_page_mkwrite); |
@@ -2426,8 +2434,6 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2426 | count = ocount; | 2434 | count = ocount; |
2427 | pos = *ppos; | 2435 | pos = *ppos; |
2428 | 2436 | ||
2429 | vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE); | ||
2430 | |||
2431 | /* We can write back this queue in page reclaim */ | 2437 | /* We can write back this queue in page reclaim */ |
2432 | current->backing_dev_info = mapping->backing_dev_info; | 2438 | current->backing_dev_info = mapping->backing_dev_info; |
2433 | written = 0; | 2439 | written = 0; |
@@ -2526,6 +2532,7 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2526 | 2532 | ||
2527 | BUG_ON(iocb->ki_pos != pos); | 2533 | BUG_ON(iocb->ki_pos != pos); |
2528 | 2534 | ||
2535 | sb_start_write(inode->i_sb); | ||
2529 | mutex_lock(&inode->i_mutex); | 2536 | mutex_lock(&inode->i_mutex); |
2530 | blk_start_plug(&plug); | 2537 | blk_start_plug(&plug); |
2531 | 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); |
@@ -2539,6 +2546,7 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2539 | ret = err; | 2546 | ret = err; |
2540 | } | 2547 | } |
2541 | blk_finish_plug(&plug); | 2548 | blk_finish_plug(&plug); |
2549 | sb_end_write(inode->i_sb); | ||
2542 | return ret; | 2550 | return ret; |
2543 | } | 2551 | } |
2544 | EXPORT_SYMBOL(generic_file_aio_write); | 2552 | EXPORT_SYMBOL(generic_file_aio_write); |
diff --git a/mm/filemap_xip.c b/mm/filemap_xip.c index 80b34ef82dfe..13e013b1270c 100644 --- a/mm/filemap_xip.c +++ b/mm/filemap_xip.c | |||
@@ -402,6 +402,8 @@ xip_file_write(struct file *filp, const char __user *buf, size_t len, | |||
402 | loff_t pos; | 402 | loff_t pos; |
403 | ssize_t ret; | 403 | ssize_t ret; |
404 | 404 | ||
405 | sb_start_write(inode->i_sb); | ||
406 | |||
405 | mutex_lock(&inode->i_mutex); | 407 | mutex_lock(&inode->i_mutex); |
406 | 408 | ||
407 | if (!access_ok(VERIFY_READ, buf, len)) { | 409 | if (!access_ok(VERIFY_READ, buf, len)) { |
@@ -412,8 +414,6 @@ xip_file_write(struct file *filp, const char __user *buf, size_t len, | |||
412 | pos = *ppos; | 414 | pos = *ppos; |
413 | count = len; | 415 | count = len; |
414 | 416 | ||
415 | vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE); | ||
416 | |||
417 | /* We can write back this queue in page reclaim */ | 417 | /* We can write back this queue in page reclaim */ |
418 | current->backing_dev_info = mapping->backing_dev_info; | 418 | current->backing_dev_info = mapping->backing_dev_info; |
419 | 419 | ||
@@ -437,6 +437,7 @@ xip_file_write(struct file *filp, const char __user *buf, size_t len, | |||
437 | current->backing_dev_info = NULL; | 437 | current->backing_dev_info = NULL; |
438 | out_up: | 438 | out_up: |
439 | mutex_unlock(&inode->i_mutex); | 439 | mutex_unlock(&inode->i_mutex); |
440 | sb_end_write(inode->i_sb); | ||
440 | return ret; | 441 | return ret; |
441 | } | 442 | } |
442 | EXPORT_SYMBOL_GPL(xip_file_write); | 443 | EXPORT_SYMBOL_GPL(xip_file_write); |