]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/jffs2/file.c
vfb: only enable if explicitly requested when compiled in
[linux-2.6-omap-h63xx.git] / fs / jffs2 / file.c
index 023a17539dd4f7c296aed08e957a1867bf4bde3e..5e920343b2c598595f2c068455e17d7d360c5a4f 100644 (file)
@@ -115,9 +115,9 @@ static int jffs2_readpage (struct file *filp, struct page *pg)
        struct jffs2_inode_info *f = JFFS2_INODE_INFO(pg->mapping->host);
        int ret;
 
-       down(&f->sem);
+       mutex_lock(&f->sem);
        ret = jffs2_do_readpage_unlock(pg->mapping->host, pg);
-       up(&f->sem);
+       mutex_unlock(&f->sem);
        return ret;
 }
 
@@ -129,7 +129,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
        struct inode *inode = mapping->host;
        struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
        pgoff_t index = pos >> PAGE_CACHE_SHIFT;
-       uint32_t pageofs = pos & (PAGE_CACHE_SIZE - 1);
+       uint32_t pageofs = index << PAGE_CACHE_SHIFT;
        int ret = 0;
 
        pg = __grab_cache_page(mapping, index);
@@ -154,7 +154,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
                if (ret)
                        goto out_page;
 
-               down(&f->sem);
+               mutex_lock(&f->sem);
                memset(&ri, 0, sizeof(ri));
 
                ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
@@ -181,7 +181,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
                if (IS_ERR(fn)) {
                        ret = PTR_ERR(fn);
                        jffs2_complete_reservation(c);
-                       up(&f->sem);
+                       mutex_unlock(&f->sem);
                        goto out_page;
                }
                ret = jffs2_add_full_dnode_to_inode(c, f, fn);
@@ -195,12 +195,12 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
                        jffs2_mark_node_obsolete(c, fn->raw);
                        jffs2_free_full_dnode(fn);
                        jffs2_complete_reservation(c);
-                       up(&f->sem);
+                       mutex_unlock(&f->sem);
                        goto out_page;
                }
                jffs2_complete_reservation(c);
                inode->i_size = pageofs;
-               up(&f->sem);
+               mutex_unlock(&f->sem);
        }
 
        /*
@@ -209,9 +209,9 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
         * case of a short-copy.
         */
        if (!PageUptodate(pg)) {
-               down(&f->sem);
+               mutex_lock(&f->sem);
                ret = jffs2_do_readpage_nolock(inode, pg);
-               up(&f->sem);
+               mutex_unlock(&f->sem);
                if (ret)
                        goto out_page;
        }
@@ -255,7 +255,7 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
                   _whole_ page. This helps to reduce the number of
                   nodes in files which have many short writes, like
                   syslog files. */
-               start = aligned_start = 0;
+               aligned_start = 0;
        }
 
        ri = jffs2_alloc_raw_inode();
@@ -291,14 +291,11 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
        }
 
        /* Adjust writtenlen for the padding we did, so we don't confuse our caller */
-       if (writtenlen < (start&3))
-               writtenlen = 0;
-       else
-               writtenlen -= (start&3);
+       writtenlen -= min(writtenlen, (start - aligned_start));
 
        if (writtenlen) {
-               if (inode->i_size < (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen) {
-                       inode->i_size = (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen;
+               if (inode->i_size < pos + writtenlen) {
+                       inode->i_size = pos + writtenlen;
                        inode->i_blocks = (inode->i_size + 511) >> 9;
 
                        inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime));