- for (raw = first_raw; raw != jeb->last_node; raw = ref_next(raw)) {
- uint32_t rawlen = ref_totlen(c, jeb, raw);
- struct jffs2_inode_cache *ic;
- struct jffs2_raw_node_ref *new_ref;
- struct jffs2_raw_node_ref **adjust_ref = NULL;
- struct jffs2_inode_info *f = NULL;
-
- D1(printk(KERN_DEBUG "Refiling block of %08x at %08x(%d) to %08x\n",
- rawlen, ref_offset(raw), ref_flags(raw), ofs));
-
- ic = jffs2_raw_ref_to_ic(raw);
-
- /* Ick. This XATTR mess should be fixed shortly... */
- if (ic && ic->class == RAWNODE_CLASS_XATTR_DATUM) {
- struct jffs2_xattr_datum *xd = (void *)ic;
- BUG_ON(xd->node != raw);
- adjust_ref = &xd->node;
- raw->next_in_ino = NULL;
- ic = NULL;
- } else if (ic && ic->class == RAWNODE_CLASS_XATTR_REF) {
- struct jffs2_xattr_datum *xr = (void *)ic;
- BUG_ON(xr->node != raw);
- adjust_ref = &xr->node;
- raw->next_in_ino = NULL;
- ic = NULL;
- } else if (ic && ic->class == RAWNODE_CLASS_INODE_CACHE) {
- struct jffs2_raw_node_ref **p = &ic->nodes;
-
- /* Remove the old node from the per-inode list */
- while (*p && *p != (void *)ic) {
- if (*p == raw) {
- (*p) = (raw->next_in_ino);
- raw->next_in_ino = NULL;
- break;
- }
- p = &((*p)->next_in_ino);
- }
-
- if (ic->state == INO_STATE_PRESENT && !ref_obsolete(raw)) {
- /* If it's an in-core inode, then we have to adjust any
- full_dirent or full_dnode structure to point to the
- new version instead of the old */
- f = jffs2_gc_fetch_inode(c, ic->ino, ic->nlink);
- if (IS_ERR(f)) {
- /* Should never happen; it _must_ be present */
- JFFS2_ERROR("Failed to iget() ino #%u, err %ld\n",
- ic->ino, PTR_ERR(f));
- BUG();
- }
- /* We don't lock f->sem. There's a number of ways we could
- end up in here with it already being locked, and nobody's
- going to modify it on us anyway because we hold the
- alloc_sem. We're only changing one ->raw pointer too,
- which we can get away with without upsetting readers. */
- adjust_ref = jffs2_incore_replace_raw(c, f, raw,
- (void *)(buf?:c->wbuf) + (ref_offset(raw) - start));
- } else if (unlikely(ic->state != INO_STATE_PRESENT &&
- ic->state != INO_STATE_CHECKEDABSENT &&
- ic->state != INO_STATE_GC)) {
- JFFS2_ERROR("Inode #%u is in strange state %d!\n", ic->ino, ic->state);
- BUG();
- }
- }