2 * JFFS2 -- Journalling Flash File System, Version 2.
4 * Copyright (C) 2001-2003 Red Hat, Inc.
6 * Created by David Woodhouse <dwmw2@redhat.com>
8 * For licensing information, see the file 'LICENCE' in this directory.
10 * $Id: nodelist.c,v 1.87 2004/11/14 17:07:07 dedekind Exp $
14 #include <linux/kernel.h>
15 #include <linux/sched.h>
17 #include <linux/mtd/mtd.h>
18 #include <linux/rbtree.h>
19 #include <linux/crc32.h>
20 #include <linux/slab.h>
21 #include <linux/pagemap.h>
24 void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new, struct jffs2_full_dirent **list)
26 struct jffs2_full_dirent **prev = list;
27 D1(printk(KERN_DEBUG "jffs2_add_fd_to_list( %p, %p (->%p))\n", new, list, *list));
29 while ((*prev) && (*prev)->nhash <= new->nhash) {
30 if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) {
31 /* Duplicate. Free one */
32 if (new->version < (*prev)->version) {
33 D1(printk(KERN_DEBUG "Eep! Marking new dirent node obsolete\n"));
34 D1(printk(KERN_DEBUG "New dirent is \"%s\"->ino #%u. Old is \"%s\"->ino #%u\n", new->name, new->ino, (*prev)->name, (*prev)->ino));
35 jffs2_mark_node_obsolete(c, new->raw);
36 jffs2_free_full_dirent(new);
38 D1(printk(KERN_DEBUG "Marking old dirent node (ino #%u) obsolete\n", (*prev)->ino));
39 new->next = (*prev)->next;
40 jffs2_mark_node_obsolete(c, ((*prev)->raw));
41 jffs2_free_full_dirent(*prev);
46 prev = &((*prev)->next);
53 printk(KERN_DEBUG "Dirent \"%s\" (hash 0x%08x, ino #%u\n", (*list)->name, (*list)->nhash, (*list)->ino);
54 list = &(*list)->next;
58 /* Put a new tmp_dnode_info into the list, keeping the list in
59 order of increasing version
61 static void jffs2_add_tn_to_list(struct jffs2_tmp_dnode_info *tn, struct jffs2_tmp_dnode_info **list)
63 struct jffs2_tmp_dnode_info **prev = list;
65 while ((*prev) && (*prev)->version < tn->version) {
66 prev = &((*prev)->next);
72 static void jffs2_free_tmp_dnode_info_list(struct jffs2_tmp_dnode_info *tn)
74 struct jffs2_tmp_dnode_info *next;
79 jffs2_free_full_dnode(next->fn);
80 jffs2_free_tmp_dnode_info(next);
84 static void jffs2_free_full_dirent_list(struct jffs2_full_dirent *fd)
86 struct jffs2_full_dirent *next;
90 jffs2_free_full_dirent(fd);
96 /* Get tmp_dnode_info and full_dirent for all non-obsolete nodes associated
97 with this ino, returning the former in order of version */
99 int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
100 struct jffs2_tmp_dnode_info **tnp, struct jffs2_full_dirent **fdp,
101 uint32_t *highest_version, uint32_t *latest_mctime,
102 uint32_t *mctime_ver)
104 struct jffs2_raw_node_ref *ref = f->inocache->nodes;
105 struct jffs2_tmp_dnode_info *tn, *ret_tn = NULL;
106 struct jffs2_full_dirent *fd, *ret_fd = NULL;
107 union jffs2_node_union node;
113 D1(printk(KERN_DEBUG "jffs2_get_inode_nodes(): ino #%u\n", f->inocache->ino));
114 if (!f->inocache->nodes) {
115 printk(KERN_WARNING "Eep. no nodes for ino #%u\n", f->inocache->ino);
118 spin_lock(&c->erase_completion_lock);
120 for (ref = f->inocache->nodes; ref && ref->next_in_ino; ref = ref->next_in_ino) {
121 /* Work out whether it's a data node or a dirent node */
122 if (ref_obsolete(ref)) {
123 /* FIXME: On NAND flash we may need to read these */
124 D1(printk(KERN_DEBUG "node at 0x%08x is obsoleted. Ignoring.\n", ref_offset(ref)));
127 /* We can hold a pointer to a non-obsolete node without the spinlock,
128 but _obsolete_ nodes may disappear at any time, if the block
129 they're in gets erased */
130 spin_unlock(&c->erase_completion_lock);
135 err = jffs2_flash_read(c, (ref_offset(ref)),
136 min_t(uint32_t, ref_totlen(c, NULL, ref), sizeof(node)),
137 &retlen, (void *)&node);
139 printk(KERN_WARNING "error %d reading node at 0x%08x in get_inode_nodes()\n", err, ref_offset(ref));
144 /* Check we've managed to read at least the common node header */
145 if (retlen < min_t(uint32_t, ref_totlen(c, NULL, ref), sizeof(node.u))) {
146 printk(KERN_WARNING "short read in get_inode_nodes()\n");
151 switch (je16_to_cpu(node.u.nodetype)) {
152 case JFFS2_NODETYPE_DIRENT:
153 D1(printk(KERN_DEBUG "Node at %08x (%d) is a dirent node\n", ref_offset(ref), ref_flags(ref)));
154 if (ref_flags(ref) == REF_UNCHECKED) {
155 printk(KERN_WARNING "BUG: Dirent node at 0x%08x never got checked? How?\n", ref_offset(ref));
158 if (retlen < sizeof(node.d)) {
159 printk(KERN_WARNING "short read in get_inode_nodes()\n");
164 if (PAD((node.d.nsize + sizeof (node.d))) != PAD(je32_to_cpu (node.d.totlen))) {
165 printk(KERN_NOTICE "jffs2_get_inode_nodes(): Illegal nsize in node at 0x%08x: nsize 0x%02x, totlen %04x\n",
166 ref_offset(ref), node.d.nsize, je32_to_cpu(node.d.totlen));
167 jffs2_mark_node_obsolete(c, ref);
168 spin_lock(&c->erase_completion_lock);
171 if (je32_to_cpu(node.d.version) > *highest_version)
172 *highest_version = je32_to_cpu(node.d.version);
173 if (ref_obsolete(ref)) {
174 /* Obsoleted. This cannot happen, surely? dwmw2 20020308 */
175 printk(KERN_ERR "Dirent node at 0x%08x became obsolete while we weren't looking\n",
180 fd = jffs2_alloc_full_dirent(node.d.nsize+1);
185 memset(fd,0,sizeof(struct jffs2_full_dirent) + node.d.nsize+1);
187 fd->version = je32_to_cpu(node.d.version);
188 fd->ino = je32_to_cpu(node.d.ino);
189 fd->type = node.d.type;
191 /* Pick out the mctime of the latest dirent */
192 if(fd->version > *mctime_ver) {
193 *mctime_ver = fd->version;
194 *latest_mctime = je32_to_cpu(node.d.mctime);
197 /* memcpy as much of the name as possible from the raw
198 dirent we've already read from the flash
200 if (retlen > sizeof(struct jffs2_raw_dirent))
201 memcpy(&fd->name[0], &node.d.name[0], min_t(uint32_t, node.d.nsize, (retlen-sizeof(struct jffs2_raw_dirent))));
203 /* Do we need to copy any more of the name directly
206 if (node.d.nsize + sizeof(struct jffs2_raw_dirent) > retlen) {
208 int already = retlen - sizeof(struct jffs2_raw_dirent);
210 err = jffs2_flash_read(c, (ref_offset(ref)) + retlen,
211 node.d.nsize - already, &retlen, &fd->name[already]);
212 if (!err && retlen != node.d.nsize - already)
216 printk(KERN_WARNING "Read remainder of name in jffs2_get_inode_nodes(): error %d\n", err);
217 jffs2_free_full_dirent(fd);
221 fd->nhash = full_name_hash(fd->name, node.d.nsize);
223 /* Wheee. We now have a complete jffs2_full_dirent structure, with
224 the name in it and everything. Link it into the list
226 D1(printk(KERN_DEBUG "Adding fd \"%s\", ino #%u\n", fd->name, fd->ino));
227 jffs2_add_fd_to_list(c, fd, &ret_fd);
230 case JFFS2_NODETYPE_INODE:
231 D1(printk(KERN_DEBUG "Node at %08x (%d) is a data node\n", ref_offset(ref), ref_flags(ref)));
232 if (retlen < sizeof(node.i)) {
233 printk(KERN_WARNING "read too short for dnode\n");
237 if (je32_to_cpu(node.i.version) > *highest_version)
238 *highest_version = je32_to_cpu(node.i.version);
239 D1(printk(KERN_DEBUG "version %d, highest_version now %d\n", je32_to_cpu(node.i.version), *highest_version));
241 if (ref_obsolete(ref)) {
242 /* Obsoleted. This cannot happen, surely? dwmw2 20020308 */
243 printk(KERN_ERR "Inode node at 0x%08x became obsolete while we weren't looking\n",
248 /* If we've never checked the CRCs on this node, check them now. */
249 if (ref_flags(ref) == REF_UNCHECKED) {
251 struct jffs2_eraseblock *jeb;
253 crc = crc32(0, &node, sizeof(node.i)-8);
254 if (crc != je32_to_cpu(node.i.node_crc)) {
255 printk(KERN_NOTICE "jffs2_get_inode_nodes(): CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
256 ref_offset(ref), je32_to_cpu(node.i.node_crc), crc);
257 jffs2_mark_node_obsolete(c, ref);
258 spin_lock(&c->erase_completion_lock);
263 if ( je32_to_cpu(node.i.offset) > je32_to_cpu(node.i.isize) ||
264 PAD(je32_to_cpu(node.i.csize) + sizeof (node.i)) != PAD(je32_to_cpu(node.i.totlen))) {
265 printk(KERN_NOTICE "jffs2_get_inode_nodes(): Inode corrupted at 0x%08x, totlen %d, #ino %d, version %d, isize %d, csize %d, dsize %d \n",
266 ref_offset(ref), je32_to_cpu(node.i.totlen), je32_to_cpu(node.i.ino),
267 je32_to_cpu(node.i.version), je32_to_cpu(node.i.isize),
268 je32_to_cpu(node.i.csize), je32_to_cpu(node.i.dsize));
269 jffs2_mark_node_obsolete(c, ref);
270 spin_lock(&c->erase_completion_lock);
274 if (node.i.compr != JFFS2_COMPR_ZERO && je32_to_cpu(node.i.csize)) {
275 unsigned char *buf=NULL;
276 uint32_t pointed = 0;
279 err = c->mtd->point (c->mtd, ref_offset(ref) + sizeof(node.i), je32_to_cpu(node.i.csize),
281 if (!err && retlen < je32_to_cpu(node.i.csize)) {
282 D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", retlen));
283 c->mtd->unpoint(c->mtd, buf, ref_offset(ref) + sizeof(node.i), je32_to_cpu(node.i.csize));
285 D1(printk(KERN_DEBUG "MTD point failed %d\n", err));
287 pointed = 1; /* succefully pointed to device */
291 buf = kmalloc(je32_to_cpu(node.i.csize), GFP_KERNEL);
295 err = jffs2_flash_read(c, ref_offset(ref) + sizeof(node.i), je32_to_cpu(node.i.csize),
297 if (!err && retlen != je32_to_cpu(node.i.csize))
304 crc = crc32(0, buf, je32_to_cpu(node.i.csize));
309 c->mtd->unpoint(c->mtd, buf, ref_offset(ref) + sizeof(node.i), je32_to_cpu(node.i.csize));
312 if (crc != je32_to_cpu(node.i.data_crc)) {
313 printk(KERN_NOTICE "jffs2_get_inode_nodes(): Data CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
314 ref_offset(ref), je32_to_cpu(node.i.data_crc), crc);
315 jffs2_mark_node_obsolete(c, ref);
316 spin_lock(&c->erase_completion_lock);
322 /* Mark the node as having been checked and fix the accounting accordingly */
323 spin_lock(&c->erase_completion_lock);
324 jeb = &c->blocks[ref->flash_offset / c->sector_size];
325 len = ref_totlen(c, jeb, ref);
327 jeb->used_size += len;
328 jeb->unchecked_size -= len;
330 c->unchecked_size -= len;
332 /* If node covers at least a whole page, or if it starts at the
333 beginning of a page and runs to the end of the file, or if
334 it's a hole node, mark it REF_PRISTINE, else REF_NORMAL.
336 If it's actually overlapped, it'll get made NORMAL (or OBSOLETE)
337 when the overlapping node(s) get added to the tree anyway.
339 if ((je32_to_cpu(node.i.dsize) >= PAGE_CACHE_SIZE) ||
340 ( ((je32_to_cpu(node.i.offset)&(PAGE_CACHE_SIZE-1))==0) &&
341 (je32_to_cpu(node.i.dsize)+je32_to_cpu(node.i.offset) == je32_to_cpu(node.i.isize)))) {
342 D1(printk(KERN_DEBUG "Marking node at 0x%08x REF_PRISTINE\n", ref_offset(ref)));
343 ref->flash_offset = ref_offset(ref) | REF_PRISTINE;
345 D1(printk(KERN_DEBUG "Marking node at 0x%08x REF_NORMAL\n", ref_offset(ref)));
346 ref->flash_offset = ref_offset(ref) | REF_NORMAL;
348 spin_unlock(&c->erase_completion_lock);
351 tn = jffs2_alloc_tmp_dnode_info();
353 D1(printk(KERN_DEBUG "alloc tn failed\n"));
358 tn->fn = jffs2_alloc_full_dnode();
360 D1(printk(KERN_DEBUG "alloc fn failed\n"));
362 jffs2_free_tmp_dnode_info(tn);
365 tn->version = je32_to_cpu(node.i.version);
366 tn->fn->ofs = je32_to_cpu(node.i.offset);
367 /* There was a bug where we wrote hole nodes out with
368 csize/dsize swapped. Deal with it */
369 if (node.i.compr == JFFS2_COMPR_ZERO && !je32_to_cpu(node.i.dsize) && je32_to_cpu(node.i.csize))
370 tn->fn->size = je32_to_cpu(node.i.csize);
371 else // normal case...
372 tn->fn->size = je32_to_cpu(node.i.dsize);
374 D1(printk(KERN_DEBUG "dnode @%08x: ver %u, offset %04x, dsize %04x\n",
375 ref_offset(ref), je32_to_cpu(node.i.version),
376 je32_to_cpu(node.i.offset), je32_to_cpu(node.i.dsize)));
377 jffs2_add_tn_to_list(tn, &ret_tn);
381 if (ref_flags(ref) == REF_UNCHECKED) {
382 struct jffs2_eraseblock *jeb;
385 printk(KERN_ERR "Eep. Unknown node type %04x at %08x was marked REF_UNCHECKED\n",
386 je16_to_cpu(node.u.nodetype), ref_offset(ref));
388 /* Mark the node as having been checked and fix the accounting accordingly */
389 spin_lock(&c->erase_completion_lock);
390 jeb = &c->blocks[ref->flash_offset / c->sector_size];
391 len = ref_totlen(c, jeb, ref);
393 jeb->used_size += len;
394 jeb->unchecked_size -= len;
396 c->unchecked_size -= len;
398 mark_ref_normal(ref);
399 spin_unlock(&c->erase_completion_lock);
401 node.u.nodetype = cpu_to_je16(JFFS2_NODE_ACCURATE | je16_to_cpu(node.u.nodetype));
402 if (crc32(0, &node, sizeof(struct jffs2_unknown_node)-4) != je32_to_cpu(node.u.hdr_crc)) {
403 /* Hmmm. This should have been caught at scan time. */
404 printk(KERN_ERR "Node header CRC failed at %08x. But it must have been OK earlier.\n",
406 printk(KERN_ERR "Node was: { %04x, %04x, %08x, %08x }\n",
407 je16_to_cpu(node.u.magic), je16_to_cpu(node.u.nodetype), je32_to_cpu(node.u.totlen),
408 je32_to_cpu(node.u.hdr_crc));
409 jffs2_mark_node_obsolete(c, ref);
410 } else switch(je16_to_cpu(node.u.nodetype) & JFFS2_COMPAT_MASK) {
411 case JFFS2_FEATURE_INCOMPAT:
412 printk(KERN_NOTICE "Unknown INCOMPAT nodetype %04X at %08x\n", je16_to_cpu(node.u.nodetype), ref_offset(ref));
416 case JFFS2_FEATURE_ROCOMPAT:
417 printk(KERN_NOTICE "Unknown ROCOMPAT nodetype %04X at %08x\n", je16_to_cpu(node.u.nodetype), ref_offset(ref));
418 if (!(c->flags & JFFS2_SB_FLAG_RO))
421 case JFFS2_FEATURE_RWCOMPAT_COPY:
422 printk(KERN_NOTICE "Unknown RWCOMPAT_COPY nodetype %04X at %08x\n", je16_to_cpu(node.u.nodetype), ref_offset(ref));
424 case JFFS2_FEATURE_RWCOMPAT_DELETE:
425 printk(KERN_NOTICE "Unknown RWCOMPAT_DELETE nodetype %04X at %08x\n", je16_to_cpu(node.u.nodetype), ref_offset(ref));
426 jffs2_mark_node_obsolete(c, ref);
431 spin_lock(&c->erase_completion_lock);
434 spin_unlock(&c->erase_completion_lock);
441 jffs2_free_tmp_dnode_info_list(ret_tn);
442 jffs2_free_full_dirent_list(ret_fd);
446 void jffs2_set_inocache_state(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic, int state)
448 spin_lock(&c->inocache_lock);
450 wake_up(&c->inocache_wq);
451 spin_unlock(&c->inocache_lock);
454 /* During mount, this needs no locking. During normal operation, its
455 callers want to do other stuff while still holding the inocache_lock.
456 Rather than introducing special case get_ino_cache functions or
457 callbacks, we just let the caller do the locking itself. */
459 struct jffs2_inode_cache *jffs2_get_ino_cache(struct jffs2_sb_info *c, uint32_t ino)
461 struct jffs2_inode_cache *ret;
463 D2(printk(KERN_DEBUG "jffs2_get_ino_cache(): ino %u\n", ino));
465 ret = c->inocache_list[ino % INOCACHE_HASHSIZE];
466 while (ret && ret->ino < ino) {
470 if (ret && ret->ino != ino)
473 D2(printk(KERN_DEBUG "jffs2_get_ino_cache found %p for ino %u\n", ret, ino));
477 void jffs2_add_ino_cache (struct jffs2_sb_info *c, struct jffs2_inode_cache *new)
479 struct jffs2_inode_cache **prev;
480 D2(printk(KERN_DEBUG "jffs2_add_ino_cache: Add %p (ino #%u)\n", new, new->ino));
481 spin_lock(&c->inocache_lock);
483 prev = &c->inocache_list[new->ino % INOCACHE_HASHSIZE];
485 while ((*prev) && (*prev)->ino < new->ino) {
486 prev = &(*prev)->next;
491 spin_unlock(&c->inocache_lock);
494 void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old)
496 struct jffs2_inode_cache **prev;
497 D2(printk(KERN_DEBUG "jffs2_del_ino_cache: Del %p (ino #%u)\n", old, old->ino));
498 spin_lock(&c->inocache_lock);
500 prev = &c->inocache_list[old->ino % INOCACHE_HASHSIZE];
502 while ((*prev) && (*prev)->ino < old->ino) {
503 prev = &(*prev)->next;
505 if ((*prev) == old) {
509 spin_unlock(&c->inocache_lock);
512 void jffs2_free_ino_caches(struct jffs2_sb_info *c)
515 struct jffs2_inode_cache *this, *next;
517 for (i=0; i<INOCACHE_HASHSIZE; i++) {
518 this = c->inocache_list[i];
521 D2(printk(KERN_DEBUG "jffs2_free_ino_caches: Freeing ino #%u at %p\n", this->ino, this));
522 jffs2_free_inode_cache(this);
525 c->inocache_list[i] = NULL;
529 void jffs2_free_raw_node_refs(struct jffs2_sb_info *c)
532 struct jffs2_raw_node_ref *this, *next;
534 for (i=0; i<c->nr_blocks; i++) {
535 this = c->blocks[i].first_node;
537 next = this->next_phys;
538 jffs2_free_raw_node_ref(this);
541 c->blocks[i].first_node = c->blocks[i].last_node = NULL;
545 struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_t offset)
547 /* The common case in lookup is that there will be a node
548 which precisely matches. So we go looking for that first */
549 struct rb_node *next;
550 struct jffs2_node_frag *prev = NULL;
551 struct jffs2_node_frag *frag = NULL;
553 D2(printk(KERN_DEBUG "jffs2_lookup_node_frag(%p, %d)\n", fragtree, offset));
555 next = fragtree->rb_node;
558 frag = rb_entry(next, struct jffs2_node_frag, rb);
560 D2(printk(KERN_DEBUG "Considering frag %d-%d (%p). left %p, right %p\n",
561 frag->ofs, frag->ofs+frag->size, frag, frag->rb.rb_left, frag->rb.rb_right));
562 if (frag->ofs + frag->size <= offset) {
563 D2(printk(KERN_DEBUG "Going right from frag %d-%d, before the region we care about\n",
564 frag->ofs, frag->ofs+frag->size));
565 /* Remember the closest smaller match on the way down */
566 if (!prev || frag->ofs > prev->ofs)
568 next = frag->rb.rb_right;
569 } else if (frag->ofs > offset) {
570 D2(printk(KERN_DEBUG "Going left from frag %d-%d, after the region we care about\n",
571 frag->ofs, frag->ofs+frag->size));
572 next = frag->rb.rb_left;
574 D2(printk(KERN_DEBUG "Returning frag %d,%d, matched\n",
575 frag->ofs, frag->ofs+frag->size));
580 /* Exact match not found. Go back up looking at each parent,
581 and return the closest smaller one */
584 D2(printk(KERN_DEBUG "No match. Returning frag %d,%d, closest previous\n",
585 prev->ofs, prev->ofs+prev->size));
587 D2(printk(KERN_DEBUG "Returning NULL, empty fragtree\n"));
592 /* Pass 'c' argument to indicate that nodes should be marked obsolete as
594 void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c)
596 struct jffs2_node_frag *frag;
597 struct jffs2_node_frag *parent;
602 frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb));
605 if (frag->rb.rb_left) {
606 D2(printk(KERN_DEBUG "Going left from frag (%p) %d-%d\n",
607 frag, frag->ofs, frag->ofs+frag->size));
608 frag = frag_left(frag);
611 if (frag->rb.rb_right) {
612 D2(printk(KERN_DEBUG "Going right from frag (%p) %d-%d\n",
613 frag, frag->ofs, frag->ofs+frag->size));
614 frag = frag_right(frag);
618 D2(printk(KERN_DEBUG "jffs2_kill_fragtree: frag at 0x%x-0x%x: node %p, frags %d--\n",
619 frag->ofs, frag->ofs+frag->size, frag->node,
620 frag->node?frag->node->frags:0));
622 if (frag->node && !(--frag->node->frags)) {
623 /* Not a hole, and it's the final remaining frag
624 of this node. Free the node */
626 jffs2_mark_node_obsolete(c, frag->node->raw);
628 jffs2_free_full_dnode(frag->node);
630 parent = frag_parent(frag);
632 if (frag_left(parent) == frag)
633 parent->rb.rb_left = NULL;
635 parent->rb.rb_right = NULL;
638 jffs2_free_node_frag(frag);
645 void jffs2_fragtree_insert(struct jffs2_node_frag *newfrag, struct jffs2_node_frag *base)
647 struct rb_node *parent = &base->rb;
648 struct rb_node **link = &parent;
650 D2(printk(KERN_DEBUG "jffs2_fragtree_insert(%p; %d-%d, %p)\n", newfrag,
651 newfrag->ofs, newfrag->ofs+newfrag->size, base));
655 base = rb_entry(parent, struct jffs2_node_frag, rb);
657 D2(printk(KERN_DEBUG "fragtree_insert considering frag at 0x%x\n", base->ofs));
658 if (newfrag->ofs > base->ofs)
659 link = &base->rb.rb_right;
660 else if (newfrag->ofs < base->ofs)
661 link = &base->rb.rb_left;
663 printk(KERN_CRIT "Duplicate frag at %08x (%p,%p)\n", newfrag->ofs, newfrag, base);
668 rb_link_node(&newfrag->rb, &base->rb, link);