write.c (e5451c8f8330e03ad3cfa16048b4daf961af434f) write.c (09cbfeaf1a5a67bfb3201e0c83c810cecb2efa5a)
1/*
2 * JFFS2 -- Journalling Flash File System, Version 2.
3 *
4 * Copyright © 2001-2007 Red Hat, Inc.
5 *
6 * Created by David Woodhouse <dwmw2@infradead.org>
7 *
8 * For licensing information, see the file 'LICENCE' in this directory.

--- 158 unchanged lines hidden (view full) ---

167 jffs2_free_full_dnode(fn);
168 return ERR_PTR(ret?ret:-EIO);
169 }
170 /* Mark the space used */
171 /* If node covers at least a whole page, or if it starts at the
172 beginning of a page and runs to the end of the file, or if
173 it's a hole node, mark it REF_PRISTINE, else REF_NORMAL.
174 */
1/*
2 * JFFS2 -- Journalling Flash File System, Version 2.
3 *
4 * Copyright © 2001-2007 Red Hat, Inc.
5 *
6 * Created by David Woodhouse <dwmw2@infradead.org>
7 *
8 * For licensing information, see the file 'LICENCE' in this directory.

--- 158 unchanged lines hidden (view full) ---

167 jffs2_free_full_dnode(fn);
168 return ERR_PTR(ret?ret:-EIO);
169 }
170 /* Mark the space used */
171 /* If node covers at least a whole page, or if it starts at the
172 beginning of a page and runs to the end of the file, or if
173 it's a hole node, mark it REF_PRISTINE, else REF_NORMAL.
174 */
175 if ((je32_to_cpu(ri->dsize) >= PAGE_CACHE_SIZE) ||
176 ( ((je32_to_cpu(ri->offset)&(PAGE_CACHE_SIZE-1))==0) &&
175 if ((je32_to_cpu(ri->dsize) >= PAGE_SIZE) ||
176 ( ((je32_to_cpu(ri->offset)&(PAGE_SIZE-1))==0) &&
177 (je32_to_cpu(ri->dsize)+je32_to_cpu(ri->offset) == je32_to_cpu(ri->isize)))) {
178 flash_ofs |= REF_PRISTINE;
179 } else {
180 flash_ofs |= REF_NORMAL;
181 }
182 fn->raw = jffs2_add_physical_node_ref(c, flash_ofs, PAD(sizeof(*ri)+datalen), f->inocache);
183 if (IS_ERR(fn->raw)) {
184 void *hold_err = fn->raw;

--- 176 unchanged lines hidden (view full) ---

361
362 ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN,
363 &alloclen, ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
364 if (ret) {
365 jffs2_dbg(1, "jffs2_reserve_space returned %d\n", ret);
366 break;
367 }
368 mutex_lock(&f->sem);
177 (je32_to_cpu(ri->dsize)+je32_to_cpu(ri->offset) == je32_to_cpu(ri->isize)))) {
178 flash_ofs |= REF_PRISTINE;
179 } else {
180 flash_ofs |= REF_NORMAL;
181 }
182 fn->raw = jffs2_add_physical_node_ref(c, flash_ofs, PAD(sizeof(*ri)+datalen), f->inocache);
183 if (IS_ERR(fn->raw)) {
184 void *hold_err = fn->raw;

--- 176 unchanged lines hidden (view full) ---

361
362 ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN,
363 &alloclen, ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
364 if (ret) {
365 jffs2_dbg(1, "jffs2_reserve_space returned %d\n", ret);
366 break;
367 }
368 mutex_lock(&f->sem);
369 datalen = min_t(uint32_t, writelen, PAGE_CACHE_SIZE - (offset & (PAGE_CACHE_SIZE-1)));
369 datalen = min_t(uint32_t, writelen,
370 PAGE_SIZE - (offset & (PAGE_SIZE-1)));
370 cdatalen = min_t(uint32_t, alloclen - sizeof(*ri), datalen);
371
372 comprtype = jffs2_compress(c, f, buf, &comprbuf, &datalen, &cdatalen);
373
374 ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
375 ri->nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);
376 ri->totlen = cpu_to_je32(sizeof(*ri) + cdatalen);
377 ri->hdr_crc = cpu_to_je32(crc32(0, ri, sizeof(struct jffs2_unknown_node)-4));

--- 345 unchanged lines hidden ---
371 cdatalen = min_t(uint32_t, alloclen - sizeof(*ri), datalen);
372
373 comprtype = jffs2_compress(c, f, buf, &comprbuf, &datalen, &cdatalen);
374
375 ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
376 ri->nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);
377 ri->totlen = cpu_to_je32(sizeof(*ri) + cdatalen);
378 ri->hdr_crc = cpu_to_je32(crc32(0, ri, sizeof(struct jffs2_unknown_node)-4));

--- 345 unchanged lines hidden ---