diff options
author | David Woodhouse <dwmw2@infradead.org> | 2006-05-20 14:45:26 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2006-05-20 14:45:26 -0400 |
commit | f1f9671bd8f7d2ac6a918bad806ab5bdc0daaf4e (patch) | |
tree | f1fb5992fbd299375c911eb4c36d7fc8774f9208 /fs/jffs2/scan.c | |
parent | 0cfc7da3ff4b39a3aac261ab3f6b1329e2485653 (diff) |
[JFFS2] Introduce jffs2_link_node_ref() function to reduce code duplication
The same sequence of code was repeated in many places, to add a new
struct jffs2_raw_node_ref to an eraseblock and adjust the space accounting
accordingly. Move it out-of-line.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2/scan.c')
-rw-r--r-- | fs/jffs2/scan.c | 49 |
1 files changed, 11 insertions, 38 deletions
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c index 40d62d057aa4..3cbe9f029e01 100644 --- a/fs/jffs2/scan.c +++ b/fs/jffs2/scan.c | |||
@@ -351,17 +351,11 @@ static int jffs2_scan_xattr_node(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
351 | xd->data_crc = je32_to_cpu(rx->data_crc); | 351 | xd->data_crc = je32_to_cpu(rx->data_crc); |
352 | xd->node = raw; | 352 | xd->node = raw; |
353 | 353 | ||
354 | raw->__totlen = totlen; | ||
355 | raw->flash_offset = ofs | REF_PRISTINE; | 354 | raw->flash_offset = ofs | REF_PRISTINE; |
356 | raw->next_phys = NULL; | ||
357 | raw->next_in_ino = (void *)xd; | 355 | raw->next_in_ino = (void *)xd; |
358 | if (!jeb->first_node) | ||
359 | jeb->first_node = raw; | ||
360 | if (jeb->last_node) | ||
361 | jeb->last_node->next_phys = raw; | ||
362 | jeb->last_node = raw; | ||
363 | 356 | ||
364 | USED_SPACE(PAD(je32_to_cpu(rx->totlen))); | 357 | jffs2_link_node_ref(c, jeb, raw, totlen); |
358 | |||
365 | if (jffs2_sum_active()) | 359 | if (jffs2_sum_active()) |
366 | jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset); | 360 | jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset); |
367 | dbg_xattr("scaning xdatum at %#08x (xid=%u, version=%u)\n", | 361 | dbg_xattr("scaning xdatum at %#08x (xid=%u, version=%u)\n", |
@@ -418,17 +412,11 @@ static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock | |||
418 | ref->next = c->xref_temp; | 412 | ref->next = c->xref_temp; |
419 | c->xref_temp = ref; | 413 | c->xref_temp = ref; |
420 | 414 | ||
421 | raw->__totlen = PAD(je32_to_cpu(rr->totlen)); | ||
422 | raw->flash_offset = ofs | REF_PRISTINE; | 415 | raw->flash_offset = ofs | REF_PRISTINE; |
423 | raw->next_phys = NULL; | ||
424 | raw->next_in_ino = (void *)ref; | 416 | raw->next_in_ino = (void *)ref; |
425 | if (!jeb->first_node) | ||
426 | jeb->first_node = raw; | ||
427 | if (jeb->last_node) | ||
428 | jeb->last_node->next_phys = raw; | ||
429 | jeb->last_node = raw; | ||
430 | 417 | ||
431 | USED_SPACE(PAD(je32_to_cpu(rr->totlen))); | 418 | jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rr->totlen))); |
419 | |||
432 | if (jffs2_sum_active()) | 420 | if (jffs2_sum_active()) |
433 | jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset); | 421 | jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset); |
434 | dbg_xattr("scan xref at %#08x (xid=%u, ino=%u)\n", | 422 | dbg_xattr("scan xref at %#08x (xid=%u, ino=%u)\n", |
@@ -827,12 +815,10 @@ scan_more: | |||
827 | return -ENOMEM; | 815 | return -ENOMEM; |
828 | } | 816 | } |
829 | marker_ref->next_in_ino = NULL; | 817 | marker_ref->next_in_ino = NULL; |
830 | marker_ref->next_phys = NULL; | ||
831 | marker_ref->flash_offset = ofs | REF_NORMAL; | 818 | marker_ref->flash_offset = ofs | REF_NORMAL; |
832 | marker_ref->__totlen = c->cleanmarker_size; | ||
833 | jeb->first_node = jeb->last_node = marker_ref; | ||
834 | 819 | ||
835 | USED_SPACE(PAD(c->cleanmarker_size)); | 820 | jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size); |
821 | |||
836 | ofs += PAD(c->cleanmarker_size); | 822 | ofs += PAD(c->cleanmarker_size); |
837 | } | 823 | } |
838 | break; | 824 | break; |
@@ -971,16 +957,11 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
971 | /* Wheee. It worked */ | 957 | /* Wheee. It worked */ |
972 | 958 | ||
973 | raw->flash_offset = ofs | REF_UNCHECKED; | 959 | raw->flash_offset = ofs | REF_UNCHECKED; |
974 | raw->__totlen = PAD(je32_to_cpu(ri->totlen)); | ||
975 | raw->next_phys = NULL; | ||
976 | raw->next_in_ino = ic->nodes; | ||
977 | 960 | ||
961 | raw->next_in_ino = ic->nodes; | ||
978 | ic->nodes = raw; | 962 | ic->nodes = raw; |
979 | if (!jeb->first_node) | 963 | |
980 | jeb->first_node = raw; | 964 | jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(ri->totlen))); |
981 | if (jeb->last_node) | ||
982 | jeb->last_node->next_phys = raw; | ||
983 | jeb->last_node = raw; | ||
984 | 965 | ||
985 | D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n", | 966 | D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n", |
986 | je32_to_cpu(ri->ino), je32_to_cpu(ri->version), | 967 | je32_to_cpu(ri->ino), je32_to_cpu(ri->version), |
@@ -989,8 +970,6 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
989 | 970 | ||
990 | pseudo_random += je32_to_cpu(ri->version); | 971 | pseudo_random += je32_to_cpu(ri->version); |
991 | 972 | ||
992 | UNCHECKED_SPACE(PAD(je32_to_cpu(ri->totlen))); | ||
993 | |||
994 | if (jffs2_sum_active()) { | 973 | if (jffs2_sum_active()) { |
995 | jffs2_sum_add_inode_mem(s, ri, ofs - jeb->offset); | 974 | jffs2_sum_add_inode_mem(s, ri, ofs - jeb->offset); |
996 | } | 975 | } |
@@ -1053,16 +1032,11 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
1053 | return -ENOMEM; | 1032 | return -ENOMEM; |
1054 | } | 1033 | } |
1055 | 1034 | ||
1056 | raw->__totlen = PAD(je32_to_cpu(rd->totlen)); | ||
1057 | raw->flash_offset = ofs | REF_PRISTINE; | 1035 | raw->flash_offset = ofs | REF_PRISTINE; |
1058 | raw->next_phys = NULL; | ||
1059 | raw->next_in_ino = ic->nodes; | 1036 | raw->next_in_ino = ic->nodes; |
1060 | ic->nodes = raw; | 1037 | ic->nodes = raw; |
1061 | if (!jeb->first_node) | 1038 | |
1062 | jeb->first_node = raw; | 1039 | jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rd->totlen))); |
1063 | if (jeb->last_node) | ||
1064 | jeb->last_node->next_phys = raw; | ||
1065 | jeb->last_node = raw; | ||
1066 | 1040 | ||
1067 | fd->raw = raw; | 1041 | fd->raw = raw; |
1068 | fd->next = NULL; | 1042 | fd->next = NULL; |
@@ -1070,7 +1044,6 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
1070 | fd->ino = je32_to_cpu(rd->ino); | 1044 | fd->ino = je32_to_cpu(rd->ino); |
1071 | fd->nhash = full_name_hash(fd->name, rd->nsize); | 1045 | fd->nhash = full_name_hash(fd->name, rd->nsize); |
1072 | fd->type = rd->type; | 1046 | fd->type = rd->type; |
1073 | USED_SPACE(PAD(je32_to_cpu(rd->totlen))); | ||
1074 | jffs2_add_fd_to_list(c, fd, &ic->scan_dents); | 1047 | jffs2_add_fd_to_list(c, fd, &ic->scan_dents); |
1075 | 1048 | ||
1076 | if (jffs2_sum_active()) { | 1049 | if (jffs2_sum_active()) { |