diff options
author | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-23 06:37:31 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-23 06:37:31 -0400 |
commit | 4cbb9b80e171107c6c34116283fe38e5a396c68b (patch) | |
tree | 9463f2e4774f14752cf4bb52431e14e569256f72 /fs/jffs2/xattr.c | |
parent | 6dfc6d250d0b7ebaa6423c44dcd09fcfe68deabd (diff) | |
parent | 9fe4854cd1f60273f9a3ece053f4789605f58a5e (diff) |
Merge branch 'master' of /home/tglx/work/kernel/git/mtd-2.6/
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'fs/jffs2/xattr.c')
-rw-r--r-- | fs/jffs2/xattr.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c index e16f8460ff04..008f91b1c171 100644 --- a/fs/jffs2/xattr.c +++ b/fs/jffs2/xattr.c | |||
@@ -49,9 +49,9 @@ | |||
49 | * is used to be as a wrapper of do_verify_xattr_datum() and do_load_xattr_datum(). | 49 | * is used to be as a wrapper of do_verify_xattr_datum() and do_load_xattr_datum(). |
50 | * If xd need to call do_verify_xattr_datum() at first, it's called before calling | 50 | * If xd need to call do_verify_xattr_datum() at first, it's called before calling |
51 | * do_load_xattr_datum(). The meanings of return value is same as do_verify_xattr_datum(). | 51 | * do_load_xattr_datum(). The meanings of return value is same as do_verify_xattr_datum(). |
52 | * save_xattr_datum(c, xd, phys_ofs) | 52 | * save_xattr_datum(c, xd) |
53 | * is used to write xdatum to medium. xd->version will be incremented. | 53 | * is used to write xdatum to medium. xd->version will be incremented. |
54 | * create_xattr_datum(c, xprefix, xname, xvalue, xsize, phys_ofs) | 54 | * create_xattr_datum(c, xprefix, xname, xvalue, xsize) |
55 | * is used to create new xdatum and write to medium. | 55 | * is used to create new xdatum and write to medium. |
56 | * -------------------------------------------------- */ | 56 | * -------------------------------------------------- */ |
57 | 57 | ||
@@ -301,7 +301,7 @@ static int load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x | |||
301 | return rc; | 301 | return rc; |
302 | } | 302 | } |
303 | 303 | ||
304 | static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd, uint32_t phys_ofs) | 304 | static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd) |
305 | { | 305 | { |
306 | /* must be called under down_write(xattr_sem) */ | 306 | /* must be called under down_write(xattr_sem) */ |
307 | struct jffs2_raw_xattr rx; | 307 | struct jffs2_raw_xattr rx; |
@@ -309,6 +309,7 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x | |||
309 | struct kvec vecs[2]; | 309 | struct kvec vecs[2]; |
310 | uint32_t length; | 310 | uint32_t length; |
311 | int rc, totlen; | 311 | int rc, totlen; |
312 | uint32_t phys_ofs = write_ofs(c); | ||
312 | 313 | ||
313 | BUG_ON(!xd->xname); | 314 | BUG_ON(!xd->xname); |
314 | 315 | ||
@@ -322,7 +323,6 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x | |||
322 | if (!raw) | 323 | if (!raw) |
323 | return -ENOMEM; | 324 | return -ENOMEM; |
324 | raw->flash_offset = phys_ofs; | 325 | raw->flash_offset = phys_ofs; |
325 | raw->next_in_ino = (void *)xd; | ||
326 | 326 | ||
327 | /* Setup raw-xattr */ | 327 | /* Setup raw-xattr */ |
328 | rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 328 | rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
@@ -345,8 +345,7 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x | |||
345 | rc = rc ? rc : -EIO; | 345 | rc = rc ? rc : -EIO; |
346 | if (length) { | 346 | if (length) { |
347 | raw->flash_offset |= REF_OBSOLETE; | 347 | raw->flash_offset |= REF_OBSOLETE; |
348 | raw->next_in_ino = NULL; | 348 | jffs2_add_physical_node_ref(c, raw, PAD(totlen), NULL); |
349 | jffs2_add_physical_node_ref(c, raw, PAD(totlen)); | ||
350 | jffs2_mark_node_obsolete(c, raw); | 349 | jffs2_mark_node_obsolete(c, raw); |
351 | } else { | 350 | } else { |
352 | jffs2_free_raw_node_ref(raw); | 351 | jffs2_free_raw_node_ref(raw); |
@@ -356,7 +355,9 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x | |||
356 | 355 | ||
357 | /* success */ | 356 | /* success */ |
358 | raw->flash_offset |= REF_PRISTINE; | 357 | raw->flash_offset |= REF_PRISTINE; |
359 | jffs2_add_physical_node_ref(c, raw, PAD(totlen)); | 358 | jffs2_add_physical_node_ref(c, raw, PAD(totlen), NULL); |
359 | /* FIXME */ raw->next_in_ino = (void *)xd; | ||
360 | |||
360 | if (xd->node) | 361 | if (xd->node) |
361 | delete_xattr_datum_node(c, xd); | 362 | delete_xattr_datum_node(c, xd); |
362 | xd->node = raw; | 363 | xd->node = raw; |
@@ -369,8 +370,7 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x | |||
369 | 370 | ||
370 | static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c, | 371 | static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c, |
371 | int xprefix, const char *xname, | 372 | int xprefix, const char *xname, |
372 | const char *xvalue, int xsize, | 373 | const char *xvalue, int xsize) |
373 | uint32_t phys_ofs) | ||
374 | { | 374 | { |
375 | /* must be called under down_write(xattr_sem) */ | 375 | /* must be called under down_write(xattr_sem) */ |
376 | struct jffs2_xattr_datum *xd; | 376 | struct jffs2_xattr_datum *xd; |
@@ -419,7 +419,7 @@ static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c, | |||
419 | xd->value_len = xsize; | 419 | xd->value_len = xsize; |
420 | xd->data_crc = crc32(0, data, xd->name_len + 1 + xd->value_len); | 420 | xd->data_crc = crc32(0, data, xd->name_len + 1 + xd->value_len); |
421 | 421 | ||
422 | rc = save_xattr_datum(c, xd, phys_ofs); | 422 | rc = save_xattr_datum(c, xd); |
423 | if (rc) { | 423 | if (rc) { |
424 | kfree(xd->xname); | 424 | kfree(xd->xname); |
425 | jffs2_free_xattr_datum(xd); | 425 | jffs2_free_xattr_datum(xd); |
@@ -446,9 +446,9 @@ static struct jffs2_xattr_datum *create_xattr_datum(struct jffs2_sb_info *c, | |||
446 | * delete_xattr_ref(c, ref) | 446 | * delete_xattr_ref(c, ref) |
447 | * is used to delete jffs2_xattr_ref object. If the reference counter of xdatum | 447 | * is used to delete jffs2_xattr_ref object. If the reference counter of xdatum |
448 | * is refered by this xref become 0, delete_xattr_datum() is called later. | 448 | * is refered by this xref become 0, delete_xattr_datum() is called later. |
449 | * save_xattr_ref(c, ref, phys_ofs) | 449 | * save_xattr_ref(c, ref) |
450 | * is used to write xref to medium. | 450 | * is used to write xref to medium. |
451 | * create_xattr_ref(c, ic, xd, phys_ofs) | 451 | * create_xattr_ref(c, ic, xd) |
452 | * is used to create a new xref and write to medium. | 452 | * is used to create a new xref and write to medium. |
453 | * jffs2_xattr_delete_inode(c, ic) | 453 | * jffs2_xattr_delete_inode(c, ic) |
454 | * is called to remove xrefs related to obsolete inode when inode is unlinked. | 454 | * is called to remove xrefs related to obsolete inode when inode is unlinked. |
@@ -554,19 +554,19 @@ static void delete_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *re | |||
554 | jffs2_free_xattr_ref(ref); | 554 | jffs2_free_xattr_ref(ref); |
555 | } | 555 | } |
556 | 556 | ||
557 | static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref, uint32_t phys_ofs) | 557 | static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref) |
558 | { | 558 | { |
559 | /* must be called under down_write(xattr_sem) */ | 559 | /* must be called under down_write(xattr_sem) */ |
560 | struct jffs2_raw_node_ref *raw; | 560 | struct jffs2_raw_node_ref *raw; |
561 | struct jffs2_raw_xref rr; | 561 | struct jffs2_raw_xref rr; |
562 | uint32_t length; | 562 | uint32_t length; |
563 | uint32_t phys_ofs = write_ofs(c); | ||
563 | int ret; | 564 | int ret; |
564 | 565 | ||
565 | raw = jffs2_alloc_raw_node_ref(); | 566 | raw = jffs2_alloc_raw_node_ref(); |
566 | if (!raw) | 567 | if (!raw) |
567 | return -ENOMEM; | 568 | return -ENOMEM; |
568 | raw->flash_offset = phys_ofs; | 569 | raw->flash_offset = phys_ofs; |
569 | raw->next_in_ino = (void *)ref; | ||
570 | 570 | ||
571 | rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 571 | rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
572 | rr.nodetype = cpu_to_je16(JFFS2_NODETYPE_XREF); | 572 | rr.nodetype = cpu_to_je16(JFFS2_NODETYPE_XREF); |
@@ -584,8 +584,7 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref, | |||
584 | ret = ret ? ret : -EIO; | 584 | ret = ret ? ret : -EIO; |
585 | if (length) { | 585 | if (length) { |
586 | raw->flash_offset |= REF_OBSOLETE; | 586 | raw->flash_offset |= REF_OBSOLETE; |
587 | raw->next_in_ino = NULL; | 587 | jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)), NULL); |
588 | jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr))); | ||
589 | jffs2_mark_node_obsolete(c, raw); | 588 | jffs2_mark_node_obsolete(c, raw); |
590 | } else { | 589 | } else { |
591 | jffs2_free_raw_node_ref(raw); | 590 | jffs2_free_raw_node_ref(raw); |
@@ -594,7 +593,8 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref, | |||
594 | } | 593 | } |
595 | raw->flash_offset |= REF_PRISTINE; | 594 | raw->flash_offset |= REF_PRISTINE; |
596 | 595 | ||
597 | jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr))); | 596 | jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)), NULL); |
597 | /* FIXME */ raw->next_in_ino = (void *)ref; | ||
598 | if (ref->node) | 598 | if (ref->node) |
599 | delete_xattr_ref_node(c, ref); | 599 | delete_xattr_ref_node(c, ref); |
600 | ref->node = raw; | 600 | ref->node = raw; |
@@ -605,7 +605,7 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref, | |||
605 | } | 605 | } |
606 | 606 | ||
607 | static struct jffs2_xattr_ref *create_xattr_ref(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic, | 607 | static struct jffs2_xattr_ref *create_xattr_ref(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic, |
608 | struct jffs2_xattr_datum *xd, uint32_t phys_ofs) | 608 | struct jffs2_xattr_datum *xd) |
609 | { | 609 | { |
610 | /* must be called under down_write(xattr_sem) */ | 610 | /* must be called under down_write(xattr_sem) */ |
611 | struct jffs2_xattr_ref *ref; | 611 | struct jffs2_xattr_ref *ref; |
@@ -617,7 +617,7 @@ static struct jffs2_xattr_ref *create_xattr_ref(struct jffs2_sb_info *c, struct | |||
617 | ref->ic = ic; | 617 | ref->ic = ic; |
618 | ref->xd = xd; | 618 | ref->xd = xd; |
619 | 619 | ||
620 | ret = save_xattr_ref(c, ref, phys_ofs); | 620 | ret = save_xattr_ref(c, ref); |
621 | if (ret) { | 621 | if (ret) { |
622 | jffs2_free_xattr_ref(ref); | 622 | jffs2_free_xattr_ref(ref); |
623 | return ERR_PTR(ret); | 623 | return ERR_PTR(ret); |
@@ -1063,7 +1063,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname, | |||
1063 | struct jffs2_inode_cache *ic = f->inocache; | 1063 | struct jffs2_inode_cache *ic = f->inocache; |
1064 | struct jffs2_xattr_datum *xd; | 1064 | struct jffs2_xattr_datum *xd; |
1065 | struct jffs2_xattr_ref *ref, *newref, **pref; | 1065 | struct jffs2_xattr_ref *ref, *newref, **pref; |
1066 | uint32_t phys_ofs, length, request; | 1066 | uint32_t length, request; |
1067 | int rc; | 1067 | int rc; |
1068 | 1068 | ||
1069 | rc = check_xattr_ref_inode(c, ic); | 1069 | rc = check_xattr_ref_inode(c, ic); |
@@ -1071,7 +1071,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname, | |||
1071 | return rc; | 1071 | return rc; |
1072 | 1072 | ||
1073 | request = PAD(sizeof(struct jffs2_raw_xattr) + strlen(xname) + 1 + size); | 1073 | request = PAD(sizeof(struct jffs2_raw_xattr) + strlen(xname) + 1 + size); |
1074 | rc = jffs2_reserve_space(c, request, &phys_ofs, &length, | 1074 | rc = jffs2_reserve_space(c, request, &length, |
1075 | ALLOC_NORMAL, JFFS2_SUMMARY_XATTR_SIZE); | 1075 | ALLOC_NORMAL, JFFS2_SUMMARY_XATTR_SIZE); |
1076 | if (rc) { | 1076 | if (rc) { |
1077 | JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, request); | 1077 | JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, request); |
@@ -1118,7 +1118,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname, | |||
1118 | goto out; | 1118 | goto out; |
1119 | } | 1119 | } |
1120 | found: | 1120 | found: |
1121 | xd = create_xattr_datum(c, xprefix, xname, buffer, size, phys_ofs); | 1121 | xd = create_xattr_datum(c, xprefix, xname, buffer, size); |
1122 | if (IS_ERR(xd)) { | 1122 | if (IS_ERR(xd)) { |
1123 | rc = PTR_ERR(xd); | 1123 | rc = PTR_ERR(xd); |
1124 | goto out; | 1124 | goto out; |
@@ -1128,7 +1128,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname, | |||
1128 | 1128 | ||
1129 | /* create xattr_ref */ | 1129 | /* create xattr_ref */ |
1130 | request = PAD(sizeof(struct jffs2_raw_xref)); | 1130 | request = PAD(sizeof(struct jffs2_raw_xref)); |
1131 | rc = jffs2_reserve_space(c, request, &phys_ofs, &length, | 1131 | rc = jffs2_reserve_space(c, request, &length, |
1132 | ALLOC_NORMAL, JFFS2_SUMMARY_XREF_SIZE); | 1132 | ALLOC_NORMAL, JFFS2_SUMMARY_XREF_SIZE); |
1133 | if (rc) { | 1133 | if (rc) { |
1134 | JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, request); | 1134 | JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, request); |
@@ -1142,7 +1142,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname, | |||
1142 | down_write(&c->xattr_sem); | 1142 | down_write(&c->xattr_sem); |
1143 | if (ref) | 1143 | if (ref) |
1144 | *pref = ref->next; | 1144 | *pref = ref->next; |
1145 | newref = create_xattr_ref(c, ic, xd, phys_ofs); | 1145 | newref = create_xattr_ref(c, ic, xd); |
1146 | if (IS_ERR(newref)) { | 1146 | if (IS_ERR(newref)) { |
1147 | if (ref) { | 1147 | if (ref) { |
1148 | ref->next = ic->xref; | 1148 | ref->next = ic->xref; |
@@ -1171,7 +1171,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname, | |||
1171 | * -------------------------------------------------- */ | 1171 | * -------------------------------------------------- */ |
1172 | int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd) | 1172 | int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd) |
1173 | { | 1173 | { |
1174 | uint32_t phys_ofs, totlen, length, old_ofs; | 1174 | uint32_t totlen, length, old_ofs; |
1175 | int rc = -EINVAL; | 1175 | int rc = -EINVAL; |
1176 | 1176 | ||
1177 | down_write(&c->xattr_sem); | 1177 | down_write(&c->xattr_sem); |
@@ -1191,13 +1191,13 @@ int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xatt | |||
1191 | } else if (unlikely(rc < 0)) | 1191 | } else if (unlikely(rc < 0)) |
1192 | goto out; | 1192 | goto out; |
1193 | } | 1193 | } |
1194 | rc = jffs2_reserve_space_gc(c, totlen, &phys_ofs, &length, JFFS2_SUMMARY_XATTR_SIZE); | 1194 | rc = jffs2_reserve_space_gc(c, totlen, &length, JFFS2_SUMMARY_XATTR_SIZE); |
1195 | if (rc || length < totlen) { | 1195 | if (rc || length < totlen) { |
1196 | JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, totlen); | 1196 | JFFS2_WARNING("jffs2_reserve_space()=%d, request=%u\n", rc, totlen); |
1197 | rc = rc ? rc : -EBADFD; | 1197 | rc = rc ? rc : -EBADFD; |
1198 | goto out; | 1198 | goto out; |
1199 | } | 1199 | } |
1200 | rc = save_xattr_datum(c, xd, phys_ofs); | 1200 | rc = save_xattr_datum(c, xd); |
1201 | if (!rc) | 1201 | if (!rc) |
1202 | dbg_xattr("xdatum (xid=%u, version=%u) GC'ed from %#08x to %08x\n", | 1202 | dbg_xattr("xdatum (xid=%u, version=%u) GC'ed from %#08x to %08x\n", |
1203 | xd->xid, xd->version, old_ofs, ref_offset(xd->node)); | 1203 | xd->xid, xd->version, old_ofs, ref_offset(xd->node)); |
@@ -1209,7 +1209,7 @@ int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xatt | |||
1209 | 1209 | ||
1210 | int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref) | 1210 | int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref) |
1211 | { | 1211 | { |
1212 | uint32_t phys_ofs, totlen, length, old_ofs; | 1212 | uint32_t totlen, length, old_ofs; |
1213 | int rc = -EINVAL; | 1213 | int rc = -EINVAL; |
1214 | 1214 | ||
1215 | down_write(&c->xattr_sem); | 1215 | down_write(&c->xattr_sem); |
@@ -1220,14 +1220,14 @@ int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ | |||
1220 | if (totlen != sizeof(struct jffs2_raw_xref)) | 1220 | if (totlen != sizeof(struct jffs2_raw_xref)) |
1221 | goto out; | 1221 | goto out; |
1222 | 1222 | ||
1223 | rc = jffs2_reserve_space_gc(c, totlen, &phys_ofs, &length, JFFS2_SUMMARY_XREF_SIZE); | 1223 | rc = jffs2_reserve_space_gc(c, totlen, &length, JFFS2_SUMMARY_XREF_SIZE); |
1224 | if (rc || length < totlen) { | 1224 | if (rc || length < totlen) { |
1225 | JFFS2_WARNING("%s: jffs2_reserve_space() = %d, request = %u\n", | 1225 | JFFS2_WARNING("%s: jffs2_reserve_space() = %d, request = %u\n", |
1226 | __FUNCTION__, rc, totlen); | 1226 | __FUNCTION__, rc, totlen); |
1227 | rc = rc ? rc : -EBADFD; | 1227 | rc = rc ? rc : -EBADFD; |
1228 | goto out; | 1228 | goto out; |
1229 | } | 1229 | } |
1230 | rc = save_xattr_ref(c, ref, phys_ofs); | 1230 | rc = save_xattr_ref(c, ref); |
1231 | if (!rc) | 1231 | if (!rc) |
1232 | dbg_xattr("xref (ino=%u, xid=%u) GC'ed from %#08x to %08x\n", | 1232 | dbg_xattr("xref (ino=%u, xid=%u) GC'ed from %#08x to %08x\n", |
1233 | ref->ic->ino, ref->xd->xid, old_ofs, ref_offset(ref->node)); | 1233 | ref->ic->ino, ref->xd->xid, old_ofs, ref_offset(ref->node)); |