X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=fs%2Fjffs2%2Ffile.c;h=5e920343b2c598595f2c068455e17d7d360c5a4f;hb=4b7227ca321ccf447cdc04538687c895db8b77f5;hp=023a17539dd4f7c296aed08e957a1867bf4bde3e;hpb=205c109a7a96d9a3d8ffe64c4068b70811fef5e8;p=linux-2.6 diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c index 023a17539d..5e920343b2 100644 --- a/fs/jffs2/file.c +++ b/fs/jffs2/file.c @@ -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));