]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ocfs2: Fix pos/len passed to ocfs2_write_cluster
authorMark Fasheh <mark.fasheh@oracle.com>
Mon, 17 Sep 2007 16:06:29 +0000 (09:06 -0700)
committerMark Fasheh <mark.fasheh@oracle.com>
Thu, 20 Sep 2007 22:06:09 +0000 (15:06 -0700)
This was broken for file systems whose cluster size is greater than page
size. Pos needs to be incremented as we loop through the descriptors, and
len needs to be capped to the size of a single cluster.

Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
fs/ocfs2/aops.c

index 50cd8a209012ed0cd216c651483416c71baa0d28..fa43810e597016bc12762457969a0b7271cfc3e2 100644 (file)
@@ -1211,18 +1211,33 @@ static int ocfs2_write_cluster_by_desc(struct address_space *mapping,
                                       loff_t pos, unsigned len)
 {
        int ret, i;
+       loff_t cluster_off;
+       unsigned int local_len = len;
        struct ocfs2_write_cluster_desc *desc;
+       struct ocfs2_super *osb = OCFS2_SB(mapping->host->i_sb);
 
        for (i = 0; i < wc->w_clen; i++) {
                desc = &wc->w_desc[i];
 
+               /*
+                * We have to make sure that the total write passed in
+                * doesn't extend past a single cluster.
+                */
+               local_len = len;
+               cluster_off = pos & (osb->s_clustersize - 1);
+               if ((cluster_off + local_len) > osb->s_clustersize)
+                       local_len = osb->s_clustersize - cluster_off;
+
                ret = ocfs2_write_cluster(mapping, desc->c_phys,
                                          desc->c_unwritten, data_ac, meta_ac,
-                                         wc, desc->c_cpos, pos, len);
+                                         wc, desc->c_cpos, pos, local_len);
                if (ret) {
                        mlog_errno(ret);
                        goto out;
                }
+
+               len -= local_len;
+               pos += local_len;
        }
 
        ret = 0;