[Ocfs2-commits] mfasheh commits r3057 - branches/ocfs2-1.2/fs/ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Mon Aug 27 15:12:43 PDT 2007
Author: mfasheh
Date: 2007-08-27 15:12:42 -0700 (Mon, 27 Aug 2007)
New Revision: 3057
Modified:
branches/ocfs2-1.2/fs/ocfs2/aops.c
branches/ocfs2-1.2/fs/ocfs2/dlmglue.c
branches/ocfs2-1.2/fs/ocfs2/file.c
Log:
ocfs2 1.2: Check for cluster locking in ocfs2_readpage
Readpage in ocfs2 1.2 expects cluster locks to have been taken before it's
called. Most of the time, this is fine as we get there through
ocfs2_file_read() or ocfs2_file_sendfile(). Unfortunately, this may not
always be the case - sys_readahead() for example calls ->readpage directly.
If we allow the pages to be brought into the page cache without a cluster
lock, we could expose stale or invalid disk data. What's worse - those pages
might later get marked dirty as part of a write.
Modify ocfs2_readpage() to look for the current process to be in the io
marker list. If it isn't, throw an error. sys_readahead() is smart enough to
silently ignore errors from readpage.
Remove an incorrect test of mapping->nrpages in
ocfs2_generic_handle_convert_action() - it's valid to have pages, so long as
they're not up to date, which our fix ensures.
Signed-off-by: smushran
Modified: branches/ocfs2-1.2/fs/ocfs2/aops.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/aops.c 2007-08-27 22:08:19 UTC (rev 3056)
+++ branches/ocfs2-1.2/fs/ocfs2/aops.c 2007-08-27 22:12:42 UTC (rev 3057)
@@ -36,6 +36,7 @@
#include "file.h"
#include "inode.h"
#include "journal.h"
+#include "mmap.h"
#include "symlink.h"
#include "buffer_head_io.h"
@@ -211,9 +212,17 @@
static int ocfs2_readpage(struct file *file, struct page *page)
{
int ret;
+ struct inode *inode = page->mapping->host;
mlog_entry("(0x%p, %lu)\n", file, (page ? page->index : 0));
+ if (ocfs2_is_in_io_marker_list(inode, current) == 0) {
+ mlog(0, "Inode %llu, unlocked readpage for index %lu\n",
+ (unsigned long long)OCFS2_I(inode)->ip_blkno, page->index);
+ unlock_page(page);
+ return -EINVAL;
+ }
+
ret = block_read_full_page(page, ocfs2_get_block);
mlog_exit(ret);
Modified: branches/ocfs2-1.2/fs/ocfs2/dlmglue.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/dlmglue.c 2007-08-27 22:08:19 UTC (rev 3056)
+++ branches/ocfs2-1.2/fs/ocfs2/dlmglue.c 2007-08-27 22:12:42 UTC (rev 3057)
@@ -467,19 +467,8 @@
* information is already up to data. Convert from NL to
* *anything* however should mark ourselves as needing an
* update */
- if (lockres->l_level == LKM_NLMODE) {
+ if (lockres->l_level == LKM_NLMODE)
lockres_or_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH);
- if (lockres->l_type == OCFS2_LOCK_TYPE_DATA) {
- /* we're just now getting the data lock so there
- * had better not be any pages in the page cache */
- struct inode *inode = ocfs2_lock_res_inode(lockres);
- struct address_space *mapping = inode->i_mapping;
- mlog_bug_on_msg(mapping->nrpages,
- "inode %llu nrpages %lu\n",
- (unsigned long long)OCFS2_I(inode)->ip_blkno,
- mapping->nrpages);
- }
- }
lockres->l_level = lockres->l_requested;
lockres_clear_flags(lockres, OCFS2_LOCK_BUSY);
Modified: branches/ocfs2-1.2/fs/ocfs2/file.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/file.c 2007-08-27 22:08:19 UTC (rev 3056)
+++ branches/ocfs2-1.2/fs/ocfs2/file.c 2007-08-27 22:12:42 UTC (rev 3057)
@@ -344,6 +344,7 @@
{
int ret;
struct inode *inode = in_file->f_mapping->host;
+ DECLARE_IO_MARKER(io_marker);
mlog_entry("inode %"MLFu64", ppos %lld, count = %u\n",
OCFS2_I(inode)->ip_blkno, (long long) *ppos,
@@ -367,7 +368,12 @@
down_read(&OCFS2_I(inode)->ip_alloc_sem);
+ /*
+ * We still need this so readpage doesn't throw an error.
+ */
+ ocfs2_add_io_marker(inode, &io_marker);
ret = generic_file_sendfile(in_file, ppos, count, actor, target);
+ ocfs2_del_io_marker(inode, &io_marker);
up_read(&OCFS2_I(inode)->ip_alloc_sem);
More information about the Ocfs2-commits
mailing list