diff for duplicates of <20070315234713.GH21942@ca-server1.us.oracle.com> diff --git a/a/1.txt b/N1/1.txt index 9e358fa..2a9c7b4 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -12,241 +12,4 @@ Oracle. -- Mark Fasheh Senior Software Developer, Oracle -mark.fasheh at oracle.com - --------------- next part -------------- -From: Mark Fasheh <mark.fasheh@oracle.com> - -ocfs2: Convert to new aops - -Turn ocfs2_prepare_write() and ocfs2_commit_write() into ocfs2_write_begin() -and ocfs2_write_end(). This conveniently eliminates the need for -AOP_TRUNCATED_PAGE during write. - -Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com> - - -e28911070b02362a9a3a543646da84a8fbf9f63b -diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c -index 875c114..cbec0e1 100644 ---- a/fs/ocfs2/aops.c -+++ b/fs/ocfs2/aops.c -@@ -293,29 +293,67 @@ int ocfs2_prepare_write_nolock(struct in - } - - /* -- * ocfs2_prepare_write() can be an outer-most ocfs2 call when it is called -- * from loopback. It must be able to perform its own locking around -- * ocfs2_get_block(). -+ * ocfs2_write_begin() can be an outer-most ocfs2 call when it is -+ * called from elsewhere in the kernel. It must be able to perform its -+ * own locking around ocfs2_get_block(). - */ --static int ocfs2_prepare_write(struct file *file, struct page *page, -- unsigned from, unsigned to) -+static int ocfs2_write_begin(struct file *file, struct address_space *mapping, -+ loff_t pos, unsigned len, unsigned flags, -+ struct page **pagep, void **fsdata) - { -- struct inode *inode = page->mapping->host; -+ struct inode *inode = mapping->host; -+ struct buffer_head *di_bh = NULL; -+ struct page *page = NULL; - int ret; - -- mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); -- -- ret = ocfs2_meta_lock_with_page(inode, NULL, 0, page); -+ ret = ocfs2_meta_lock(inode, &di_bh, 1); - if (ret != 0) { - mlog_errno(ret); -+ return ret; -+ } -+ -+ ret = ocfs2_data_lock(inode, 1); -+ if (ret) { -+ ocfs2_meta_unlock(inode, 1); -+ -+ mlog_errno(ret); -+ return ret; -+ } -+ -+ /* -+ * Lock the page out here to preserve ordering with -+ * ip_alloc_sem. -+ */ -+ page = __grab_cache_page(mapping, pos >> PAGE_CACHE_SHIFT); -+ if (!page) { -+ ret = -ENOMEM; -+ mlog_errno(ret); - goto out; - } - -- ret = ocfs2_prepare_write_nolock(inode, page, from, to); -+ *pagep = page; - -- ocfs2_meta_unlock(inode, 0); -+ down_read(&OCFS2_I(inode)->ip_alloc_sem); -+ ret = block_write_begin(file, mapping, pos, len, flags, pagep, fsdata, -+ ocfs2_get_block); -+ up_read(&OCFS2_I(inode)->ip_alloc_sem); - out: -- mlog_exit(ret); -+ if (ret == 0) { -+ *fsdata = di_bh; -+ } else { -+ /* -+ * Error return - the caller won't call -+ * ocfs2_write_end, so drop cluster locks here. -+ */ -+ brelse(di_bh); -+ if (page) { -+ unlock_page(page); -+ page_cache_release(page); -+ } -+ ocfs2_data_unlock(inode, 1); -+ ocfs2_meta_unlock(inode, 1); -+ } -+ - return ret; - } - -@@ -388,16 +426,18 @@ out: - return handle; - } - --static int ocfs2_commit_write(struct file *file, struct page *page, -- unsigned from, unsigned to) -+static int ocfs2_write_end(struct file *file, struct address_space *mapping, -+ loff_t pos, unsigned len, unsigned copied, -+ struct page *page, void *fsdata) - { - int ret; -- struct buffer_head *di_bh = NULL; -+ unsigned from, to; -+ struct buffer_head *di_bh = fsdata; - struct inode *inode = page->mapping->host; - handle_t *handle = NULL; - struct ocfs2_dinode *di; - -- mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); -+ mlog_entry("(0x%p, 0x%p)\n", file, page); - - /* NOTE: ocfs2_file_aio_write has ensured that it's safe for - * us to continue here without rechecking the I/O against -@@ -412,22 +452,13 @@ static int ocfs2_commit_write(struct fil - * stale inode allocation image (i_size, i_clusters, etc). - */ - -- ret = ocfs2_meta_lock_with_page(inode, &di_bh, 1, page); -- if (ret != 0) { -- mlog_errno(ret); -- goto out; -- } -- -- ret = ocfs2_data_lock_with_page(inode, 1, page); -- if (ret != 0) { -- mlog_errno(ret); -- goto out_unlock_meta; -- } -+ from = pos & (PAGE_CACHE_SIZE - 1); -+ to = from + len; - - handle = ocfs2_start_walk_page_trans(inode, page, from, to); - if (IS_ERR(handle)) { - ret = PTR_ERR(handle); -- goto out_unlock_data; -+ goto out_unlock; - } - - /* Mark our buffer early. We'd rather catch this error up here -@@ -441,8 +472,10 @@ static int ocfs2_commit_write(struct fil - } - - /* might update i_size */ -- ret = generic_commit_write(file, page, from, to); -- if (ret < 0) { -+ copied = block_write_end(file, mapping, pos, len, copied, page, fsdata); -+ if (copied < 0) { -+ ret = copied; -+ copied = 0; - mlog_errno(ret); - goto out_commit; - } -@@ -458,23 +491,30 @@ static int ocfs2_commit_write(struct fil - di->i_size = cpu_to_le64((u64)i_size_read(inode)); - - ret = ocfs2_journal_dirty(handle, di_bh); -- if (ret < 0) { -+ if (ret < 0) - mlog_errno(ret); -- goto out_commit; -- } - -+ ret = 0; - out_commit: - ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); --out_unlock_data: -+out_unlock: - ocfs2_data_unlock(inode, 1); --out_unlock_meta: - ocfs2_meta_unlock(inode, 1); --out: -+ -+ if (ret) { -+ /* -+ * We caught an error before block_write_end() - -+ * unlock and free the page. -+ */ -+ unlock_page(page); -+ page_cache_release(page); -+ } -+ - if (di_bh) - brelse(di_bh); - - mlog_exit(ret); -- return ret; -+ return copied ? copied : ret; - } - - static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block) -@@ -678,8 +718,8 @@ out: - const struct address_space_operations ocfs2_aops = { - .readpage = ocfs2_readpage, - .writepage = ocfs2_writepage, -- .prepare_write = ocfs2_prepare_write, -- .commit_write = ocfs2_commit_write, -+ .write_begin = ocfs2_write_begin, -+ .write_end = ocfs2_write_end, - .bmap = ocfs2_bmap, - .sync_page = block_sync_page, - .direct_IO = ocfs2_direct_IO, --- -1.3.3 - --------------- next part -------------- -From: Mark Fasheh <mark.fasheh@oracle.com> - -[PATCH] Export __grab_cache_page - -Needed at least by ocfs2 and ext[23]. - -Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com> - - -ec4c66f0e6012a182105405aa11813fbf836629f -diff --git a/mm/filemap.c b/mm/filemap.c -index 327c20f..c4a2d68 100644 ---- a/mm/filemap.c -+++ b/mm/filemap.c -@@ -2196,6 +2196,7 @@ repeat: - } - return page; - } -+EXPORT_SYMBOL(__grab_cache_page); - - static ssize_t generic_perform_write_2copy(struct file *file, - struct iov_iter *i, loff_t pos) --- -1.3.3 +mark.fasheh@oracle.com diff --git a/N1/2.hdr b/N1/2.hdr new file mode 100644 index 0000000..ef35cf9 --- /dev/null +++ b/N1/2.hdr @@ -0,0 +1,2 @@ +Content-Type: text/plain; charset=us-ascii +Content-Disposition: attachment; filename="0001-ocfs2-Convert-to-new-aops.txt" diff --git a/N1/2.txt b/N1/2.txt new file mode 100644 index 0000000..88c5982 --- /dev/null +++ b/N1/2.txt @@ -0,0 +1,209 @@ +From: Mark Fasheh <mark.fasheh@oracle.com> + +ocfs2: Convert to new aops + +Turn ocfs2_prepare_write() and ocfs2_commit_write() into ocfs2_write_begin() +and ocfs2_write_end(). This conveniently eliminates the need for +AOP_TRUNCATED_PAGE during write. + +Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com> + + +e28911070b02362a9a3a543646da84a8fbf9f63b +diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c +index 875c114..cbec0e1 100644 +--- a/fs/ocfs2/aops.c ++++ b/fs/ocfs2/aops.c +@@ -293,29 +293,67 @@ int ocfs2_prepare_write_nolock(struct in + } + + /* +- * ocfs2_prepare_write() can be an outer-most ocfs2 call when it is called +- * from loopback. It must be able to perform its own locking around +- * ocfs2_get_block(). ++ * ocfs2_write_begin() can be an outer-most ocfs2 call when it is ++ * called from elsewhere in the kernel. It must be able to perform its ++ * own locking around ocfs2_get_block(). + */ +-static int ocfs2_prepare_write(struct file *file, struct page *page, +- unsigned from, unsigned to) ++static int ocfs2_write_begin(struct file *file, struct address_space *mapping, ++ loff_t pos, unsigned len, unsigned flags, ++ struct page **pagep, void **fsdata) + { +- struct inode *inode = page->mapping->host; ++ struct inode *inode = mapping->host; ++ struct buffer_head *di_bh = NULL; ++ struct page *page = NULL; + int ret; + +- mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); +- +- ret = ocfs2_meta_lock_with_page(inode, NULL, 0, page); ++ ret = ocfs2_meta_lock(inode, &di_bh, 1); + if (ret != 0) { + mlog_errno(ret); ++ return ret; ++ } ++ ++ ret = ocfs2_data_lock(inode, 1); ++ if (ret) { ++ ocfs2_meta_unlock(inode, 1); ++ ++ mlog_errno(ret); ++ return ret; ++ } ++ ++ /* ++ * Lock the page out here to preserve ordering with ++ * ip_alloc_sem. ++ */ ++ page = __grab_cache_page(mapping, pos >> PAGE_CACHE_SHIFT); ++ if (!page) { ++ ret = -ENOMEM; ++ mlog_errno(ret); + goto out; + } + +- ret = ocfs2_prepare_write_nolock(inode, page, from, to); ++ *pagep = page; + +- ocfs2_meta_unlock(inode, 0); ++ down_read(&OCFS2_I(inode)->ip_alloc_sem); ++ ret = block_write_begin(file, mapping, pos, len, flags, pagep, fsdata, ++ ocfs2_get_block); ++ up_read(&OCFS2_I(inode)->ip_alloc_sem); + out: +- mlog_exit(ret); ++ if (ret == 0) { ++ *fsdata = di_bh; ++ } else { ++ /* ++ * Error return - the caller won't call ++ * ocfs2_write_end, so drop cluster locks here. ++ */ ++ brelse(di_bh); ++ if (page) { ++ unlock_page(page); ++ page_cache_release(page); ++ } ++ ocfs2_data_unlock(inode, 1); ++ ocfs2_meta_unlock(inode, 1); ++ } ++ + return ret; + } + +@@ -388,16 +426,18 @@ out: + return handle; + } + +-static int ocfs2_commit_write(struct file *file, struct page *page, +- unsigned from, unsigned to) ++static int ocfs2_write_end(struct file *file, struct address_space *mapping, ++ loff_t pos, unsigned len, unsigned copied, ++ struct page *page, void *fsdata) + { + int ret; +- struct buffer_head *di_bh = NULL; ++ unsigned from, to; ++ struct buffer_head *di_bh = fsdata; + struct inode *inode = page->mapping->host; + handle_t *handle = NULL; + struct ocfs2_dinode *di; + +- mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); ++ mlog_entry("(0x%p, 0x%p)\n", file, page); + + /* NOTE: ocfs2_file_aio_write has ensured that it's safe for + * us to continue here without rechecking the I/O against +@@ -412,22 +452,13 @@ static int ocfs2_commit_write(struct fil + * stale inode allocation image (i_size, i_clusters, etc). + */ + +- ret = ocfs2_meta_lock_with_page(inode, &di_bh, 1, page); +- if (ret != 0) { +- mlog_errno(ret); +- goto out; +- } +- +- ret = ocfs2_data_lock_with_page(inode, 1, page); +- if (ret != 0) { +- mlog_errno(ret); +- goto out_unlock_meta; +- } ++ from = pos & (PAGE_CACHE_SIZE - 1); ++ to = from + len; + + handle = ocfs2_start_walk_page_trans(inode, page, from, to); + if (IS_ERR(handle)) { + ret = PTR_ERR(handle); +- goto out_unlock_data; ++ goto out_unlock; + } + + /* Mark our buffer early. We'd rather catch this error up here +@@ -441,8 +472,10 @@ static int ocfs2_commit_write(struct fil + } + + /* might update i_size */ +- ret = generic_commit_write(file, page, from, to); +- if (ret < 0) { ++ copied = block_write_end(file, mapping, pos, len, copied, page, fsdata); ++ if (copied < 0) { ++ ret = copied; ++ copied = 0; + mlog_errno(ret); + goto out_commit; + } +@@ -458,23 +491,30 @@ static int ocfs2_commit_write(struct fil + di->i_size = cpu_to_le64((u64)i_size_read(inode)); + + ret = ocfs2_journal_dirty(handle, di_bh); +- if (ret < 0) { ++ if (ret < 0) + mlog_errno(ret); +- goto out_commit; +- } + ++ ret = 0; + out_commit: + ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); +-out_unlock_data: ++out_unlock: + ocfs2_data_unlock(inode, 1); +-out_unlock_meta: + ocfs2_meta_unlock(inode, 1); +-out: ++ ++ if (ret) { ++ /* ++ * We caught an error before block_write_end() - ++ * unlock and free the page. ++ */ ++ unlock_page(page); ++ page_cache_release(page); ++ } ++ + if (di_bh) + brelse(di_bh); + + mlog_exit(ret); +- return ret; ++ return copied ? copied : ret; + } + + static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block) +@@ -678,8 +718,8 @@ out: + const struct address_space_operations ocfs2_aops = { + .readpage = ocfs2_readpage, + .writepage = ocfs2_writepage, +- .prepare_write = ocfs2_prepare_write, +- .commit_write = ocfs2_commit_write, ++ .write_begin = ocfs2_write_begin, ++ .write_end = ocfs2_write_end, + .bmap = ocfs2_bmap, + .sync_page = block_sync_page, + .direct_IO = ocfs2_direct_IO, +-- +1.3.3 diff --git a/N1/3.hdr b/N1/3.hdr new file mode 100644 index 0000000..23c1ab1 --- /dev/null +++ b/N1/3.hdr @@ -0,0 +1,2 @@ +Content-Type: text/plain; charset=us-ascii +Content-Disposition: attachment; filename="0002-Export-__grab_cache_page.txt" diff --git a/N1/3.txt b/N1/3.txt new file mode 100644 index 0000000..d9fbdd5 --- /dev/null +++ b/N1/3.txt @@ -0,0 +1,24 @@ +From: Mark Fasheh <mark.fasheh@oracle.com> + +[PATCH] Export __grab_cache_page + +Needed at least by ocfs2 and ext[23]. + +Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com> + + +ec4c66f0e6012a182105405aa11813fbf836629f +diff --git a/mm/filemap.c b/mm/filemap.c +index 327c20f..c4a2d68 100644 +--- a/mm/filemap.c ++++ b/mm/filemap.c +@@ -2196,6 +2196,7 @@ repeat: + } + return page; + } ++EXPORT_SYMBOL(__grab_cache_page); + + static ssize_t generic_perform_write_2copy(struct file *file, + struct iov_iter *i, loff_t pos) +-- +1.3.3 diff --git a/N1/4.hdr b/N1/4.hdr new file mode 100644 index 0000000..4b86001 --- /dev/null +++ b/N1/4.hdr @@ -0,0 +1,4 @@ +Content-Type: text/plain; charset="us-ascii" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Disposition: inline diff --git a/N1/4.txt b/N1/4.txt new file mode 100644 index 0000000..f9179f9 --- /dev/null +++ b/N1/4.txt @@ -0,0 +1,5 @@ +------------------------------------------------------------------------- +Take Surveys. Earn Cash. Influence the Future of IT +Join SourceForge.net's Techsay panel and you'll get the chance to share your +opinions on IT & business topics through brief surveys-and earn cash +http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV diff --git a/N1/5.hdr b/N1/5.hdr new file mode 100644 index 0000000..4b86001 --- /dev/null +++ b/N1/5.hdr @@ -0,0 +1,4 @@ +Content-Type: text/plain; charset="us-ascii" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Disposition: inline diff --git a/N1/5.txt b/N1/5.txt new file mode 100644 index 0000000..5264bf8 --- /dev/null +++ b/N1/5.txt @@ -0,0 +1,3 @@ +_______________________________________________ +NFS maillist - NFS@lists.sourceforge.net +https://lists.sourceforge.net/lists/listinfo/nfs diff --git a/a/content_digest b/N1/content_digest index dfa311a..a61c431 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -1,9 +1,16 @@ "ref\020070315161704.GH8321@wotan.suse.de\0" "From\0Mark Fasheh <mark.fasheh@oracle.com>\0" - "Subject\0[Cluster-devel] Re: Announce: new-aops-1 for 2.6.21-rc3\0" + "Subject\0Re: Announce: new-aops-1 for 2.6.21-rc3\0" "Date\0Thu, 15 Mar 2007 16:47:13 -0700\0" - "To\0cluster-devel.redhat.com\0" - "\00:1\0" + "To\0Nick Piggin <npiggin@suse.de>\0" + "Cc\0jfs-discussion@lists.sourceforge.net" + xfs@oss.sgi.com + cluster-devel@redhat.com + reiserfs-list@namesys.com + nfs@lists.sourceforge.net + Linux Filesystems <linux-fsdevel@vger.kernel.org> + " linux-ext4@vger.kernel.org\0" + "\01:1\0" "b\0" "On Thu, Mar 15, 2007 at 05:17:04PM +0100, Nick Piggin wrote:\n" "> (excludes the OCFS2 patch that Mark sent, in anticipation of an update)\n" @@ -19,9 +26,10 @@ "--\n" "Mark Fasheh\n" "Senior Software Developer, Oracle\n" - "mark.fasheh at oracle.com\n" - "\n" - "-------------- next part --------------\n" + mark.fasheh@oracle.com + "\01:2\0" + "fn\00001-ocfs2-Convert-to-new-aops.txt\0" + "b\0" "From: Mark Fasheh <mark.fasheh@oracle.com>\n" "\n" "ocfs2: Convert to new aops\n" @@ -230,9 +238,10 @@ " \t.sync_page\t= block_sync_page,\n" " \t.direct_IO\t= ocfs2_direct_IO,\n" "-- \n" - "1.3.3\n" - "\n" - "-------------- next part --------------\n" + 1.3.3 + "\01:3\0" + "fn\00002-Export-__grab_cache_page.txt\0" + "b\0" "From: Mark Fasheh <mark.fasheh@oracle.com>\n" "\n" "[PATCH] Export __grab_cache_page\n" @@ -257,5 +266,17 @@ " \t\t\t\tstruct iov_iter *i, loff_t pos)\n" "-- \n" 1.3.3 + "\01:4\0" + "b\0" + "-------------------------------------------------------------------------\n" + "Take Surveys. Earn Cash. Influence the Future of IT\n" + "Join SourceForge.net's Techsay panel and you'll get the chance to share your\n" + "opinions on IT & business topics through brief surveys-and earn cash\n" + http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV + "\01:5\0" + "b\0" + "_______________________________________________\n" + "NFS maillist - NFS@lists.sourceforge.net\n" + https://lists.sourceforge.net/lists/listinfo/nfs -3b3f6d18d8246ae5363b41dd96399d6da491d82232b2ca72d85dd701dc4e4b33 +d83f37c128cfd71e575d3ace29e27e5da7186181b17235c58aa2ca980f014e0a
diff --git a/a/1.txt b/N2/1.txt index 9e358fa..2a9c7b4 100644 --- a/a/1.txt +++ b/N2/1.txt @@ -12,241 +12,4 @@ Oracle. -- Mark Fasheh Senior Software Developer, Oracle -mark.fasheh at oracle.com - --------------- next part -------------- -From: Mark Fasheh <mark.fasheh@oracle.com> - -ocfs2: Convert to new aops - -Turn ocfs2_prepare_write() and ocfs2_commit_write() into ocfs2_write_begin() -and ocfs2_write_end(). This conveniently eliminates the need for -AOP_TRUNCATED_PAGE during write. - -Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com> - - -e28911070b02362a9a3a543646da84a8fbf9f63b -diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c -index 875c114..cbec0e1 100644 ---- a/fs/ocfs2/aops.c -+++ b/fs/ocfs2/aops.c -@@ -293,29 +293,67 @@ int ocfs2_prepare_write_nolock(struct in - } - - /* -- * ocfs2_prepare_write() can be an outer-most ocfs2 call when it is called -- * from loopback. It must be able to perform its own locking around -- * ocfs2_get_block(). -+ * ocfs2_write_begin() can be an outer-most ocfs2 call when it is -+ * called from elsewhere in the kernel. It must be able to perform its -+ * own locking around ocfs2_get_block(). - */ --static int ocfs2_prepare_write(struct file *file, struct page *page, -- unsigned from, unsigned to) -+static int ocfs2_write_begin(struct file *file, struct address_space *mapping, -+ loff_t pos, unsigned len, unsigned flags, -+ struct page **pagep, void **fsdata) - { -- struct inode *inode = page->mapping->host; -+ struct inode *inode = mapping->host; -+ struct buffer_head *di_bh = NULL; -+ struct page *page = NULL; - int ret; - -- mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); -- -- ret = ocfs2_meta_lock_with_page(inode, NULL, 0, page); -+ ret = ocfs2_meta_lock(inode, &di_bh, 1); - if (ret != 0) { - mlog_errno(ret); -+ return ret; -+ } -+ -+ ret = ocfs2_data_lock(inode, 1); -+ if (ret) { -+ ocfs2_meta_unlock(inode, 1); -+ -+ mlog_errno(ret); -+ return ret; -+ } -+ -+ /* -+ * Lock the page out here to preserve ordering with -+ * ip_alloc_sem. -+ */ -+ page = __grab_cache_page(mapping, pos >> PAGE_CACHE_SHIFT); -+ if (!page) { -+ ret = -ENOMEM; -+ mlog_errno(ret); - goto out; - } - -- ret = ocfs2_prepare_write_nolock(inode, page, from, to); -+ *pagep = page; - -- ocfs2_meta_unlock(inode, 0); -+ down_read(&OCFS2_I(inode)->ip_alloc_sem); -+ ret = block_write_begin(file, mapping, pos, len, flags, pagep, fsdata, -+ ocfs2_get_block); -+ up_read(&OCFS2_I(inode)->ip_alloc_sem); - out: -- mlog_exit(ret); -+ if (ret == 0) { -+ *fsdata = di_bh; -+ } else { -+ /* -+ * Error return - the caller won't call -+ * ocfs2_write_end, so drop cluster locks here. -+ */ -+ brelse(di_bh); -+ if (page) { -+ unlock_page(page); -+ page_cache_release(page); -+ } -+ ocfs2_data_unlock(inode, 1); -+ ocfs2_meta_unlock(inode, 1); -+ } -+ - return ret; - } - -@@ -388,16 +426,18 @@ out: - return handle; - } - --static int ocfs2_commit_write(struct file *file, struct page *page, -- unsigned from, unsigned to) -+static int ocfs2_write_end(struct file *file, struct address_space *mapping, -+ loff_t pos, unsigned len, unsigned copied, -+ struct page *page, void *fsdata) - { - int ret; -- struct buffer_head *di_bh = NULL; -+ unsigned from, to; -+ struct buffer_head *di_bh = fsdata; - struct inode *inode = page->mapping->host; - handle_t *handle = NULL; - struct ocfs2_dinode *di; - -- mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); -+ mlog_entry("(0x%p, 0x%p)\n", file, page); - - /* NOTE: ocfs2_file_aio_write has ensured that it's safe for - * us to continue here without rechecking the I/O against -@@ -412,22 +452,13 @@ static int ocfs2_commit_write(struct fil - * stale inode allocation image (i_size, i_clusters, etc). - */ - -- ret = ocfs2_meta_lock_with_page(inode, &di_bh, 1, page); -- if (ret != 0) { -- mlog_errno(ret); -- goto out; -- } -- -- ret = ocfs2_data_lock_with_page(inode, 1, page); -- if (ret != 0) { -- mlog_errno(ret); -- goto out_unlock_meta; -- } -+ from = pos & (PAGE_CACHE_SIZE - 1); -+ to = from + len; - - handle = ocfs2_start_walk_page_trans(inode, page, from, to); - if (IS_ERR(handle)) { - ret = PTR_ERR(handle); -- goto out_unlock_data; -+ goto out_unlock; - } - - /* Mark our buffer early. We'd rather catch this error up here -@@ -441,8 +472,10 @@ static int ocfs2_commit_write(struct fil - } - - /* might update i_size */ -- ret = generic_commit_write(file, page, from, to); -- if (ret < 0) { -+ copied = block_write_end(file, mapping, pos, len, copied, page, fsdata); -+ if (copied < 0) { -+ ret = copied; -+ copied = 0; - mlog_errno(ret); - goto out_commit; - } -@@ -458,23 +491,30 @@ static int ocfs2_commit_write(struct fil - di->i_size = cpu_to_le64((u64)i_size_read(inode)); - - ret = ocfs2_journal_dirty(handle, di_bh); -- if (ret < 0) { -+ if (ret < 0) - mlog_errno(ret); -- goto out_commit; -- } - -+ ret = 0; - out_commit: - ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); --out_unlock_data: -+out_unlock: - ocfs2_data_unlock(inode, 1); --out_unlock_meta: - ocfs2_meta_unlock(inode, 1); --out: -+ -+ if (ret) { -+ /* -+ * We caught an error before block_write_end() - -+ * unlock and free the page. -+ */ -+ unlock_page(page); -+ page_cache_release(page); -+ } -+ - if (di_bh) - brelse(di_bh); - - mlog_exit(ret); -- return ret; -+ return copied ? copied : ret; - } - - static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block) -@@ -678,8 +718,8 @@ out: - const struct address_space_operations ocfs2_aops = { - .readpage = ocfs2_readpage, - .writepage = ocfs2_writepage, -- .prepare_write = ocfs2_prepare_write, -- .commit_write = ocfs2_commit_write, -+ .write_begin = ocfs2_write_begin, -+ .write_end = ocfs2_write_end, - .bmap = ocfs2_bmap, - .sync_page = block_sync_page, - .direct_IO = ocfs2_direct_IO, --- -1.3.3 - --------------- next part -------------- -From: Mark Fasheh <mark.fasheh@oracle.com> - -[PATCH] Export __grab_cache_page - -Needed at least by ocfs2 and ext[23]. - -Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com> - - -ec4c66f0e6012a182105405aa11813fbf836629f -diff --git a/mm/filemap.c b/mm/filemap.c -index 327c20f..c4a2d68 100644 ---- a/mm/filemap.c -+++ b/mm/filemap.c -@@ -2196,6 +2196,7 @@ repeat: - } - return page; - } -+EXPORT_SYMBOL(__grab_cache_page); - - static ssize_t generic_perform_write_2copy(struct file *file, - struct iov_iter *i, loff_t pos) --- -1.3.3 +mark.fasheh@oracle.com diff --git a/N2/2.hdr b/N2/2.hdr new file mode 100644 index 0000000..ef35cf9 --- /dev/null +++ b/N2/2.hdr @@ -0,0 +1,2 @@ +Content-Type: text/plain; charset=us-ascii +Content-Disposition: attachment; filename="0001-ocfs2-Convert-to-new-aops.txt" diff --git a/N2/2.txt b/N2/2.txt new file mode 100644 index 0000000..88c5982 --- /dev/null +++ b/N2/2.txt @@ -0,0 +1,209 @@ +From: Mark Fasheh <mark.fasheh@oracle.com> + +ocfs2: Convert to new aops + +Turn ocfs2_prepare_write() and ocfs2_commit_write() into ocfs2_write_begin() +and ocfs2_write_end(). This conveniently eliminates the need for +AOP_TRUNCATED_PAGE during write. + +Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com> + + +e28911070b02362a9a3a543646da84a8fbf9f63b +diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c +index 875c114..cbec0e1 100644 +--- a/fs/ocfs2/aops.c ++++ b/fs/ocfs2/aops.c +@@ -293,29 +293,67 @@ int ocfs2_prepare_write_nolock(struct in + } + + /* +- * ocfs2_prepare_write() can be an outer-most ocfs2 call when it is called +- * from loopback. It must be able to perform its own locking around +- * ocfs2_get_block(). ++ * ocfs2_write_begin() can be an outer-most ocfs2 call when it is ++ * called from elsewhere in the kernel. It must be able to perform its ++ * own locking around ocfs2_get_block(). + */ +-static int ocfs2_prepare_write(struct file *file, struct page *page, +- unsigned from, unsigned to) ++static int ocfs2_write_begin(struct file *file, struct address_space *mapping, ++ loff_t pos, unsigned len, unsigned flags, ++ struct page **pagep, void **fsdata) + { +- struct inode *inode = page->mapping->host; ++ struct inode *inode = mapping->host; ++ struct buffer_head *di_bh = NULL; ++ struct page *page = NULL; + int ret; + +- mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); +- +- ret = ocfs2_meta_lock_with_page(inode, NULL, 0, page); ++ ret = ocfs2_meta_lock(inode, &di_bh, 1); + if (ret != 0) { + mlog_errno(ret); ++ return ret; ++ } ++ ++ ret = ocfs2_data_lock(inode, 1); ++ if (ret) { ++ ocfs2_meta_unlock(inode, 1); ++ ++ mlog_errno(ret); ++ return ret; ++ } ++ ++ /* ++ * Lock the page out here to preserve ordering with ++ * ip_alloc_sem. ++ */ ++ page = __grab_cache_page(mapping, pos >> PAGE_CACHE_SHIFT); ++ if (!page) { ++ ret = -ENOMEM; ++ mlog_errno(ret); + goto out; + } + +- ret = ocfs2_prepare_write_nolock(inode, page, from, to); ++ *pagep = page; + +- ocfs2_meta_unlock(inode, 0); ++ down_read(&OCFS2_I(inode)->ip_alloc_sem); ++ ret = block_write_begin(file, mapping, pos, len, flags, pagep, fsdata, ++ ocfs2_get_block); ++ up_read(&OCFS2_I(inode)->ip_alloc_sem); + out: +- mlog_exit(ret); ++ if (ret == 0) { ++ *fsdata = di_bh; ++ } else { ++ /* ++ * Error return - the caller won't call ++ * ocfs2_write_end, so drop cluster locks here. ++ */ ++ brelse(di_bh); ++ if (page) { ++ unlock_page(page); ++ page_cache_release(page); ++ } ++ ocfs2_data_unlock(inode, 1); ++ ocfs2_meta_unlock(inode, 1); ++ } ++ + return ret; + } + +@@ -388,16 +426,18 @@ out: + return handle; + } + +-static int ocfs2_commit_write(struct file *file, struct page *page, +- unsigned from, unsigned to) ++static int ocfs2_write_end(struct file *file, struct address_space *mapping, ++ loff_t pos, unsigned len, unsigned copied, ++ struct page *page, void *fsdata) + { + int ret; +- struct buffer_head *di_bh = NULL; ++ unsigned from, to; ++ struct buffer_head *di_bh = fsdata; + struct inode *inode = page->mapping->host; + handle_t *handle = NULL; + struct ocfs2_dinode *di; + +- mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); ++ mlog_entry("(0x%p, 0x%p)\n", file, page); + + /* NOTE: ocfs2_file_aio_write has ensured that it's safe for + * us to continue here without rechecking the I/O against +@@ -412,22 +452,13 @@ static int ocfs2_commit_write(struct fil + * stale inode allocation image (i_size, i_clusters, etc). + */ + +- ret = ocfs2_meta_lock_with_page(inode, &di_bh, 1, page); +- if (ret != 0) { +- mlog_errno(ret); +- goto out; +- } +- +- ret = ocfs2_data_lock_with_page(inode, 1, page); +- if (ret != 0) { +- mlog_errno(ret); +- goto out_unlock_meta; +- } ++ from = pos & (PAGE_CACHE_SIZE - 1); ++ to = from + len; + + handle = ocfs2_start_walk_page_trans(inode, page, from, to); + if (IS_ERR(handle)) { + ret = PTR_ERR(handle); +- goto out_unlock_data; ++ goto out_unlock; + } + + /* Mark our buffer early. We'd rather catch this error up here +@@ -441,8 +472,10 @@ static int ocfs2_commit_write(struct fil + } + + /* might update i_size */ +- ret = generic_commit_write(file, page, from, to); +- if (ret < 0) { ++ copied = block_write_end(file, mapping, pos, len, copied, page, fsdata); ++ if (copied < 0) { ++ ret = copied; ++ copied = 0; + mlog_errno(ret); + goto out_commit; + } +@@ -458,23 +491,30 @@ static int ocfs2_commit_write(struct fil + di->i_size = cpu_to_le64((u64)i_size_read(inode)); + + ret = ocfs2_journal_dirty(handle, di_bh); +- if (ret < 0) { ++ if (ret < 0) + mlog_errno(ret); +- goto out_commit; +- } + ++ ret = 0; + out_commit: + ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); +-out_unlock_data: ++out_unlock: + ocfs2_data_unlock(inode, 1); +-out_unlock_meta: + ocfs2_meta_unlock(inode, 1); +-out: ++ ++ if (ret) { ++ /* ++ * We caught an error before block_write_end() - ++ * unlock and free the page. ++ */ ++ unlock_page(page); ++ page_cache_release(page); ++ } ++ + if (di_bh) + brelse(di_bh); + + mlog_exit(ret); +- return ret; ++ return copied ? copied : ret; + } + + static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block) +@@ -678,8 +718,8 @@ out: + const struct address_space_operations ocfs2_aops = { + .readpage = ocfs2_readpage, + .writepage = ocfs2_writepage, +- .prepare_write = ocfs2_prepare_write, +- .commit_write = ocfs2_commit_write, ++ .write_begin = ocfs2_write_begin, ++ .write_end = ocfs2_write_end, + .bmap = ocfs2_bmap, + .sync_page = block_sync_page, + .direct_IO = ocfs2_direct_IO, +-- +1.3.3 diff --git a/N2/3.hdr b/N2/3.hdr new file mode 100644 index 0000000..23c1ab1 --- /dev/null +++ b/N2/3.hdr @@ -0,0 +1,2 @@ +Content-Type: text/plain; charset=us-ascii +Content-Disposition: attachment; filename="0002-Export-__grab_cache_page.txt" diff --git a/N2/3.txt b/N2/3.txt new file mode 100644 index 0000000..d9fbdd5 --- /dev/null +++ b/N2/3.txt @@ -0,0 +1,24 @@ +From: Mark Fasheh <mark.fasheh@oracle.com> + +[PATCH] Export __grab_cache_page + +Needed at least by ocfs2 and ext[23]. + +Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com> + + +ec4c66f0e6012a182105405aa11813fbf836629f +diff --git a/mm/filemap.c b/mm/filemap.c +index 327c20f..c4a2d68 100644 +--- a/mm/filemap.c ++++ b/mm/filemap.c +@@ -2196,6 +2196,7 @@ repeat: + } + return page; + } ++EXPORT_SYMBOL(__grab_cache_page); + + static ssize_t generic_perform_write_2copy(struct file *file, + struct iov_iter *i, loff_t pos) +-- +1.3.3 diff --git a/a/content_digest b/N2/content_digest index dfa311a..5b4d0c0 100644 --- a/a/content_digest +++ b/N2/content_digest @@ -1,9 +1,16 @@ "ref\020070315161704.GH8321@wotan.suse.de\0" "From\0Mark Fasheh <mark.fasheh@oracle.com>\0" - "Subject\0[Cluster-devel] Re: Announce: new-aops-1 for 2.6.21-rc3\0" + "Subject\0Re: Announce: new-aops-1 for 2.6.21-rc3\0" "Date\0Thu, 15 Mar 2007 16:47:13 -0700\0" - "To\0cluster-devel.redhat.com\0" - "\00:1\0" + "To\0Nick Piggin <npiggin@suse.de>\0" + "Cc\0Linux Filesystems <linux-fsdevel@vger.kernel.org>" + reiserfs-list@namesys.com + linux-ext4@vger.kernel.org + xfs@oss.sgi.com + nfs@lists.sourceforge.net + cluster-devel@redhat.com + " jfs-discussion@lists.sourceforge.net\0" + "\01:1\0" "b\0" "On Thu, Mar 15, 2007 at 05:17:04PM +0100, Nick Piggin wrote:\n" "> (excludes the OCFS2 patch that Mark sent, in anticipation of an update)\n" @@ -19,9 +26,10 @@ "--\n" "Mark Fasheh\n" "Senior Software Developer, Oracle\n" - "mark.fasheh at oracle.com\n" - "\n" - "-------------- next part --------------\n" + mark.fasheh@oracle.com + "\01:2\0" + "fn\00001-ocfs2-Convert-to-new-aops.txt\0" + "b\0" "From: Mark Fasheh <mark.fasheh@oracle.com>\n" "\n" "ocfs2: Convert to new aops\n" @@ -230,9 +238,10 @@ " \t.sync_page\t= block_sync_page,\n" " \t.direct_IO\t= ocfs2_direct_IO,\n" "-- \n" - "1.3.3\n" - "\n" - "-------------- next part --------------\n" + 1.3.3 + "\01:3\0" + "fn\00002-Export-__grab_cache_page.txt\0" + "b\0" "From: Mark Fasheh <mark.fasheh@oracle.com>\n" "\n" "[PATCH] Export __grab_cache_page\n" @@ -258,4 +267,4 @@ "-- \n" 1.3.3 -3b3f6d18d8246ae5363b41dd96399d6da491d82232b2ca72d85dd701dc4e4b33 +d9a0baadda445f581168839ca5d26c7d9228e1268d85d7732db6711e0f706e25
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.