aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h74
1 files changed, 4 insertions, 70 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index a942a2427228..d1c6f023a302 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -426,77 +426,11 @@ struct btrfs_root {
426 offsetof(type, member), \ 426 offsetof(type, member), \
427 sizeof(((type *)0)->member))) 427 sizeof(((type *)0)->member)))
428 428
429#ifndef BTRFS_SETGET_FUNCS
429#define BTRFS_SETGET_FUNCS(name, type, member, bits) \ 430#define BTRFS_SETGET_FUNCS(name, type, member, bits) \
430static inline u##bits btrfs_##name(struct extent_buffer *eb, \ 431u##bits btrfs_##name(struct extent_buffer *eb, type *s); \
431 type *s) \ 432void btrfs_set_##name(struct extent_buffer *eb, type *s, u##bits val);
432{ \ 433#endif
433 int err; \
434 char *map_token; \
435 char *kaddr; \
436 int unmap_on_exit = (eb->map_token == NULL); \
437 unsigned long map_start; \
438 unsigned long map_len; \
439 unsigned long offset = (unsigned long)s + \
440 offsetof(type, member); \
441 if (eb->map_token && offset >= eb->map_start && \
442 offset + sizeof(((type *)0)->member) <= eb->map_start + \
443 eb->map_len) { \
444 kaddr = eb->kaddr; \
445 map_start = eb->map_start; \
446 err = 0; \
447 } else { \
448 err = map_extent_buffer(eb, offset, \
449 sizeof(((type *)0)->member), \
450 &map_token, &kaddr, \
451 &map_start, &map_len, KM_USER1); \
452 } \
453 if (!err) { \
454 __le##bits *tmp = (__le##bits *)(kaddr + offset - \
455 map_start); \
456 u##bits res = le##bits##_to_cpu(*tmp); \
457 if (unmap_on_exit) \
458 unmap_extent_buffer(eb, map_token, KM_USER1); \
459 return res; \
460 } else { \
461 __le##bits res; \
462 read_eb_member(eb, s, type, member, &res); \
463 return le##bits##_to_cpu(res); \
464 } \
465} \
466static inline void btrfs_set_##name(struct extent_buffer *eb, \
467 type *s, u##bits val) \
468{ \
469 int err; \
470 char *map_token; \
471 char *kaddr; \
472 unsigned long map_start; \
473 unsigned long map_len; \
474 int unmap_on_exit = (eb->map_token == NULL); \
475 unsigned long offset = (unsigned long)s + \
476 offsetof(type, member); \
477 if (eb->map_token && offset >= eb->map_start && \
478 offset + sizeof(((type *)0)->member) <= eb->map_start + \
479 eb->map_len) { \
480 kaddr = eb->kaddr; \
481 map_start = eb->map_start; \
482 err = 0; \
483 } else { \
484 err = map_extent_buffer(eb, offset, \
485 sizeof(((type *)0)->member), \
486 &map_token, &kaddr, \
487 &map_start, &map_len, KM_USER1); \
488 } \
489 if (!err) { \
490 __le##bits *tmp = (__le##bits *)(kaddr + offset - \
491 map_start); \
492 *tmp = cpu_to_le##bits(val); \
493 if (unmap_on_exit) \
494 unmap_extent_buffer(eb, map_token, KM_USER1); \
495 } else { \
496 val = cpu_to_le##bits(val); \
497 write_eb_member(eb, s, type, member, &val); \
498 } \
499}
500 434
501#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \ 435#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \
502static inline u##bits btrfs_##name(struct extent_buffer *eb) \ 436static inline u##bits btrfs_##name(struct extent_buffer *eb) \