ext3: add writepage sanity checks
authorDmitry Monakhov <dmonakhov@openvz.org>
Tue, 2 Mar 2010 12:51:02 +0000 (15:51 +0300)
committerJan Kara <jack@suse.cz>
Thu, 4 Mar 2010 23:20:27 +0000 (00:20 +0100)
- There is theoretical possibility to perform writepage on
   RO superblock. Add explicit check for what case.
- Page must being locked before writepage.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/ext3/inode.c

index c0ff9d6ffde63ae5e76b4d30c561e1b451671590..eda9121d7d57ec69fbb04c86930f6a19b9292692 100644 (file)
@@ -1528,6 +1528,7 @@ static int ext3_ordered_writepage(struct page *page,
        int err;
 
        J_ASSERT(PageLocked(page));
+       WARN_ON_ONCE(IS_RDONLY(inode));
 
        /*
         * We give up here if we're reentered, because it might be for a
@@ -1600,6 +1601,9 @@ static int ext3_writeback_writepage(struct page *page,
        int ret = 0;
        int err;
 
+       J_ASSERT(PageLocked(page));
+       WARN_ON_ONCE(IS_RDONLY(inode));
+
        if (ext3_journal_current_handle())
                goto out_fail;
 
@@ -1642,6 +1646,9 @@ static int ext3_journalled_writepage(struct page *page,
        int ret = 0;
        int err;
 
+       J_ASSERT(PageLocked(page));
+       WARN_ON_ONCE(IS_RDONLY(inode));
+
        if (ext3_journal_current_handle())
                goto no_write;