···10841084 default y10851085 help10861086 Zlib is designed to be a free, general-purpose, legally unencumbered,10871087- lossless data-compression library for use on virtually any computer 10871087+ lossless data-compression library for use on virtually any computer10881088 hardware and operating system. See <http://www.gzip.org/zlib/> for10891089 further information.10901090-10901090+10911091 Say 'Y' if unsure.1092109210931093config JFFS2_RTIME···11091109 default JFFS2_CMODE_PRIORITY11101110 depends on JFFS2_FS11111111 help11121112- You can set here the default compression mode of JFFS2 from 11121112+ You can set here the default compression mode of JFFS2 from11131113 the available compression modes. Don't touch if unsure.1114111411151115config JFFS2_CMODE_NONE···11201120config JFFS2_CMODE_PRIORITY11211121 bool "priority"11221122 help11231123- Tries the compressors in a predefinied order and chooses the first 11231123+ Tries the compressors in a predefinied order and chooses the first11241124 successful one.1125112511261126config JFFS2_CMODE_SIZE11271127 bool "size (EXPERIMENTAL)"11281128 help11291129- Tries all compressors and chooses the one which has the smallest 11291129+ Tries all compressors and chooses the one which has the smallest11301130 result.1131113111321132endchoice
+2-2
fs/jffs2/background.c
···5151 D1(printk(KERN_DEBUG "JFFS2: Garbage collect thread is pid %d\n", pid));5252 wait_for_completion(&c->gc_thread_start);5353 }5454-5454+5555 return ret;5656}5757···101101102102 cond_resched();103103104104- /* Put_super will send a SIGKILL and then wait on the sem. 104104+ /* Put_super will send a SIGKILL and then wait on the sem.105105 */106106 while (signal_pending(current)) {107107 siginfo_t info;
+14-14
fs/jffs2/build.c
···77 *88 * For licensing information, see the file 'LICENCE' in this directory.99 *1010- * $Id: build.c,v 1.84 2005/09/27 13:40:49 dedekind Exp $1010+ * $Id: build.c,v 1.85 2005/11/07 11:14:38 gleixner Exp $1111 *1212 */1313···129129 for_each_inode(i, c, ic) {130130 if (ic->nlink)131131 continue;132132-132132+133133 jffs2_build_remove_unlinked_inode(c, ic, &dead_fds);134134 cond_resched();135135- } 135135+ }136136137137 dbg_fsbuild("pass 2a starting\n");138138···149149150150 dbg_fsbuild("pass 2a complete\n");151151 dbg_fsbuild("freeing temporary data structures\n");152152-152152+153153 /* Finally, we can scan again and free the dirent structs */154154 for_each_inode(i, c, ic) {155155 while(ic->scan_dents) {···161161 cond_resched();162162 }163163 c->flags &= ~JFFS2_SB_FLAG_BUILDING;164164-164164+165165 dbg_fsbuild("FS build complete\n");166166167167 /* Rotate the lists by some number to ensure wear levelling */···191191 struct jffs2_full_dirent *fd;192192193193 dbg_fsbuild("removing ino #%u with nlink == zero.\n", ic->ino);194194-194194+195195 raw = ic->nodes;196196 while (raw != (void *)ic) {197197 struct jffs2_raw_node_ref *next = raw->next_in_ino;···220220 whinged = 1;221221222222 dbg_fsbuild("removing child \"%s\", ino #%u\n", fd->name, fd->ino);223223-223223+224224 child_ic = jffs2_get_ino_cache(c, fd->ino);225225 if (!child_ic) {226226 dbg_fsbuild("cannot remove child \"%s\", ino #%u, because it doesn't exist\n",···229229 continue;230230 }231231232232- /* Reduce nlink of the child. If it's now zero, stick it on the 232232+ /* Reduce nlink of the child. If it's now zero, stick it on the233233 dead_fds list to be cleaned up later. Else just free the fd */234234235235 child_ic->nlink--;236236-236236+237237 if (!child_ic->nlink) {238238 dbg_fsbuild("inode #%u (\"%s\") has now got zero nlink, adding to dead_fds list.\n",239239 fd->ino, fd->name);···248248 }249249250250 /*251251- We don't delete the inocache from the hash list and free it yet. 251251+ We don't delete the inocache from the hash list and free it yet.252252 The erase code will do that, when all the nodes are completely gone.253253 */254254}···262262 because there's not enough free space... */263263 c->resv_blocks_deletion = 2;264264265265- /* Be conservative about how much space we need before we allow writes. 265265+ /* Be conservative about how much space we need before we allow writes.266266 On top of that which is required for deletia, require an extra 2%267267 of the medium to be available, for overhead caused by nodes being268268 split across blocks, etc. */···277277278278 c->resv_blocks_gctrigger = c->resv_blocks_write + 1;279279280280- /* When do we allow garbage collection to merge nodes to make 280280+ /* When do we allow garbage collection to merge nodes to make281281 long-term progress at the expense of short-term space exhaustion? */282282 c->resv_blocks_gcmerge = c->resv_blocks_deletion + 1;283283···303303 c->resv_blocks_gcbad, c->resv_blocks_gcbad*c->sector_size/1024);304304 dbg_fsbuild("Amount of dirty space required to GC: %d bytes\n",305305 c->nospc_dirty_size);306306-} 306306+}307307308308int jffs2_do_mount_fs(struct jffs2_sb_info *c)309309{···355355#ifndef __ECOS356356 if (jffs2_blocks_use_vmalloc(c))357357 vfree(c->blocks);358358- else 358358+ else359359#endif360360 kfree(c->blocks);361361
+14-14
fs/jffs2/compr.c
···99 *1010 * For licensing information, see the file 'LICENCE' in this directory.1111 *1212- * $Id: compr.c,v 1.45 2005/07/26 13:24:40 havasi Exp $1212+ * $Id: compr.c,v 1.46 2005/11/07 11:14:38 gleixner Exp $1313 *1414 */1515···3636 * data.3737 *3838 * Returns: Lower byte to be stored with data indicating compression type used.3939- * Zero is used to show that the data could not be compressed - the 3939+ * Zero is used to show that the data could not be compressed - the4040 * compressed version was actually larger than the original.4141 * Upper byte will be used later. (soon)4242 *4343 * If the cdata buffer isn't large enough to hold all the uncompressed data,4444- * jffs2_compress should compress as much as will fit, and should set 4444+ * jffs2_compress should compress as much as will fit, and should set4545 * *datalen accordingly to show the amount of data which were compressed.4646 */4747uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,4848- unsigned char *data_in, unsigned char **cpage_out, 4848+ unsigned char *data_in, unsigned char **cpage_out,4949 uint32_t *datalen, uint32_t *cdatalen)5050{5151 int ret = JFFS2_COMPR_NONE;···164164}165165166166int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,167167- uint16_t comprtype, unsigned char *cdata_in, 167167+ uint16_t comprtype, unsigned char *cdata_in,168168 unsigned char *data_out, uint32_t cdatalen, uint32_t datalen)169169{170170 struct jffs2_compressor *this;···298298299299 act_buf += sprintf(act_buf,"JFFS2 compressor statistics:\n");300300 act_buf += sprintf(act_buf,"%10s ","none");301301- act_buf += sprintf(act_buf,"compr: %d blocks (%d) decompr: %d blocks\n", none_stat_compr_blocks, 301301+ act_buf += sprintf(act_buf,"compr: %d blocks (%d) decompr: %d blocks\n", none_stat_compr_blocks,302302 none_stat_compr_size, none_stat_decompr_blocks);303303 spin_lock(&jffs2_compressor_list_lock);304304 list_for_each_entry(this, &jffs2_compressor_list, list) {···307307 act_buf += sprintf(act_buf,"- ");308308 else309309 act_buf += sprintf(act_buf,"+ ");310310- act_buf += sprintf(act_buf,"compr: %d blocks (%d/%d) decompr: %d blocks ", this->stat_compr_blocks, 311311- this->stat_compr_new_size, this->stat_compr_orig_size, 310310+ act_buf += sprintf(act_buf,"compr: %d blocks (%d/%d) decompr: %d blocks ", this->stat_compr_blocks,311311+ this->stat_compr_new_size, this->stat_compr_orig_size,312312 this->stat_decompr_blocks);313313 act_buf += sprintf(act_buf,"\n");314314 }···317317 return buf;318318}319319320320-char *jffs2_get_compression_mode_name(void) 320320+char *jffs2_get_compression_mode_name(void)321321{322322 switch (jffs2_compression_mode) {323323 case JFFS2_COMPR_MODE_NONE:···330330 return "unkown";331331}332332333333-int jffs2_set_compression_mode_name(const char *name) 333333+int jffs2_set_compression_mode_name(const char *name)334334{335335 if (!strcmp("none",name)) {336336 jffs2_compression_mode = JFFS2_COMPR_MODE_NONE;···355355 if (!strcmp(this->name, name)) {356356 this->disabled = disabled;357357 spin_unlock(&jffs2_compressor_list_lock);358358- return 0; 358358+ return 0;359359 }360360 }361361 spin_unlock(&jffs2_compressor_list_lock);···385385 }386386 }387387 spin_unlock(&jffs2_compressor_list_lock);388388- printk(KERN_WARNING "JFFS2: compressor %s not found.\n",name); 388388+ printk(KERN_WARNING "JFFS2: compressor %s not found.\n",name);389389 return 1;390390reinsert:391391 /* list is sorted in the order of priority, so if···412412 kfree(comprbuf);413413}414414415415-int jffs2_compressors_init(void) 415415+int jffs2_compressors_init(void)416416{417417/* Registering compressors */418418#ifdef CONFIG_JFFS2_ZLIB···440440 return 0;441441}442442443443-int jffs2_compressors_exit(void) 443443+int jffs2_compressors_exit(void)444444{445445/* Unregistering compressors */446446#ifdef CONFIG_JFFS2_RUBIN
+2-2
fs/jffs2/compr.h
···44 * Copyright (C) 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>,55 * University of Szeged, Hungary66 *77- * For licensing information, see the file 'LICENCE' in the 77+ * For licensing information, see the file 'LICENCE' in the88 * jffs2 directory.99 *1010- * $Id: compr.h,v 1.8 2005/07/26 13:24:40 havasi Exp $1010+ * $Id: compr.h,v 1.9 2005/11/07 11:14:38 gleixner Exp $1111 *1212 */1313
+16-16
fs/jffs2/compr_rtime.c
···2424#include <linux/kernel.h>2525#include <linux/types.h>2626#include <linux/errno.h>2727-#include <linux/string.h> 2828-#include <linux/jffs2.h> 2727+#include <linux/string.h>2828+#include <linux/jffs2.h>2929#include "compr.h"30303131/* _compress returns the compressed size, -1 if bigger */···3838 int outpos = 0;3939 int pos=0;40404141- memset(positions,0,sizeof(positions)); 4242-4141+ memset(positions,0,sizeof(positions));4242+4343 while (pos < (*sourcelen) && outpos <= (*dstlen)-2) {4444 int backpos, runlen=0;4545 unsigned char value;4646-4646+4747 value = data_in[pos];48484949 cpage_out[outpos++] = data_in[pos++];5050-5050+5151 backpos = positions[value];5252 positions[value]=pos;5353-5353+5454 while ((backpos < pos) && (pos < (*sourcelen)) &&5555 (data_in[pos]==data_in[backpos++]) && (runlen<255)) {5656 pos++;···6363 /* We failed */6464 return -1;6565 }6666-6666+6767 /* Tell the caller how much we managed to compress, and how much space it took */6868 *sourcelen = pos;6969 *dstlen = outpos;7070 return 0;7171-} 7171+}727273737474static int jffs2_rtime_decompress(unsigned char *data_in,···7979 short positions[256];8080 int outpos = 0;8181 int pos=0;8282-8383- memset(positions,0,sizeof(positions)); 8484-8282+8383+ memset(positions,0,sizeof(positions));8484+8585 while (outpos<destlen) {8686 unsigned char value;8787 int backoffs;8888 int repeat;8989-8989+9090 value = data_in[pos++];9191 cpage_out[outpos++] = value; /* first the verbatim copied byte */9292 repeat = data_in[pos++];9393 backoffs = positions[value];9494-9494+9595 positions[value]=outpos;9696 if (repeat) {9797 if (backoffs + repeat >= outpos) {···101101 }102102 } else {103103 memcpy(&cpage_out[outpos],&cpage_out[backoffs],repeat);104104- outpos+=repeat; 104104+ outpos+=repeat;105105 }106106 }107107 }108108 return 0;109109-} 109109+}110110111111static struct jffs2_compressor jffs2_rtime_comp = {112112 .priority = JFFS2_RTIME_PRIORITY,
+18-19
fs/jffs2/compr_rubin.c
···1111 *1212 */13131414-1514#include <linux/string.h>1615#include <linux/types.h>1716#include <linux/jffs2.h>···1920#include "compr.h"20212122static void init_rubin(struct rubin_state *rs, int div, int *bits)2222-{ 2323+{2324 int c;24252526 rs->q = 0;···39404041 while ((rs->q >= UPPER_BIT_RUBIN) || ((rs->p + rs->q) <= UPPER_BIT_RUBIN)) {4142 rs->bit_number++;4242-4343+4344 ret = pushbit(&rs->pp, (rs->q & UPPER_BIT_RUBIN) ? 1 : 0, 0);4445 if (ret)4546 return ret;···676868696970static void end_rubin(struct rubin_state *rs)7070-{ 7171+{71727273 int i;7374···81828283static void init_decode(struct rubin_state *rs, int div, int *bits)8384{8484- init_rubin(rs, div, bits); 8585+ init_rubin(rs, div, bits);85868687 /* behalve lower */8788 rs->rec_q = 0;···187188188189189190190190-static int rubin_do_compress(int bit_divider, int *bits, unsigned char *data_in, 191191+static int rubin_do_compress(int bit_divider, int *bits, unsigned char *data_in,191192 unsigned char *cpage_out, uint32_t *sourcelen, uint32_t *dstlen)192193 {193194 int outpos = 0;···197198 init_pushpull(&rs.pp, cpage_out, *dstlen * 8, 0, 32);198199199200 init_rubin(&rs, bit_divider, bits);200200-201201+201202 while (pos < (*sourcelen) && !out_byte(&rs, data_in[pos]))202203 pos++;203203-204204+204205 end_rubin(&rs);205206206207 if (outpos > pos) {207208 /* We failed */208209 return -1;209210 }210210-211211- /* Tell the caller how much we managed to compress, 211211+212212+ /* Tell the caller how much we managed to compress,212213 * and how much space it took */213213-214214+214215 outpos = (pushedbits(&rs.pp)+7)/8;215215-216216+216217 if (outpos >= pos)217218 return -1; /* We didn't actually compress */218219 *sourcelen = pos;219220 *dstlen = outpos;220221 return 0;221221-} 222222+}222223#if 0223224/* _compress returns the compressed size, -1 if bigger */224224-int jffs2_rubinmips_compress(unsigned char *data_in, unsigned char *cpage_out, 225225+int jffs2_rubinmips_compress(unsigned char *data_in, unsigned char *cpage_out,225226 uint32_t *sourcelen, uint32_t *dstlen, void *model)226227{227228 return rubin_do_compress(BIT_DIVIDER_MIPS, bits_mips, data_in, cpage_out, sourcelen, dstlen);···276277 }277278278279 ret = rubin_do_compress(256, bits, data_in, cpage_out+8, &mysrclen, &mydstlen);279279- if (ret) 280280+ if (ret)280281 return ret;281282282283 /* Add back the 8 bytes we took for the probabilities */···292293 return 0;293294}294295295295-static void rubin_do_decompress(int bit_divider, int *bits, unsigned char *cdata_in, 296296+static void rubin_do_decompress(int bit_divider, int *bits, unsigned char *cdata_in,296297 unsigned char *page_out, uint32_t srclen, uint32_t destlen)297298{298299 int outpos = 0;299300 struct rubin_state rs;300300-301301+301302 init_pushpull(&rs.pp, cdata_in, srclen, 0, 0);302303 init_decode(&rs, bit_divider, bits);303303-304304+304305 while (outpos < destlen) {305306 page_out[outpos++] = in_byte(&rs);306307 }307307-} 308308+}308309309310310311static int jffs2_rubinmips_decompress(unsigned char *data_in,
+3-3
fs/jffs2/compr_rubin.h
···11/* Rubin encoder/decoder header */22/* work started at : aug 3, 1994 */33/* last modification : aug 15, 1994 */44-/* $Id: compr_rubin.h,v 1.6 2002/01/25 01:49:26 dwmw2 Exp $ */44+/* $Id: compr_rubin.h,v 1.7 2005/11/07 11:14:38 gleixner Exp $ */5566#include "pushpull.h"77···111112121313struct rubin_state {1414- unsigned long p; 1515- unsigned long q; 1414+ unsigned long p;1515+ unsigned long q;1616 unsigned long rec_q;1717 long bit_number;1818 struct pushpull pp;
+7-7
fs/jffs2/compr_zlib.c
···77 *88 * For licensing information, see the file 'LICENCE' in this directory.99 *1010- * $Id: compr_zlib.c,v 1.31 2005/05/20 19:30:06 gleixner Exp $1010+ * $Id: compr_zlib.c,v 1.32 2005/11/07 11:14:38 gleixner Exp $1111 *1212 */1313···2424#include "nodelist.h"2525#include "compr.h"26262727- /* Plan: call deflate() with avail_in == *sourcelen, 2828- avail_out = *dstlen - 12 and flush == Z_FINISH. 2727+ /* Plan: call deflate() with avail_in == *sourcelen,2828+ avail_out = *dstlen - 12 and flush == Z_FINISH.2929 If it doesn't manage to finish, call it again with3030 avail_in == 0 and avail_out set to the remaining 123131- bytes for it to clean up. 3131+ bytes for it to clean up.3232 Q: Is 12 bytes sufficient?3333 */3434#define STREAM_END_SPACE 12···89899090 def_strm.next_in = data_in;9191 def_strm.total_in = 0;9292-9292+9393 def_strm.next_out = cpage_out;9494 def_strm.total_out = 0;9595···9999 D1(printk(KERN_DEBUG "calling deflate with avail_in %d, avail_out %d\n",100100 def_strm.avail_in, def_strm.avail_out));101101 ret = zlib_deflate(&def_strm, Z_PARTIAL_FLUSH);102102- D1(printk(KERN_DEBUG "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", 102102+ D1(printk(KERN_DEBUG "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n",103103 def_strm.avail_in, def_strm.avail_out, def_strm.total_in, def_strm.total_out));104104 if (ret != Z_OK) {105105 D1(printk(KERN_DEBUG "deflate in loop returned %d\n", ret));···150150 inf_strm.next_in = data_in;151151 inf_strm.avail_in = srclen;152152 inf_strm.total_in = 0;153153-153153+154154 inf_strm.next_out = cpage_out;155155 inf_strm.avail_out = destlen;156156 inf_strm.total_out = 0;
···77 *88 * For licensing information, see the file 'LICENCE' in this directory.99 *1010- * $Id: debug.h,v 1.20 2005/10/24 16:22:34 dedekind Exp $1010+ * $Id: debug.h,v 1.21 2005/11/07 11:14:39 gleixner Exp $1111 *1212 */1313#ifndef _JFFS2_DEBUG_H_···2424#define JFFS2_DBG_PARANOIA_CHECKS2525#define JFFS2_DBG_DUMPS26262727-/* 2727+/*2828 * By defining/undefining the below macros one may select debugging messages2929 * fro specific JFFS2 subsystems.3030 */···4545/* Sanity checks are supposed to be light-weight and enabled by default */4646#define JFFS2_DBG_SANITY_CHECKS47474848-/* 4848+/*4949 * Dx() are mainly used for debugging messages, they must go away and be5050 * superseded by nicer dbg_xxx() macros...5151 */···9191 " (%d) %s: " fmt, current->pid, \9292 __FUNCTION__, ##__VA_ARGS__); \9393 } while(0)9494-9494+9595#define JFFS2_NOTICE(fmt, ...) \9696 do { \9797 printk(JFFS2_NOTICE_MSG_PREFIX \···106106 __FUNCTION__, ##__VA_ARGS__); \107107 } while(0)108108109109-/* 109109+/*110110 * We split our debugging messages on several parts, depending on the JFFS2111111 * subsystem the message belongs to.112112 */
+37-37
fs/jffs2/dir.c
···77 *88 * For licensing information, see the file 'LICENCE' in this directory.99 *1010- * $Id: dir.c,v 1.89 2005/09/07 08:34:54 havasi Exp $1010+ * $Id: dir.c,v 1.90 2005/11/07 11:14:39 gleixner Exp $1111 *1212 */1313···646465656666/* We keep the dirent list sorted in increasing order of name hash,6767- and we use the same hash function as the dentries. Makes this 6767+ and we use the same hash function as the dentries. Makes this6868 nice and simple6969*/7070static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target,···85858686 /* NB: The 2.2 backport will need to explicitly check for '.' and '..' here */8787 for (fd_list = dir_f->dents; fd_list && fd_list->nhash <= target->d_name.hash; fd_list = fd_list->next) {8888- if (fd_list->nhash == target->d_name.hash && 8888+ if (fd_list->nhash == target->d_name.hash &&8989 (!fd || fd_list->version > fd->version) &&9090 strlen(fd_list->name) == target->d_name.len &&9191 !strncmp(fd_list->name, target->d_name.name, target->d_name.len)) {···147147 curofs++;148148 /* First loop: curofs = 2; offset = 2 */149149 if (curofs < offset) {150150- D2(printk(KERN_DEBUG "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n", 150150+ D2(printk(KERN_DEBUG "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n",151151 fd->name, fd->ino, fd->type, curofs, offset));152152 continue;153153 }···182182 ri = jffs2_alloc_raw_inode();183183 if (!ri)184184 return -ENOMEM;185185-185185+186186 c = JFFS2_SB_INFO(dir_i->i_sb);187187188188 D1(printk(KERN_DEBUG "jffs2_create()\n"));···203203 f = JFFS2_INODE_INFO(inode);204204 dir_f = JFFS2_INODE_INFO(dir_i);205205206206- ret = jffs2_do_create(c, dir_f, f, ri, 206206+ ret = jffs2_do_create(c, dir_f, f, ri,207207 dentry->d_name.name, dentry->d_name.len);208208209209 if (ret) {···234234 int ret;235235 uint32_t now = get_seconds();236236237237- ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, 237237+ ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name,238238 dentry->d_name.len, dead_f, now);239239 if (dead_f->inocache)240240 dentry->d_inode->i_nlink = dead_f->inocache->nlink;···303303304304 if (!ri)305305 return -ENOMEM;306306-306306+307307 c = JFFS2_SB_INFO(dir_i->i_sb);308308-309309- /* Try to reserve enough space for both node and dirent. 310310- * Just the node will do for now, though 308308+309309+ /* Try to reserve enough space for both node and dirent.310310+ * Just the node will do for now, though311311 */312312 namelen = dentry->d_name.len;313313 ret = jffs2_reserve_space(c, sizeof(*ri) + targetlen, &phys_ofs, &alloclen,···338338 ri->compr = JFFS2_COMPR_NONE;339339 ri->data_crc = cpu_to_je32(crc32(0, target, targetlen));340340 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));341341-341341+342342 fn = jffs2_write_dnode(c, f, ri, target, targetlen, phys_ofs, ALLOC_NORMAL);343343344344 jffs2_free_raw_inode(ri);···364364 memcpy(f->target, target, targetlen + 1);365365 D1(printk(KERN_DEBUG "jffs2_symlink: symlink's target '%s' cached\n", (char *)f->target));366366367367- /* No data here. Only a metadata node, which will be 367367+ /* No data here. Only a metadata node, which will be368368 obsoleted by the first data write369369 */370370 f->metadata = fn;···407407 fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL);408408409409 if (IS_ERR(fd)) {410410- /* dirent failed to write. Delete the inode normally 410410+ /* dirent failed to write. Delete the inode normally411411 as if it were the final unlink() */412412 jffs2_complete_reservation(c);413413 jffs2_free_raw_dirent(rd);···450450 ri = jffs2_alloc_raw_inode();451451 if (!ri)452452 return -ENOMEM;453453-453453+454454 c = JFFS2_SB_INFO(dir_i->i_sb);455455456456- /* Try to reserve enough space for both node and dirent. 457457- * Just the node will do for now, though 456456+ /* Try to reserve enough space for both node and dirent.457457+ * Just the node will do for now, though458458 */459459 namelen = dentry->d_name.len;460460 ret = jffs2_reserve_space(c, sizeof(*ri), &phys_ofs, &alloclen, ALLOC_NORMAL,···482482483483 ri->data_crc = cpu_to_je32(0);484484 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));485485-485485+486486 fn = jffs2_write_dnode(c, f, ri, NULL, 0, phys_ofs, ALLOC_NORMAL);487487488488 jffs2_free_raw_inode(ri);···494494 jffs2_clear_inode(inode);495495 return PTR_ERR(fn);496496 }497497- /* No data here. Only a metadata node, which will be 497497+ /* No data here. Only a metadata node, which will be498498 obsoleted by the first data write499499 */500500 f->metadata = fn;···508508 jffs2_clear_inode(inode);509509 return ret;510510 }511511-511511+512512 rd = jffs2_alloc_raw_dirent();513513 if (!rd) {514514 /* Argh. Now we treat it like a normal delete */···535535 rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen));536536537537 fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL);538538-538538+539539 if (IS_ERR(fd)) {540540- /* dirent failed to write. Delete the inode normally 540540+ /* dirent failed to write. Delete the inode normally541541 as if it were the final unlink() */542542 jffs2_complete_reservation(c);543543 jffs2_free_raw_dirent(rd);···599599 ri = jffs2_alloc_raw_inode();600600 if (!ri)601601 return -ENOMEM;602602-602602+603603 c = JFFS2_SB_INFO(dir_i->i_sb);604604-604604+605605 if (S_ISBLK(mode) || S_ISCHR(mode)) {606606 dev = cpu_to_je16(old_encode_dev(rdev));607607 devlen = sizeof(dev);608608 }609609-610610- /* Try to reserve enough space for both node and dirent. 611611- * Just the node will do for now, though 609609+610610+ /* Try to reserve enough space for both node and dirent.611611+ * Just the node will do for now, though612612 */613613 namelen = dentry->d_name.len;614614 ret = jffs2_reserve_space(c, sizeof(*ri) + devlen, &phys_ofs, &alloclen,···638638 ri->compr = JFFS2_COMPR_NONE;639639 ri->data_crc = cpu_to_je32(crc32(0, &dev, devlen));640640 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));641641-641641+642642 fn = jffs2_write_dnode(c, f, ri, (char *)&dev, devlen, phys_ofs, ALLOC_NORMAL);643643644644 jffs2_free_raw_inode(ri);···650650 jffs2_clear_inode(inode);651651 return PTR_ERR(fn);652652 }653653- /* No data here. Only a metadata node, which will be 653653+ /* No data here. Only a metadata node, which will be654654 obsoleted by the first data write655655 */656656 f->metadata = fn;···694694 rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen));695695696696 fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL);697697-697697+698698 if (IS_ERR(fd)) {699699- /* dirent failed to write. Delete the inode normally 699699+ /* dirent failed to write. Delete the inode normally700700 as if it were the final unlink() */701701 jffs2_complete_reservation(c);702702 jffs2_free_raw_dirent(rd);···730730 uint8_t type;731731 uint32_t now;732732733733- /* The VFS will check for us and prevent trying to rename a 733733+ /* The VFS will check for us and prevent trying to rename a734734 * file over a directory and vice versa, but if it's a directory,735735 * the VFS can't check whether the victim is empty. The filesystem736736 * needs to do that for itself.···752752 }753753754754 /* XXX: We probably ought to alloc enough space for755755- both nodes at the same time. Writing the new link, 755755+ both nodes at the same time. Writing the new link,756756 then getting -ENOSPC, is quite bad :)757757 */758758759759 /* Make a hard link */760760-760760+761761 /* XXX: This is ugly */762762 type = (old_dentry->d_inode->i_mode & S_IFMT) >> 12;763763 if (!type) type = DT_REG;764764765765 now = get_seconds();766766- ret = jffs2_do_link(c, JFFS2_INODE_INFO(new_dir_i), 766766+ ret = jffs2_do_link(c, JFFS2_INODE_INFO(new_dir_i),767767 old_dentry->d_inode->i_ino, type,768768 new_dentry->d_name.name, new_dentry->d_name.len, now);769769···782782 }783783 }784784785785- /* If it was a directory we moved, and there was no victim, 785785+ /* If it was a directory we moved, and there was no victim,786786 increase i_nlink on its new parent */787787 if (S_ISDIR(old_dentry->d_inode->i_mode) && !victim_f)788788 new_dir_i->i_nlink++;789789790790 /* Unlink the original */791791- ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i), 791791+ ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i),792792 old_dentry->d_name.name, old_dentry->d_name.len, NULL, now);793793794794 /* We don't touch inode->i_nlink */
+14-14
fs/jffs2/erase.c
···2424 struct jffs2_eraseblock *jeb;2525 struct jffs2_sb_info *c;2626};2727-2727+2828#ifndef __ECOS2929static void jffs2_erase_callback(struct erase_info *);3030#endif···7171 instr->callback = jffs2_erase_callback;7272 instr->priv = (unsigned long)(&instr[1]);7373 instr->fail_addr = 0xffffffff;7474-7474+7575 ((struct erase_priv_struct *)instr->priv)->jeb = jeb;7676 ((struct erase_priv_struct *)instr->priv)->c = c;7777···9696 return;9797 }98989999- if (ret == -EROFS) 9999+ if (ret == -EROFS)100100 printk(KERN_WARNING "Erase at 0x%08x failed immediately: -EROFS. Is the sector locked?\n", jeb->offset);101101 else102102 printk(KERN_WARNING "Erase at 0x%08x failed immediately: errno %d\n", jeb->offset, ret);···197197 c->nr_erasing_blocks--;198198 spin_unlock(&c->erase_completion_lock);199199 wake_up(&c->erase_wait);200200-} 200200+}201201202202#ifndef __ECOS203203static void jffs2_erase_callback(struct erase_info *instr)···209209 jffs2_erase_failed(priv->c, priv->jeb, instr->fail_addr);210210 } else {211211 jffs2_erase_succeeded(priv->c, priv->jeb);212212- } 212212+ }213213 kfree(instr);214214}215215#endif /* !__ECOS */···227227 /* Walk the inode's list once, removing any nodes from this eraseblock */228228 while (1) {229229 if (!(*prev)->next_in_ino) {230230- /* We're looking at the jffs2_inode_cache, which is 230230+ /* We're looking at the jffs2_inode_cache, which is231231 at the end of the linked list. Stash it and continue232232 from the beginning of the list */233233 ic = (struct jffs2_inode_cache *)(*prev);234234 prev = &ic->nodes;235235 continue;236236- } 236236+ }237237238238 if (SECTOR_ADDR((*prev)->flash_offset) == jeb->offset) {239239 /* It's in the block we're erasing */···267267 printk(KERN_DEBUG "After remove_node_refs_from_ino_list: \n" KERN_DEBUG);268268269269 this = ic->nodes;270270-270270+271271 while(this) {272272 printk( "0x%08x(%d)->", ref_offset(this), ref_flags(this));273273 if (++i == 5) {···290290 while(jeb->first_node) {291291 ref = jeb->first_node;292292 jeb->first_node = ref->next_phys;293293-293293+294294 /* Remove from the inode-list */295295 if (ref->next_in_ino)296296 jffs2_remove_node_refs_from_ino_list(c, ref, jeb);···307307 uint32_t ofs;308308 size_t retlen;309309 int ret = -EIO;310310-310310+311311 ebuf = kmalloc(PAGE_SIZE, GFP_KERNEL);312312 if (!ebuf) {313313 printk(KERN_WARNING "Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n", jeb->offset);···361361 case -EIO: goto filebad;362362 }363363364364- /* Write the erase complete marker */ 364364+ /* Write the erase complete marker */365365 D1(printk(KERN_DEBUG "Writing erased marker to block at 0x%08x\n", jeb->offset));366366 bad_offset = jeb->offset;367367···399399 vecs[0].iov_base = (unsigned char *) ▮400400 vecs[0].iov_len = sizeof(marker);401401 ret = jffs2_flash_direct_writev(c, vecs, 1, jeb->offset, &retlen);402402-402402+403403 if (ret || retlen != sizeof(marker)) {404404 if (ret)405405 printk(KERN_WARNING "Write clean marker to block at 0x%08x failed: %d\n",···416416 marker_ref->next_phys = NULL;417417 marker_ref->flash_offset = jeb->offset | REF_NORMAL;418418 marker_ref->__totlen = c->cleanmarker_size;419419-419419+420420 jeb->first_node = jeb->last_node = marker_ref;421421-421421+422422 jeb->free_size = c->sector_size - c->cleanmarker_size;423423 jeb->used_size = c->cleanmarker_size;424424 jeb->dirty_size = 0;
+10-10
fs/jffs2/file.c
···34343535 /* Trigger GC to flush any pending writes for this inode */3636 jffs2_flush_wbuf_gc(c, inode->i_ino);3737-3838- return 0; 3737+3838+ return 0;3939}40404141struct file_operations jffs2_file_operations =···107107{108108 struct jffs2_inode_info *f = JFFS2_INODE_INFO(pg->mapping->host);109109 int ret;110110-110110+111111 down(&f->sem);112112 ret = jffs2_do_readpage_unlock(pg->mapping->host, pg);113113 up(&f->sem);···130130 struct jffs2_raw_inode ri;131131 struct jffs2_full_dnode *fn;132132 uint32_t phys_ofs, alloc_len;133133-133133+134134 D1(printk(KERN_DEBUG "Writing new hole frag 0x%x-0x%x between current EOF and new page\n",135135 (unsigned int)inode->i_size, pageofs));136136···160160 ri.compr = JFFS2_COMPR_ZERO;161161 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));162162 ri.data_crc = cpu_to_je32(0);163163-163163+164164 fn = jffs2_write_dnode(c, f, &ri, NULL, 0, phys_ofs, ALLOC_NORMAL);165165166166 if (IS_ERR(fn)) {···187187 inode->i_size = pageofs;188188 up(&f->sem);189189 }190190-190190+191191 /* Read in the page if it wasn't already present, unless it's a whole page */192192 if (!PageUptodate(pg) && (start || end < PAGE_CACHE_SIZE)) {193193 down(&f->sem);···218218 if (!start && end == PAGE_CACHE_SIZE) {219219 /* We need to avoid deadlock with page_cache_read() in220220 jffs2_garbage_collect_pass(). So we have to mark the221221- page up to date, to prevent page_cache_read() from 221221+ page up to date, to prevent page_cache_read() from222222 trying to re-lock it. */223223 SetPageUptodate(pg);224224 }···252252 /* There was an error writing. */253253 SetPageError(pg);254254 }255255-255255+256256 /* Adjust writtenlen for the padding we did, so we don't confuse our caller */257257 if (writtenlen < (start&3))258258 writtenlen = 0;···263263 if (inode->i_size < (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen) {264264 inode->i_size = (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen;265265 inode->i_blocks = (inode->i_size + 511) >> 9;266266-266266+267267 inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime));268268 }269269 }···272272273273 if (start+writtenlen < end) {274274 /* generic_file_write has written more to the page cache than we've275275- actually written to the medium. Mark the page !Uptodate so that 275275+ actually written to the medium. Mark the page !Uptodate so that276276 it gets reread */277277 D1(printk(KERN_DEBUG "jffs2_commit_write(): Not all bytes written. Marking page !uptodate\n"));278278 SetPageError(pg);
+28-28
fs/jffs2/fs.c
···4040 int ret;4141 D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino));4242 ret = inode_change_ok(inode, iattr);4343- if (ret) 4343+ if (ret)4444 return ret;45454646 /* Special cases - we don't want more than one data node···7373 kfree(mdata);7474 return -ENOMEM;7575 }7676-7676+7777 ret = jffs2_reserve_space(c, sizeof(*ri) + mdatalen, &phys_ofs, &alloclen,7878 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);7979 if (ret) {···8484 }8585 down(&f->sem);8686 ivalid = iattr->ia_valid;8787-8787+8888 ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);8989 ri->nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);9090 ri->totlen = cpu_to_je32(sizeof(*ri) + mdatalen);···100100 if (iattr->ia_mode & S_ISGID &&101101 !in_group_p(je16_to_cpu(ri->gid)) && !capable(CAP_FSETID))102102 ri->mode = cpu_to_jemode(iattr->ia_mode & ~S_ISGID);103103- else 103103+ else104104 ri->mode = cpu_to_jemode(iattr->ia_mode);105105 else106106 ri->mode = cpu_to_jemode(inode->i_mode);···129129 new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, phys_ofs, ALLOC_NORMAL);130130 if (S_ISLNK(inode->i_mode))131131 kfree(mdata);132132-132132+133133 if (IS_ERR(new_metadata)) {134134 jffs2_complete_reservation(c);135135 jffs2_free_raw_inode(ri);···167167 jffs2_complete_reservation(c);168168169169 /* We have to do the vmtruncate() without f->sem held, since170170- some pages may be locked and waiting for it in readpage(). 170170+ some pages may be locked and waiting for it in readpage().171171 We are protected from a simultaneous write() extending i_size172172 back past iattr->ia_size, because do_truncate() holds the173173 generic inode semaphore. */···210210211211void jffs2_clear_inode (struct inode *inode)212212{213213- /* We can forget about this inode for now - drop all 213213+ /* We can forget about this inode for now - drop all214214 * the nodelists associated with it, etc.215215 */216216 struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);217217 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);218218-218218+219219 D1(printk(KERN_DEBUG "jffs2_clear_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode));220220221221 jffs2_do_clear_inode(c, f);···234234 c = JFFS2_SB_INFO(inode->i_sb);235235236236 jffs2_init_inode_info(f);237237-237237+238238 ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node);239239240240 if (ret) {···254254255255 inode->i_blksize = PAGE_SIZE;256256 inode->i_blocks = (inode->i_size + 511) >> 9;257257-257257+258258 switch (inode->i_mode & S_IFMT) {259259 jint16_t rdev;260260261261 case S_IFLNK:262262 inode->i_op = &jffs2_symlink_inode_operations;263263 break;264264-264264+265265 case S_IFDIR:266266 {267267 struct jffs2_full_dirent *fd;···298298 jffs2_do_clear_inode(c, f);299299 make_bad_inode(inode);300300 return;301301- } 301301+ }302302303303 case S_IFSOCK:304304 case S_IFIFO:···354354 down(&c->alloc_sem);355355 jffs2_flush_wbuf_pad(c);356356 up(&c->alloc_sem);357357- } 357357+ }358358359359 if (!(*flags & MS_RDONLY))360360 jffs2_start_garbage_collect_thread(c);361361-361361+362362 *flags |= MS_NOATIME;363363364364 return 0;···392392 D1(printk(KERN_DEBUG "jffs2_new_inode(): dir_i %ld, mode 0x%x\n", dir_i->i_ino, mode));393393394394 c = JFFS2_SB_INFO(sb);395395-395395+396396 inode = new_inode(sb);397397-397397+398398 if (!inode)399399 return ERR_PTR(-ENOMEM);400400···458458#endif459459460460 c->flash_size = c->mtd->size;461461- c->sector_size = c->mtd->erasesize; 461461+ c->sector_size = c->mtd->erasesize;462462 blocks = c->flash_size / c->sector_size;463463464464 /*465465 * Size alignment check466466 */467467 if ((c->sector_size * blocks) != c->flash_size) {468468- c->flash_size = c->sector_size * blocks; 468468+ c->flash_size = c->sector_size * blocks;469469 printk(KERN_INFO "jffs2: Flash size not aligned to erasesize, reducing to %dKiB\n",470470 c->flash_size / 1024);471471 }···543543 struct jffs2_inode_cache *ic;544544 if (!nlink) {545545 /* The inode has zero nlink but its nodes weren't yet marked546546- obsolete. This has to be because we're still waiting for 546546+ obsolete. This has to be because we're still waiting for547547 the final (close() and) iput() to happen.548548549549- There's a possibility that the final iput() could have 549549+ There's a possibility that the final iput() could have550550 happened while we were contemplating. In order to ensure551551 that we don't cause a new read_inode() (which would fail)552552 for the inode in question, we use ilookup() in this case553553 instead of iget().554554555555- The nlink can't _become_ zero at this point because we're 555555+ The nlink can't _become_ zero at this point because we're556556 holding the alloc_sem, and jffs2_do_unlink() would also557557 need that while decrementing nlink on any inode.558558 */···599599 return JFFS2_INODE_INFO(inode);600600}601601602602-unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, 603603- struct jffs2_inode_info *f, 602602+unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c,603603+ struct jffs2_inode_info *f,604604 unsigned long offset,605605 unsigned long *priv)606606{607607 struct inode *inode = OFNI_EDONI_2SFFJ(f);608608 struct page *pg;609609610610- pg = read_cache_page(inode->i_mapping, offset >> PAGE_CACHE_SHIFT, 610610+ pg = read_cache_page(inode->i_mapping, offset >> PAGE_CACHE_SHIFT,611611 (void *)jffs2_do_readpage_unlock, inode);612612 if (IS_ERR(pg))613613 return (void *)pg;614614-614614+615615 *priv = (unsigned long)pg;616616 return kmap(pg);617617}···628628629629static int jffs2_flash_setup(struct jffs2_sb_info *c) {630630 int ret = 0;631631-631631+632632 if (jffs2_cleanmarker_oob(c)) {633633 /* NAND flash... do setup accordingly */634634 ret = jffs2_nand_flash_setup(c);···642642 if (ret)643643 return ret;644644 }645645-645645+646646 /* and Dataflash */647647 if (jffs2_dataflash(c)) {648648 ret = jffs2_dataflash_setup(c);···670670 if (jffs2_nor_ecc(c)) {671671 jffs2_nor_ecc_flash_cleanup(c);672672 }673673-673673+674674 /* and DataFlash */675675 if (jffs2_dataflash(c)) {676676 jffs2_dataflash_cleanup(c);
+56-56
fs/jffs2/gc.c
···77 *88 * For licensing information, see the file 'LICENCE' in this directory.99 *1010- * $Id: gc.c,v 1.154 2005/09/07 08:34:54 havasi Exp $1010+ * $Id: gc.c,v 1.155 2005/11/07 11:14:39 gleixner Exp $1111 *1212 */1313···2121#include "nodelist.h"2222#include "compr.h"23232424-static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, 2424+static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,2525 struct jffs2_inode_cache *ic,2626 struct jffs2_raw_node_ref *raw);2727-static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 2727+static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,2828 struct jffs2_inode_info *f, struct jffs2_full_dnode *fd);2929-static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 2929+static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,3030 struct jffs2_inode_info *f, struct jffs2_full_dirent *fd);3131-static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 3131+static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,3232 struct jffs2_inode_info *f, struct jffs2_full_dirent *fd);3333static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,3434 struct jffs2_inode_info *f, struct jffs2_full_dnode *fn,···5555 D1(printk(KERN_DEBUG "Picking block from bad_used_list to GC next\n"));5656 nextlist = &c->bad_used_list;5757 } else if (n < 50 && !list_empty(&c->erasable_list)) {5858- /* Note that most of them will have gone directly to be erased. 5858+ /* Note that most of them will have gone directly to be erased.5959 So don't favour the erasable_list _too_ much. */6060 D1(printk(KERN_DEBUG "Picking block from erasable_list to GC next\n"));6161 nextlist = &c->erasable_list;···101101 printk(KERN_WARNING "Eep. ret->gc_node for block at 0x%08x is NULL\n", ret->offset);102102 BUG();103103 }104104-104104+105105 /* Have we accidentally picked a clean block with wasted space ? */106106 if (ret->wasted_size) {107107 D1(printk(KERN_DEBUG "Converting wasted_size %08x to dirty_size\n", ret->wasted_size));···136136137137 /* We can't start doing GC yet. We haven't finished checking138138 the node CRCs etc. Do it now. */139139-139139+140140 /* checked_ino is protected by the alloc_sem */141141 if (c->checked_ino > c->highest_ino) {142142 printk(KERN_CRIT "Checked all inodes but still 0x%x bytes of unchecked space?\n",···178178179179 case INO_STATE_READING:180180 /* We need to wait for it to finish, lest we move on181181- and trigger the BUG() above while we haven't yet 181181+ and trigger the BUG() above while we haven't yet182182 finished checking all its nodes */183183 D1(printk(KERN_DEBUG "Waiting for ino #%u to finish reading\n", ic->ino));184184 up(&c->alloc_sem);···228228 }229229230230 raw = jeb->gc_node;231231-231231+232232 while(ref_obsolete(raw)) {233233 D1(printk(KERN_DEBUG "Node at 0x%08x is obsolete... skipping\n", ref_offset(raw)));234234 raw = raw->next_phys;235235 if (unlikely(!raw)) {236236 printk(KERN_WARNING "eep. End of raw list while still supposedly nodes to GC\n");237237- printk(KERN_WARNING "erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n", 237237+ printk(KERN_WARNING "erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n",238238 jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size);239239 jeb->gc_node = raw;240240 spin_unlock(&c->erase_completion_lock);···259259 ic = jffs2_raw_ref_to_ic(raw);260260261261 /* We need to hold the inocache. Either the erase_completion_lock or262262- the inocache_lock are sufficient; we trade down since the inocache_lock 262262+ the inocache_lock are sufficient; we trade down since the inocache_lock263263 causes less contention. */264264 spin_lock(&c->inocache_lock);265265···278278279279 switch(ic->state) {280280 case INO_STATE_CHECKEDABSENT:281281- /* It's been checked, but it's not currently in-core. 281281+ /* It's been checked, but it's not currently in-core.282282 We can just copy any pristine nodes, but have283283 to prevent anyone else from doing read_inode() while284284 we're at it, so we set the state accordingly */285285 if (ref_flags(raw) == REF_PRISTINE)286286 ic->state = INO_STATE_GC;287287 else {288288- D1(printk(KERN_DEBUG "Ino #%u is absent but node not REF_PRISTINE. Reading.\n", 288288+ D1(printk(KERN_DEBUG "Ino #%u is absent but node not REF_PRISTINE. Reading.\n",289289 ic->ino));290290 }291291 break;···298298 case INO_STATE_CHECKING:299299 case INO_STATE_GC:300300 /* Should never happen. We should have finished checking301301- by the time we actually start doing any GC, and since 302302- we're holding the alloc_sem, no other garbage collection 301301+ by the time we actually start doing any GC, and since302302+ we're holding the alloc_sem, no other garbage collection303303 can happen.304304 */305305 printk(KERN_CRIT "Inode #%u already in state %d in jffs2_garbage_collect_pass()!\n",···319319 D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() waiting for ino #%u in state %d\n",320320 ic->ino, ic->state));321321 sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock);322322- /* And because we dropped the alloc_sem we must start again from the 322322+ /* And because we dropped the alloc_sem we must start again from the323323 beginning. Ponder chance of livelock here -- we're returning success324324 without actually making any progress.325325326326- Q: What are the chances that the inode is back in INO_STATE_READING 326326+ Q: What are the chances that the inode is back in INO_STATE_READING327327 again by the time we next enter this function? And that this happens328328 enough times to cause a real delay?329329330330- A: Small enough that I don't care :) 330330+ A: Small enough that I don't care :)331331 */332332 return 0;333333 }334334335335 /* OK. Now if the inode is in state INO_STATE_GC, we are going to copy the336336- node intact, and we don't have to muck about with the fragtree etc. 336336+ node intact, and we don't have to muck about with the fragtree etc.337337 because we know it's not in-core. If it _was_ in-core, we go through338338 all the iget() crap anyway */339339···453453 if (!ret) {454454 /* Urgh. Return it sensibly. */455455 frag->node->raw = f->inocache->nodes;456456- } 456456+ }457457 if (ret != -EBADFD)458458 goto upnout;459459 }···467467 }468468 goto upnout;469469 }470470-470470+471471 /* Wasn't a dnode. Try dirent */472472 for (fd = f->dents; fd; fd=fd->next) {473473 if (fd->raw == raw)···494494 return ret;495495}496496497497-static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, 497497+static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,498498 struct jffs2_inode_cache *ic,499499 struct jffs2_raw_node_ref *raw)500500{···580580 }581581 break;582582 default:583583- printk(KERN_WARNING "Unknown node type for REF_PRISTINE node at 0x%08x: 0x%04x\n", 583583+ printk(KERN_WARNING "Unknown node type for REF_PRISTINE node at 0x%08x: 0x%04x\n",584584 ref_offset(raw), je16_to_cpu(node->u.nodetype));585585 goto bail;586586 }···621621 retried = 1;622622623623 D1(printk(KERN_DEBUG "Retrying failed write of REF_PRISTINE node.\n"));624624-624624+625625 jffs2_dbg_acct_sanity_check(c,jeb);626626 jffs2_dbg_acct_paranoia_check(c, jeb);627627···669669 goto out_node;670670}671671672672-static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 672672+static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,673673 struct jffs2_inode_info *f, struct jffs2_full_dnode *fn)674674{675675 struct jffs2_full_dnode *new_fn;···684684 S_ISCHR(JFFS2_F_I_MODE(f)) ) {685685 /* For these, we don't actually need to read the old node */686686 /* FIXME: for minor or major > 255. */687687- dev = cpu_to_je16(((JFFS2_F_I_RDEV_MAJ(f) << 8) | 687687+ dev = cpu_to_je16(((JFFS2_F_I_RDEV_MAJ(f) << 8) |688688 JFFS2_F_I_RDEV_MIN(f)));689689 mdata = (char *)&dev;690690 mdatalen = sizeof(dev);···705705 D1(printk(KERN_DEBUG "jffs2_garbage_collect_metadata(): Writing %d bites of symlink target\n", mdatalen));706706707707 }708708-708708+709709 ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &phys_ofs, &alloclen,710710 JFFS2_SUMMARY_INODE_SIZE);711711 if (ret) {···713713 sizeof(ri)+ mdatalen, ret);714714 goto out;715715 }716716-716716+717717 last_frag = frag_last(&f->fragtree);718718 if (last_frag)719719 /* Fetch the inode length from the fragtree rather then···721721 ilen = last_frag->ofs + last_frag->size;722722 else723723 ilen = JFFS2_F_I_SIZE(f);724724-724724+725725 memset(&ri, 0, sizeof(ri));726726 ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);727727 ri.nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);···760760 return ret;761761}762762763763-static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 763763+static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,764764 struct jffs2_inode_info *f, struct jffs2_full_dirent *fd)765765{766766 struct jffs2_full_dirent *new_fd;···781781 so refrain from splatting them. */782782 if (JFFS2_F_I_MTIME(f) == JFFS2_F_I_CTIME(f))783783 rd.mctime = cpu_to_je32(JFFS2_F_I_MTIME(f));784784- else 784784+ else785785 rd.mctime = cpu_to_je32(0);786786 rd.type = fd->type;787787 rd.node_crc = cpu_to_je32(crc32(0, &rd, sizeof(rd)-8));788788 rd.name_crc = cpu_to_je32(crc32(0, fd->name, rd.nsize));789789-789789+790790 ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &phys_ofs, &alloclen,791791 JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize));792792 if (ret) {···804804 return 0;805805}806806807807-static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 807807+static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,808808 struct jffs2_inode_info *f, struct jffs2_full_dirent *fd)809809{810810 struct jffs2_full_dirent **fdp = &f->dents;···843843 if (ref_totlen(c, NULL, raw) != rawlen)844844 continue;845845846846- /* Doesn't matter if there's one in the same erase block. We're going to 846846+ /* Doesn't matter if there's one in the same erase block. We're going to847847 delete it too at the same time. */848848 if (SECTOR_ADDR(raw->flash_offset) == SECTOR_ADDR(fd->raw->flash_offset))849849 continue;···895895 kfree(rd);896896 }897897898898- /* FIXME: If we're deleting a dirent which contains the current mtime and ctime, 898898+ /* FIXME: If we're deleting a dirent which contains the current mtime and ctime,899899 we should update the metadata node with those times accordingly */900900901901 /* No need for it any more. Just mark it obsolete and remove it from the list */···927927928928 D1(printk(KERN_DEBUG "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n",929929 f->inocache->ino, start, end));930930-930930+931931 memset(&ri, 0, sizeof(ri));932932933933 if(fn->frags > 1) {934934 size_t readlen;935935 uint32_t crc;936936- /* It's partially obsoleted by a later write. So we have to 936936+ /* It's partially obsoleted by a later write. So we have to937937 write it out again with the _same_ version as before */938938 ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (char *)&ri);939939 if (readlen != sizeof(ri) || ret) {···955955 crc = crc32(0, &ri, sizeof(ri)-8);956956 if (crc != je32_to_cpu(ri.node_crc)) {957957 printk(KERN_WARNING "jffs2_garbage_collect_hole: Node at 0x%08x had CRC 0x%08x which doesn't match calculated CRC 0x%08x\n",958958- ref_offset(fn->raw), 958958+ ref_offset(fn->raw),959959 je32_to_cpu(ri.node_crc), crc);960960 /* FIXME: We could possibly deal with this by writing new holes for each frag */961961- printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", 961961+ printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n",962962 start, end, f->inocache->ino);963963 goto fill;964964 }965965 if (ri.compr != JFFS2_COMPR_ZERO) {966966 printk(KERN_WARNING "jffs2_garbage_collect_hole: Node 0x%08x wasn't a hole node!\n", ref_offset(fn->raw));967967- printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", 967967+ printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n",968968 start, end, f->inocache->ino);969969 goto fill;970970 }···982982 ri.csize = cpu_to_je32(0);983983 ri.compr = JFFS2_COMPR_ZERO;984984 }985985-985985+986986 frag = frag_last(&f->fragtree);987987 if (frag)988988 /* Fetch the inode length from the fragtree rather then···10241024 return 0;10251025 }1026102610271027- /* 10271027+ /*10281028 * We should only get here in the case where the node we are10291029 * replacing had more than one frag, so we kept the same version10301030- * number as before. (Except in case of error -- see 'goto fill;' 10301030+ * number as before. (Except in case of error -- see 'goto fill;'10311031 * above.)10321032 */10331033 D1(if(unlikely(fn->frags <= 1)) {···10391039 /* This is a partially-overlapped hole node. Mark it REF_NORMAL not REF_PRISTINE */10401040 mark_ref_normal(new_fn->raw);1041104110421042- for (frag = jffs2_lookup_node_frag(&f->fragtree, fn->ofs); 10421042+ for (frag = jffs2_lookup_node_frag(&f->fragtree, fn->ofs);10431043 frag; frag = frag_next(frag)) {10441044 if (frag->ofs > fn->size + fn->ofs)10451045 break;···10571057 printk(KERN_WARNING "jffs2_garbage_collect_hole: New node has no frags!\n");10581058 BUG();10591059 }10601060-10601060+10611061 jffs2_mark_node_obsolete(c, fn->raw);10621062 jffs2_free_full_dnode(fn);10631063-10631063+10641064 return 0;10651065}10661066···10701070{10711071 struct jffs2_full_dnode *new_fn;10721072 struct jffs2_raw_inode ri;10731073- uint32_t alloclen, phys_ofs, offset, orig_end, orig_start; 10731073+ uint32_t alloclen, phys_ofs, offset, orig_end, orig_start;10741074 int ret = 0;10751075 unsigned char *comprbuf = NULL, *writebuf;10761076 unsigned long pg;10771077 unsigned char *pg_ptr;10781078-10781078+10791079 memset(&ri, 0, sizeof(ri));1080108010811081 D1(printk(KERN_DEBUG "Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n",···10871087 if (c->nr_free_blocks + c->nr_erasing_blocks > c->resv_blocks_gcmerge) {10881088 /* Attempt to do some merging. But only expand to cover logically10891089 adjacent frags if the block containing them is already considered10901090- to be dirty. Otherwise we end up with GC just going round in 10911091- circles dirtying the nodes it already wrote out, especially 10901090+ to be dirty. Otherwise we end up with GC just going round in10911091+ circles dirtying the nodes it already wrote out, especially10921092 on NAND where we have small eraseblocks and hence a much higher10931093 chance of nodes having to be split to cross boundaries. */10941094···11221122 break;11231123 } else {1124112411251125- /* OK, it's a frag which extends to the beginning of the page. Does it live 11251125+ /* OK, it's a frag which extends to the beginning of the page. Does it live11261126 in a block which is still considered clean? If so, don't obsolete it.11271127 If not, cover it anyway. */11281128···11721172 break;11731173 } else {1174117411751175- /* OK, it's a frag which extends to the beginning of the page. Does it live 11751175+ /* OK, it's a frag which extends to the beginning of the page. Does it live11761176 in a block which is still considered clean? If so, don't obsolete it.11771177 If not, cover it anyway. */11781178···11991199 break;12001200 }12011201 }12021202- D1(printk(KERN_DEBUG "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n", 12021202+ D1(printk(KERN_DEBUG "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n",12031203 orig_start, orig_end, start, end));1204120412051205 D1(BUG_ON(end > frag_last(&f->fragtree)->ofs + frag_last(&f->fragtree)->size));12061206 BUG_ON(end < orig_end);12071207 BUG_ON(start > orig_start);12081208 }12091209-12091209+12101210 /* First, use readpage() to read the appropriate page into the page cache */12111211 /* Q: What happens if we actually try to GC the _same_ page for which commit_write()12121212 * triggered garbage collection in the first place?···12631263 ri.usercompr = (comprtype >> 8) & 0xff;12641264 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));12651265 ri.data_crc = cpu_to_je32(crc32(0, comprbuf, cdatalen));12661266-12661266+12671267 new_fn = jffs2_write_dnode(c, f, &ri, comprbuf, cdatalen, phys_ofs, ALLOC_GC);1268126812691269 jffs2_free_comprbuf(comprbuf, writebuf);
+1-1
fs/jffs2/histo.h
···11/* This file provides the bit-probabilities for the input file */22-#define BIT_DIVIDER 629 22+#define BIT_DIVIDER 62933static int bits[9] = { 179,167,183,165,159,198,178,119,}; /* ia32 .so files */
···77 *88 * For licensing information, see the file 'LICENCE' in this directory.99 *1010- * $Id: ioctl.c,v 1.9 2004/11/16 20:36:11 dwmw2 Exp $1010+ * $Id: ioctl.c,v 1.10 2005/11/07 11:14:40 gleixner Exp $1111 *1212 */13131414#include <linux/fs.h>15151616-int jffs2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 1616+int jffs2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,1717 unsigned long arg)1818{1919 /* Later, this will provide for lsattr.jffs2 and chattr.jffs2, which2020 will include compression support etc. */2121 return -ENOTTY;2222}2323-2323+
+2-2
fs/jffs2/malloc.c
···77 *88 * For licensing information, see the file 'LICENCE' in this directory.99 *1010- * $Id: malloc.c,v 1.30 2005/09/20 14:27:34 dedekind Exp $1010+ * $Id: malloc.c,v 1.31 2005/11/07 11:14:40 gleixner Exp $1111 *1212 */1313···29293030int __init jffs2_create_slab_caches(void)3131{3232- full_dnode_slab = kmem_cache_create("jffs2_full_dnode", 3232+ full_dnode_slab = kmem_cache_create("jffs2_full_dnode",3333 sizeof(struct jffs2_full_dnode),3434 0, 0, NULL, NULL);3535 if (!full_dnode_slab)
+85-85
fs/jffs2/nodelist.c
···77 *88 * For licensing information, see the file 'LICENCE' in this directory.99 *1010- * $Id: nodelist.c,v 1.114 2005/09/21 13:28:35 dedekind Exp $1010+ * $Id: nodelist.c,v 1.115 2005/11/07 11:14:40 gleixner Exp $1111 *1212 */1313···2424void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new, struct jffs2_full_dirent **list)2525{2626 struct jffs2_full_dirent **prev = list;2727-2727+2828 dbg_dentlist("add dirent \"%s\", ino #%u\n", new->name, new->ino);29293030 while ((*prev) && (*prev)->nhash <= new->nhash) {···7575 if (size == 0)7676 return;77777878- /* 7878+ /*7979 * If the last fragment starts at the RAM page boundary, it is8080 * REF_PRISTINE irrespective of its size.8181 */8282 frag = frag_last(list);8383 if (frag->node && (frag->ofs & (PAGE_CACHE_SIZE - 1)) == 0) {8484 dbg_fragtree2("marking the last fragment 0x%08x-0x%08x REF_PRISTINE.\n",8585- frag->ofs, frag->ofs + frag->size); 8585+ frag->ofs, frag->ofs + frag->size);8686 frag->node->raw->flash_offset = ref_offset(frag->node->raw) | REF_PRISTINE;8787 }8888}···102102 ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size, this->node->frags);103103 mark_ref_normal(this->node->raw);104104 }105105-105105+106106 }107107 jffs2_free_node_frag(this);108108}···117117 while (*link) {118118 parent = *link;119119 base = rb_entry(parent, struct jffs2_node_frag, rb);120120-120120+121121 if (newfrag->ofs > base->ofs)122122 link = &base->rb.rb_right;123123 else if (newfrag->ofs < base->ofs)···137137static inline struct jffs2_node_frag * new_fragment(struct jffs2_full_dnode *fn, uint32_t ofs, uint32_t size)138138{139139 struct jffs2_node_frag *newfrag;140140-140140+141141 newfrag = jffs2_alloc_node_frag();142142 if (likely(newfrag)) {143143 newfrag->ofs = ofs;···169169 }170170171171 if (this) {172172- /* By definition, the 'this' node has no right-hand child, 172172+ /* By definition, the 'this' node has no right-hand child,173173 because there are no frags with offset greater than it.174174 So that's where we want to put the hole */175175 dbg_fragtree2("add hole frag %#04x-%#04x on the right of the new frag.\n",···183183 rb_insert_color(&holefrag->rb, root);184184 this = holefrag;185185 }186186-186186+187187 if (this) {188188- /* By definition, the 'this' node has no right-hand child, 188188+ /* By definition, the 'this' node has no right-hand child,189189 because there are no frags with offset greater than it.190190 So that's where we want to put new fragment */191191 dbg_fragtree2("add the new node at the right\n");192192- rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); 192192+ rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right);193193 } else {194194 dbg_fragtree2("insert the new node at the root of the tree\n");195195 rb_link_node(&newfrag->rb, NULL, &root->rb_node);···216216 dbg_fragtree2("lookup gave no frag\n");217217 lastend = 0;218218 }219219-219219+220220 /* See if we ran off the end of the fragtree */221221 if (lastend <= newfrag->ofs) {222222 /* We did */···243243 this->ofs, this->ofs + this->size);244244245245 /* OK. 'this' is pointing at the first frag that newfrag->ofs at least partially obsoletes,246246- * - i.e. newfrag->ofs < this->ofs+this->size && newfrag->ofs >= this->ofs 246246+ * - i.e. newfrag->ofs < this->ofs+this->size && newfrag->ofs >= this->ofs247247 */248248 if (newfrag->ofs > this->ofs) {249249 /* This node isn't completely obsoleted. The start of it remains valid */···261261 if (this->node)262262 dbg_fragtree2("split old frag 0x%04x-0x%04x, phys 0x%08x\n",263263 this->ofs, this->ofs+this->size, ref_offset(this->node->raw));264264- else 264264+ else265265 dbg_fragtree2("split old hole frag 0x%04x-0x%04x\n",266266 this->ofs, this->ofs+this->size);267267-267267+268268 /* New second frag pointing to this's node */269269 newfrag2 = new_fragment(this->node, newfrag->ofs + newfrag->size,270270 this->ofs + this->size - newfrag->ofs - newfrag->size);···284284 from newfrag to insert newfrag2. */285285 jffs2_fragtree_insert(newfrag, this);286286 rb_insert_color(&newfrag->rb, root);287287-287287+288288 jffs2_fragtree_insert(newfrag2, newfrag);289289 rb_insert_color(&newfrag2->rb, root);290290-290290+291291 return 0;292292 }293293 /* New node just reduces 'this' frag in size, doesn't split it */···297297 jffs2_fragtree_insert(newfrag, this);298298 rb_insert_color(&newfrag->rb, root);299299 } else {300300- /* New frag starts at the same point as 'this' used to. Replace 300300+ /* New frag starts at the same point as 'this' used to. Replace301301 it in the tree without doing a delete and insertion */302302 dbg_fragtree2("inserting newfrag (*%p),%d-%d in before 'this' (*%p),%d-%d\n",303303 newfrag, newfrag->ofs, newfrag->ofs+newfrag->size, this, this->ofs, this->ofs+this->size);304304-304304+305305 rb_replace_node(&this->rb, &newfrag->rb, root);306306-306306+307307 if (newfrag->ofs + newfrag->size >= this->ofs+this->size) {308308 dbg_fragtree2("obsoleting node frag %p (%x-%x)\n", this, this->ofs, this->ofs+this->size);309309 jffs2_obsolete_node_frag(c, this);···317317 }318318 }319319 /* OK, now we have newfrag added in the correct place in the tree, but320320- frag_next(newfrag) may be a fragment which is overlapped by it 320320+ frag_next(newfrag) may be a fragment which is overlapped by it321321 */322322 while ((this = frag_next(newfrag)) && newfrag->ofs + newfrag->size >= this->ofs + this->size) {323323 /* 'this' frag is obsoleted completely. */···326326 rb_erase(&this->rb, root);327327 jffs2_obsolete_node_frag(c, this);328328 }329329- /* Now we're pointing at the first frag which isn't totally obsoleted by 329329+ /* Now we're pointing at the first frag which isn't totally obsoleted by330330 the new frag */331331332332 if (!this || newfrag->ofs + newfrag->size == this->ofs)···344344 return 0;345345}346346347347-/* 347347+/*348348 * Given an inode, probably with existing tree of fragments, add the new node349349 * to the fragment tree.350350 */···363363364364 dbg_fragtree("adding node %#04x-%#04x @0x%08x on flash, newfrag *%p\n",365365 fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag);366366-366366+367367 ret = jffs2_add_frag_to_fragtree(c, &f->fragtree, newfrag);368368 if (unlikely(ret))369369 return ret;···374374 struct jffs2_node_frag *prev = frag_prev(newfrag);375375376376 mark_ref_normal(fn->raw);377377- /* If we don't start at zero there's _always_ a previous */ 377377+ /* If we don't start at zero there's _always_ a previous */378378 if (prev->node)379379 mark_ref_normal(prev->node->raw);380380 }381381382382 if ((newfrag->ofs+newfrag->size) & (PAGE_CACHE_SIZE-1)) {383383 struct jffs2_node_frag *next = frag_next(newfrag);384384-384384+385385 if (next) {386386 mark_ref_normal(fn->raw);387387 if (next->node)···412412413413 if (!jffs2_is_writebuffered(c))414414 goto adj_acc;415415-415415+416416 /* Calculate how many bytes were already checked */417417 ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode);418418 len = ofs % c->wbuf_pagesize;···424424 ref_offset(ref), tn->csize, ofs);425425 goto adj_acc;426426 }427427-427427+428428 ofs += len;429429 len = tn->csize - len;430430-430430+431431 dbg_readinode("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n",432432 ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len);433433-433433+434434#ifndef __ECOS435435 /* TODO: instead, incapsulate point() stuff to jffs2_flash_read(),436436 * adding and jffs2_flash_read_end() interface. */···445445 pointed = 1; /* succefully pointed to device */446446 }447447#endif448448-448448+449449 if (!pointed) {450450 buffer = kmalloc(len, GFP_KERNEL);451451 if (unlikely(!buffer))452452 return -ENOMEM;453453-453453+454454 /* TODO: this is very frequent pattern, make it a separate455455 * routine */456456 err = jffs2_flash_read(c, ofs, len, &retlen, buffer);···458458 JFFS2_ERROR("can not read %d bytes from 0x%08x, error code: %d.\n", len, ofs, err);459459 goto free_out;460460 }461461-461461+462462 if (retlen != len) {463463 JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", ofs, retlen, len);464464 err = -EIO;···485485 jeb = &c->blocks[ref->flash_offset / c->sector_size];486486 len = ref_totlen(c, jeb, ref);487487488488- /* 488488+ /*489489 * Mark the node as having been checked and fix the490490 * accounting accordingly.491491 */···516516static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn)517517{518518 int ret;519519-519519+520520 BUG_ON(ref_obsolete(tn->fn->raw));521521522522 /* We only check the data CRC of unchecked nodes */523523 if (ref_flags(tn->fn->raw) != REF_UNCHECKED)524524 return 0;525525-525525+526526 dbg_fragtree2("check node %#04x-%#04x, phys offs %#08x.\n",527527 tn->fn->ofs, tn->fn->ofs + tn->fn->size, ref_offset(tn->fn->raw));528528···538538 return ret;539539}540540541541-/* 541541+/*542542 * Helper function for jffs2_add_older_frag_to_fragtree().543543 *544544 * Called when the new fragment that is being inserted···551551 newfrag->ofs, newfrag->ofs + newfrag->size, hole->ofs, hole->ofs + hole->size);552552553553 if (hole->ofs == newfrag->ofs) {554554- /* 554554+ /*555555 * Well, the new fragment actually starts at the same offset as556556 * the hole.557557 */558558 if (hole->ofs + hole->size > newfrag->ofs + newfrag->size) {559559- /* 559559+ /*560560 * We replace the overlapped left part of the hole by561561 * the new node.562562 */563563-563563+564564 dbg_fragtree2("insert fragment %#04x-%#04x and cut the left part of the hole\n",565565 newfrag->ofs, newfrag->ofs + newfrag->size);566566 rb_replace_node(&hole->rb, &newfrag->rb, root);567567-567567+568568 hole->ofs += newfrag->size;569569 hole->size -= newfrag->size;570570-571571- /* 570570+571571+ /*572572 * We know that 'hole' should be the right hand573573 * fragment.574574 */575575 jffs2_fragtree_insert(hole, newfrag);576576 rb_insert_color(&hole->rb, root);577577 } else {578578- /* 578578+ /*579579 * Ah, the new fragment is of the same size as the hole.580580 * Relace the hole by it.581581 */···586586 }587587 } else {588588 /* The new fragment lefts some hole space at the left */589589-589589+590590 struct jffs2_node_frag * newfrag2 = NULL;591591592592 if (hole->ofs + hole->size > newfrag->ofs + newfrag->size) {···606606607607 jffs2_fragtree_insert(newfrag, hole);608608 rb_insert_color(&newfrag->rb, root);609609-609609+610610 if (newfrag2) {611611 dbg_fragtree2("left the hole %#04x-%#04x at the right\n",612612 newfrag2->ofs, newfrag2->ofs + newfrag2->size);···654654 lastend = this->ofs + this->size;655655 else656656 lastend = 0;657657-657657+658658 /* Detect the preliminary type of node */659659 if (fn->size >= PAGE_CACHE_SIZE)660660 ref_flag = REF_PRISTINE;661661 else662662 ref_flag = REF_NORMAL;663663-663663+664664 /* See if we ran off the end of the root */665665 if (lastend <= fn_ofs) {666666 /* We did */667667-668668- /* 667667+668668+ /*669669 * We are going to insert the new node into the670670 * fragment tree, so check it.671671 */···691691 fn->frags = 0;692692693693 while (1) {694694- /* 694694+ /*695695 * Here we have:696696 * fn_ofs < this->ofs + this->size && fn_ofs >= this->ofs.697697- * 697697+ *698698 * Remember, 'this' has higher version, any non-hole node699699 * which is already in the fragtree is newer then the newly700700 * inserted.701701 */702702 if (!this->node) {703703- /* 703703+ /*704704 * 'this' is the hole fragment, so at least the705705 * beginning of the new fragment is valid.706706 */707707-708708- /* 707707+708708+ /*709709 * We are going to insert the new node into the710710 * fragment tree, so check it.711711 */···715715 return err;716716 checked = 1;717717 }718718-718718+719719 if (this->ofs + this->size >= fn_ofs + fn_size) {720720 /* We split the hole on two parts */721721···730730 goto out_ok;731731 }732732733733- /* 733733+ /*734734 * The beginning of the new fragment is valid since it735735 * overlaps the hole node.736736 */···742742 this->ofs + this->size - fn_ofs);743743 if (unlikely(!newfrag))744744 return -ENOMEM;745745-745745+746746 if (fn_ofs == this->ofs) {747747- /* 747747+ /*748748 * The new node starts at the same offset as749749 * the hole and supersieds the hole.750750 */···754754 rb_replace_node(&this->rb, &newfrag->rb, root);755755 jffs2_free_node_frag(this);756756 } else {757757- /* 757757+ /*758758 * The hole becomes shorter as its right part759759 * is supersieded by the new fragment.760760 */761761 dbg_fragtree2("reduce size of hole %#04x-%#04x to %#04x-%#04x\n",762762 this->ofs, this->ofs + this->size, this->ofs, this->ofs + this->size - newfrag->size);763763-763763+764764 dbg_fragtree2("add new fragment %#04x-%#04x, refcnt %d\n", fn_ofs,765765 fn_ofs + this->ofs + this->size - fn_ofs, fn->frags);766766-766766+767767 this->size -= newfrag->size;768768 jffs2_fragtree_insert(newfrag, this);769769 rb_insert_color(&newfrag->rb, root);770770 }771771-771771+772772 fn_ofs += newfrag->size;773773 fn_size -= newfrag->size;774774 this = rb_entry(rb_next(&newfrag->rb),···778778 this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)");779779 }780780781781- /* 781781+ /*782782 * 'This' node is not the hole so it obsoletes the new fragment783783 * either fully or partially.784784 */···791791 goto out_ok;792792 } else {793793 struct jffs2_node_frag *new_this;794794-794794+795795 /* 'This' node obsoletes the beginning of the new node */796796 dbg_fragtree2("the beginning %#04x-%#04x is obsolete\n", fn_ofs, this->ofs + this->size);797797798798 ref_flag = REF_NORMAL;799799-799799+800800 fn_size -= this->ofs + this->size - fn_ofs;801801 fn_ofs = this->ofs + this->size;802802 dbg_fragtree2("now considering %#04x-%#04x\n", fn_ofs, fn_ofs + fn_size);803803-803803+804804 new_this = rb_entry(rb_next(&this->rb), struct jffs2_node_frag, rb);805805 if (!new_this) {806806- /* 806806+ /*807807 * There is no next fragment. Add the rest of808808 * the new node as the right-hand child.809809 */···813813 return err;814814 checked = 1;815815 }816816-816816+817817 fn->frags += 1;818818 newfrag = new_fragment(fn, fn_ofs, fn_size);819819 if (unlikely(!newfrag))···821821822822 dbg_fragtree2("there are no more fragments, insert %#04x-%#04x\n",823823 newfrag->ofs, newfrag->ofs + newfrag->size);824824- rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); 824824+ rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right);825825 rb_insert_color(&newfrag->rb, root);826826 goto out_ok;827827 } else {···862862863863/* During mount, this needs no locking. During normal operation, its864864 callers want to do other stuff while still holding the inocache_lock.865865- Rather than introducing special case get_ino_cache functions or 865865+ Rather than introducing special case get_ino_cache functions or866866 callbacks, we just let the caller do the locking itself. */867867-867867+868868struct jffs2_inode_cache *jffs2_get_ino_cache(struct jffs2_sb_info *c, uint32_t ino)869869{870870 struct jffs2_inode_cache *ret;···873873 while (ret && ret->ino < ino) {874874 ret = ret->next;875875 }876876-876876+877877 if (ret && ret->ino != ino)878878 ret = NULL;879879···907907908908 dbg_inocache("del %p (ino #%u)\n", old, old->ino);909909 spin_lock(&c->inocache_lock);910910-910910+911911 prev = &c->inocache_list[old->ino % INOCACHE_HASHSIZE];912912-912912+913913 while ((*prev) && (*prev)->ino < old->ino) {914914 prev = &(*prev)->next;915915 }···919919920920 /* Free it now unless it's in READING or CLEARING state, which921921 are the transitions upon read_inode() and clear_inode(). The922922- rest of the time we know nobody else is looking at it, and 922922+ rest of the time we know nobody else is looking at it, and923923 if it's held by read_inode() or clear_inode() they'll free it924924 for themselves. */925925 if (old->state != INO_STATE_READING && old->state != INO_STATE_CLEARING)···932932{933933 int i;934934 struct jffs2_inode_cache *this, *next;935935-935935+936936 for (i=0; i<INOCACHE_HASHSIZE; i++) {937937 this = c->inocache_list[i];938938 while (this) {···959959 c->blocks[i].first_node = c->blocks[i].last_node = NULL;960960 }961961}962962-962962+963963struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_t offset)964964{965965- /* The common case in lookup is that there will be a node 965965+ /* The common case in lookup is that there will be a node966966 which precisely matches. So we go looking for that first */967967 struct rb_node *next;968968 struct jffs2_node_frag *prev = NULL;···993993 if (prev)994994 dbg_fragtree2("no match. Returning frag %#04x-%#04x, closest previous\n",995995 prev->ofs, prev->ofs+prev->size);996996- else 996996+ else997997 dbg_fragtree2("returning NULL, empty fragtree\n");998998-998998+999999 return prev;10001000}10011001···10101010 return;1011101110121012 dbg_fragtree("killing\n");10131013-10131013+10141014 frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb));10151015 while(frag) {10161016 if (frag->rb.rb_left) {···10231023 }1024102410251025 if (frag->node && !(--frag->node->frags)) {10261026- /* Not a hole, and it's the final remaining frag 10261026+ /* Not a hole, and it's the final remaining frag10271027 of this node. Free the node */10281028 if (c)10291029 jffs2_mark_node_obsolete(c, frag->node->raw);10301030-10301030+10311031 jffs2_free_full_dnode(frag->node);10321032 }10331033 parent = frag_parent(frag);10341034 if (parent) {10351035 if (frag_left(parent) == frag)10361036 parent->rb.rb_left = NULL;10371037- else 10371037+ else10381038 parent->rb.rb_right = NULL;10391039 }10401040
+13-13
fs/jffs2/nodelist.h
···5858#define je16_to_cpu(x) (le16_to_cpu(x.v16))5959#define je32_to_cpu(x) (le32_to_cpu(x.v32))6060#define jemode_to_cpu(x) (le32_to_cpu(jffs2_to_os_mode((x).m)))6161-#else 6161+#else6262#error wibble6363#endif6464···6868/*6969 This is all we need to keep in-core for each raw node during normal7070 operation. As and when we do read_inode on a particular inode, we can7171- scan the nodes which are listed for it and build up a proper map of 7171+ scan the nodes which are listed for it and build up a proper map of7272 which nodes are currently valid. JFFSv1 always used to keep that whole7373 map in core for each inode.7474*/···85858686 /* flash_offset & 3 always has to be zero, because nodes are8787 always aligned at 4 bytes. So we have a couple of extra bits8888- to play with, which indicate the node's status; see below: */ 8888+ to play with, which indicate the node's status; see below: */8989#define REF_UNCHECKED 0 /* We haven't yet checked the CRC or built its inode */9090#define REF_OBSOLETE 1 /* Obsolete, can be completely ignored */9191#define REF_PRISTINE 2 /* Completely clean. GC without looking */···9898/* For each inode in the filesystem, we need to keep a record of9999 nlink, because it would be a PITA to scan the whole directory tree100100 at read_inode() time to calculate it, and to keep sufficient information101101- in the raw_node_ref (basically both parent and child inode number for 101101+ in the raw_node_ref (basically both parent and child inode number for102102 dirent nodes) would take more space than this does. We also keep103103 a pointer to the first physical node which is part of this inode, too.104104*/···128128#define INOCACHE_HASHSIZE 128129129130130/*131131- Larger representation of a raw node, kept in-core only when the 131131+ Larger representation of a raw node, kept in-core only when the132132 struct inode for this particular ino is instantiated.133133*/134134···138138 uint32_t ofs; /* The offset to which the data of this node belongs */139139 uint32_t size;140140 uint32_t frags; /* Number of fragments which currently refer141141- to this node. When this reaches zero, 141141+ to this node. When this reaches zero,142142 the node is obsolete. */143143};144144145145-/* 145145+/*146146 Even larger representation of a raw node, kept in-core only while147147 we're actually building up the original map of which nodes go where,148148 in read_inode()···155155 uint32_t data_crc;156156 uint32_t partial_crc;157157 uint32_t csize;158158-}; 158158+};159159160160struct jffs2_full_dirent161161{···169169};170170171171/*172172- Fragments - used to build a map of which raw node to obtain 172172+ Fragments - used to build a map of which raw node to obtain173173 data from for each part of the ino174174*/175175struct jffs2_node_frag···209209 struct jffs2_raw_node_ref *ref)210210{211211 uint32_t ref_end;212212-212212+213213 if (ref->next_phys)214214 ref_end = ref_offset(ref->next_phys);215215 else {···264264#define VERYDIRTY(c, size) ((size) >= ((c)->sector_size / 2))265265266266/* check if dirty space is more than 255 Byte */267267-#define ISDIRTY(size) ((size) > sizeof (struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN) 267267+#define ISDIRTY(size) ((size) > sizeof (struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN)268268269269#define PAD(x) (((x)+3)&~3)270270···341341struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs, int alloc_mode);342342struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_dirent *rd, const unsigned char *name, uint32_t namelen, uint32_t flash_ofs, int alloc_mode);343343int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,344344- struct jffs2_raw_inode *ri, unsigned char *buf, 344344+ struct jffs2_raw_inode *ri, unsigned char *buf,345345 uint32_t offset, uint32_t writelen, uint32_t *retlen);346346int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const char *name, int namelen);347347int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, const char *name, int namelen, struct jffs2_inode_info *dead_f, uint32_t time);···349349350350351351/* readinode.c */352352-int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 352352+int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,353353 uint32_t ino, struct jffs2_raw_inode *latest_node);354354int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);355355void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f);
+29-29
fs/jffs2/nodemgmt.c
···8888 up(&c->alloc_sem);8989 return -ENOSPC;9090 }9191-9191+9292 /* Calc possibly available space. Possibly available means that we9393 * don't know, if unchecked size contains obsoleted nodes, which could give us some9494 * more usable space. This will affect the sum only once, as gc first finishes checking9595 * of nodes.9696- + Return -ENOSPC, if the maximum possibly available space is less or equal than 9696+ + Return -ENOSPC, if the maximum possibly available space is less or equal than9797 * blocksneeded * sector_size.9898 * This blocks endless gc looping on a filesystem, which is nearly full, even if9999 * the check above passes.···118118 c->nr_free_blocks, c->nr_erasing_blocks, c->free_size, c->dirty_size, c->wasted_size, c->used_size, c->erasing_size, c->bad_size,119119 c->free_size + c->dirty_size + c->wasted_size + c->used_size + c->erasing_size + c->bad_size, c->flash_size));120120 spin_unlock(&c->erase_completion_lock);121121-121121+122122 ret = jffs2_garbage_collect_pass(c);123123 if (ret)124124 return ret;···183183 jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size));184184 list_add_tail(&jeb->list, &c->dirty_list);185185 }186186- } else { 186186+ } else {187187 D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",188188 jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size));189189 list_add_tail(&jeb->list, &c->clean_list);···197197static int jffs2_find_nextblock(struct jffs2_sb_info *c)198198{199199 struct list_head *next;200200-200200+201201 /* Take the next block off the 'free' list */202202203203 if (list_empty(&c->free_list)) {···229229 if (!c->nr_erasing_blocks) {230230 /* Ouch. We're in GC, or we wouldn't have got here.231231 And there's no space left. At all. */232232- printk(KERN_CRIT "Argh. No free space left for GC. nr_erasing_blocks is %d. nr_free_blocks is %d. (erasableempty: %s, erasingempty: %s, erasependingempty: %s)\n", 233233- c->nr_erasing_blocks, c->nr_free_blocks, list_empty(&c->erasable_list)?"yes":"no", 232232+ printk(KERN_CRIT "Argh. No free space left for GC. nr_erasing_blocks is %d. nr_free_blocks is %d. (erasableempty: %s, erasingempty: %s, erasependingempty: %s)\n",233233+ c->nr_erasing_blocks, c->nr_free_blocks, list_empty(&c->erasable_list)?"yes":"no",234234 list_empty(&c->erasing_list)?"yes":"no", list_empty(&c->erase_pending_list)?"yes":"no");235235 return -ENOSPC;236236 }···250250 list_del(next);251251 c->nextblock = list_entry(next, struct jffs2_eraseblock, list);252252 c->nr_free_blocks--;253253-253253+254254 jffs2_sum_reset_collected(c->summary); /* reset collected summary */255255256256 D1(printk(KERN_DEBUG "jffs2_find_nextblock(): new nextblock = 0x%08x\n", c->nextblock->offset));···354354355355 if (c->cleanmarker_size && jeb->used_size == c->cleanmarker_size &&356356 !jeb->first_node->next_in_ino) {357357- /* Only node in it beforehand was a CLEANMARKER node (we think). 357357+ /* Only node in it beforehand was a CLEANMARKER node (we think).358358 So mark it obsolete now that there's going to be another node359359- in the block. This will reduce used_size to zero but We've 359359+ in the block. This will reduce used_size to zero but We've360360 already set c->nextblock so that jffs2_mark_node_obsolete()361361 won't try to refile it to the dirty_list.362362 */···376376 * @len: length of this physical node377377 * @dirty: dirty flag for new node378378 *379379- * Should only be used to report nodes for which space has been allocated 379379+ * Should only be used to report nodes for which space has been allocated380380 * by jffs2_reserve_space.381381 *382382 * Must be called with the alloc_sem held.383383 */384384-384384+385385int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new)386386{387387 struct jffs2_eraseblock *jeb;···488488489489 if (jffs2_can_mark_obsolete(c) && !jffs2_is_readonly(c) &&490490 !(c->flags & (JFFS2_SB_FLAG_SCANNING | JFFS2_SB_FLAG_BUILDING))) {491491- /* Hm. This may confuse static lock analysis. If any of the above 492492- three conditions is false, we're going to return from this 491491+ /* Hm. This may confuse static lock analysis. If any of the above492492+ three conditions is false, we're going to return from this493493 function without actually obliterating any nodes or freeing494494 any jffs2_raw_node_refs. So we don't need to stop erases from495495 happening, or protect against people holding an obsolete···546546 D1(printk(KERN_DEBUG "Wasting\n"));547547 addedsize = 0;548548 jeb->wasted_size += ref_totlen(c, jeb, ref);549549- c->wasted_size += ref_totlen(c, jeb, ref); 549549+ c->wasted_size += ref_totlen(c, jeb, ref);550550 }551551 ref->flash_offset = ref_offset(ref) | REF_OBSOLETE;552552-552552+553553 jffs2_dbg_acct_sanity_check_nolock(c, jeb);554554 jffs2_dbg_acct_paranoia_check_nolock(c, jeb);555555556556 if (c->flags & JFFS2_SB_FLAG_SCANNING) {557557 /* Flash scanning is in progress. Don't muck about with the block558558 lists because they're not ready yet, and don't actually559559- obliterate nodes that look obsolete. If they weren't 559559+ obliterate nodes that look obsolete. If they weren't560560 marked obsolete on the flash at the time they _became_561561 obsolete, there was probably a reason for that. */562562 spin_unlock(&c->erase_completion_lock);···590590 immediately reused, and we spread the load a bit. */591591 D1(printk(KERN_DEBUG "...and adding to erasable_list\n"));592592 list_add_tail(&jeb->list, &c->erasable_list);593593- } 593593+ }594594 }595595 D1(printk(KERN_DEBUG "Done OK\n"));596596 } else if (jeb == c->gcblock) {···608608 list_add_tail(&jeb->list, &c->very_dirty_list);609609 } else {610610 D1(printk(KERN_DEBUG "Eraseblock at 0x%08x not moved anywhere. (free 0x%08x, dirty 0x%08x, used 0x%08x)\n",611611- jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); 612612- } 611611+ jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size));612612+ }613613614614 spin_unlock(&c->erase_completion_lock);615615···656656657657 /* Nodes which have been marked obsolete no longer need to be658658 associated with any inode. Remove them from the per-inode list.659659-660660- Note we can't do this for NAND at the moment because we need 659659+660660+ Note we can't do this for NAND at the moment because we need661661 obsolete dirent nodes to stay on the lists, because of the662662 horridness in jffs2_garbage_collect_deletion_dirent(). Also663663- because we delete the inocache, and on NAND we need that to 663663+ because we delete the inocache, and on NAND we need that to664664 stay around until all the nodes are actually erased, in order665665 to stop us from giving the same inode number to another newly666666 created inode. */···689689 if (ref->next_phys && ref_obsolete(ref->next_phys) &&690690 !ref->next_phys->next_in_ino) {691691 struct jffs2_raw_node_ref *n = ref->next_phys;692692-692692+693693 spin_lock(&c->erase_completion_lock);694694695695 ref->__totlen += n->__totlen;···703703704704 jffs2_free_raw_node_ref(n);705705 }706706-706706+707707 /* Also merge with the previous node in the list, if there is one708708 and that one is obsolete */709709 if (ref != jeb->first_node ) {···713713714714 while (p->next_phys != ref)715715 p = p->next_phys;716716-716716+717717 if (ref_obsolete(p) && !ref->next_in_ino) {718718 p->__totlen += ref->__totlen;719719 if (jeb->last_node == ref) {···753753 */754754 dirty = c->dirty_size + c->erasing_size - c->nr_erasing_blocks * c->sector_size;755755756756- if (c->nr_free_blocks + c->nr_erasing_blocks < c->resv_blocks_gctrigger && 757757- (dirty > c->nospc_dirty_size)) 756756+ if (c->nr_free_blocks + c->nr_erasing_blocks < c->resv_blocks_gctrigger &&757757+ (dirty > c->nospc_dirty_size))758758 ret = 1;759759760760- D1(printk(KERN_DEBUG "jffs2_thread_should_wake(): nr_free_blocks %d, nr_erasing_blocks %d, dirty_size 0x%x: %s\n", 760760+ D1(printk(KERN_DEBUG "jffs2_thread_should_wake(): nr_free_blocks %d, nr_erasing_blocks %d, dirty_size 0x%x: %s\n",761761 c->nr_free_blocks, c->nr_erasing_blocks, c->dirty_size, ret?"yes":"no"));762762763763 return ret;
···77 *88 * For licensing information, see the file 'LICENCE' in this directory.99 *1010- * $Id: read.c,v 1.41 2005/07/22 10:32:08 dedekind Exp $1010+ * $Id: read.c,v 1.42 2005/11/07 11:14:41 gleixner Exp $1111 *1212 */1313···4343 }4444 if (readlen != sizeof(*ri)) {4545 jffs2_free_raw_inode(ri);4646- printk(KERN_WARNING "Short read from 0x%08x: wanted 0x%zx bytes, got 0x%zx\n", 4646+ printk(KERN_WARNING "Short read from 0x%08x: wanted 0x%zx bytes, got 0x%zx\n",4747 ref_offset(fd->raw), sizeof(*ri), readlen);4848 return -EIO;4949 }···6161 }6262 /* There was a bug where we wrote hole nodes out with csize/dsize6363 swapped. Deal with it */6464- if (ri->compr == JFFS2_COMPR_ZERO && !je32_to_cpu(ri->dsize) && 6464+ if (ri->compr == JFFS2_COMPR_ZERO && !je32_to_cpu(ri->dsize) &&6565 je32_to_cpu(ri->csize)) {6666 ri->dsize = ri->csize;6767 ri->csize = cpu_to_je32(0);···7474 goto out_ri;7575 });76767777-7777+7878 if (ri->compr == JFFS2_COMPR_ZERO) {7979 memset(buf, 0, len);8080 goto out_ri;···82828383 /* Cases:8484 Reading whole node and it's uncompressed - read directly to buffer provided, check CRC.8585- Reading whole node and it's compressed - read into comprbuf, check CRC and decompress to buffer provided 8686- Reading partial node and it's uncompressed - read into readbuf, check CRC, and copy 8585+ Reading whole node and it's compressed - read into comprbuf, check CRC and decompress to buffer provided8686+ Reading partial node and it's uncompressed - read into readbuf, check CRC, and copy8787 Reading partial node and it's compressed - read into readbuf, check checksum, decompress to decomprbuf and copy8888 */8989 if (ri->compr == JFFS2_COMPR_NONE && len == je32_to_cpu(ri->dsize)) {···129129 D2(printk(KERN_DEBUG "Data CRC matches calculated CRC %08x\n", crc));130130 if (ri->compr != JFFS2_COMPR_NONE) {131131 D2(printk(KERN_DEBUG "Decompress %d bytes from %p to %d bytes at %p\n",132132- je32_to_cpu(ri->csize), readbuf, je32_to_cpu(ri->dsize), decomprbuf)); 132132+ je32_to_cpu(ri->csize), readbuf, je32_to_cpu(ri->dsize), decomprbuf));133133 ret = jffs2_decompress(c, f, ri->compr | (ri->usercompr << 8), readbuf, decomprbuf, je32_to_cpu(ri->csize), je32_to_cpu(ri->dsize));134134 if (ret) {135135 printk(KERN_WARNING "Error: jffs2_decompress returned %d\n", ret);···191191 } else {192192 uint32_t readlen;193193 uint32_t fragofs; /* offset within the frag to start reading */194194-194194+195195 fragofs = offset - frag->ofs;196196 readlen = min(frag->size - fragofs, end - offset);197197 D1(printk(KERN_DEBUG "Reading %d-%d from node at 0x%08x (%d)\n",
+42-42
fs/jffs2/readinode.c
···77 *88 * For licensing information, see the file 'LICENCE' in this directory.99 *1010- * $Id: readinode.c,v 1.142 2005/09/20 14:27:34 dedekind Exp $1010+ * $Id: readinode.c,v 1.143 2005/11/07 11:14:41 gleixner Exp $1111 *1212 */1313···116116 uint32_t *latest_mctime, uint32_t *mctime_ver)117117{118118 struct jffs2_full_dirent *fd;119119-119119+120120 /* The direntry nodes are checked during the flash scanning */121121 BUG_ON(ref_flags(ref) == REF_UNCHECKED);122122 /* Obsoleted. This cannot happen, surely? dwmw2 20020308 */123123 BUG_ON(ref_obsolete(ref));124124-124124+125125 /* Sanity check */126126 if (unlikely(PAD((rd->nsize + sizeof(*rd))) != PAD(je32_to_cpu(rd->totlen)))) {127127 JFFS2_ERROR("illegal nsize in node at %#08x: nsize %#02x, totlen %#04x\n",128128 ref_offset(ref), rd->nsize, je32_to_cpu(rd->totlen));129129 return 1;130130 }131131-131131+132132 fd = jffs2_alloc_full_dirent(rd->nsize + 1);133133 if (unlikely(!fd))134134 return -ENOMEM;···144144 *latest_mctime = je32_to_cpu(rd->mctime);145145 }146146147147- /* 147147+ /*148148 * Copy as much of the name as possible from the raw149149 * dirent we've already read from the flash.150150 */151151 if (read > sizeof(*rd))152152 memcpy(&fd->name[0], &rd->name[0],153153 min_t(uint32_t, rd->nsize, (read - sizeof(*rd)) ));154154-154154+155155 /* Do we need to copy any more of the name directly from the flash? */156156 if (rd->nsize + sizeof(*rd) > read) {157157 /* FIXME: point() */158158 int err;159159 int already = read - sizeof(*rd);160160-161161- err = jffs2_flash_read(c, (ref_offset(ref)) + read, 160160+161161+ err = jffs2_flash_read(c, (ref_offset(ref)) + read,162162 rd->nsize - already, &read, &fd->name[already]);163163 if (unlikely(read != rd->nsize - already) && likely(!err))164164 return -EIO;165165-165165+166166 if (unlikely(err)) {167167 JFFS2_ERROR("read remainder of name: error %d\n", err);168168 jffs2_free_full_dirent(fd);169169 return -EIO;170170 }171171 }172172-172172+173173 fd->nhash = full_name_hash(fd->name, rd->nsize);174174 fd->next = NULL;175175 fd->name[rd->nsize] = '\0';176176-176176+177177 /*178178 * Wheee. We now have a complete jffs2_full_dirent structure, with179179- * the name in it and everything. Link it into the list 179179+ * the name in it and everything. Link it into the list180180 */181181 jffs2_add_fd_to_list(c, fd, fdp);182182···198198 struct jffs2_tmp_dnode_info *tn;199199 uint32_t len, csize;200200 int ret = 1;201201-201201+202202 /* Obsoleted. This cannot happen, surely? dwmw2 20020308 */203203 BUG_ON(ref_obsolete(ref));204204···210210211211 tn->partial_crc = 0;212212 csize = je32_to_cpu(rd->csize);213213-213213+214214 /* If we've never checked the CRCs on this node, check them now */215215 if (ref_flags(ref) == REF_UNCHECKED) {216216 uint32_t crc;···221221 ref_offset(ref), je32_to_cpu(rd->node_crc), crc);222222 goto free_out;223223 }224224-224224+225225 /* Sanity checks */226226 if (unlikely(je32_to_cpu(rd->offset) > je32_to_cpu(rd->isize)) ||227227 unlikely(PAD(je32_to_cpu(rd->csize) + sizeof(*rd)) != PAD(je32_to_cpu(rd->totlen)))) {···313313 ret = -ENOMEM;314314 goto free_out;315315 }316316-316316+317317 tn->version = je32_to_cpu(rd->version);318318 tn->fn->ofs = je32_to_cpu(rd->offset);319319 tn->data_crc = je32_to_cpu(rd->data_crc);320320 tn->csize = csize;321321 tn->fn->raw = ref;322322-322322+323323 /* There was a bug where we wrote hole nodes out with324324 csize/dsize swapped. Deal with it */325325 if (rd->compr == JFFS2_COMPR_ZERO && !je32_to_cpu(rd->dsize) && csize)···329329330330 dbg_readinode("dnode @%08x: ver %u, offset %#04x, dsize %#04x, csize %#04x\n",331331 ref_offset(ref), je32_to_cpu(rd->version), je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize), csize);332332-332332+333333 jffs2_add_tn_to_tree(tn, tnp);334334335335 return 0;···351351{352352 /* We don't mark unknown nodes as REF_UNCHECKED */353353 BUG_ON(ref_flags(ref) == REF_UNCHECKED);354354-354354+355355 un->nodetype = cpu_to_je16(JFFS2_NODE_ACCURATE | je16_to_cpu(un->nodetype));356356357357 if (crc32(0, un, sizeof(struct jffs2_unknown_node) - 4) != je32_to_cpu(un->hdr_crc)) {···423423 bufstart = buf + *rdlen;424424 len = right_size - *rdlen;425425 }426426-426426+427427 dbg_readinode("read more %d bytes\n", len);428428429429 err = jffs2_flash_read(c, offs, len, &retlen, bufstart);···432432 "error code: %d.\n", len, offs, err);433433 return err;434434 }435435-435435+436436 if (retlen < len) {437437 JFFS2_ERROR("short read at %#08x: %d instead of %d.\n",438438 offs, retlen, len);···460460 int len, err;461461462462 *mctime_ver = 0;463463-463463+464464 dbg_readinode("ino #%u\n", f->inocache->ino);465465466466 if (jffs2_is_writebuffered(c)) {···487487 buf = kmalloc(len, GFP_KERNEL);488488 if (!buf)489489 return -ENOMEM;490490-490490+491491 spin_lock(&c->erase_completion_lock);492492 valid_ref = jffs2_first_valid_node(f->inocache->nodes);493493 if (!valid_ref && f->inocache->ino != 1)···514514 * size = JFFS2_MIN_NODE_HEADER.515515 */516516 if (jffs2_is_writebuffered(c)) {517517- /* 517517+ /*518518 * We treat 'buf' as 2 adjacent wbufs. We want to519519 * adjust bufstart such as it points to the520520 * beginning of the node within this wbuf.···540540 JFFS2_ERROR("can not read %d bytes from 0x%08x, " "error code: %d.\n", len, ref_offset(ref), err);541541 goto free_out;542542 }543543-543543+544544 if (retlen < len) {545545 JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", ref_offset(ref), retlen, len);546546 err = -EIO;547547 goto free_out;548548 }549549-549549+550550 node = (union jffs2_node_union *)bufstart;551551-551551+552552 switch (je16_to_cpu(node->u.nodetype)) {553553-553553+554554 case JFFS2_NODETYPE_DIRENT:555555556556 if (JFFS2_MIN_NODE_HEADER < sizeof(struct jffs2_raw_dirent)) {···558558 if (unlikely(err))559559 goto free_out;560560 }561561-561561+562562 err = read_direntry(c, ref, &node->d, retlen, &ret_fd, latest_mctime, mctime_ver);563563 if (err == 1) {564564 jffs2_mark_node_obsolete(c, ref);565565 break;566566 } else if (unlikely(err))567567 goto free_out;568568-568568+569569 if (je32_to_cpu(node->d.version) > *highest_version)570570 *highest_version = je32_to_cpu(node->d.version);571571572572 break;573573574574 case JFFS2_NODETYPE_INODE:575575-575575+576576 if (JFFS2_MIN_NODE_HEADER < sizeof(struct jffs2_raw_inode)) {577577 err = read_more(c, ref, sizeof(struct jffs2_raw_inode), &len, buf, bufstart);578578 if (unlikely(err))···588588589589 if (je32_to_cpu(node->i.version) > *highest_version)590590 *highest_version = je32_to_cpu(node->i.version);591591-591591+592592 break;593593594594 default:···597597 if (unlikely(err))598598 goto free_out;599599 }600600-600600+601601 err = read_unknown(c, ref, &node->u);602602 if (err == 1) {603603 jffs2_mark_node_obsolete(c, ref);···625625 return err;626626}627627628628-static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, 628628+static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,629629 struct jffs2_inode_info *f,630630 struct jffs2_raw_inode *latest_node)631631{···677677 ret = 0; /* Prevent freeing the metadata update node */678678 } else679679 jffs2_mark_node_obsolete(c, fn->raw);680680-680680+681681 BUG_ON(rb->rb_left);682682 if (rb->rb_parent && rb->rb_parent->rb_left == rb) {683683 /* We were then left-hand child of our parent. We need···763763 }764764 break;765765766766-766766+767767 case S_IFREG:768768 /* If it was a regular file, truncate it to the latest node's isize */769769 jffs2_truncate_fragtree(c, &f->fragtree, je32_to_cpu(latest_node->isize));···788788 jffs2_do_clear_inode(c, f);789789 return -ENOMEM;790790 }791791-791791+792792 ret = jffs2_flash_read(c, ref_offset(fn->raw) + sizeof(*latest_node),793793 je32_to_cpu(latest_node->csize), &retlen, (char *)f->target);794794-794794+795795 if (ret || retlen != je32_to_cpu(latest_node->csize)) {796796 if (retlen != je32_to_cpu(latest_node->csize))797797 ret = -EIO;···805805 f->target[je32_to_cpu(latest_node->csize)] = '\0';806806 dbg_readinode("symlink's target '%s' cached\n", f->target);807807 }808808-808808+809809 /* fall through... */810810811811 case S_IFBLK:···848848}849849850850/* Scan the list of all nodes present for this ino, build map of versions, etc. */851851-int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 851851+int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,852852 uint32_t ino, struct jffs2_raw_inode *latest_node)853853{854854 dbg_readinode("read inode #%u\n", ino);···864864 case INO_STATE_CHECKEDABSENT:865865 f->inocache->state = INO_STATE_READING;866866 break;867867-867867+868868 case INO_STATE_CHECKING:869869 case INO_STATE_GC:870870 /* If it's in either of these states, we need···957957 kfree(f->target);958958 f->target = NULL;959959 }960960-960960+961961 fds = f->dents;962962 while(fds) {963963 fd = fds;
+26-26
fs/jffs2/scan.c
···3838static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,3939 unsigned char *buf, uint32_t buf_size, struct jffs2_summary *s);40404141-/* These helper functions _must_ increase ofs and also do the dirty/used space accounting. 4141+/* These helper functions _must_ increase ofs and also do the dirty/used space accounting.4242 * Returning an error will abort the mount - bad checksums etc. should just mark the space4343 * as dirty.4444 */4545-static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 4545+static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,4646 struct jffs2_raw_inode *ri, uint32_t ofs, struct jffs2_summary *s);4747static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,4848 struct jffs2_raw_dirent *rd, uint32_t ofs, struct jffs2_summary *s);···131131 /* Now decide which list to put it on */132132 switch(ret) {133133 case BLK_STATE_ALLFF:134134- /* 135135- * Empty block. Since we can't be sure it 134134+ /*135135+ * Empty block. Since we can't be sure it136136 * was entirely erased, we just queue it for erase137137 * again. It will be marked as such when the erase138138 * is complete. Meanwhile we still count it as empty···234234 }235235#ifdef CONFIG_JFFS2_FS_WRITEBUFFER236236 if (!jffs2_can_mark_obsolete(c) && c->nextblock && (c->nextblock->free_size % c->wbuf_pagesize)) {237237- /* If we're going to start writing into a block which already 237237+ /* If we're going to start writing into a block which already238238 contains data, and the end of the data isn't page-aligned,239239 skip a little and align it. */240240···250250 }251251#endif252252 if (c->nr_erasing_blocks) {253253- if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { 253253+ if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) {254254 printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n");255255 printk(KERN_NOTICE "empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n",empty_blocks,bad_blocks,c->nr_blocks);256256 ret = -EIO;···263263 if (buf_size)264264 kfree(flashbuf);265265#ifndef __ECOS266266- else 266266+ else267267 c->mtd->unpoint(c->mtd, flashbuf, 0, c->mtd->size);268268#endif269269 return ret;···391391 if (err)392392 return err;393393 }394394-394394+395395 /* We temporarily use 'ofs' as a pointer into the buffer/jeb */396396 ofs = 0;397397···431431432432 dbg_summary("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset);433433434434-scan_more: 434434+scan_more:435435 while(ofs < jeb->offset + c->sector_size) {436436437437 jffs2_dbg_acct_paranoia_check_nolock(c, jeb);···496496497497 /* If we're only checking the beginning of a block with a cleanmarker,498498 bail now */499499- if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && 499499+ if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) &&500500 c->cleanmarker_size && !jeb->dirty_size && !jeb->first_node->next_phys) {501501 D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE(c->sector_size)));502502 return BLK_STATE_CLEANMARKER;···505505 /* See how much more there is to read in this eraseblock... */506506 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);507507 if (!buf_len) {508508- /* No more to read. Break out of main loop without marking 508508+ /* No more to read. Break out of main loop without marking509509 this range of empty space as dirty (because it's not) */510510 D1(printk(KERN_DEBUG "Empty flash at %08x runs to end of block. Treating as free_space\n",511511 empty_start));···540540 }541541 if (je16_to_cpu(node->magic) != JFFS2_MAGIC_BITMASK) {542542 /* OK. We're out of possibilities. Whinge and move on */543543- noisy_printk(&noise, "jffs2_scan_eraseblock(): Magic bitmask 0x%04x not found at 0x%08x: 0x%04x instead\n", 544544- JFFS2_MAGIC_BITMASK, ofs, 543543+ noisy_printk(&noise, "jffs2_scan_eraseblock(): Magic bitmask 0x%04x not found at 0x%08x: 0x%04x instead\n",544544+ JFFS2_MAGIC_BITMASK, ofs,545545 je16_to_cpu(node->magic));546546 DIRTY_SPACE(4);547547 ofs += 4;···556556 if (hdr_crc != je32_to_cpu(node->hdr_crc)) {557557 noisy_printk(&noise, "jffs2_scan_eraseblock(): Node at 0x%08x {0x%04x, 0x%04x, 0x%08x) has invalid CRC 0x%08x (calculated 0x%08x)\n",558558 ofs, je16_to_cpu(node->magic),559559- je16_to_cpu(node->nodetype), 559559+ je16_to_cpu(node->nodetype),560560 je32_to_cpu(node->totlen),561561 je32_to_cpu(node->hdr_crc),562562 hdr_crc);···565565 continue;566566 }567567568568- if (ofs + je32_to_cpu(node->totlen) > 568568+ if (ofs + je32_to_cpu(node->totlen) >569569 jeb->offset + c->sector_size) {570570 /* Eep. Node goes over the end of the erase block. */571571 printk(KERN_WARNING "Node at 0x%08x with length 0x%08x would run over the end of the erase block\n",···600600 if (err) return err;601601 ofs += PAD(je32_to_cpu(node->totlen));602602 break;603603-603603+604604 case JFFS2_NODETYPE_DIRENT:605605 if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) {606606 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);···620620 case JFFS2_NODETYPE_CLEANMARKER:621621 D1(printk(KERN_DEBUG "CLEANMARKER node found at 0x%08x\n", ofs));622622 if (je32_to_cpu(node->totlen) != c->cleanmarker_size) {623623- printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n", 623623+ printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n",624624 ofs, je32_to_cpu(node->totlen), c->cleanmarker_size);625625 DIRTY_SPACE(PAD(sizeof(struct jffs2_unknown_node)));626626 ofs += PAD(sizeof(struct jffs2_unknown_node));···639639 marker_ref->flash_offset = ofs | REF_NORMAL;640640 marker_ref->__totlen = c->cleanmarker_size;641641 jeb->first_node = jeb->last_node = marker_ref;642642-642642+643643 USED_SPACE(PAD(c->cleanmarker_size));644644 ofs += PAD(c->cleanmarker_size);645645 }···690690 }691691 }692692693693- D1(printk(KERN_DEBUG "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x\n", jeb->offset, 693693+ D1(printk(KERN_DEBUG "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x\n", jeb->offset,694694 jeb->free_size, jeb->dirty_size, jeb->unchecked_size, jeb->used_size));695695696696 /* mark_node_obsolete can add to wasted !! */···730730 return ic;731731}732732733733-static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 733733+static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,734734 struct jffs2_raw_inode *ri, uint32_t ofs, struct jffs2_summary *s)735735{736736 struct jffs2_raw_node_ref *raw;···740740 D1(printk(KERN_DEBUG "jffs2_scan_inode_node(): Node at 0x%08x\n", ofs));741741742742 /* We do very little here now. Just check the ino# to which we should attribute743743- this node; we can do all the CRC checking etc. later. There's a tradeoff here -- 743743+ this node; we can do all the CRC checking etc. later. There's a tradeoff here --744744 we used to scan the flash once only, reading everything we want from it into745745 memory, then building all our in-core data structures and freeing the extra746746 information. Now we allow the first part of the mount to complete a lot quicker,747747- but we have to go _back_ to the flash in order to finish the CRC checking, etc. 747747+ but we have to go _back_ to the flash in order to finish the CRC checking, etc.748748 Which means that the _full_ amount of time to get to proper write mode with GC749749 operational may actually be _longer_ than before. Sucks to be me. */750750···790790 jeb->last_node->next_phys = raw;791791 jeb->last_node = raw;792792793793- D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n", 793793+ D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n",794794 je32_to_cpu(ri->ino), je32_to_cpu(ri->version),795795 je32_to_cpu(ri->offset),796796 je32_to_cpu(ri->offset)+je32_to_cpu(ri->dsize)));···806806 return 0;807807}808808809809-static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 809809+static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,810810 struct jffs2_raw_dirent *rd, uint32_t ofs, struct jffs2_summary *s)811811{812812 struct jffs2_raw_node_ref *raw;···840840 crc = crc32(0, fd->name, rd->nsize);841841 if (crc != je32_to_cpu(rd->name_crc)) {842842 printk(KERN_NOTICE "jffs2_scan_dirent_node(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",843843- ofs, je32_to_cpu(rd->name_crc), crc); 843843+ ofs, je32_to_cpu(rd->name_crc), crc);844844 D1(printk(KERN_NOTICE "Name for which CRC failed is (now) '%s', ino #%d\n", fd->name, je32_to_cpu(rd->ino)));845845 jffs2_free_full_dirent(fd);846846 /* FIXME: Why do we believe totlen? */···860860 jffs2_free_raw_node_ref(raw);861861 return -ENOMEM;862862 }863863-863863+864864 raw->__totlen = PAD(je32_to_cpu(rd->totlen));865865 raw->flash_offset = ofs | REF_PRISTINE;866866 raw->next_phys = NULL;
···77 *88 * For licensing information, see the file 'LICENCE' in this directory.99 *1010- * $Id: super.c,v 1.109 2005/09/07 08:34:55 havasi Exp $1010+ * $Id: super.c,v 1.110 2005/11/07 11:14:42 gleixner Exp $1111 *1212 */1313···62626363 down(&c->alloc_sem);6464 jffs2_flush_wbuf_pad(c);6565- up(&c->alloc_sem); 6565+ up(&c->alloc_sem);6666 return 0;6767}6868···112112}113113114114static struct super_block *jffs2_get_sb_mtd(struct file_system_type *fs_type,115115- int flags, const char *dev_name, 115115+ int flags, const char *dev_name,116116 void *data, struct mtd_info *mtd)117117{118118 struct super_block *sb;···172172}173173174174static struct super_block *jffs2_get_sb_mtdnr(struct file_system_type *fs_type,175175- int flags, const char *dev_name, 175175+ int flags, const char *dev_name,176176 void *data, int mtdnr)177177{178178 struct mtd_info *mtd;···201201202202 /* The preferred way of mounting in future; especially when203203 CONFIG_BLK_DEV is implemented - we specify the underlying204204- MTD device by number or by name, so that we don't require 204204+ MTD device by number or by name, so that we don't require205205 block device support to be present in the kernel. */206206207207 /* FIXME: How to do the root fs this way? */···225225 } else if (isdigit(dev_name[3])) {226226 /* Mount by MTD device number name */227227 char *endptr;228228-228228+229229 mtdnr = simple_strtoul(dev_name+3, &endptr, 0);230230 if (!*endptr) {231231 /* It was a valid number */···235235 }236236 }237237238238- /* Try the old way - the hack where we allowed users to mount 238238+ /* Try the old way - the hack where we allowed users to mount239239 /dev/mtdblock$(n) but didn't actually _use_ the blkdev */240240241241 err = path_lookup(dev_name, LOOKUP_FOLLOW, &nd);···376376377377MODULE_DESCRIPTION("The Journalling Flash File System, v2");378378MODULE_AUTHOR("Red Hat, Inc.");379379-MODULE_LICENSE("GPL"); // Actually dual-licensed, but it doesn't matter for 379379+MODULE_LICENSE("GPL"); // Actually dual-licensed, but it doesn't matter for380380 // the sake of this tag. It's Free Software.
+4-4
fs/jffs2/symlink.c
···77 *88 * For licensing information, see the file 'LICENCE' in this directory.99 *1010- * $Id: symlink.c,v 1.18 2005/11/06 11:03:27 gleixner Exp $1010+ * $Id: symlink.c,v 1.19 2005/11/07 11:14:42 gleixner Exp $1111 *1212 */1313···2121static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd);22222323struct inode_operations jffs2_symlink_inode_operations =2424-{ 2424+{2525 .readlink = generic_readlink,2626 .follow_link = jffs2_follow_link,2727 .setattr = jffs2_setattr···4444 * stopped using our f->target string which we provide by means of4545 * nd_set_link() call.4646 */4747-4747+4848 if (!p) {4949 printk(KERN_ERR "jffs2_follow_link(): can't find symlink taerget\n");5050 p = ERR_PTR(-EIO);···5252 D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s'\n", (char *) f->target));53535454 nd_set_link(nd, p);5555-5555+5656 /*5757 * We will unlock the f->sem mutex but VFS will use the f->target string. This is safe5858 * since the only way that may cause f->target to be changed is iput() operation.
+64-64
fs/jffs2/wbuf.c
···188188 /* Find the first node to be recovered, by skipping over every189189 node which ends before the wbuf starts, or which is obsolete. */190190 first_raw = &jeb->first_node;191191- while (*first_raw && 191191+ while (*first_raw &&192192 (ref_obsolete(*first_raw) ||193193 (ref_offset(*first_raw)+ref_totlen(c, jeb, *first_raw)) < c->wbuf_ofs)) {194194 D1(printk(KERN_DEBUG "Skipping node at 0x%08x(%d)-0x%08x which is either before 0x%08x or obsolete\n",···237237 ret = c->mtd->read_ecc(c->mtd, start, c->wbuf_ofs - start, &retlen, buf, NULL, c->oobinfo);238238 else239239 ret = c->mtd->read(c->mtd, start, c->wbuf_ofs - start, &retlen, buf);240240-240240+241241 if (ret == -EBADMSG && retlen == c->wbuf_ofs - start) {242242 /* ECC recovered */243243 ret = 0;···274274 if (end-start >= c->wbuf_pagesize) {275275 /* Need to do another write immediately, but it's possible276276 that this is just because the wbuf itself is completely277277- full, and there's nothing earlier read back from the 278278- flash. Hence 'buf' isn't necessarily what we're writing 277277+ full, and there's nothing earlier read back from the278278+ flash. Hence 'buf' isn't necessarily what we're writing279279 from. */280280 unsigned char *rewrite_buf = buf?:c->wbuf;281281 uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize);282282283283 D1(printk(KERN_DEBUG "Write 0x%x bytes at 0x%08x in wbuf recover\n",284284 towrite, ofs));285285-285285+286286#ifdef BREAKMEHEADER287287 static int breakme;288288 if (breakme++ == 20) {···434434 this happens, if we have a change to a new block,435435 or if fsync forces us to flush the writebuffer.436436 if we have a switch to next page, we will not have437437- enough remaining space for this. 437437+ enough remaining space for this.438438 */439439 if (pad ) {440440 c->wbuf_len = PAD(c->wbuf_len);···442442 /* Pad with JFFS2_DIRTY_BITMASK initially. this helps out ECC'd NOR443443 with 8 byte page size */444444 memset(c->wbuf + c->wbuf_len, 0, c->wbuf_pagesize - c->wbuf_len);445445-445445+446446 if ( c->wbuf_len + sizeof(struct jffs2_unknown_node) < c->wbuf_pagesize) {447447 struct jffs2_unknown_node *padnode = (void *)(c->wbuf + c->wbuf_len);448448 padnode->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);···453453 }454454 /* else jffs2_flash_writev has actually filled in the rest of the455455 buffer for us, and will deal with the node refs etc. later. */456456-456456+457457#ifdef BREAKME458458 static int breakme;459459 if (breakme++ == 20) {···462462 c->mtd->write_ecc(c->mtd, c->wbuf_ofs, c->wbuf_pagesize,463463 &retlen, brokenbuf, NULL, c->oobinfo);464464 ret = -EIO;465465- } else 465465+ } else466466#endif467467-467467+468468 if (jffs2_cleanmarker_oob(c))469469 ret = c->mtd->write_ecc(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, c->wbuf, NULL, c->oobinfo);470470 else···485485 }486486487487 spin_lock(&c->erase_completion_lock);488488-488488+489489 /* Adjust free size of the block if we padded. */490490 if (pad) {491491 struct jffs2_eraseblock *jeb;···495495 D1(printk(KERN_DEBUG "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n",496496 (jeb==c->nextblock)?"next":"", jeb->offset));497497498498- /* wbuf_pagesize - wbuf_len is the amount of space that's to be 498498+ /* wbuf_pagesize - wbuf_len is the amount of space that's to be499499 padded. If there is less free space in the block than that,500500 something screwed up */501501 if (jeb->free_size < (c->wbuf_pagesize - c->wbuf_len)) {···523523 return 0;524524}525525526526-/* Trigger garbage collection to flush the write-buffer. 526526+/* Trigger garbage collection to flush the write-buffer.527527 If ino arg is zero, do it if _any_ real (i.e. not GC) writes are528528- outstanding. If ino arg non-zero, do it only if a write for the 528528+ outstanding. If ino arg non-zero, do it only if a write for the529529 given inode is outstanding. */530530int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino)531531{···620620 /* If not NAND flash, don't bother */621621 if (!jffs2_is_writebuffered(c))622622 return jffs2_flash_direct_writev(c, invecs, count, to, retlen);623623-623623+624624 down_write(&c->wbuf_sem);625625626626 /* If wbuf_ofs is not initialized, set it to target address */627627 if (c->wbuf_ofs == 0xFFFFFFFF) {628628 c->wbuf_ofs = PAGE_DIV(to);629629- c->wbuf_len = PAGE_MOD(to); 629629+ c->wbuf_len = PAGE_MOD(to);630630 memset(c->wbuf,0xff,c->wbuf_pagesize);631631 }632632···640640 memset(c->wbuf,0xff,c->wbuf_pagesize);641641 }642642 }643643-644644- /* Sanity checks on target address. 645645- It's permitted to write at PAD(c->wbuf_len+c->wbuf_ofs), 646646- and it's permitted to write at the beginning of a new 643643+644644+ /* Sanity checks on target address.645645+ It's permitted to write at PAD(c->wbuf_len+c->wbuf_ofs),646646+ and it's permitted to write at the beginning of a new647647 erase block. Anything else, and you die.648648 New block starts at xxx000c (0-b = block header)649649 */···661661 }662662 /* set pointer to new block */663663 c->wbuf_ofs = PAGE_DIV(to);664664- c->wbuf_len = PAGE_MOD(to); 665665- } 664664+ c->wbuf_len = PAGE_MOD(to);665665+ }666666667667 if (to != PAD(c->wbuf_ofs + c->wbuf_len)) {668668 /* We're not writing immediately after the writebuffer. Bad. */···682682 invec = 0;683683 outvec = 0;684684685685- /* Fill writebuffer first, if already in use */ 685685+ /* Fill writebuffer first, if already in use */686686 if (c->wbuf_len) {687687 uint32_t invec_ofs = 0;688688689689- /* adjust alignment offset */ 689689+ /* adjust alignment offset */690690 if (c->wbuf_len != PAGE_MOD(to)) {691691 c->wbuf_len = PAGE_MOD(to);692692 /* take care of alignment to next page */693693 if (!c->wbuf_len)694694 c->wbuf_len = c->wbuf_pagesize;695695 }696696-696696+697697 while(c->wbuf_len < c->wbuf_pagesize) {698698 uint32_t thislen;699699-699699+700700 if (invec == count)701701 goto alldone;702702···704704705705 if (thislen >= invecs[invec].iov_len)706706 thislen = invecs[invec].iov_len;707707-707707+708708 invec_ofs = thislen;709709710710 memcpy(c->wbuf + c->wbuf_len, invecs[invec].iov_base, thislen);711711 c->wbuf_len += thislen;712712 donelen += thislen;713713 /* Get next invec, if actual did not fill the buffer */714714- if (c->wbuf_len < c->wbuf_pagesize) 714714+ if (c->wbuf_len < c->wbuf_pagesize)715715 invec++;716716- } 717717-716716+ }717717+718718 /* write buffer is full, flush buffer */719719 ret = __jffs2_flush_wbuf(c, NOPAD);720720 if (ret) {···773773774774 /* We did cross a page boundary, so we write some now */775775 if (jffs2_cleanmarker_oob(c))776776- ret = c->mtd->writev_ecc(c->mtd, outvecs, splitvec+1, outvec_to, &wbuf_retlen, NULL, c->oobinfo); 776776+ ret = c->mtd->writev_ecc(c->mtd, outvecs, splitvec+1, outvec_to, &wbuf_retlen, NULL, c->oobinfo);777777 else778778 ret = jffs2_flash_direct_writev(c, outvecs, splitvec+1, outvec_to, &wbuf_retlen);779779-779779+780780 if (ret < 0 || wbuf_retlen != PAGE_DIV(totlen)) {781781 /* At this point we have no problem,782782 c->wbuf is empty. However refile nextblock to avoid···793793 spin_unlock(&c->erase_completion_lock);794794 goto exit;795795 }796796-796796+797797 donelen += wbuf_retlen;798798 c->wbuf_ofs = PAGE_DIV(outvec_to) + PAGE_DIV(totlen);799799···837837 jffs2_wbuf_dirties_inode(c, ino);838838839839 ret = 0;840840-840840+841841exit:842842 up_write(&c->wbuf_sem);843843 return ret;···880880 if ( (ret == -EBADMSG) && (*retlen == len) ) {881881 printk(KERN_WARNING "mtd->read(0x%zx bytes from 0x%llx) returned ECC error\n",882882 len, ofs);883883- /* 884884- * We have the raw data without ECC correction in the buffer, maybe 883883+ /*884884+ * We have the raw data without ECC correction in the buffer, maybe885885 * we are lucky and all data or parts are correct. We check the node.886886 * If data are corrupted node check will sort it out.887887 * We keep this block, it will fail on write or erase and the we888888 * mark it bad. Or should we do that now? But we should give him a chance.889889- * Maybe we had a system crash or power loss before the ecc write or 889889+ * Maybe we had a system crash or power loss before the ecc write or890890 * a erase was completed.891891 * So we return success. :)892892 */893893 ret = 0;894894- } 894894+ }895895896896 /* if no writebuffer available or write buffer empty, return */897897 if (!c->wbuf_pagesize || !c->wbuf_len)···906906 if (owbf > c->wbuf_len) /* is read beyond write buffer ? */907907 goto exit;908908 lwbf = c->wbuf_len - owbf; /* number of bytes to copy */909909- if (lwbf > len) 909909+ if (lwbf > len)910910 lwbf = len;911911- } else { 911911+ } else {912912 orbf = (c->wbuf_ofs - ofs); /* offset in read buffer */913913 if (orbf > len) /* is write beyond write buffer ? */914914 goto exit;915915 lwbf = len - orbf; /* number of bytes to copy */916916- if (lwbf > c->wbuf_len) 916916+ if (lwbf > c->wbuf_len)917917 lwbf = c->wbuf_len;918918- } 918918+ }919919 if (lwbf > 0)920920 memcpy(buf+orbf,c->wbuf+owbf,lwbf);921921···943943 printk(KERN_NOTICE "jffs2_check_oob_empty(): allocation of temporary data buffer for oob check failed\n");944944 return -ENOMEM;945945 }946946- /* 946946+ /*947947 * if mode = 0, we scan for a total empty oob area, else we have948948 * to take care of the cleanmarker in the first page of the block949949 */···952952 D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB failed %d for block at %08x\n", ret, jeb->offset));953953 goto out;954954 }955955-955955+956956 if (retlen < len) {957957 D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB return short read "958958 "(%zd bytes not %d) for block at %08x\n", retlen, len, jeb->offset));959959 ret = -EIO;960960 goto out;961961 }962962-962962+963963 /* Special check for first page */964964 for(i = 0; i < oob_size ; i++) {965965 /* Yeah, we know about the cleanmarker. */966966- if (mode && i >= c->fsdata_pos && 966966+ if (mode && i >= c->fsdata_pos &&967967 i < c->fsdata_pos + c->fsdata_len)968968 continue;969969970970 if (buf[i] != 0xFF) {971971 D2(printk(KERN_DEBUG "Found %02x at %x in OOB for %08x\n",972972 buf[i], i, jeb->offset));973973- ret = 1; 973973+ ret = 1;974974 goto out;975975 }976976 }977977978978- /* we know, we are aligned :) */ 978978+ /* we know, we are aligned :) */979979 for (page = oob_size; page < len; page += sizeof(long)) {980980 unsigned long dat = *(unsigned long *)(&buf[page]);981981 if(dat != -1) {982982- ret = 1; 982982+ ret = 1;983983 goto out;984984 }985985 }986986987987out:988988- kfree(buf); 989989-988988+ kfree(buf);989989+990990 return ret;991991}992992···10681068 n.totlen = cpu_to_je32(8);1069106910701070 ret = jffs2_flash_write_oob(c, jeb->offset + c->fsdata_pos, c->fsdata_len, &retlen, (unsigned char *)&n);10711071-10711071+10721072 if (ret) {10731073 D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): Write failed for block at %08x: error %d\n", jeb->offset, ret));10741074 return ret;···10801080 return 0;10811081}1082108210831083-/* 10831083+/*10841084 * On NAND we try to mark this block bad. If the block was erased more10851085 * than MAX_ERASE_FAILURES we mark it finaly bad.10861086 * Don't care about failures. This block remains on the erase-pending···1101110111021102 D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Marking bad block at %08x\n", bad_offset));11031103 ret = c->mtd->block_markbad(c->mtd, bad_offset);11041104-11041104+11051105 if (ret) {11061106 D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret));11071107 return ret;···11251125 /* Do this only, if we have an oob buffer */11261126 if (!c->mtd->oobsize)11271127 return 0;11281128-11281128+11291129 /* Cleanmarker is out-of-band, so inline size zero */11301130 c->cleanmarker_size = 0;11311131···11511151 c->fsdata_len = NAND_JFFS2_OOB16_FSDALEN;11521152 c->badblock_pos = 15;11531153 break;11541154-11541154+11551155 default:11561156 D1(printk(KERN_DEBUG "JFFS2 on NAND. No autoplacment info found\n"));11571157 return -EINVAL;···11681168 init_rwsem(&c->wbuf_sem);11691169 c->wbuf_pagesize = c->mtd->oobblock;11701170 c->wbuf_ofs = 0xFFFFFFFF;11711171-11711171+11721172 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);11731173 if (!c->wbuf)11741174 return -ENOMEM;···1194119411951195int jffs2_dataflash_setup(struct jffs2_sb_info *c) {11961196 c->cleanmarker_size = 0; /* No cleanmarkers needed */11971197-11971197+11981198 /* Initialize write buffer */11991199 init_rwsem(&c->wbuf_sem);12001200-12011201-12001200+12011201+12021202 c->wbuf_pagesize = c->mtd->erasesize;12031203-12031203+12041204 /* Find a suitable c->sector_size12051205 * - Not too much sectors12061206 * - Sectors have to be at least 4 K + some bytes···12101210 */1211121112121212 c->sector_size = 8 * c->mtd->erasesize;12131213-12131213+12141214 while (c->sector_size < 8192) {12151215 c->sector_size *= 2;12161216 }12171217-12171217+12181218 /* It may be necessary to adjust the flash size */12191219 c->flash_size = c->mtd->size;12201220···12221222 c->flash_size = (c->flash_size / c->sector_size) * c->sector_size;12231223 printk(KERN_WARNING "JFFS2 flash size adjusted to %dKiB\n", c->flash_size);12241224 };12251225-12251225+12261226 c->wbuf_ofs = 0xFFFFFFFF;12271227 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);12281228 if (!c->wbuf)
+34-34
fs/jffs2/write.c
···77 *88 * For licensing information, see the file 'LICENCE' in this directory.99 *1010- * $Id: write.c,v 1.96 2005/09/07 08:34:55 havasi Exp $1010+ * $Id: write.c,v 1.97 2005/11/07 11:14:42 gleixner Exp $1111 *1212 */1313···5454 return 0;5555}56565757-/* jffs2_write_dnode - given a raw_inode, allocate a full_dnode for it, 5757+/* jffs2_write_dnode - given a raw_inode, allocate a full_dnode for it,5858 write it to the flash, link it into the existing inode/fragment list */59596060struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs, int alloc_mode)···8686 raw = jffs2_alloc_raw_node_ref();8787 if (!raw)8888 return ERR_PTR(-ENOMEM);8989-8989+9090 fn = jffs2_alloc_full_dnode();9191 if (!fn) {9292 jffs2_free_raw_node_ref(raw);···110110 if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) {111111 BUG_ON(!retried);112112 D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, "113113- "highest version %d -> updating dnode\n", 113113+ "highest version %d -> updating dnode\n",114114 je32_to_cpu(ri->version), f->highest_version));115115 ri->version = cpu_to_je32(++f->highest_version);116116 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));···120120 (alloc_mode==ALLOC_GC)?0:f->inocache->ino);121121122122 if (ret || (retlen != sizeof(*ri) + datalen)) {123123- printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", 123123+ printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n",124124 sizeof(*ri)+datalen, flash_ofs, ret, retlen);125125126126 /* Mark the space as dirtied */···128128 /* Doesn't belong to any inode */129129 raw->next_in_ino = NULL;130130131131- /* Don't change raw->size to match retlen. We may have 131131+ /* Don't change raw->size to match retlen. We may have132132 written the node header already, and only the data will133133 seem corrupted, in which case the scan would skip over134134- any node we write before the original intended end of 134134+ any node we write before the original intended end of135135 this node */136136 raw->flash_offset |= REF_OBSOLETE;137137 jffs2_add_physical_node_ref(c, raw);···148148 retried = 1;149149150150 D1(printk(KERN_DEBUG "Retrying failed write.\n"));151151-151151+152152 jffs2_dbg_acct_sanity_check(c,jeb);153153 jffs2_dbg_acct_paranoia_check(c, jeb);154154···159159 /* Locking pain */160160 up(&f->sem);161161 jffs2_complete_reservation(c);162162-162162+163163 ret = jffs2_reserve_space(c, sizeof(*ri) + datalen, &flash_ofs,164164 &dummy, alloc_mode, JFFS2_SUMMARY_INODE_SIZE);165165 down(&f->sem);···181181 return ERR_PTR(ret?ret:-EIO);182182 }183183 /* Mark the space used */184184- /* If node covers at least a whole page, or if it starts at the 185185- beginning of a page and runs to the end of the file, or if 186186- it's a hole node, mark it REF_PRISTINE, else REF_NORMAL. 184184+ /* If node covers at least a whole page, or if it starts at the185185+ beginning of a page and runs to the end of the file, or if186186+ it's a hole node, mark it REF_PRISTINE, else REF_NORMAL.187187 */188188 if ((je32_to_cpu(ri->dsize) >= PAGE_CACHE_SIZE) ||189189 ( ((je32_to_cpu(ri->offset)&(PAGE_CACHE_SIZE-1))==0) &&···201201 spin_unlock(&c->erase_completion_lock);202202203203 D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n",204204- flash_ofs, ref_flags(raw), je32_to_cpu(ri->dsize), 204204+ flash_ofs, ref_flags(raw), je32_to_cpu(ri->dsize),205205 je32_to_cpu(ri->csize), je32_to_cpu(ri->node_crc),206206 je32_to_cpu(ri->data_crc), je32_to_cpu(ri->totlen)));207207···221221 int retried = 0;222222 int ret;223223224224- D1(printk(KERN_DEBUG "jffs2_write_dirent(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n", 224224+ D1(printk(KERN_DEBUG "jffs2_write_dirent(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n",225225 je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino),226226 je32_to_cpu(rd->name_crc)));227227···235235 vecs[0].iov_len = sizeof(*rd);236236 vecs[1].iov_base = (unsigned char *)name;237237 vecs[1].iov_len = namelen;238238-238238+239239 jffs2_dbg_prewrite_paranoia_check(c, flash_ofs, vecs[0].iov_len + vecs[1].iov_len);240240241241 raw = jffs2_alloc_raw_node_ref();···276276 ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen,277277 (alloc_mode==ALLOC_GC)?0:je32_to_cpu(rd->pino));278278 if (ret || (retlen != sizeof(*rd) + namelen)) {279279- printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", 279279+ printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n",280280 sizeof(*rd)+namelen, flash_ofs, ret, retlen);281281 /* Mark the space as dirtied */282282 if (retlen) {···307307 /* Locking pain */308308 up(&f->sem);309309 jffs2_complete_reservation(c);310310-310310+311311 ret = jffs2_reserve_space(c, sizeof(*rd) + namelen, &flash_ofs,312312 &dummy, alloc_mode, JFFS2_SUMMARY_DIRENT_SIZE(namelen));313313 down(&f->sem);···346346 we don't have to go digging in struct inode or its equivalent. It should set:347347 mode, uid, gid, (starting)isize, atime, ctime, mtime */348348int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,349349- struct jffs2_raw_inode *ri, unsigned char *buf, 349349+ struct jffs2_raw_inode *ri, unsigned char *buf,350350 uint32_t offset, uint32_t writelen, uint32_t *retlen)351351{352352 int ret = 0;···354354355355 D1(printk(KERN_DEBUG "jffs2_write_inode_range(): Ino #%u, ofs 0x%x, len 0x%x\n",356356 f->inocache->ino, offset, writelen));357357-357357+358358 while(writelen) {359359 struct jffs2_full_dnode *fn;360360 unsigned char *comprbuf = NULL;···451451 uint32_t alloclen, phys_ofs;452452 int ret;453453454454- /* Try to reserve enough space for both node and dirent. 455455- * Just the node will do for now, though 454454+ /* Try to reserve enough space for both node and dirent.455455+ * Just the node will do for now, though456456 */457457 ret = jffs2_reserve_space(c, sizeof(*ri), &phys_ofs, &alloclen, ALLOC_NORMAL,458458 JFFS2_SUMMARY_INODE_SIZE);···477477 jffs2_complete_reservation(c);478478 return PTR_ERR(fn);479479 }480480- /* No data here. Only a metadata node, which will be 480480+ /* No data here. Only a metadata node, which will be481481 obsoleted by the first data write482482 */483483 f->metadata = fn;···486486 jffs2_complete_reservation(c);487487 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen,488488 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen));489489-489489+490490 if (ret) {491491 /* Eep. */492492 D1(printk(KERN_DEBUG "jffs2_reserve_space() for dirent failed\n"));···519519 fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_NORMAL);520520521521 jffs2_free_raw_dirent(rd);522522-522522+523523 if (IS_ERR(fd)) {524524- /* dirent failed to write. Delete the inode normally 524524+ /* dirent failed to write. Delete the inode normally525525 as if it were the final unlink() */526526 jffs2_complete_reservation(c);527527 up(&dir_f->sem);···548548 uint32_t alloclen, phys_ofs;549549 int ret;550550551551- if (1 /* alternative branch needs testing */ || 551551+ if (1 /* alternative branch needs testing */ ||552552 !jffs2_can_mark_obsolete(c)) {553553 /* We can't mark stuff obsolete on the medium. We need to write a deletion dirent */554554···570570 rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT);571571 rd->totlen = cpu_to_je32(sizeof(*rd) + namelen);572572 rd->hdr_crc = cpu_to_je32(crc32(0, rd, sizeof(struct jffs2_unknown_node)-4));573573-573573+574574 rd->pino = cpu_to_je32(dir_f->inocache->ino);575575 rd->version = cpu_to_je32(++dir_f->highest_version);576576 rd->ino = cpu_to_je32(0);···581581 rd->name_crc = cpu_to_je32(crc32(0, name, namelen));582582583583 fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_DELETION);584584-584584+585585 jffs2_free_raw_dirent(rd);586586587587 if (IS_ERR(fd)) {···600600 down(&dir_f->sem);601601602602 while ((*prev) && (*prev)->nhash <= nhash) {603603- if ((*prev)->nhash == nhash && 603603+ if ((*prev)->nhash == nhash &&604604 !memcmp((*prev)->name, name, namelen) &&605605 !(*prev)->name[namelen]) {606606 struct jffs2_full_dirent *this = *prev;···621621 /* dead_f is NULL if this was a rename not a real unlink */622622 /* Also catch the !f->inocache case, where there was a dirent623623 pointing to an inode which didn't exist. */624624- if (dead_f && dead_f->inocache) { 624624+ if (dead_f && dead_f->inocache) {625625626626 down(&dead_f->sem);627627···629629 while (dead_f->dents) {630630 /* There can be only deleted ones */631631 fd = dead_f->dents;632632-632632+633633 dead_f->dents = fd->next;634634-634634+635635 if (fd->ino) {636636 printk(KERN_WARNING "Deleting inode #%u with active dentry \"%s\"->ino #%u\n",637637 dead_f->inocache->ino, fd->name, fd->ino);···672672 jffs2_free_raw_dirent(rd);673673 return ret;674674 }675675-675675+676676 down(&dir_f->sem);677677678678 /* Build a deletion node */···693693 rd->name_crc = cpu_to_je32(crc32(0, name, namelen));694694695695 fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_NORMAL);696696-696696+697697 jffs2_free_raw_dirent(rd);698698699699 if (IS_ERR(fd)) {
+6-6
include/linux/jffs2.h
···55 *66 * Created by David Woodhouse <dwmw2@infradead.org>77 *88- * For licensing information, see the file 'LICENCE' in the 88+ * For licensing information, see the file 'LICENCE' in the99 * jffs2 directory.1010 *1111 * $Id: jffs2.h,v 1.38 2005/09/26 11:37:23 havasi Exp $···7070//#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)717172727373-#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at 7474- mount time, don't wait for it to 7373+#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at7474+ mount time, don't wait for it to7575 happen later */7676-#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific 7676+#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific7777 compression type */78787979···120120} __attribute__((packed));121121122122/* The JFFS2 raw inode structure: Used for storage on physical media. */123123-/* The uid, gid, atime, mtime and ctime members could be longer, but 123123+/* The uid, gid, atime, mtime and ctime members could be longer, but124124 are left like this for space efficiency. If and when people decide125125 they really need them extended, it's simple enough to add support for126126 a new type of raw node.···165165 jint32_t sum[0]; /* inode summary info */166166} __attribute__((packed));167167168168-union jffs2_node_union 168168+union jffs2_node_union169169{170170 struct jffs2_raw_inode i;171171 struct jffs2_raw_dirent d;
+2-2
include/linux/jffs2_fs_i.h
···11-/* $Id: jffs2_fs_i.h,v 1.18 2005/07/17 11:13:48 dedekind Exp $ */11+/* $Id: jffs2_fs_i.h,v 1.19 2005/11/07 11:14:52 gleixner Exp $ */2233#ifndef _JFFS2_FS_I44#define _JFFS2_FS_I···2525 /* There may be one datanode which isn't referenced by any of the2626 above fragments, if it contains a metadata update but no actual2727 data - or if this is a directory inode */2828- /* This also holds the _only_ dnode for symlinks/device nodes, 2828+ /* This also holds the _only_ dnode for symlinks/device nodes,2929 etc. */3030 struct jffs2_full_dnode *metadata;3131
+7-7
include/linux/jffs2_fs_sb.h
···2020struct jffs2_inodirty;21212222/* A struct for the overall file system control. Pointers to2323- jffs2_sb_info structs are named `c' in the source code. 2323+ jffs2_sb_info structs are named `c' in the source code.2424 Nee jffs_control2525*/2626struct jffs2_sb_info {···3535 struct completion gc_thread_start; /* GC thread start completion */3636 struct completion gc_thread_exit; /* GC thread exit completion port */37373838- struct semaphore alloc_sem; /* Used to protect all the following 3838+ struct semaphore alloc_sem; /* Used to protect all the following3939 fields, and also to protect against4040 out-of-order writing of nodes. And GC. */4141 uint32_t cleanmarker_size; /* Size of an _inline_ CLEANMARKER···6464 uint32_t nospc_dirty_size;65656666 uint32_t nr_blocks;6767- struct jffs2_eraseblock *blocks; /* The whole array of blocks. Used for getting blocks 6767+ struct jffs2_eraseblock *blocks; /* The whole array of blocks. Used for getting blocks6868 * from the offset (blocks[ofs / sector_size]) */6969 struct jffs2_eraseblock *nextblock; /* The block we're currently filling */7070···8282 struct list_head bad_list; /* Bad blocks. */8383 struct list_head bad_used_list; /* Bad blocks with valid data in. */84848585- spinlock_t erase_completion_lock; /* Protect free_list and erasing_list 8585+ spinlock_t erase_completion_lock; /* Protect free_list and erasing_list8686 against erase completion handler */8787 wait_queue_head_t erase_wait; /* For waiting for erases to complete */88888989 wait_queue_head_t inocache_wq;9090 struct jffs2_inode_cache **inocache_list;9191 spinlock_t inocache_lock;9292-9292+9393 /* Sem to allow jffs2_garbage_collect_deletion_dirent to9494- drop the erase_completion_lock while it's holding a pointer 9494+ drop the erase_completion_lock while it's holding a pointer9595 to an obsoleted node. I don't like this. Alternatives welcomed. */9696 struct semaphore erase_free_sem;97979898 uint32_t wbuf_pagesize; /* 0 for NOR and other flashes with no wbuf */9999-9999+100100#ifdef CONFIG_JFFS2_FS_WRITEBUFFER101101 /* Write-behind buffer for NAND flash */102102 unsigned char *wbuf;