• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/fs/jffs2/

Lines Matching defs:xd

27  * is_xattr_datum_unchecked(c, xd)
30 * unload_xattr_datum(c, xd)
36 * do_verify_xattr_datum(c, xd)
43 * do_load_xattr_datum(c, xd)
46 * load_xattr_datum(c, xd)
48 * If xd need to call do_verify_xattr_datum() at first, it's called before calling
50 * save_xattr_datum(c, xd)
51 * is used to write xdatum to medium. xd->version will be incremented.
54 * unrefer_xattr_datum(c, xd)
56 * is set on xd->flags and chained xattr_dead_list or release it immediately.
66 static int is_xattr_datum_unchecked(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
72 for (raw=xd->node; raw != (void *)xd; raw=raw->next_in_ino) {
82 static void unload_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
85 D1(dbg_xattr("%s: xid=%u, version=%u\n", __FUNCTION__, xd->xid, xd->version));
86 if (xd->xname) {
87 c->xdatum_mem_usage -= (xd->name_len + 1 + xd->value_len);
88 kfree(xd->xname);
91 list_del_init(&xd->xindex);
92 xd->hashkey = 0;
93 xd->xname = NULL;
94 xd->xvalue = NULL;
100 struct jffs2_xattr_datum *xd, *_xd;
111 list_for_each_entry_safe(xd, _xd, &c->xattrindex[index], xindex) {
112 if (xd->flags & JFFS2_XFLAGS_HOT) {
113 xd->flags &= ~JFFS2_XFLAGS_HOT;
114 } else if (!(xd->flags & JFFS2_XFLAGS_BIND)) {
115 unload_xattr_datum(c, xd);
127 static int do_verify_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
138 offset = ref_offset(xd->node);
139 if (ref_flags(xd->node) == REF_PRISTINE)
153 xd->flags |= JFFS2_XFLAGS_INVALID;
160 || je32_to_cpu(rx.xid) != xd->xid
161 || je32_to_cpu(rx.version) != xd->version) {
167 je32_to_cpu(rx.xid), xd->xid,
168 je32_to_cpu(rx.version), xd->version);
169 xd->flags |= JFFS2_XFLAGS_INVALID;
172 xd->xprefix = rx.xprefix;
173 xd->name_len = rx.name_len;
174 xd->value_len = je16_to_cpu(rx.value_len);
175 xd->data_crc = je32_to_cpu(rx.data_crc);
179 for (raw=xd->node; raw != (void *)xd; raw=raw->next_in_ino) {
186 raw->flash_offset = ref_offset(raw) | ((xd->node==raw) ? REF_PRISTINE : REF_NORMAL);
191 list_del_init(&xd->xindex);
194 xd->xid, xd->version);
199 static int do_load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
207 BUG_ON(ref_flags(xd->node) != REF_PRISTINE);
208 BUG_ON(!list_empty(&xd->xindex));
210 length = xd->name_len + 1 + xd->value_len;
215 ret = jffs2_flash_read(c, ref_offset(xd->node)+sizeof(struct jffs2_raw_xattr),
220 ret, length, readlen, ref_offset(xd->node));
225 data[xd->name_len] = '\0';
227 if (crc != xd->data_crc) {
230 ref_offset(xd->node), xd->data_crc, crc);
232 xd->flags |= JFFS2_XFLAGS_INVALID;
236 xd->flags |= JFFS2_XFLAGS_HOT;
237 xd->xname = data;
238 xd->xvalue = data + xd->name_len+1;
242 xd->hashkey = xattr_datum_hashkey(xd->xprefix, xd->xname, xd->xvalue, xd->value_len);
243 i = xd->hashkey % XATTRINDEX_HASHSIZE;
244 list_add(&xd->xindex, &c->xattrindex[i]);
248 if (!xd->xname)
253 xd->xid, xd->xprefix, xd->xname);
258 static int load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
267 BUG_ON(xd->flags & JFFS2_XFLAGS_DEAD);
268 if (xd->xname)
270 if (xd->flags & JFFS2_XFLAGS_INVALID)
272 if (unlikely(is_xattr_datum_unchecked(c, xd)))
273 rc = do_verify_xattr_datum(c, xd);
275 rc = do_load_xattr_datum(c, xd);
279 static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
288 BUG_ON(!xd->xname);
289 BUG_ON(xd->flags & (JFFS2_XFLAGS_DEAD|JFFS2_XFLAGS_INVALID));
293 vecs[1].iov_base = xd->xname;
294 vecs[1].iov_len = xd->name_len + 1 + xd->value_len;
304 rx.xid = cpu_to_je32(xd->xid);
305 rx.version = cpu_to_je32(++xd->version);
306 rx.xprefix = xd->xprefix;
307 rx.name_len = xd->name_len;
308 rx.value_len = cpu_to_je16(xd->value_len);
323 jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, PAD(totlen), (void *)xd);
326 xd->xid, xd->version, xd->xprefix, xd->xname);
336 struct jffs2_xattr_datum *xd;
344 list_for_each_entry(xd, &c->xattrindex[i], xindex) {
345 if (xd->hashkey==hashkey
346 && xd->xprefix==xprefix
347 && xd->value_len==xsize
348 && !strcmp(xd->xname, xname)
349 && !memcmp(xd->xvalue, xvalue, xsize)) {
350 atomic_inc(&xd->refcnt);
351 return xd;
358 xd = jffs2_alloc_xattr_datum();
359 if (!xd)
364 jffs2_free_xattr_datum(xd);
370 atomic_set(&xd->refcnt, 1);
371 xd->xid = ++c->highest_xid;
372 xd->flags |= JFFS2_XFLAGS_HOT;
373 xd->xprefix = xprefix;
375 xd->hashkey = hashkey;
376 xd->xname = data;
377 xd->xvalue = data + name_len + 1;
378 xd->name_len = name_len;
379 xd->value_len = xsize;
380 xd->data_crc = crc32(0, data, xd->name_len + 1 + xd->value_len);
382 rc = save_xattr_datum(c, xd);
384 kfree(xd->xname);
385 jffs2_free_xattr_datum(xd);
391 list_add(&xd->xindex, &c->xattrindex[i]);
393 c->xdatum_mem_usage += (xd->name_len + 1 + xd->value_len);
396 return xd;
399 static void unrefer_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
402 if (atomic_dec_and_lock(&xd->refcnt, &c->erase_completion_lock)) {
403 unload_xattr_datum(c, xd);
404 xd->flags |= JFFS2_XFLAGS_DEAD;
405 if (xd->node == (void *)xd) {
406 BUG_ON(!(xd->flags & JFFS2_XFLAGS_INVALID));
407 jffs2_free_xattr_datum(xd);
409 list_add(&xd->xindex, &c->xattr_dead_list);
414 xd->xid, xd->version);
425 * create_xattr_ref(c, ic, xd)
519 rr.xid = cpu_to_je32(ref->xd->xid);
538 dbg_xattr("success on saving xref (ino=%u, xid=%u)\n", ref->ic->ino, ref->xd->xid);
544 struct jffs2_xattr_datum *xd)
554 ref->xd = xd;
572 struct jffs2_xattr_datum *xd;
574 xd = ref->xd;
577 ref->xid = ref->xd->xid;
586 unrefer_xattr_datum(c, xd);
610 struct jffs2_xattr_datum *xd;
616 xd = ref->xd;
617 if (atomic_dec_and_test(&xd->refcnt)) {
618 unload_xattr_datum(c, xd);
619 jffs2_free_xattr_datum(xd);
642 if (!ref->xd->xname) {
643 rc = load_xattr_datum(c, ref->xd);
652 if (!cmp->xd->xname) {
653 ref->xd->flags |= JFFS2_XFLAGS_BIND;
654 rc = load_xattr_datum(c, cmp->xd);
655 ref->xd->flags &= ~JFFS2_XFLAGS_BIND;
663 if (ref->xd->xprefix == cmp->xd->xprefix
664 && !strcmp(ref->xd->xname, cmp->xd->xname)) {
715 struct jffs2_xattr_datum *xd;
721 list_for_each_entry(xd, &c->xattrindex[i], xindex) {
722 if (xd->xid==xid)
723 return xd;
730 struct jffs2_xattr_datum *xd, *_xd;
745 list_for_each_entry_safe(xd, _xd, &c->xattrindex[i], xindex) {
746 list_del(&xd->xindex);
747 if (xd->xname)
748 kfree(xd->xname);
749 jffs2_free_xattr_datum(xd);
753 list_for_each_entry_safe(xd, _xd, &c->xattr_dead_list, xindex) {
754 list_del(&xd->xindex);
755 jffs2_free_xattr_datum(xd);
757 list_for_each_entry_safe(xd, _xd, &c->xattr_unchecked, xindex) {
758 list_del(&xd->xindex);
759 jffs2_free_xattr_datum(xd);
768 struct jffs2_xattr_datum *xd, *_xd;
829 ref->xd and ref->ic are not valid yet. */
830 xd = jffs2_find_xattr_datum(c, ref->xid);
832 if (!xd || !ic || !ic->nlink) {
841 ref->xd = xd;
843 atomic_inc(&xd->refcnt);
851 list_for_each_entry_safe(xd, _xd, &c->xattrindex[i], xindex) {
853 list_del_init(&xd->xindex);
854 if (!atomic_read(&xd->refcnt)) {
856 xd->xid, xd->version);
857 xd->flags |= JFFS2_XFLAGS_DEAD;
858 list_add(&xd->xindex, &c->xattr_unchecked);
862 if (is_xattr_datum_unchecked(c, xd)) {
864 xd->xid, xd->version);
865 list_add(&xd->xindex, &c->xattr_unchecked);
881 struct jffs2_xattr_datum *xd;
883 xd = jffs2_find_xattr_datum(c, xid);
884 if (!xd) {
885 xd = jffs2_alloc_xattr_datum();
886 if (!xd)
888 xd->xid = xid;
889 xd->version = version;
890 if (xd->xid > c->highest_xid)
891 c->highest_xid = xd->xid;
892 list_add_tail(&xd->xindex, &c->xattrindex[xid % XATTRINDEX_HASHSIZE]);
894 return xd;
957 struct jffs2_xattr_datum *xd;
971 xd = ref->xd;
972 if (!xd->xname) {
980 rc = load_xattr_datum(c, xd);
989 xhandle = xprefix_to_handler(xd->xprefix);
993 rc = xhandle->list(inode, buffer+len, size-len, xd->xname, xd->name_len);
995 rc = xhandle->list(inode, NULL, 0, xd->xname, xd->name_len);
1017 struct jffs2_xattr_datum *xd;
1030 xd = ref->xd;
1031 if (xd->xprefix != xprefix)
1033 if (!xd->xname) {
1041 rc = load_xattr_datum(c, xd);
1051 if (!strcmp(xname, xd->xname)) {
1052 rc = xd->value_len;
1057 memcpy(buffer, xd->xvalue, rc);
1079 struct jffs2_xattr_datum *xd;
1100 xd = ref->xd;
1101 if (xd->xprefix != xprefix)
1103 if (!xd->xname) {
1104 rc = load_xattr_datum(c, xd);
1112 if (!strcmp(xd->xname, xname)) {
1119 ref->xid = xd->xid;
1128 unrefer_xattr_datum(c, xd);
1131 ref->xd = xd;
1149 xd = create_xattr_datum(c, xprefix, xname, buffer, size);
1150 if (IS_ERR(xd)) {
1151 rc = PTR_ERR(xd);
1164 unrefer_xattr_datum(c, xd);
1170 newref = create_xattr_ref(c, ic, xd);
1177 unrefer_xattr_datum(c, xd);
1188 * jffs2_garbage_collect_xattr_datum(c, xd, raw)
1194 * jffs2_release_xattr_datum(c, xd)
1199 int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd,
1206 if (xd->node != raw)
1208 if (xd->flags & (JFFS2_XFLAGS_DEAD|JFFS2_XFLAGS_INVALID))
1211 rc = load_xattr_datum(c, xd);
1216 old_ofs = ref_offset(xd->node);
1218 + xd->name_len + 1 + xd->value_len);
1224 rc = save_xattr_datum(c, xd);
1227 xd->xid, xd->version, old_ofs, ref_offset(xd->node));
1262 ref->ic->ino, ref->xd->xid, old_ofs, ref_offset(ref->node));
1272 struct jffs2_xattr_datum *xd, *_xd;
1279 list_for_each_entry_safe(xd, _xd, &c->xattr_unchecked, xindex) {
1280 rc = do_verify_xattr_datum(c, xd);
1283 list_del_init(&xd->xindex);
1285 for (raw=xd->node; raw != (void *)xd; raw=raw->next_in_ino) {
1293 | ((xd->node == (void *)raw) ? REF_PRISTINE : REF_NORMAL);
1295 if (xd->flags & JFFS2_XFLAGS_DEAD)
1296 list_add(&xd->xindex, &c->xattr_dead_list);
1303 void jffs2_release_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
1306 if (atomic_read(&xd->refcnt) || xd->node != (void *)xd)
1309 list_del(&xd->xindex);
1310 jffs2_free_xattr_datum(xd);