Commit 55144768 authored by Nick Piggin's avatar Nick Piggin Committed by Linus Torvalds

fs: remove some AOP_TRUNCATED_PAGE

prepare/commit_write no longer returns AOP_TRUNCATED_PAGE since OCFS2 and
GFS2 were converted to the new aops, so we can make some simplifications
for that.

[michal.k.k.piotrowski@gmail.com: fix warning]
Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
Cc: Michael Halcrow <mhalcrow@us.ibm.com>
Cc: Mark Fasheh <mark.fasheh@oracle.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Signed-off-by: default avatarMichal Piotrowski <michal.k.k.piotrowski@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 03158cd7
...@@ -621,11 +621,7 @@ struct address_space_operations { ...@@ -621,11 +621,7 @@ struct address_space_operations {
any basic-blocks on storage, then those blocks should be any basic-blocks on storage, then those blocks should be
pre-read (if they haven't been read already) so that the pre-read (if they haven't been read already) so that the
updated blocks can be written out properly. updated blocks can be written out properly.
The page will be locked. If prepare_write wants to unlock the The page will be locked.
page it, like readpage, may do so and return
AOP_TRUNCATED_PAGE.
In this case the prepare_write will be retried one the lock is
regained.
Note: the page _must not_ be marked uptodate in this function Note: the page _must not_ be marked uptodate in this function
(or anywhere else) unless it actually is uptodate right now. As (or anywhere else) unless it actually is uptodate right now. As
......
...@@ -446,11 +446,9 @@ int ecryptfs_writepage_and_release_lower_page(struct page *lower_page, ...@@ -446,11 +446,9 @@ int ecryptfs_writepage_and_release_lower_page(struct page *lower_page,
return rc; return rc;
} }
static static void ecryptfs_release_lower_page(struct page *lower_page)
void ecryptfs_release_lower_page(struct page *lower_page, int page_locked)
{ {
if (page_locked) unlock_page(lower_page);
unlock_page(lower_page);
page_cache_release(lower_page); page_cache_release(lower_page);
} }
...@@ -471,7 +469,6 @@ static int ecryptfs_write_inode_size_to_header(struct file *lower_file, ...@@ -471,7 +469,6 @@ static int ecryptfs_write_inode_size_to_header(struct file *lower_file,
const struct address_space_operations *lower_a_ops; const struct address_space_operations *lower_a_ops;
u64 file_size; u64 file_size;
retry:
header_page = grab_cache_page(lower_inode->i_mapping, 0); header_page = grab_cache_page(lower_inode->i_mapping, 0);
if (!header_page) { if (!header_page) {
ecryptfs_printk(KERN_ERR, "grab_cache_page for " ecryptfs_printk(KERN_ERR, "grab_cache_page for "
...@@ -482,11 +479,7 @@ static int ecryptfs_write_inode_size_to_header(struct file *lower_file, ...@@ -482,11 +479,7 @@ static int ecryptfs_write_inode_size_to_header(struct file *lower_file,
lower_a_ops = lower_inode->i_mapping->a_ops; lower_a_ops = lower_inode->i_mapping->a_ops;
rc = lower_a_ops->prepare_write(lower_file, header_page, 0, 8); rc = lower_a_ops->prepare_write(lower_file, header_page, 0, 8);
if (rc) { if (rc) {
if (rc == AOP_TRUNCATED_PAGE) { ecryptfs_release_lower_page(header_page);
ecryptfs_release_lower_page(header_page, 0);
goto retry;
} else
ecryptfs_release_lower_page(header_page, 1);
goto out; goto out;
} }
file_size = (u64)i_size_read(inode); file_size = (u64)i_size_read(inode);
...@@ -500,11 +493,7 @@ static int ecryptfs_write_inode_size_to_header(struct file *lower_file, ...@@ -500,11 +493,7 @@ static int ecryptfs_write_inode_size_to_header(struct file *lower_file,
if (rc < 0) if (rc < 0)
ecryptfs_printk(KERN_ERR, "Error commiting header page " ecryptfs_printk(KERN_ERR, "Error commiting header page "
"write\n"); "write\n");
if (rc == AOP_TRUNCATED_PAGE) { ecryptfs_release_lower_page(header_page);
ecryptfs_release_lower_page(header_page, 0);
goto retry;
} else
ecryptfs_release_lower_page(header_page, 1);
lower_inode->i_mtime = lower_inode->i_ctime = CURRENT_TIME; lower_inode->i_mtime = lower_inode->i_ctime = CURRENT_TIME;
mark_inode_dirty_sync(inode); mark_inode_dirty_sync(inode);
out: out:
...@@ -593,7 +582,6 @@ int ecryptfs_get_lower_page(struct page **lower_page, struct inode *lower_inode, ...@@ -593,7 +582,6 @@ int ecryptfs_get_lower_page(struct page **lower_page, struct inode *lower_inode,
{ {
int rc = 0; int rc = 0;
retry:
*lower_page = grab_cache_page(lower_inode->i_mapping, lower_page_index); *lower_page = grab_cache_page(lower_inode->i_mapping, lower_page_index);
if (!(*lower_page)) { if (!(*lower_page)) {
rc = -EINVAL; rc = -EINVAL;
...@@ -607,16 +595,11 @@ int ecryptfs_get_lower_page(struct page **lower_page, struct inode *lower_inode, ...@@ -607,16 +595,11 @@ int ecryptfs_get_lower_page(struct page **lower_page, struct inode *lower_inode,
byte_offset, byte_offset,
region_bytes); region_bytes);
if (rc) { if (rc) {
if (rc == AOP_TRUNCATED_PAGE) { ecryptfs_printk(KERN_ERR, "prepare_write for "
ecryptfs_release_lower_page(*lower_page, 0); "lower_page_index = [0x%.16x] failed; rc = "
goto retry; "[%d]\n", lower_page_index, rc);
} else { ecryptfs_release_lower_page(*lower_page);
ecryptfs_printk(KERN_ERR, "prepare_write for " (*lower_page) = NULL;
"lower_page_index = [0x%.16x] failed; rc = "
"[%d]\n", lower_page_index, rc);
ecryptfs_release_lower_page(*lower_page, 1);
(*lower_page) = NULL;
}
} }
out: out:
return rc; return rc;
...@@ -632,19 +615,16 @@ ecryptfs_commit_lower_page(struct page *lower_page, struct inode *lower_inode, ...@@ -632,19 +615,16 @@ ecryptfs_commit_lower_page(struct page *lower_page, struct inode *lower_inode,
struct file *lower_file, int byte_offset, struct file *lower_file, int byte_offset,
int region_size) int region_size)
{ {
int page_locked = 1;
int rc = 0; int rc = 0;
rc = lower_inode->i_mapping->a_ops->commit_write( rc = lower_inode->i_mapping->a_ops->commit_write(
lower_file, lower_page, byte_offset, region_size); lower_file, lower_page, byte_offset, region_size);
if (rc == AOP_TRUNCATED_PAGE)
page_locked = 0;
if (rc < 0) { if (rc < 0) {
ecryptfs_printk(KERN_ERR, ecryptfs_printk(KERN_ERR,
"Error committing write; rc = [%d]\n", rc); "Error committing write; rc = [%d]\n", rc);
} else } else
rc = 0; rc = 0;
ecryptfs_release_lower_page(lower_page, page_locked); ecryptfs_release_lower_page(lower_page);
return rc; return rc;
} }
......
...@@ -381,7 +381,7 @@ struct iattr { ...@@ -381,7 +381,7 @@ struct iattr {
* trying again. The aop will be taking reasonable * trying again. The aop will be taking reasonable
* precautions not to livelock. If the caller held a page * precautions not to livelock. If the caller held a page
* reference, it should drop it before retrying. Returned * reference, it should drop it before retrying. Returned
* by readpage(), prepare_write(), and commit_write(). * by readpage().
* *
* address_space_operation functions return these large constants to indicate * address_space_operation functions return these large constants to indicate
* special semantics to the caller. These are much larger than the bytes in a * special semantics to the caller. These are much larger than the bytes in a
......
...@@ -1898,13 +1898,10 @@ int pagecache_write_begin(struct file *file, struct address_space *mapping, ...@@ -1898,13 +1898,10 @@ int pagecache_write_begin(struct file *file, struct address_space *mapping,
ret = aops->prepare_write(file, page, offset, offset+len); ret = aops->prepare_write(file, page, offset, offset+len);
if (ret) { if (ret) {
if (ret != AOP_TRUNCATED_PAGE) unlock_page(page);
unlock_page(page);
page_cache_release(page); page_cache_release(page);
if (pos + len > inode->i_size) if (pos + len > inode->i_size)
vmtruncate(inode, inode->i_size); vmtruncate(inode, inode->i_size);
if (ret == AOP_TRUNCATED_PAGE)
goto again;
} }
return ret; return ret;
} }
...@@ -1931,7 +1928,6 @@ int pagecache_write_end(struct file *file, struct address_space *mapping, ...@@ -1931,7 +1928,6 @@ int pagecache_write_end(struct file *file, struct address_space *mapping,
unlock_page(page); unlock_page(page);
mark_page_accessed(page); mark_page_accessed(page);
page_cache_release(page); page_cache_release(page);
BUG_ON(ret == AOP_TRUNCATED_PAGE); /* can't deal with */
if (ret < 0) { if (ret < 0) {
if (pos + len > inode->i_size) if (pos + len > inode->i_size)
...@@ -2142,7 +2138,7 @@ static ssize_t generic_perform_write_2copy(struct file *file, ...@@ -2142,7 +2138,7 @@ static ssize_t generic_perform_write_2copy(struct file *file,
flush_dcache_page(page); flush_dcache_page(page);
status = a_ops->commit_write(file, page, offset, offset+bytes); status = a_ops->commit_write(file, page, offset, offset+bytes);
if (unlikely(status < 0 || status == AOP_TRUNCATED_PAGE)) if (unlikely(status < 0))
goto fs_write_aop_error; goto fs_write_aop_error;
if (unlikely(status > 0)) /* filesystem did partial write */ if (unlikely(status > 0)) /* filesystem did partial write */
copied = min_t(size_t, copied, status); copied = min_t(size_t, copied, status);
...@@ -2162,8 +2158,7 @@ static ssize_t generic_perform_write_2copy(struct file *file, ...@@ -2162,8 +2158,7 @@ static ssize_t generic_perform_write_2copy(struct file *file,
continue; continue;
fs_write_aop_error: fs_write_aop_error:
if (status != AOP_TRUNCATED_PAGE) unlock_page(page);
unlock_page(page);
page_cache_release(page); page_cache_release(page);
if (src_page) if (src_page)
page_cache_release(src_page); page_cache_release(src_page);
...@@ -2175,10 +2170,7 @@ static ssize_t generic_perform_write_2copy(struct file *file, ...@@ -2175,10 +2170,7 @@ static ssize_t generic_perform_write_2copy(struct file *file,
*/ */
if (pos + bytes > inode->i_size) if (pos + bytes > inode->i_size)
vmtruncate(inode, inode->i_size); vmtruncate(inode, inode->i_size);
if (status == AOP_TRUNCATED_PAGE) break;
continue;
else
break;
} while (iov_iter_count(i)); } while (iov_iter_count(i));
return written ? written : status; return written ? written : status;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment