blob: 30f888414ce77f1ce5534d9e23650a2ca8b4f0d3 [file] [log] [blame]
Ferenc Havasie631ddb2005-09-07 09:35:26 +01001/*
2 * JFFS2 -- Journalling Flash File System, Version 2.
3 *
4 * Copyright (C) 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>,
5 * Zoltan Sogor <weth@inf.u-szeged.hu>,
6 * Patrik Kluba <pajko@halom.u-szeged.hu>,
7 * University of Szeged, Hungary
KaiGai Kohei332a6b92006-06-24 09:17:42 +09008 * 2006 KaiGai Kohei <kaigai@ak.jp.nec.com>
Ferenc Havasie631ddb2005-09-07 09:35:26 +01009 *
10 * For licensing information, see the file 'LICENCE' in this directory.
11 *
Ferenc Havasi2bc97642005-09-26 12:37:25 +010012 * $Id: summary.c,v 1.4 2005/09/26 11:37:21 havasi Exp $
Ferenc Havasie631ddb2005-09-07 09:35:26 +010013 *
14 */
15
16#include <linux/kernel.h>
Ferenc Havasie631ddb2005-09-07 09:35:26 +010017#include <linux/slab.h>
18#include <linux/mtd/mtd.h>
19#include <linux/pagemap.h>
20#include <linux/crc32.h>
21#include <linux/compiler.h>
22#include <linux/vmalloc.h>
23#include "nodelist.h"
24#include "debug.h"
25
26int jffs2_sum_init(struct jffs2_sb_info *c)
27{
Yan Burman3d375d92006-12-04 15:03:01 -080028 c->summary = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
Ferenc Havasie631ddb2005-09-07 09:35:26 +010029
30 if (!c->summary) {
31 JFFS2_WARNING("Can't allocate memory for summary information!\n");
32 return -ENOMEM;
33 }
34
Ferenc Havasie631ddb2005-09-07 09:35:26 +010035 c->summary->sum_buf = vmalloc(c->sector_size);
36
37 if (!c->summary->sum_buf) {
38 JFFS2_WARNING("Can't allocate buffer for writing out summary information!\n");
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010039 kfree(c->summary);
Ferenc Havasie631ddb2005-09-07 09:35:26 +010040 return -ENOMEM;
41 }
42
Andreas Mohrd6e05ed2006-06-26 18:35:02 +020043 dbg_summary("returned successfully\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +010044
45 return 0;
46}
47
48void jffs2_sum_exit(struct jffs2_sb_info *c)
49{
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010050 dbg_summary("called\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +010051
52 jffs2_sum_disable_collecting(c->summary);
53
54 vfree(c->summary->sum_buf);
55 c->summary->sum_buf = NULL;
56
57 kfree(c->summary);
58 c->summary = NULL;
59}
60
61static int jffs2_sum_add_mem(struct jffs2_summary *s, union jffs2_sum_mem *item)
62{
63 if (!s->sum_list_head)
64 s->sum_list_head = (union jffs2_sum_mem *) item;
65 if (s->sum_list_tail)
66 s->sum_list_tail->u.next = (union jffs2_sum_mem *) item;
67 s->sum_list_tail = (union jffs2_sum_mem *) item;
68
69 switch (je16_to_cpu(item->u.nodetype)) {
70 case JFFS2_NODETYPE_INODE:
71 s->sum_size += JFFS2_SUMMARY_INODE_SIZE;
72 s->sum_num++;
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010073 dbg_summary("inode (%u) added to summary\n",
Ferenc Havasie631ddb2005-09-07 09:35:26 +010074 je32_to_cpu(item->i.inode));
75 break;
76 case JFFS2_NODETYPE_DIRENT:
77 s->sum_size += JFFS2_SUMMARY_DIRENT_SIZE(item->d.nsize);
78 s->sum_num++;
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010079 dbg_summary("dirent (%u) added to summary\n",
Ferenc Havasie631ddb2005-09-07 09:35:26 +010080 je32_to_cpu(item->d.ino));
81 break;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090082#ifdef CONFIG_JFFS2_FS_XATTR
83 case JFFS2_NODETYPE_XATTR:
84 s->sum_size += JFFS2_SUMMARY_XATTR_SIZE;
85 s->sum_num++;
86 dbg_summary("xattr (xid=%u, version=%u) added to summary\n",
87 je32_to_cpu(item->x.xid), je32_to_cpu(item->x.version));
88 break;
89 case JFFS2_NODETYPE_XREF:
90 s->sum_size += JFFS2_SUMMARY_XREF_SIZE;
91 s->sum_num++;
92 dbg_summary("xref added to summary\n");
93 break;
94#endif
Ferenc Havasie631ddb2005-09-07 09:35:26 +010095 default:
Thomas Gleixner182ec4e2005-11-07 11:16:07 +000096 JFFS2_WARNING("UNKNOWN node type %u\n",
Ferenc Havasie631ddb2005-09-07 09:35:26 +010097 je16_to_cpu(item->u.nodetype));
98 return 1;
99 }
100 return 0;
101}
102
103
104/* The following 3 functions are called from scan.c to collect summary info for not closed jeb */
105
106int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size)
107{
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100108 dbg_summary("called with %u\n", size);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100109 s->sum_padded += size;
110 return 0;
111}
112
113int jffs2_sum_add_inode_mem(struct jffs2_summary *s, struct jffs2_raw_inode *ri,
114 uint32_t ofs)
115{
116 struct jffs2_sum_inode_mem *temp = kmalloc(sizeof(struct jffs2_sum_inode_mem), GFP_KERNEL);
117
118 if (!temp)
119 return -ENOMEM;
120
121 temp->nodetype = ri->nodetype;
122 temp->inode = ri->ino;
123 temp->version = ri->version;
124 temp->offset = cpu_to_je32(ofs); /* relative offset from the begining of the jeb */
125 temp->totlen = ri->totlen;
126 temp->next = NULL;
127
128 return jffs2_sum_add_mem(s, (union jffs2_sum_mem *)temp);
129}
130
131int jffs2_sum_add_dirent_mem(struct jffs2_summary *s, struct jffs2_raw_dirent *rd,
132 uint32_t ofs)
133{
134 struct jffs2_sum_dirent_mem *temp =
135 kmalloc(sizeof(struct jffs2_sum_dirent_mem) + rd->nsize, GFP_KERNEL);
136
137 if (!temp)
138 return -ENOMEM;
139
140 temp->nodetype = rd->nodetype;
141 temp->totlen = rd->totlen;
142 temp->offset = cpu_to_je32(ofs); /* relative from the begining of the jeb */
143 temp->pino = rd->pino;
144 temp->version = rd->version;
145 temp->ino = rd->ino;
146 temp->nsize = rd->nsize;
147 temp->type = rd->type;
148 temp->next = NULL;
149
150 memcpy(temp->name, rd->name, rd->nsize);
151
152 return jffs2_sum_add_mem(s, (union jffs2_sum_mem *)temp);
153}
154
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900155#ifdef CONFIG_JFFS2_FS_XATTR
156int jffs2_sum_add_xattr_mem(struct jffs2_summary *s, struct jffs2_raw_xattr *rx, uint32_t ofs)
157{
158 struct jffs2_sum_xattr_mem *temp;
159
160 temp = kmalloc(sizeof(struct jffs2_sum_xattr_mem), GFP_KERNEL);
161 if (!temp)
162 return -ENOMEM;
163
164 temp->nodetype = rx->nodetype;
165 temp->xid = rx->xid;
166 temp->version = rx->version;
167 temp->offset = cpu_to_je32(ofs);
168 temp->totlen = rx->totlen;
169 temp->next = NULL;
170
171 return jffs2_sum_add_mem(s, (union jffs2_sum_mem *)temp);
172}
173
174int jffs2_sum_add_xref_mem(struct jffs2_summary *s, struct jffs2_raw_xref *rr, uint32_t ofs)
175{
176 struct jffs2_sum_xref_mem *temp;
177
178 temp = kmalloc(sizeof(struct jffs2_sum_xref_mem), GFP_KERNEL);
179 if (!temp)
180 return -ENOMEM;
181
182 temp->nodetype = rr->nodetype;
183 temp->offset = cpu_to_je32(ofs);
184 temp->next = NULL;
185
186 return jffs2_sum_add_mem(s, (union jffs2_sum_mem *)temp);
187}
188#endif
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100189/* Cleanup every collected summary information */
190
191static void jffs2_sum_clean_collected(struct jffs2_summary *s)
192{
193 union jffs2_sum_mem *temp;
194
195 if (!s->sum_list_head) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100196 dbg_summary("already empty\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100197 }
198 while (s->sum_list_head) {
199 temp = s->sum_list_head;
200 s->sum_list_head = s->sum_list_head->u.next;
201 kfree(temp);
202 }
203 s->sum_list_tail = NULL;
204 s->sum_padded = 0;
205 s->sum_num = 0;
206}
207
208void jffs2_sum_reset_collected(struct jffs2_summary *s)
209{
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100210 dbg_summary("called\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100211 jffs2_sum_clean_collected(s);
212 s->sum_size = 0;
213}
214
215void jffs2_sum_disable_collecting(struct jffs2_summary *s)
216{
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100217 dbg_summary("called\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100218 jffs2_sum_clean_collected(s);
219 s->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
220}
221
Thomas Gleixner182ec4e2005-11-07 11:16:07 +0000222int jffs2_sum_is_disabled(struct jffs2_summary *s)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100223{
224 return (s->sum_size == JFFS2_SUMMARY_NOSUM_SIZE);
225}
226
227/* Move the collected summary information into sb (called from scan.c) */
228
229void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s)
230{
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100231 dbg_summary("oldsize=0x%x oldnum=%u => newsize=0x%x newnum=%u\n",
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100232 c->summary->sum_size, c->summary->sum_num,
233 s->sum_size, s->sum_num);
234
235 c->summary->sum_size = s->sum_size;
236 c->summary->sum_num = s->sum_num;
237 c->summary->sum_padded = s->sum_padded;
238 c->summary->sum_list_head = s->sum_list_head;
239 c->summary->sum_list_tail = s->sum_list_tail;
240
241 s->sum_list_head = s->sum_list_tail = NULL;
242}
243
244/* Called from wbuf.c to collect writed node info */
245
246int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
247 unsigned long count, uint32_t ofs)
248{
249 union jffs2_node_union *node;
250 struct jffs2_eraseblock *jeb;
251
Zoltan Sogor27bea322006-09-16 12:15:59 -0700252 if (c->summary->sum_size == JFFS2_SUMMARY_NOSUM_SIZE) {
253 dbg_summary("Summary is disabled for this jeb! Skipping summary info!\n");
254 return 0;
255 }
256
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100257 node = invecs[0].iov_base;
258 jeb = &c->blocks[ofs / c->sector_size];
259 ofs -= jeb->offset;
260
261 switch (je16_to_cpu(node->u.nodetype)) {
262 case JFFS2_NODETYPE_INODE: {
263 struct jffs2_sum_inode_mem *temp =
264 kmalloc(sizeof(struct jffs2_sum_inode_mem), GFP_KERNEL);
265
266 if (!temp)
267 goto no_mem;
268
269 temp->nodetype = node->i.nodetype;
270 temp->inode = node->i.ino;
271 temp->version = node->i.version;
272 temp->offset = cpu_to_je32(ofs);
273 temp->totlen = node->i.totlen;
274 temp->next = NULL;
275
276 return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp);
277 }
278
279 case JFFS2_NODETYPE_DIRENT: {
280 struct jffs2_sum_dirent_mem *temp =
281 kmalloc(sizeof(struct jffs2_sum_dirent_mem) + node->d.nsize, GFP_KERNEL);
282
283 if (!temp)
284 goto no_mem;
285
286 temp->nodetype = node->d.nodetype;
287 temp->totlen = node->d.totlen;
288 temp->offset = cpu_to_je32(ofs);
289 temp->pino = node->d.pino;
290 temp->version = node->d.version;
291 temp->ino = node->d.ino;
292 temp->nsize = node->d.nsize;
293 temp->type = node->d.type;
294 temp->next = NULL;
295
296 switch (count) {
297 case 1:
298 memcpy(temp->name,node->d.name,node->d.nsize);
299 break;
300
301 case 2:
302 memcpy(temp->name,invecs[1].iov_base,node->d.nsize);
303 break;
304
305 default:
306 BUG(); /* impossible count value */
307 break;
308 }
309
310 return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp);
311 }
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900312#ifdef CONFIG_JFFS2_FS_XATTR
313 case JFFS2_NODETYPE_XATTR: {
314 struct jffs2_sum_xattr_mem *temp;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900315 temp = kmalloc(sizeof(struct jffs2_sum_xattr_mem), GFP_KERNEL);
316 if (!temp)
317 goto no_mem;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100318
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900319 temp->nodetype = node->x.nodetype;
320 temp->xid = node->x.xid;
321 temp->version = node->x.version;
322 temp->totlen = node->x.totlen;
323 temp->offset = cpu_to_je32(ofs);
324 temp->next = NULL;
325
326 return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp);
327 }
328 case JFFS2_NODETYPE_XREF: {
329 struct jffs2_sum_xref_mem *temp;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900330 temp = kmalloc(sizeof(struct jffs2_sum_xref_mem), GFP_KERNEL);
331 if (!temp)
332 goto no_mem;
333 temp->nodetype = node->r.nodetype;
334 temp->offset = cpu_to_je32(ofs);
335 temp->next = NULL;
336
337 return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp);
338 }
339#endif
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100340 case JFFS2_NODETYPE_PADDING:
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100341 dbg_summary("node PADDING\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100342 c->summary->sum_padded += je32_to_cpu(node->u.totlen);
343 break;
344
345 case JFFS2_NODETYPE_CLEANMARKER:
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100346 dbg_summary("node CLEANMARKER\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100347 break;
348
349 case JFFS2_NODETYPE_SUMMARY:
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100350 dbg_summary("node SUMMARY\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100351 break;
352
353 default:
354 /* If you implement a new node type you should also implement
355 summary support for it or disable summary.
356 */
357 BUG();
358 break;
359 }
360
361 return 0;
362
363no_mem:
364 JFFS2_WARNING("MEMORY ALLOCATION ERROR!");
365 return -ENOMEM;
366}
367
David Woodhouse2f785402006-05-24 02:04:45 +0100368static struct jffs2_raw_node_ref *sum_link_node_ref(struct jffs2_sb_info *c,
369 struct jffs2_eraseblock *jeb,
370 uint32_t ofs, uint32_t len,
371 struct jffs2_inode_cache *ic)
David Woodhouse49f11d42006-05-21 04:00:01 +0100372{
David Woodhouse49f11d42006-05-21 04:00:01 +0100373 /* If there was a gap, mark it dirty */
David Woodhouse2f785402006-05-24 02:04:45 +0100374 if ((ofs & ~3) > c->sector_size - jeb->free_size) {
375 /* Ew. Summary doesn't actually tell us explicitly about dirty space */
376 jffs2_scan_dirty_space(c, jeb, (ofs & ~3) - (c->sector_size - jeb->free_size));
David Woodhouse49f11d42006-05-21 04:00:01 +0100377 }
David Woodhouse49f11d42006-05-21 04:00:01 +0100378
David Woodhouse2f785402006-05-24 02:04:45 +0100379 return jffs2_link_node_ref(c, jeb, jeb->offset + ofs, len, ic);
David Woodhouse49f11d42006-05-21 04:00:01 +0100380}
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100381
382/* Process the stored summary information - helper function for jffs2_sum_scan_sumnode() */
383
384static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
Ferenc Havasi2bc97642005-09-26 12:37:25 +0100385 struct jffs2_raw_summary *summary, uint32_t *pseudo_random)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100386{
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100387 struct jffs2_inode_cache *ic;
388 struct jffs2_full_dirent *fd;
389 void *sp;
390 int i, ino;
David Woodhouse68270992006-05-21 03:46:05 +0100391 int err;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100392
393 sp = summary->sum;
394
395 for (i=0; i<je32_to_cpu(summary->sum_num); i++) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100396 dbg_summary("processing summary index %d\n", i);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100397
Artem Bityutskiya2166b92006-12-28 12:01:41 +0200398 cond_resched();
399
David Woodhouse2f785402006-05-24 02:04:45 +0100400 /* Make sure there's a spare ref for dirty space */
David Woodhouse046b8b92006-05-25 01:50:35 +0100401 err = jffs2_prealloc_raw_node_refs(c, jeb, 2);
David Woodhouse2f785402006-05-24 02:04:45 +0100402 if (err)
403 return err;
404
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100405 switch (je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype)) {
406 case JFFS2_NODETYPE_INODE: {
407 struct jffs2_sum_inode_flash *spi;
408 spi = sp;
409
410 ino = je32_to_cpu(spi->inode);
411
David Woodhouse9167e0f2006-05-21 13:13:45 +0100412 dbg_summary("Inode at 0x%08x-0x%08x\n",
413 jeb->offset + je32_to_cpu(spi->offset),
David Woodhouse8b9e9fe2006-05-25 01:53:09 +0100414 jeb->offset + je32_to_cpu(spi->offset) + je32_to_cpu(spi->totlen));
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100415
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100416 ic = jffs2_scan_make_ino_cache(c, ino);
417 if (!ic) {
418 JFFS2_NOTICE("scan_make_ino_cache failed\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100419 return -ENOMEM;
420 }
421
David Woodhouse2f785402006-05-24 02:04:45 +0100422 sum_link_node_ref(c, jeb, je32_to_cpu(spi->offset) | REF_UNCHECKED,
423 PAD(je32_to_cpu(spi->totlen)), ic);
David Woodhousef1f96712006-05-20 19:45:26 +0100424
425 *pseudo_random += je32_to_cpu(spi->version);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100426
427 sp += JFFS2_SUMMARY_INODE_SIZE;
428
429 break;
430 }
431
432 case JFFS2_NODETYPE_DIRENT: {
433 struct jffs2_sum_dirent_flash *spd;
434 spd = sp;
435
David Woodhouse8b9e9fe2006-05-25 01:53:09 +0100436 dbg_summary("Dirent at 0x%08x-0x%08x\n",
David Woodhouse9167e0f2006-05-21 13:13:45 +0100437 jeb->offset + je32_to_cpu(spd->offset),
438 jeb->offset + je32_to_cpu(spd->offset) + je32_to_cpu(spd->totlen));
439
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100440
441 fd = jffs2_alloc_full_dirent(spd->nsize+1);
David Woodhouse9641b782006-05-20 16:13:34 +0100442 if (!fd)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100443 return -ENOMEM;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100444
445 memcpy(&fd->name, spd->name, spd->nsize);
446 fd->name[spd->nsize] = 0;
447
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100448 ic = jffs2_scan_make_ino_cache(c, je32_to_cpu(spd->pino));
449 if (!ic) {
450 jffs2_free_full_dirent(fd);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100451 return -ENOMEM;
452 }
453
David Woodhouse1046d882006-06-18 22:44:21 +0100454 fd->raw = sum_link_node_ref(c, jeb, je32_to_cpu(spd->offset) | REF_UNCHECKED,
David Woodhouse2f785402006-05-24 02:04:45 +0100455 PAD(je32_to_cpu(spd->totlen)), ic);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100456
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100457 fd->next = NULL;
458 fd->version = je32_to_cpu(spd->version);
459 fd->ino = je32_to_cpu(spd->ino);
460 fd->nhash = full_name_hash(fd->name, spd->nsize);
461 fd->type = spd->type;
David Woodhousef1f96712006-05-20 19:45:26 +0100462
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100463 jffs2_add_fd_to_list(c, fd, &ic->scan_dents);
464
465 *pseudo_random += je32_to_cpu(spd->version);
466
467 sp += JFFS2_SUMMARY_DIRENT_SIZE(spd->nsize);
468
469 break;
470 }
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900471#ifdef CONFIG_JFFS2_FS_XATTR
472 case JFFS2_NODETYPE_XATTR: {
473 struct jffs2_xattr_datum *xd;
474 struct jffs2_sum_xattr_flash *spx;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100475
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900476 spx = (struct jffs2_sum_xattr_flash *)sp;
David Woodhouse9167e0f2006-05-21 13:13:45 +0100477 dbg_summary("xattr at %#08x-%#08x (xid=%u, version=%u)\n",
David Woodhouse49f11d42006-05-21 04:00:01 +0100478 jeb->offset + je32_to_cpu(spx->offset),
David Woodhouse9167e0f2006-05-21 13:13:45 +0100479 jeb->offset + je32_to_cpu(spx->offset) + je32_to_cpu(spx->totlen),
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900480 je32_to_cpu(spx->xid), je32_to_cpu(spx->version));
David Woodhouse2f785402006-05-24 02:04:45 +0100481
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900482 xd = jffs2_setup_xattr_datum(c, je32_to_cpu(spx->xid),
483 je32_to_cpu(spx->version));
KaiGai Koheic9f700f2006-06-11 10:35:15 +0900484 if (IS_ERR(xd))
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900485 return PTR_ERR(xd);
KaiGai Koheic9f700f2006-06-11 10:35:15 +0900486 if (xd->version > je32_to_cpu(spx->version)) {
487 /* node is not the newest one */
488 struct jffs2_raw_node_ref *raw
489 = sum_link_node_ref(c, jeb, je32_to_cpu(spx->offset) | REF_UNCHECKED,
490 PAD(je32_to_cpu(spx->totlen)), NULL);
491 raw->next_in_ino = xd->node->next_in_ino;
492 xd->node->next_in_ino = raw;
493 } else {
494 xd->version = je32_to_cpu(spx->version);
495 sum_link_node_ref(c, jeb, je32_to_cpu(spx->offset) | REF_UNCHECKED,
496 PAD(je32_to_cpu(spx->totlen)), (void *)xd);
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900497 }
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900498 *pseudo_random += je32_to_cpu(spx->xid);
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900499 sp += JFFS2_SUMMARY_XATTR_SIZE;
500
501 break;
502 }
503 case JFFS2_NODETYPE_XREF: {
504 struct jffs2_xattr_ref *ref;
505 struct jffs2_sum_xref_flash *spr;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900506
507 spr = (struct jffs2_sum_xref_flash *)sp;
David Woodhouse9167e0f2006-05-21 13:13:45 +0100508 dbg_summary("xref at %#08x-%#08x\n",
David Woodhouse49f11d42006-05-21 04:00:01 +0100509 jeb->offset + je32_to_cpu(spr->offset),
David Woodhouse9bfeb692006-05-26 21:19:05 +0100510 jeb->offset + je32_to_cpu(spr->offset) +
511 (uint32_t)PAD(sizeof(struct jffs2_raw_xref)));
David Woodhouse9167e0f2006-05-21 13:13:45 +0100512
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900513 ref = jffs2_alloc_xattr_ref();
514 if (!ref) {
515 JFFS2_NOTICE("allocation of xattr_datum failed\n");
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900516 return -ENOMEM;
517 }
KaiGai Kohei8f2b6f42006-05-13 15:15:07 +0900518 ref->next = c->xref_temp;
519 c->xref_temp = ref;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900520
KaiGai Koheic9f700f2006-06-11 10:35:15 +0900521 sum_link_node_ref(c, jeb, je32_to_cpu(spr->offset) | REF_UNCHECKED,
522 PAD(sizeof(struct jffs2_raw_xref)), (void *)ref);
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900523
David Woodhouse2f785402006-05-24 02:04:45 +0100524 *pseudo_random += ref->node->flash_offset;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900525 sp += JFFS2_SUMMARY_XREF_SIZE;
526
527 break;
528 }
529#endif
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100530 default : {
David Woodhouse7807ef72006-05-21 03:45:27 +0100531 uint16_t nodetype = je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype);
532 JFFS2_WARNING("Unsupported node type %x found in summary! Exiting...\n", nodetype);
533 if ((nodetype & JFFS2_COMPAT_MASK) == JFFS2_FEATURE_INCOMPAT)
534 return -EIO;
535
536 /* For compatible node types, just fall back to the full scan */
537 c->wasted_size -= jeb->wasted_size;
538 c->free_size += c->sector_size - jeb->free_size;
539 c->used_size -= jeb->used_size;
540 c->dirty_size -= jeb->dirty_size;
541 jeb->wasted_size = jeb->used_size = jeb->dirty_size = 0;
542 jeb->free_size = c->sector_size;
543
David Woodhousec38c1b62006-05-25 01:38:27 +0100544 jffs2_free_jeb_node_refs(c, jeb);
David Woodhouse7807ef72006-05-21 03:45:27 +0100545 return -ENOTRECOVERABLE;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100546 }
547 }
548 }
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100549 return 0;
550}
551
552/* Process the summary node - called from jffs2_scan_eraseblock() */
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100553int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
David Woodhouse9641b782006-05-20 16:13:34 +0100554 struct jffs2_raw_summary *summary, uint32_t sumsize,
555 uint32_t *pseudo_random)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100556{
557 struct jffs2_unknown_node crcnode;
David Woodhouse9641b782006-05-20 16:13:34 +0100558 int ret, ofs;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100559 uint32_t crc;
560
David Woodhouse49f11d42006-05-21 04:00:01 +0100561 ofs = c->sector_size - sumsize;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100562
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100563 dbg_summary("summary found for 0x%08x at 0x%08x (0x%x bytes)\n",
David Woodhouse49f11d42006-05-21 04:00:01 +0100564 jeb->offset, jeb->offset + ofs, sumsize);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100565
566 /* OK, now check for node validity and CRC */
567 crcnode.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
568 crcnode.nodetype = cpu_to_je16(JFFS2_NODETYPE_SUMMARY);
569 crcnode.totlen = summary->totlen;
570 crc = crc32(0, &crcnode, sizeof(crcnode)-4);
571
572 if (je32_to_cpu(summary->hdr_crc) != crc) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100573 dbg_summary("Summary node header is corrupt (bad CRC or "
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100574 "no summary at all)\n");
575 goto crc_err;
576 }
577
578 if (je32_to_cpu(summary->totlen) != sumsize) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100579 dbg_summary("Summary node is corrupt (wrong erasesize?)\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100580 goto crc_err;
581 }
582
Ferenc Havasi2bc97642005-09-26 12:37:25 +0100583 crc = crc32(0, summary, sizeof(struct jffs2_raw_summary)-8);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100584
585 if (je32_to_cpu(summary->node_crc) != crc) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100586 dbg_summary("Summary node is corrupt (bad CRC)\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100587 goto crc_err;
588 }
589
Ferenc Havasi2bc97642005-09-26 12:37:25 +0100590 crc = crc32(0, summary->sum, sumsize - sizeof(struct jffs2_raw_summary));
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100591
592 if (je32_to_cpu(summary->sum_crc) != crc) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100593 dbg_summary("Summary node data is corrupt (bad CRC)\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100594 goto crc_err;
595 }
596
597 if ( je32_to_cpu(summary->cln_mkr) ) {
598
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100599 dbg_summary("Summary : CLEANMARKER node \n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100600
David Woodhouse098a1982006-05-30 09:00:14 +0100601 ret = jffs2_prealloc_raw_node_refs(c, jeb, 1);
602 if (ret)
603 return ret;
604
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100605 if (je32_to_cpu(summary->cln_mkr) != c->cleanmarker_size) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100606 dbg_summary("CLEANMARKER node has totlen 0x%x != normal 0x%x\n",
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100607 je32_to_cpu(summary->cln_mkr), c->cleanmarker_size);
David Woodhouse098a1982006-05-30 09:00:14 +0100608 if ((ret = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(summary->cln_mkr)))))
609 return ret;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100610 } else if (jeb->first_node) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100611 dbg_summary("CLEANMARKER node not first node in block "
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100612 "(0x%08x)\n", jeb->offset);
David Woodhouse098a1982006-05-30 09:00:14 +0100613 if ((ret = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(summary->cln_mkr)))))
614 return ret;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100615 } else {
David Woodhouse2f785402006-05-24 02:04:45 +0100616 jffs2_link_node_ref(c, jeb, jeb->offset | REF_NORMAL,
617 je32_to_cpu(summary->cln_mkr), NULL);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100618 }
619 }
620
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100621 ret = jffs2_sum_process_sum_data(c, jeb, summary, pseudo_random);
David Woodhouse7807ef72006-05-21 03:45:27 +0100622 /* -ENOTRECOVERABLE isn't a fatal error -- it means we should do a full
623 scan of this eraseblock. So return zero */
624 if (ret == -ENOTRECOVERABLE)
625 return 0;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100626 if (ret)
David Woodhouse7807ef72006-05-21 03:45:27 +0100627 return ret; /* real error */
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100628
629 /* for PARANOIA_CHECK */
David Woodhouse046b8b92006-05-25 01:50:35 +0100630 ret = jffs2_prealloc_raw_node_refs(c, jeb, 2);
David Woodhouse2f785402006-05-24 02:04:45 +0100631 if (ret)
632 return ret;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100633
David Woodhousef61579c32006-05-25 01:42:40 +0100634 sum_link_node_ref(c, jeb, ofs | REF_NORMAL, sumsize, NULL);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100635
David Woodhouse49f11d42006-05-21 04:00:01 +0100636 if (unlikely(jeb->free_size)) {
637 JFFS2_WARNING("Free size 0x%x bytes in eraseblock @0x%08x with summary?\n",
638 jeb->free_size, jeb->offset);
639 jeb->wasted_size += jeb->free_size;
640 c->wasted_size += jeb->free_size;
641 c->free_size -= jeb->free_size;
642 jeb->free_size = 0;
643 }
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100644
645 return jffs2_scan_classify_jeb(c, jeb);
646
647crc_err:
648 JFFS2_WARNING("Summary node crc error, skipping summary information.\n");
649
650 return 0;
651}
652
653/* Write summary data to flash - helper function for jffs2_sum_write_sumnode() */
654
655static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
656 uint32_t infosize, uint32_t datasize, int padsize)
657{
Ferenc Havasi2bc97642005-09-26 12:37:25 +0100658 struct jffs2_raw_summary isum;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100659 union jffs2_sum_mem *temp;
660 struct jffs2_sum_marker *sm;
661 struct kvec vecs[2];
David Woodhouse2f785402006-05-24 02:04:45 +0100662 uint32_t sum_ofs;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100663 void *wpage;
664 int ret;
665 size_t retlen;
666
667 memset(c->summary->sum_buf, 0xff, datasize);
668 memset(&isum, 0, sizeof(isum));
669
670 isum.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
671 isum.nodetype = cpu_to_je16(JFFS2_NODETYPE_SUMMARY);
672 isum.totlen = cpu_to_je32(infosize);
673 isum.hdr_crc = cpu_to_je32(crc32(0, &isum, sizeof(struct jffs2_unknown_node) - 4));
674 isum.padded = cpu_to_je32(c->summary->sum_padded);
675 isum.cln_mkr = cpu_to_je32(c->cleanmarker_size);
676 isum.sum_num = cpu_to_je32(c->summary->sum_num);
677 wpage = c->summary->sum_buf;
678
679 while (c->summary->sum_num) {
Jesper Juhl20ffdcb2006-05-12 11:55:51 +0100680 temp = c->summary->sum_list_head;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100681
Jesper Juhl20ffdcb2006-05-12 11:55:51 +0100682 switch (je16_to_cpu(temp->u.nodetype)) {
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100683 case JFFS2_NODETYPE_INODE: {
684 struct jffs2_sum_inode_flash *sino_ptr = wpage;
685
Jesper Juhl20ffdcb2006-05-12 11:55:51 +0100686 sino_ptr->nodetype = temp->i.nodetype;
687 sino_ptr->inode = temp->i.inode;
688 sino_ptr->version = temp->i.version;
689 sino_ptr->offset = temp->i.offset;
690 sino_ptr->totlen = temp->i.totlen;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100691
692 wpage += JFFS2_SUMMARY_INODE_SIZE;
693
694 break;
695 }
696
697 case JFFS2_NODETYPE_DIRENT: {
698 struct jffs2_sum_dirent_flash *sdrnt_ptr = wpage;
699
Jesper Juhl20ffdcb2006-05-12 11:55:51 +0100700 sdrnt_ptr->nodetype = temp->d.nodetype;
701 sdrnt_ptr->totlen = temp->d.totlen;
702 sdrnt_ptr->offset = temp->d.offset;
703 sdrnt_ptr->pino = temp->d.pino;
704 sdrnt_ptr->version = temp->d.version;
705 sdrnt_ptr->ino = temp->d.ino;
706 sdrnt_ptr->nsize = temp->d.nsize;
707 sdrnt_ptr->type = temp->d.type;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100708
Jesper Juhl20ffdcb2006-05-12 11:55:51 +0100709 memcpy(sdrnt_ptr->name, temp->d.name,
710 temp->d.nsize);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100711
Jesper Juhl20ffdcb2006-05-12 11:55:51 +0100712 wpage += JFFS2_SUMMARY_DIRENT_SIZE(temp->d.nsize);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100713
714 break;
715 }
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900716#ifdef CONFIG_JFFS2_FS_XATTR
717 case JFFS2_NODETYPE_XATTR: {
718 struct jffs2_sum_xattr_flash *sxattr_ptr = wpage;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100719
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900720 temp = c->summary->sum_list_head;
721 sxattr_ptr->nodetype = temp->x.nodetype;
722 sxattr_ptr->xid = temp->x.xid;
723 sxattr_ptr->version = temp->x.version;
724 sxattr_ptr->offset = temp->x.offset;
725 sxattr_ptr->totlen = temp->x.totlen;
726
727 wpage += JFFS2_SUMMARY_XATTR_SIZE;
728 break;
729 }
730 case JFFS2_NODETYPE_XREF: {
731 struct jffs2_sum_xref_flash *sxref_ptr = wpage;
732
733 temp = c->summary->sum_list_head;
734 sxref_ptr->nodetype = temp->r.nodetype;
735 sxref_ptr->offset = temp->r.offset;
736
737 wpage += JFFS2_SUMMARY_XREF_SIZE;
738 break;
739 }
740#endif
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100741 default : {
David Woodhouse61715862006-05-21 00:02:06 +0100742 if ((je16_to_cpu(temp->u.nodetype) & JFFS2_COMPAT_MASK)
743 == JFFS2_FEATURE_RWCOMPAT_COPY) {
744 dbg_summary("Writing unknown RWCOMPAT_COPY node type %x\n",
745 je16_to_cpu(temp->u.nodetype));
746 jffs2_sum_disable_collecting(c->summary);
747 } else {
748 BUG(); /* unknown node in summary information */
749 }
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100750 }
751 }
752
Jesper Juhl20ffdcb2006-05-12 11:55:51 +0100753 c->summary->sum_list_head = temp->u.next;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100754 kfree(temp);
755
756 c->summary->sum_num--;
757 }
758
759 jffs2_sum_reset_collected(c->summary);
760
761 wpage += padsize;
762
763 sm = wpage;
764 sm->offset = cpu_to_je32(c->sector_size - jeb->free_size);
765 sm->magic = cpu_to_je32(JFFS2_SUM_MAGIC);
766
767 isum.sum_crc = cpu_to_je32(crc32(0, c->summary->sum_buf, datasize));
768 isum.node_crc = cpu_to_je32(crc32(0, &isum, sizeof(isum) - 8));
769
770 vecs[0].iov_base = &isum;
771 vecs[0].iov_len = sizeof(isum);
772 vecs[1].iov_base = c->summary->sum_buf;
773 vecs[1].iov_len = datasize;
774
David Woodhouse2f785402006-05-24 02:04:45 +0100775 sum_ofs = jeb->offset + c->sector_size - jeb->free_size;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100776
David Woodhouse2f785402006-05-24 02:04:45 +0100777 dbg_summary("JFFS2: writing out data to flash to pos : 0x%08x\n",
778 sum_ofs);
779
780 ret = jffs2_flash_writev(c, vecs, 2, sum_ofs, &retlen, 0);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100781
782 if (ret || (retlen != infosize)) {
David Woodhouse010b06d2006-05-21 13:15:59 +0100783
David Woodhousec41ff6e2006-05-16 17:05:33 +0100784 JFFS2_WARNING("Write of %u bytes at 0x%08x failed. returned %d, retlen %zd\n",
David Woodhouse2f785402006-05-24 02:04:45 +0100785 infosize, sum_ofs, ret, retlen);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100786
David Woodhouse9bfeb692006-05-26 21:19:05 +0100787 if (retlen) {
788 /* Waste remaining space */
789 spin_lock(&c->erase_completion_lock);
790 jffs2_link_node_ref(c, jeb, sum_ofs | REF_OBSOLETE, infosize, NULL);
791 spin_unlock(&c->erase_completion_lock);
792 }
David Woodhouse010b06d2006-05-21 13:15:59 +0100793
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100794 c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100795
David Woodhouse2f785402006-05-24 02:04:45 +0100796 return 0;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100797 }
798
David Woodhouse010b06d2006-05-21 13:15:59 +0100799 spin_lock(&c->erase_completion_lock);
David Woodhouse2f785402006-05-24 02:04:45 +0100800 jffs2_link_node_ref(c, jeb, sum_ofs | REF_NORMAL, infosize, NULL);
801 spin_unlock(&c->erase_completion_lock);
David Woodhouse010b06d2006-05-21 13:15:59 +0100802
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100803 return 0;
804}
805
806/* Write out summary information - called from jffs2_do_reserve_space */
807
808int jffs2_sum_write_sumnode(struct jffs2_sb_info *c)
809{
David Woodhouse2f785402006-05-24 02:04:45 +0100810 int datasize, infosize, padsize;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100811 struct jffs2_eraseblock *jeb;
David Woodhouse2f785402006-05-24 02:04:45 +0100812 int ret;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100813
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100814 dbg_summary("called\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100815
David Woodhouse2f785402006-05-24 02:04:45 +0100816 spin_unlock(&c->erase_completion_lock);
David Woodhouse2f785402006-05-24 02:04:45 +0100817
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100818 jeb = c->nextblock;
David Woodhouse046b8b92006-05-25 01:50:35 +0100819 jffs2_prealloc_raw_node_refs(c, jeb, 1);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100820
821 if (!c->summary->sum_num || !c->summary->sum_list_head) {
822 JFFS2_WARNING("Empty summary info!!!\n");
823 BUG();
824 }
825
826 datasize = c->summary->sum_size + sizeof(struct jffs2_sum_marker);
Ferenc Havasi2bc97642005-09-26 12:37:25 +0100827 infosize = sizeof(struct jffs2_raw_summary) + datasize;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100828 padsize = jeb->free_size - infosize;
Thomas Gleixner182ec4e2005-11-07 11:16:07 +0000829 infosize += padsize;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100830 datasize += padsize;
831
832 /* Is there enough space for summary? */
833 if (padsize < 0) {
834 /* don't try to write out summary for this jeb */
835 jffs2_sum_disable_collecting(c->summary);
836
837 JFFS2_WARNING("Not enough space for summary, padsize = %d\n", padsize);
David Woodhouse9bfeb692006-05-26 21:19:05 +0100838 spin_lock(&c->erase_completion_lock);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100839 return 0;
840 }
841
842 ret = jffs2_sum_write_data(c, jeb, infosize, datasize, padsize);
David Woodhouse010b06d2006-05-21 13:15:59 +0100843 spin_lock(&c->erase_completion_lock);
David Woodhouse2f785402006-05-24 02:04:45 +0100844 return ret;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100845}