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. Cc: Linux Filesystems <linux-fsdevel@xxxxxxxxxxxxxxx> Signed-off-by: Nick Piggin <npiggin@xxxxxxx> Documentation/filesystems/vfs.txt | 6 ----- fs/ecryptfs/mmap.c | 39 +++++++++----------------------------- include/linux/fs.h | 2 - mm/filemap.c | 21 +++++++------------- 4 files changed, 20 insertions(+), 48 deletions(-) Index: linux-2.6/Documentation/filesystems/vfs.txt =================================================================== --- linux-2.6.orig/Documentation/filesystems/vfs.txt +++ linux-2.6/Documentation/filesystems/vfs.txt @@ -619,11 +619,7 @@ struct address_space_operations { any basic-blocks on storage, then those blocks should be pre-read (if they haven't been read already) so that the updated blocks can be written out properly. - The page will be locked. If prepare_write wants to unlock the - 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. + The page will be locked. Note: the page _must not_ be marked uptodate in this function (or anywhere else) unless it actually is uptodate right now. As Index: linux-2.6/fs/ecryptfs/mmap.c =================================================================== --- linux-2.6.orig/fs/ecryptfs/mmap.c +++ linux-2.6/fs/ecryptfs/mmap.c @@ -412,11 +412,9 @@ out: return rc; } -static -void ecryptfs_release_lower_page(struct page *lower_page, int page_locked) +static void ecryptfs_release_lower_page(struct page *lower_page) { - if (page_locked) - unlock_page(lower_page); + unlock_page(lower_page); page_cache_release(lower_page); } @@ -437,7 +435,6 @@ static int ecryptfs_write_inode_size_to_ const struct address_space_operations *lower_a_ops; u64 file_size; -retry: header_page = grab_cache_page(lower_inode->i_mapping, 0); if (!header_page) { ecryptfs_printk(KERN_ERR, "grab_cache_page for " @@ -448,11 +445,7 @@ retry: lower_a_ops = lower_inode->i_mapping->a_ops; rc = lower_a_ops->prepare_write(lower_file, header_page, 0, 8); if (rc) { - if (rc == AOP_TRUNCATED_PAGE) { - ecryptfs_release_lower_page(header_page, 0); - goto retry; - } else - ecryptfs_release_lower_page(header_page, 1); + ecryptfs_release_lower_page(header_page); goto out; } file_size = (u64)i_size_read(inode); @@ -466,11 +459,7 @@ retry: if (rc < 0) ecryptfs_printk(KERN_ERR, "Error commiting header page " "write\n"); - if (rc == AOP_TRUNCATED_PAGE) { - ecryptfs_release_lower_page(header_page, 0); - goto retry; - } else - ecryptfs_release_lower_page(header_page, 1); + ecryptfs_release_lower_page(header_page); lower_inode->i_mtime = lower_inode->i_ctime = CURRENT_TIME; mark_inode_dirty_sync(inode); out: @@ -573,16 +562,11 @@ retry: byte_offset, region_bytes); if (rc) { - if (rc == AOP_TRUNCATED_PAGE) { - ecryptfs_release_lower_page(*lower_page, 0); - goto retry; - } else { - ecryptfs_printk(KERN_ERR, "prepare_write for " - "lower_page_index = [0x%.16x] failed; rc = " - "[%d]\n", lower_page_index, rc); - ecryptfs_release_lower_page(*lower_page, 1); - (*lower_page) = NULL; - } + ecryptfs_printk(KERN_ERR, "prepare_write for " + "lower_page_index = [0x%.16x] failed; rc = " + "[%d]\n", lower_page_index, rc); + ecryptfs_release_lower_page(*lower_page); + (*lower_page) = NULL; } out: return rc; @@ -598,19 +582,16 @@ ecryptfs_commit_lower_page(struct page * struct file *lower_file, int byte_offset, int region_size) { - int page_locked = 1; int rc = 0; rc = lower_inode->i_mapping->a_ops->commit_write( lower_file, lower_page, byte_offset, region_size); - if (rc == AOP_TRUNCATED_PAGE) - page_locked = 0; if (rc < 0) { ecryptfs_printk(KERN_ERR, "Error committing write; rc = [%d]\n", rc); } else rc = 0; - ecryptfs_release_lower_page(lower_page, page_locked); + ecryptfs_release_lower_page(lower_page); return rc; } Index: linux-2.6/mm/filemap.c =================================================================== --- linux-2.6.orig/mm/filemap.c +++ linux-2.6/mm/filemap.c @@ -1987,8 +1987,11 @@ again: ret = aops->readpage(file, page); page_cache_release(page); if (ret) { - if (ret == AOP_TRUNCATED_PAGE) - goto again; + /* + * ret cannot be AOP_TRUNCATED_PAGE, because + * the only filesystems that return that from + * ->readpage actually use ->write_begin + */ return ret; } goto again; @@ -1996,13 +1999,10 @@ again: ret = aops->prepare_write(file, page, offset, offset+len); if (ret) { - if (ret != AOP_TRUNCATED_PAGE) - unlock_page(page); + unlock_page(page); page_cache_release(page); if (pos + len > inode->i_size) vmtruncate(inode, inode->i_size); - if (ret == AOP_TRUNCATED_PAGE) - goto again; } return ret; } @@ -2027,7 +2027,6 @@ int pagecache_write_end(struct file *fil ret = aops->commit_write(file, page, offset, offset+len); unlock_page(page); page_cache_release(page); - BUG_ON(ret == AOP_TRUNCATED_PAGE); /* can't deal with */ if (ret < 0) { if (pos + len > inode->i_size) @@ -2258,8 +2257,7 @@ static ssize_t generic_perform_write_2co continue; fs_write_aop_error: - if (status != AOP_TRUNCATED_PAGE) - unlock_page(page); + unlock_page(page); page_cache_release(page); if (src_page) page_cache_release(src_page); @@ -2271,10 +2269,7 @@ fs_write_aop_error: */ if (pos + bytes > inode->i_size) vmtruncate(inode, inode->i_size); - if (status == AOP_TRUNCATED_PAGE) - continue; - else - break; + break; } while (iov_iter_count(i)); return written ? written : status; Index: linux-2.6/include/linux/fs.h =================================================================== --- linux-2.6.orig/include/linux/fs.h +++ linux-2.6/include/linux/fs.h @@ -378,7 +378,7 @@ struct iattr { * trying again. The aop will be taking reasonable * precautions not to livelock. If the caller held a page * 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 * special semantics to the caller. These are much larger than the bytes in a -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html