blob: c4f7e4703c0a32a0b8b43dd5903d184ad61e7cf1 [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>
17#include <linux/sched.h>
18#include <linux/slab.h>
19#include <linux/mtd/mtd.h>
20#include <linux/pagemap.h>
21#include <linux/crc32.h>
22#include <linux/compiler.h>
23#include <linux/vmalloc.h>
24#include "nodelist.h"
25#include "debug.h"
26
27int jffs2_sum_init(struct jffs2_sb_info *c)
28{
Yan Burman3d375d92006-12-04 15:03:01 -080029 c->summary = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
Ferenc Havasie631ddb2005-09-07 09:35:26 +010030
31 if (!c->summary) {
32 JFFS2_WARNING("Can't allocate memory for summary information!\n");
33 return -ENOMEM;
34 }
35
Ferenc Havasie631ddb2005-09-07 09:35:26 +010036 c->summary->sum_buf = vmalloc(c->sector_size);
37
38 if (!c->summary->sum_buf) {
39 JFFS2_WARNING("Can't allocate buffer for writing out summary information!\n");
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010040 kfree(c->summary);
Ferenc Havasie631ddb2005-09-07 09:35:26 +010041 return -ENOMEM;
42 }
43
Andreas Mohrd6e05ed2006-06-26 18:35:02 +020044 dbg_summary("returned successfully\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +010045
46 return 0;
47}
48
49void jffs2_sum_exit(struct jffs2_sb_info *c)
50{
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010051 dbg_summary("called\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +010052
53 jffs2_sum_disable_collecting(c->summary);
54
55 vfree(c->summary->sum_buf);
56 c->summary->sum_buf = NULL;
57
58 kfree(c->summary);
59 c->summary = NULL;
60}
61
62static int jffs2_sum_add_mem(struct jffs2_summary *s, union jffs2_sum_mem *item)
63{
64 if (!s->sum_list_head)
65 s->sum_list_head = (union jffs2_sum_mem *) item;
66 if (s->sum_list_tail)
67 s->sum_list_tail->u.next = (union jffs2_sum_mem *) item;
68 s->sum_list_tail = (union jffs2_sum_mem *) item;
69
70 switch (je16_to_cpu(item->u.nodetype)) {
71 case JFFS2_NODETYPE_INODE:
72 s->sum_size += JFFS2_SUMMARY_INODE_SIZE;
73 s->sum_num++;
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010074 dbg_summary("inode (%u) added to summary\n",
Ferenc Havasie631ddb2005-09-07 09:35:26 +010075 je32_to_cpu(item->i.inode));
76 break;
77 case JFFS2_NODETYPE_DIRENT:
78 s->sum_size += JFFS2_SUMMARY_DIRENT_SIZE(item->d.nsize);
79 s->sum_num++;
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010080 dbg_summary("dirent (%u) added to summary\n",
Ferenc Havasie631ddb2005-09-07 09:35:26 +010081 je32_to_cpu(item->d.ino));
82 break;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +090083#ifdef CONFIG_JFFS2_FS_XATTR
84 case JFFS2_NODETYPE_XATTR:
85 s->sum_size += JFFS2_SUMMARY_XATTR_SIZE;
86 s->sum_num++;
87 dbg_summary("xattr (xid=%u, version=%u) added to summary\n",
88 je32_to_cpu(item->x.xid), je32_to_cpu(item->x.version));
89 break;
90 case JFFS2_NODETYPE_XREF:
91 s->sum_size += JFFS2_SUMMARY_XREF_SIZE;
92 s->sum_num++;
93 dbg_summary("xref added to summary\n");
94 break;
95#endif
Ferenc Havasie631ddb2005-09-07 09:35:26 +010096 default:
Thomas Gleixner182ec4e2005-11-07 11:16:07 +000097 JFFS2_WARNING("UNKNOWN node type %u\n",
Ferenc Havasie631ddb2005-09-07 09:35:26 +010098 je16_to_cpu(item->u.nodetype));
99 return 1;
100 }
101 return 0;
102}
103
104
105/* The following 3 functions are called from scan.c to collect summary info for not closed jeb */
106
107int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size)
108{
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100109 dbg_summary("called with %u\n", size);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100110 s->sum_padded += size;
111 return 0;
112}
113
114int jffs2_sum_add_inode_mem(struct jffs2_summary *s, struct jffs2_raw_inode *ri,
115 uint32_t ofs)
116{
117 struct jffs2_sum_inode_mem *temp = kmalloc(sizeof(struct jffs2_sum_inode_mem), GFP_KERNEL);
118
119 if (!temp)
120 return -ENOMEM;
121
122 temp->nodetype = ri->nodetype;
123 temp->inode = ri->ino;
124 temp->version = ri->version;
125 temp->offset = cpu_to_je32(ofs); /* relative offset from the begining of the jeb */
126 temp->totlen = ri->totlen;
127 temp->next = NULL;
128
129 return jffs2_sum_add_mem(s, (union jffs2_sum_mem *)temp);
130}
131
132int jffs2_sum_add_dirent_mem(struct jffs2_summary *s, struct jffs2_raw_dirent *rd,
133 uint32_t ofs)
134{
135 struct jffs2_sum_dirent_mem *temp =
136 kmalloc(sizeof(struct jffs2_sum_dirent_mem) + rd->nsize, GFP_KERNEL);
137
138 if (!temp)
139 return -ENOMEM;
140
141 temp->nodetype = rd->nodetype;
142 temp->totlen = rd->totlen;
143 temp->offset = cpu_to_je32(ofs); /* relative from the begining of the jeb */
144 temp->pino = rd->pino;
145 temp->version = rd->version;
146 temp->ino = rd->ino;
147 temp->nsize = rd->nsize;
148 temp->type = rd->type;
149 temp->next = NULL;
150
151 memcpy(temp->name, rd->name, rd->nsize);
152
153 return jffs2_sum_add_mem(s, (union jffs2_sum_mem *)temp);
154}
155
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900156#ifdef CONFIG_JFFS2_FS_XATTR
157int jffs2_sum_add_xattr_mem(struct jffs2_summary *s, struct jffs2_raw_xattr *rx, uint32_t ofs)
158{
159 struct jffs2_sum_xattr_mem *temp;
160
161 temp = kmalloc(sizeof(struct jffs2_sum_xattr_mem), GFP_KERNEL);
162 if (!temp)
163 return -ENOMEM;
164
165 temp->nodetype = rx->nodetype;
166 temp->xid = rx->xid;
167 temp->version = rx->version;
168 temp->offset = cpu_to_je32(ofs);
169 temp->totlen = rx->totlen;
170 temp->next = NULL;
171
172 return jffs2_sum_add_mem(s, (union jffs2_sum_mem *)temp);
173}
174
175int jffs2_sum_add_xref_mem(struct jffs2_summary *s, struct jffs2_raw_xref *rr, uint32_t ofs)
176{
177 struct jffs2_sum_xref_mem *temp;
178
179 temp = kmalloc(sizeof(struct jffs2_sum_xref_mem), GFP_KERNEL);
180 if (!temp)
181 return -ENOMEM;
182
183 temp->nodetype = rr->nodetype;
184 temp->offset = cpu_to_je32(ofs);
185 temp->next = NULL;
186
187 return jffs2_sum_add_mem(s, (union jffs2_sum_mem *)temp);
188}
189#endif
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100190/* Cleanup every collected summary information */
191
192static void jffs2_sum_clean_collected(struct jffs2_summary *s)
193{
194 union jffs2_sum_mem *temp;
195
196 if (!s->sum_list_head) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100197 dbg_summary("already empty\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100198 }
199 while (s->sum_list_head) {
200 temp = s->sum_list_head;
201 s->sum_list_head = s->sum_list_head->u.next;
202 kfree(temp);
203 }
204 s->sum_list_tail = NULL;
205 s->sum_padded = 0;
206 s->sum_num = 0;
207}
208
209void jffs2_sum_reset_collected(struct jffs2_summary *s)
210{
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100211 dbg_summary("called\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100212 jffs2_sum_clean_collected(s);
213 s->sum_size = 0;
214}
215
216void jffs2_sum_disable_collecting(struct jffs2_summary *s)
217{
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100218 dbg_summary("called\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100219 jffs2_sum_clean_collected(s);
220 s->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
221}
222
Thomas Gleixner182ec4e2005-11-07 11:16:07 +0000223int jffs2_sum_is_disabled(struct jffs2_summary *s)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100224{
225 return (s->sum_size == JFFS2_SUMMARY_NOSUM_SIZE);
226}
227
228/* Move the collected summary information into sb (called from scan.c) */
229
230void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s)
231{
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100232 dbg_summary("oldsize=0x%x oldnum=%u => newsize=0x%x newnum=%u\n",
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100233 c->summary->sum_size, c->summary->sum_num,
234 s->sum_size, s->sum_num);
235
236 c->summary->sum_size = s->sum_size;
237 c->summary->sum_num = s->sum_num;
238 c->summary->sum_padded = s->sum_padded;
239 c->summary->sum_list_head = s->sum_list_head;
240 c->summary->sum_list_tail = s->sum_list_tail;
241
242 s->sum_list_head = s->sum_list_tail = NULL;
243}
244
245/* Called from wbuf.c to collect writed node info */
246
247int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
248 unsigned long count, uint32_t ofs)
249{
250 union jffs2_node_union *node;
251 struct jffs2_eraseblock *jeb;
252
Zoltan Sogor27bea322006-09-16 12:15:59 -0700253 if (c->summary->sum_size == JFFS2_SUMMARY_NOSUM_SIZE) {
254 dbg_summary("Summary is disabled for this jeb! Skipping summary info!\n");
255 return 0;
256 }
257
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100258 node = invecs[0].iov_base;
259 jeb = &c->blocks[ofs / c->sector_size];
260 ofs -= jeb->offset;
261
262 switch (je16_to_cpu(node->u.nodetype)) {
263 case JFFS2_NODETYPE_INODE: {
264 struct jffs2_sum_inode_mem *temp =
265 kmalloc(sizeof(struct jffs2_sum_inode_mem), GFP_KERNEL);
266
267 if (!temp)
268 goto no_mem;
269
270 temp->nodetype = node->i.nodetype;
271 temp->inode = node->i.ino;
272 temp->version = node->i.version;
273 temp->offset = cpu_to_je32(ofs);
274 temp->totlen = node->i.totlen;
275 temp->next = NULL;
276
277 return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp);
278 }
279
280 case JFFS2_NODETYPE_DIRENT: {
281 struct jffs2_sum_dirent_mem *temp =
282 kmalloc(sizeof(struct jffs2_sum_dirent_mem) + node->d.nsize, GFP_KERNEL);
283
284 if (!temp)
285 goto no_mem;
286
287 temp->nodetype = node->d.nodetype;
288 temp->totlen = node->d.totlen;
289 temp->offset = cpu_to_je32(ofs);
290 temp->pino = node->d.pino;
291 temp->version = node->d.version;
292 temp->ino = node->d.ino;
293 temp->nsize = node->d.nsize;
294 temp->type = node->d.type;
295 temp->next = NULL;
296
297 switch (count) {
298 case 1:
299 memcpy(temp->name,node->d.name,node->d.nsize);
300 break;
301
302 case 2:
303 memcpy(temp->name,invecs[1].iov_base,node->d.nsize);
304 break;
305
306 default:
307 BUG(); /* impossible count value */
308 break;
309 }
310
311 return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp);
312 }
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900313#ifdef CONFIG_JFFS2_FS_XATTR
314 case JFFS2_NODETYPE_XATTR: {
315 struct jffs2_sum_xattr_mem *temp;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900316 temp = kmalloc(sizeof(struct jffs2_sum_xattr_mem), GFP_KERNEL);
317 if (!temp)
318 goto no_mem;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100319
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900320 temp->nodetype = node->x.nodetype;
321 temp->xid = node->x.xid;
322 temp->version = node->x.version;
323 temp->totlen = node->x.totlen;
324 temp->offset = cpu_to_je32(ofs);
325 temp->next = NULL;
326
327 return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp);
328 }
329 case JFFS2_NODETYPE_XREF: {
330 struct jffs2_sum_xref_mem *temp;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900331 temp = kmalloc(sizeof(struct jffs2_sum_xref_mem), GFP_KERNEL);
332 if (!temp)
333 goto no_mem;
334 temp->nodetype = node->r.nodetype;
335 temp->offset = cpu_to_je32(ofs);
336 temp->next = NULL;
337
338 return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp);
339 }
340#endif
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100341 case JFFS2_NODETYPE_PADDING:
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100342 dbg_summary("node PADDING\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100343 c->summary->sum_padded += je32_to_cpu(node->u.totlen);
344 break;
345
346 case JFFS2_NODETYPE_CLEANMARKER:
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100347 dbg_summary("node CLEANMARKER\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100348 break;
349
350 case JFFS2_NODETYPE_SUMMARY:
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100351 dbg_summary("node SUMMARY\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100352 break;
353
354 default:
355 /* If you implement a new node type you should also implement
356 summary support for it or disable summary.
357 */
358 BUG();
359 break;
360 }
361
362 return 0;
363
364no_mem:
365 JFFS2_WARNING("MEMORY ALLOCATION ERROR!");
366 return -ENOMEM;
367}
368
David Woodhouse2f785402006-05-24 02:04:45 +0100369static struct jffs2_raw_node_ref *sum_link_node_ref(struct jffs2_sb_info *c,
370 struct jffs2_eraseblock *jeb,
371 uint32_t ofs, uint32_t len,
372 struct jffs2_inode_cache *ic)
David Woodhouse49f11d42006-05-21 04:00:01 +0100373{
David Woodhouse49f11d42006-05-21 04:00:01 +0100374 /* If there was a gap, mark it dirty */
David Woodhouse2f785402006-05-24 02:04:45 +0100375 if ((ofs & ~3) > c->sector_size - jeb->free_size) {
376 /* Ew. Summary doesn't actually tell us explicitly about dirty space */
377 jffs2_scan_dirty_space(c, jeb, (ofs & ~3) - (c->sector_size - jeb->free_size));
David Woodhouse49f11d42006-05-21 04:00:01 +0100378 }
David Woodhouse49f11d42006-05-21 04:00:01 +0100379
David Woodhouse2f785402006-05-24 02:04:45 +0100380 return jffs2_link_node_ref(c, jeb, jeb->offset + ofs, len, ic);
David Woodhouse49f11d42006-05-21 04:00:01 +0100381}
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100382
383/* Process the stored summary information - helper function for jffs2_sum_scan_sumnode() */
384
385static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
Ferenc Havasi2bc97642005-09-26 12:37:25 +0100386 struct jffs2_raw_summary *summary, uint32_t *pseudo_random)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100387{
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100388 struct jffs2_inode_cache *ic;
389 struct jffs2_full_dirent *fd;
390 void *sp;
391 int i, ino;
David Woodhouse68270992006-05-21 03:46:05 +0100392 int err;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100393
394 sp = summary->sum;
395
396 for (i=0; i<je32_to_cpu(summary->sum_num); i++) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100397 dbg_summary("processing summary index %d\n", i);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100398
David Woodhouse2f785402006-05-24 02:04:45 +0100399 /* Make sure there's a spare ref for dirty space */
David Woodhouse046b8b92006-05-25 01:50:35 +0100400 err = jffs2_prealloc_raw_node_refs(c, jeb, 2);
David Woodhouse2f785402006-05-24 02:04:45 +0100401 if (err)
402 return err;
403
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100404 switch (je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype)) {
405 case JFFS2_NODETYPE_INODE: {
406 struct jffs2_sum_inode_flash *spi;
407 spi = sp;
408
409 ino = je32_to_cpu(spi->inode);
410
David Woodhouse9167e0f2006-05-21 13:13:45 +0100411 dbg_summary("Inode at 0x%08x-0x%08x\n",
412 jeb->offset + je32_to_cpu(spi->offset),
David Woodhouse8b9e9fe2006-05-25 01:53:09 +0100413 jeb->offset + je32_to_cpu(spi->offset) + je32_to_cpu(spi->totlen));
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100414
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100415 ic = jffs2_scan_make_ino_cache(c, ino);
416 if (!ic) {
417 JFFS2_NOTICE("scan_make_ino_cache failed\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100418 return -ENOMEM;
419 }
420
David Woodhouse2f785402006-05-24 02:04:45 +0100421 sum_link_node_ref(c, jeb, je32_to_cpu(spi->offset) | REF_UNCHECKED,
422 PAD(je32_to_cpu(spi->totlen)), ic);
David Woodhousef1f96712006-05-20 19:45:26 +0100423
424 *pseudo_random += je32_to_cpu(spi->version);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100425
426 sp += JFFS2_SUMMARY_INODE_SIZE;
427
428 break;
429 }
430
431 case JFFS2_NODETYPE_DIRENT: {
432 struct jffs2_sum_dirent_flash *spd;
433 spd = sp;
434
David Woodhouse8b9e9fe2006-05-25 01:53:09 +0100435 dbg_summary("Dirent at 0x%08x-0x%08x\n",
David Woodhouse9167e0f2006-05-21 13:13:45 +0100436 jeb->offset + je32_to_cpu(spd->offset),
437 jeb->offset + je32_to_cpu(spd->offset) + je32_to_cpu(spd->totlen));
438
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100439
440 fd = jffs2_alloc_full_dirent(spd->nsize+1);
David Woodhouse9641b782006-05-20 16:13:34 +0100441 if (!fd)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100442 return -ENOMEM;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100443
444 memcpy(&fd->name, spd->name, spd->nsize);
445 fd->name[spd->nsize] = 0;
446
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100447 ic = jffs2_scan_make_ino_cache(c, je32_to_cpu(spd->pino));
448 if (!ic) {
449 jffs2_free_full_dirent(fd);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100450 return -ENOMEM;
451 }
452
David Woodhouse1046d882006-06-18 22:44:21 +0100453 fd->raw = sum_link_node_ref(c, jeb, je32_to_cpu(spd->offset) | REF_UNCHECKED,
David Woodhouse2f785402006-05-24 02:04:45 +0100454 PAD(je32_to_cpu(spd->totlen)), ic);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100455
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100456 fd->next = NULL;
457 fd->version = je32_to_cpu(spd->version);
458 fd->ino = je32_to_cpu(spd->ino);
459 fd->nhash = full_name_hash(fd->name, spd->nsize);
460 fd->type = spd->type;
David Woodhousef1f96712006-05-20 19:45:26 +0100461
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100462 jffs2_add_fd_to_list(c, fd, &ic->scan_dents);
463
464 *pseudo_random += je32_to_cpu(spd->version);
465
466 sp += JFFS2_SUMMARY_DIRENT_SIZE(spd->nsize);
467
468 break;
469 }
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900470#ifdef CONFIG_JFFS2_FS_XATTR
471 case JFFS2_NODETYPE_XATTR: {
472 struct jffs2_xattr_datum *xd;
473 struct jffs2_sum_xattr_flash *spx;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100474
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900475 spx = (struct jffs2_sum_xattr_flash *)sp;
David Woodhouse9167e0f2006-05-21 13:13:45 +0100476 dbg_summary("xattr at %#08x-%#08x (xid=%u, version=%u)\n",
David Woodhouse49f11d42006-05-21 04:00:01 +0100477 jeb->offset + je32_to_cpu(spx->offset),
David Woodhouse9167e0f2006-05-21 13:13:45 +0100478 jeb->offset + je32_to_cpu(spx->offset) + je32_to_cpu(spx->totlen),
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900479 je32_to_cpu(spx->xid), je32_to_cpu(spx->version));
David Woodhouse2f785402006-05-24 02:04:45 +0100480
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900481 xd = jffs2_setup_xattr_datum(c, je32_to_cpu(spx->xid),
482 je32_to_cpu(spx->version));
KaiGai Koheic9f700f2006-06-11 10:35:15 +0900483 if (IS_ERR(xd))
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900484 return PTR_ERR(xd);
KaiGai Koheic9f700f2006-06-11 10:35:15 +0900485 if (xd->version > je32_to_cpu(spx->version)) {
486 /* node is not the newest one */
487 struct jffs2_raw_node_ref *raw
488 = sum_link_node_ref(c, jeb, je32_to_cpu(spx->offset) | REF_UNCHECKED,
489 PAD(je32_to_cpu(spx->totlen)), NULL);
490 raw->next_in_ino = xd->node->next_in_ino;
491 xd->node->next_in_ino = raw;
492 } else {
493 xd->version = je32_to_cpu(spx->version);
494 sum_link_node_ref(c, jeb, je32_to_cpu(spx->offset) | REF_UNCHECKED,
495 PAD(je32_to_cpu(spx->totlen)), (void *)xd);
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900496 }
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900497 *pseudo_random += je32_to_cpu(spx->xid);
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900498 sp += JFFS2_SUMMARY_XATTR_SIZE;
499
500 break;
501 }
502 case JFFS2_NODETYPE_XREF: {
503 struct jffs2_xattr_ref *ref;
504 struct jffs2_sum_xref_flash *spr;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900505
506 spr = (struct jffs2_sum_xref_flash *)sp;
David Woodhouse9167e0f2006-05-21 13:13:45 +0100507 dbg_summary("xref at %#08x-%#08x\n",
David Woodhouse49f11d42006-05-21 04:00:01 +0100508 jeb->offset + je32_to_cpu(spr->offset),
David Woodhouse9bfeb692006-05-26 21:19:05 +0100509 jeb->offset + je32_to_cpu(spr->offset) +
510 (uint32_t)PAD(sizeof(struct jffs2_raw_xref)));
David Woodhouse9167e0f2006-05-21 13:13:45 +0100511
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900512 ref = jffs2_alloc_xattr_ref();
513 if (!ref) {
514 JFFS2_NOTICE("allocation of xattr_datum failed\n");
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900515 return -ENOMEM;
516 }
KaiGai Kohei8f2b6f42006-05-13 15:15:07 +0900517 ref->next = c->xref_temp;
518 c->xref_temp = ref;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900519
KaiGai Koheic9f700f2006-06-11 10:35:15 +0900520 sum_link_node_ref(c, jeb, je32_to_cpu(spr->offset) | REF_UNCHECKED,
521 PAD(sizeof(struct jffs2_raw_xref)), (void *)ref);
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900522
David Woodhouse2f785402006-05-24 02:04:45 +0100523 *pseudo_random += ref->node->flash_offset;
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900524 sp += JFFS2_SUMMARY_XREF_SIZE;
525
526 break;
527 }
528#endif
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100529 default : {
David Woodhouse7807ef72006-05-21 03:45:27 +0100530 uint16_t nodetype = je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype);
531 JFFS2_WARNING("Unsupported node type %x found in summary! Exiting...\n", nodetype);
532 if ((nodetype & JFFS2_COMPAT_MASK) == JFFS2_FEATURE_INCOMPAT)
533 return -EIO;
534
535 /* For compatible node types, just fall back to the full scan */
536 c->wasted_size -= jeb->wasted_size;
537 c->free_size += c->sector_size - jeb->free_size;
538 c->used_size -= jeb->used_size;
539 c->dirty_size -= jeb->dirty_size;
540 jeb->wasted_size = jeb->used_size = jeb->dirty_size = 0;
541 jeb->free_size = c->sector_size;
542
David Woodhousec38c1b62006-05-25 01:38:27 +0100543 jffs2_free_jeb_node_refs(c, jeb);
David Woodhouse7807ef72006-05-21 03:45:27 +0100544 return -ENOTRECOVERABLE;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100545 }
546 }
547 }
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100548 return 0;
549}
550
551/* Process the summary node - called from jffs2_scan_eraseblock() */
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100552int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
David Woodhouse9641b782006-05-20 16:13:34 +0100553 struct jffs2_raw_summary *summary, uint32_t sumsize,
554 uint32_t *pseudo_random)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100555{
556 struct jffs2_unknown_node crcnode;
David Woodhouse9641b782006-05-20 16:13:34 +0100557 int ret, ofs;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100558 uint32_t crc;
559
David Woodhouse49f11d42006-05-21 04:00:01 +0100560 ofs = c->sector_size - sumsize;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100561
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100562 dbg_summary("summary found for 0x%08x at 0x%08x (0x%x bytes)\n",
David Woodhouse49f11d42006-05-21 04:00:01 +0100563 jeb->offset, jeb->offset + ofs, sumsize);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100564
565 /* OK, now check for node validity and CRC */
566 crcnode.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
567 crcnode.nodetype = cpu_to_je16(JFFS2_NODETYPE_SUMMARY);
568 crcnode.totlen = summary->totlen;
569 crc = crc32(0, &crcnode, sizeof(crcnode)-4);
570
571 if (je32_to_cpu(summary->hdr_crc) != crc) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100572 dbg_summary("Summary node header is corrupt (bad CRC or "
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100573 "no summary at all)\n");
574 goto crc_err;
575 }
576
577 if (je32_to_cpu(summary->totlen) != sumsize) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100578 dbg_summary("Summary node is corrupt (wrong erasesize?)\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100579 goto crc_err;
580 }
581
Ferenc Havasi2bc97642005-09-26 12:37:25 +0100582 crc = crc32(0, summary, sizeof(struct jffs2_raw_summary)-8);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100583
584 if (je32_to_cpu(summary->node_crc) != crc) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100585 dbg_summary("Summary node is corrupt (bad CRC)\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100586 goto crc_err;
587 }
588
Ferenc Havasi2bc97642005-09-26 12:37:25 +0100589 crc = crc32(0, summary->sum, sumsize - sizeof(struct jffs2_raw_summary));
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100590
591 if (je32_to_cpu(summary->sum_crc) != crc) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100592 dbg_summary("Summary node data is corrupt (bad CRC)\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100593 goto crc_err;
594 }
595
596 if ( je32_to_cpu(summary->cln_mkr) ) {
597
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100598 dbg_summary("Summary : CLEANMARKER node \n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100599
David Woodhouse098a1982006-05-30 09:00:14 +0100600 ret = jffs2_prealloc_raw_node_refs(c, jeb, 1);
601 if (ret)
602 return ret;
603
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100604 if (je32_to_cpu(summary->cln_mkr) != c->cleanmarker_size) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100605 dbg_summary("CLEANMARKER node has totlen 0x%x != normal 0x%x\n",
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100606 je32_to_cpu(summary->cln_mkr), c->cleanmarker_size);
David Woodhouse098a1982006-05-30 09:00:14 +0100607 if ((ret = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(summary->cln_mkr)))))
608 return ret;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100609 } else if (jeb->first_node) {
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100610 dbg_summary("CLEANMARKER node not first node in block "
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100611 "(0x%08x)\n", jeb->offset);
David Woodhouse098a1982006-05-30 09:00:14 +0100612 if ((ret = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(summary->cln_mkr)))))
613 return ret;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100614 } else {
David Woodhouse2f785402006-05-24 02:04:45 +0100615 jffs2_link_node_ref(c, jeb, jeb->offset | REF_NORMAL,
616 je32_to_cpu(summary->cln_mkr), NULL);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100617 }
618 }
619
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100620 ret = jffs2_sum_process_sum_data(c, jeb, summary, pseudo_random);
David Woodhouse7807ef72006-05-21 03:45:27 +0100621 /* -ENOTRECOVERABLE isn't a fatal error -- it means we should do a full
622 scan of this eraseblock. So return zero */
623 if (ret == -ENOTRECOVERABLE)
624 return 0;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100625 if (ret)
David Woodhouse7807ef72006-05-21 03:45:27 +0100626 return ret; /* real error */
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100627
628 /* for PARANOIA_CHECK */
David Woodhouse046b8b92006-05-25 01:50:35 +0100629 ret = jffs2_prealloc_raw_node_refs(c, jeb, 2);
David Woodhouse2f785402006-05-24 02:04:45 +0100630 if (ret)
631 return ret;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100632
David Woodhousef61579c32006-05-25 01:42:40 +0100633 sum_link_node_ref(c, jeb, ofs | REF_NORMAL, sumsize, NULL);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100634
David Woodhouse49f11d42006-05-21 04:00:01 +0100635 if (unlikely(jeb->free_size)) {
636 JFFS2_WARNING("Free size 0x%x bytes in eraseblock @0x%08x with summary?\n",
637 jeb->free_size, jeb->offset);
638 jeb->wasted_size += jeb->free_size;
639 c->wasted_size += jeb->free_size;
640 c->free_size -= jeb->free_size;
641 jeb->free_size = 0;
642 }
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100643
644 return jffs2_scan_classify_jeb(c, jeb);
645
646crc_err:
647 JFFS2_WARNING("Summary node crc error, skipping summary information.\n");
648
649 return 0;
650}
651
652/* Write summary data to flash - helper function for jffs2_sum_write_sumnode() */
653
654static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
655 uint32_t infosize, uint32_t datasize, int padsize)
656{
Ferenc Havasi2bc97642005-09-26 12:37:25 +0100657 struct jffs2_raw_summary isum;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100658 union jffs2_sum_mem *temp;
659 struct jffs2_sum_marker *sm;
660 struct kvec vecs[2];
David Woodhouse2f785402006-05-24 02:04:45 +0100661 uint32_t sum_ofs;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100662 void *wpage;
663 int ret;
664 size_t retlen;
665
666 memset(c->summary->sum_buf, 0xff, datasize);
667 memset(&isum, 0, sizeof(isum));
668
669 isum.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
670 isum.nodetype = cpu_to_je16(JFFS2_NODETYPE_SUMMARY);
671 isum.totlen = cpu_to_je32(infosize);
672 isum.hdr_crc = cpu_to_je32(crc32(0, &isum, sizeof(struct jffs2_unknown_node) - 4));
673 isum.padded = cpu_to_je32(c->summary->sum_padded);
674 isum.cln_mkr = cpu_to_je32(c->cleanmarker_size);
675 isum.sum_num = cpu_to_je32(c->summary->sum_num);
676 wpage = c->summary->sum_buf;
677
678 while (c->summary->sum_num) {
Jesper Juhl20ffdcb2006-05-12 11:55:51 +0100679 temp = c->summary->sum_list_head;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100680
Jesper Juhl20ffdcb2006-05-12 11:55:51 +0100681 switch (je16_to_cpu(temp->u.nodetype)) {
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100682 case JFFS2_NODETYPE_INODE: {
683 struct jffs2_sum_inode_flash *sino_ptr = wpage;
684
Jesper Juhl20ffdcb2006-05-12 11:55:51 +0100685 sino_ptr->nodetype = temp->i.nodetype;
686 sino_ptr->inode = temp->i.inode;
687 sino_ptr->version = temp->i.version;
688 sino_ptr->offset = temp->i.offset;
689 sino_ptr->totlen = temp->i.totlen;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100690
691 wpage += JFFS2_SUMMARY_INODE_SIZE;
692
693 break;
694 }
695
696 case JFFS2_NODETYPE_DIRENT: {
697 struct jffs2_sum_dirent_flash *sdrnt_ptr = wpage;
698
Jesper Juhl20ffdcb2006-05-12 11:55:51 +0100699 sdrnt_ptr->nodetype = temp->d.nodetype;
700 sdrnt_ptr->totlen = temp->d.totlen;
701 sdrnt_ptr->offset = temp->d.offset;
702 sdrnt_ptr->pino = temp->d.pino;
703 sdrnt_ptr->version = temp->d.version;
704 sdrnt_ptr->ino = temp->d.ino;
705 sdrnt_ptr->nsize = temp->d.nsize;
706 sdrnt_ptr->type = temp->d.type;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100707
Jesper Juhl20ffdcb2006-05-12 11:55:51 +0100708 memcpy(sdrnt_ptr->name, temp->d.name,
709 temp->d.nsize);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100710
Jesper Juhl20ffdcb2006-05-12 11:55:51 +0100711 wpage += JFFS2_SUMMARY_DIRENT_SIZE(temp->d.nsize);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100712
713 break;
714 }
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900715#ifdef CONFIG_JFFS2_FS_XATTR
716 case JFFS2_NODETYPE_XATTR: {
717 struct jffs2_sum_xattr_flash *sxattr_ptr = wpage;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100718
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900719 temp = c->summary->sum_list_head;
720 sxattr_ptr->nodetype = temp->x.nodetype;
721 sxattr_ptr->xid = temp->x.xid;
722 sxattr_ptr->version = temp->x.version;
723 sxattr_ptr->offset = temp->x.offset;
724 sxattr_ptr->totlen = temp->x.totlen;
725
726 wpage += JFFS2_SUMMARY_XATTR_SIZE;
727 break;
728 }
729 case JFFS2_NODETYPE_XREF: {
730 struct jffs2_sum_xref_flash *sxref_ptr = wpage;
731
732 temp = c->summary->sum_list_head;
733 sxref_ptr->nodetype = temp->r.nodetype;
734 sxref_ptr->offset = temp->r.offset;
735
736 wpage += JFFS2_SUMMARY_XREF_SIZE;
737 break;
738 }
739#endif
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100740 default : {
David Woodhouse61715862006-05-21 00:02:06 +0100741 if ((je16_to_cpu(temp->u.nodetype) & JFFS2_COMPAT_MASK)
742 == JFFS2_FEATURE_RWCOMPAT_COPY) {
743 dbg_summary("Writing unknown RWCOMPAT_COPY node type %x\n",
744 je16_to_cpu(temp->u.nodetype));
745 jffs2_sum_disable_collecting(c->summary);
746 } else {
747 BUG(); /* unknown node in summary information */
748 }
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100749 }
750 }
751
Jesper Juhl20ffdcb2006-05-12 11:55:51 +0100752 c->summary->sum_list_head = temp->u.next;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100753 kfree(temp);
754
755 c->summary->sum_num--;
756 }
757
758 jffs2_sum_reset_collected(c->summary);
759
760 wpage += padsize;
761
762 sm = wpage;
763 sm->offset = cpu_to_je32(c->sector_size - jeb->free_size);
764 sm->magic = cpu_to_je32(JFFS2_SUM_MAGIC);
765
766 isum.sum_crc = cpu_to_je32(crc32(0, c->summary->sum_buf, datasize));
767 isum.node_crc = cpu_to_je32(crc32(0, &isum, sizeof(isum) - 8));
768
769 vecs[0].iov_base = &isum;
770 vecs[0].iov_len = sizeof(isum);
771 vecs[1].iov_base = c->summary->sum_buf;
772 vecs[1].iov_len = datasize;
773
David Woodhouse2f785402006-05-24 02:04:45 +0100774 sum_ofs = jeb->offset + c->sector_size - jeb->free_size;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100775
David Woodhouse2f785402006-05-24 02:04:45 +0100776 dbg_summary("JFFS2: writing out data to flash to pos : 0x%08x\n",
777 sum_ofs);
778
779 ret = jffs2_flash_writev(c, vecs, 2, sum_ofs, &retlen, 0);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100780
781 if (ret || (retlen != infosize)) {
David Woodhouse010b06d2006-05-21 13:15:59 +0100782
David Woodhousec41ff6e2006-05-16 17:05:33 +0100783 JFFS2_WARNING("Write of %u bytes at 0x%08x failed. returned %d, retlen %zd\n",
David Woodhouse2f785402006-05-24 02:04:45 +0100784 infosize, sum_ofs, ret, retlen);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100785
David Woodhouse9bfeb692006-05-26 21:19:05 +0100786 if (retlen) {
787 /* Waste remaining space */
788 spin_lock(&c->erase_completion_lock);
789 jffs2_link_node_ref(c, jeb, sum_ofs | REF_OBSOLETE, infosize, NULL);
790 spin_unlock(&c->erase_completion_lock);
791 }
David Woodhouse010b06d2006-05-21 13:15:59 +0100792
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100793 c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100794
David Woodhouse2f785402006-05-24 02:04:45 +0100795 return 0;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100796 }
797
David Woodhouse010b06d2006-05-21 13:15:59 +0100798 spin_lock(&c->erase_completion_lock);
David Woodhouse2f785402006-05-24 02:04:45 +0100799 jffs2_link_node_ref(c, jeb, sum_ofs | REF_NORMAL, infosize, NULL);
800 spin_unlock(&c->erase_completion_lock);
David Woodhouse010b06d2006-05-21 13:15:59 +0100801
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100802 return 0;
803}
804
805/* Write out summary information - called from jffs2_do_reserve_space */
806
807int jffs2_sum_write_sumnode(struct jffs2_sb_info *c)
808{
David Woodhouse2f785402006-05-24 02:04:45 +0100809 int datasize, infosize, padsize;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100810 struct jffs2_eraseblock *jeb;
David Woodhouse2f785402006-05-24 02:04:45 +0100811 int ret;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100812
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100813 dbg_summary("called\n");
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100814
David Woodhouse2f785402006-05-24 02:04:45 +0100815 spin_unlock(&c->erase_completion_lock);
David Woodhouse2f785402006-05-24 02:04:45 +0100816
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100817 jeb = c->nextblock;
David Woodhouse046b8b92006-05-25 01:50:35 +0100818 jffs2_prealloc_raw_node_refs(c, jeb, 1);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100819
820 if (!c->summary->sum_num || !c->summary->sum_list_head) {
821 JFFS2_WARNING("Empty summary info!!!\n");
822 BUG();
823 }
824
825 datasize = c->summary->sum_size + sizeof(struct jffs2_sum_marker);
Ferenc Havasi2bc97642005-09-26 12:37:25 +0100826 infosize = sizeof(struct jffs2_raw_summary) + datasize;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100827 padsize = jeb->free_size - infosize;
Thomas Gleixner182ec4e2005-11-07 11:16:07 +0000828 infosize += padsize;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100829 datasize += padsize;
830
831 /* Is there enough space for summary? */
832 if (padsize < 0) {
833 /* don't try to write out summary for this jeb */
834 jffs2_sum_disable_collecting(c->summary);
835
836 JFFS2_WARNING("Not enough space for summary, padsize = %d\n", padsize);
David Woodhouse9bfeb692006-05-26 21:19:05 +0100837 spin_lock(&c->erase_completion_lock);
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100838 return 0;
839 }
840
841 ret = jffs2_sum_write_data(c, jeb, infosize, datasize, padsize);
David Woodhouse010b06d2006-05-21 13:15:59 +0100842 spin_lock(&c->erase_completion_lock);
David Woodhouse2f785402006-05-24 02:04:45 +0100843 return ret;
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100844}