Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=30b8548f2c270c0205558fe4826a6ab8e7fe51ad
Commit:     30b8548f2c270c0205558fe4826a6ab8e7fe51ad
Parent:     c0123adef626607535f3c2c93b530c36780885e0
Author:     [EMAIL PROTECTED] <[EMAIL PROTECTED]>
AuthorDate: Thu Sep 6 08:02:25 2007 +0800
Committer:  Mark Fasheh <[EMAIL PROTECTED]>
CommitDate: Tue Sep 11 11:39:05 2007 -0700

    [PATCH] ocfs2: Fix a wrong cluster calculation.
    
    In ocfs2_alloc_write_write_ctxt, the written clusters length is calculated
    by the byte length only. This may cause some problems if we start to write
    at some position in the end of one cluster and last to a second cluster
    while the "len" is smaller than a cluster size. In that case, we have to
    write 2 clusters actually.
    So we have to take the start position into consideration also.
    
    Signed-off-by: Tao Ma <[EMAIL PROTECTED]>
    Signed-off-by: Mark Fasheh <[EMAIL PROTECTED]>
---
 fs/ocfs2/aops.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 460d440..50cd8a2 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -855,6 +855,7 @@ static int ocfs2_alloc_write_ctxt(struct ocfs2_write_ctxt 
**wcp,
                                  struct ocfs2_super *osb, loff_t pos,
                                  unsigned len, struct buffer_head *di_bh)
 {
+       u32 cend;
        struct ocfs2_write_ctxt *wc;
 
        wc = kzalloc(sizeof(struct ocfs2_write_ctxt), GFP_NOFS);
@@ -862,7 +863,8 @@ static int ocfs2_alloc_write_ctxt(struct ocfs2_write_ctxt 
**wcp,
                return -ENOMEM;
 
        wc->w_cpos = pos >> osb->s_clustersize_bits;
-       wc->w_clen = ocfs2_clusters_for_bytes(osb->sb, len);
+       cend = (pos + len - 1) >> osb->s_clustersize_bits;
+       wc->w_clen = cend - wc->w_cpos + 1;
        get_bh(di_bh);
        wc->w_di_bh = di_bh;
 
-
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