Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=eeb47d1234af1a9267836f680a8e114b2e88d0dc
Commit:     eeb47d1234af1a9267836f680a8e114b2e88d0dc
Parent:     59be7dc97bacc0fd8e22f0be6e2aebb5c9b4ff47
Author:     Mark Fasheh <[EMAIL PROTECTED]>
AuthorDate: Wed Jun 6 16:15:24 2007 -0700
Committer:  Mark Fasheh <[EMAIL PROTECTED]>
CommitDate: Wed Jun 6 16:42:03 2007 -0700

    ocfs2: Fix invalid assertion during write on 64k pages
    
    The write path code intends to bug if a math error (or unhandled case)
    results in a write outside of the current cluster boundaries. The actual
    BUG_ON() statements however are incorrect, leading to a crash on kernels
    with 64k page size. Fix those by checking against the right variables.
    
    Also, move the assertions higher up within the functions so that they trip
    *before* the code starts to mark buffers.
    
    Signed-off-by: Mark Fasheh <[EMAIL PROTECTED]>
---
 fs/ocfs2/aops.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 0023b31..a480b09 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -798,6 +798,11 @@ int ocfs2_map_and_write_splice_data(struct inode *inode,
        }
        to = from + bytes;
 
+       BUG_ON(from > PAGE_CACHE_SIZE);
+       BUG_ON(to > PAGE_CACHE_SIZE);
+       BUG_ON(from < cluster_start);
+       BUG_ON(to > cluster_end);
+
        if (wc->w_this_page_new)
                ret = ocfs2_map_page_blocks(wc->w_this_page, p_blkno, inode,
                                            cluster_start, cluster_end, 1);
@@ -809,11 +814,6 @@ int ocfs2_map_and_write_splice_data(struct inode *inode,
                goto out;
        }
 
-       BUG_ON(from > PAGE_CACHE_SIZE);
-       BUG_ON(to > PAGE_CACHE_SIZE);
-       BUG_ON(from > osb->s_clustersize);
-       BUG_ON(to > osb->s_clustersize);
-
        src = buf->ops->map(sp->s_pipe, buf, 1);
        dst = kmap_atomic(wc->w_this_page, KM_USER1);
        memcpy(dst + from, src + src_from, bytes);
@@ -890,6 +890,11 @@ int ocfs2_map_and_write_user_data(struct inode *inode,
 
        to = from + bytes;
 
+       BUG_ON(from > PAGE_CACHE_SIZE);
+       BUG_ON(to > PAGE_CACHE_SIZE);
+       BUG_ON(from < cluster_start);
+       BUG_ON(to > cluster_end);
+
        if (wc->w_this_page_new)
                ret = ocfs2_map_page_blocks(wc->w_this_page, p_blkno, inode,
                                            cluster_start, cluster_end, 1);
@@ -901,11 +906,6 @@ int ocfs2_map_and_write_user_data(struct inode *inode,
                goto out;
        }
 
-       BUG_ON(from > PAGE_CACHE_SIZE);
-       BUG_ON(to > PAGE_CACHE_SIZE);
-       BUG_ON(from > osb->s_clustersize);
-       BUG_ON(to > osb->s_clustersize);
-
        dst = kmap(wc->w_this_page);
        memcpy(dst + from, bp->b_src_buf + src_from, bytes);
        kunmap(wc->w_this_page);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to