diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-12 19:22:50 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-12 19:22:50 -0500 |
| commit | 83c0fb6500b13c9b7564fe453b76356dc58415d4 (patch) | |
| tree | fe4c449dabb67da76ea1f6045f490c044327a46b /fs/udf/balloc.c | |
| parent | 11bfe2ea732c6499c46c4f3a63d567c05b9dbafd (diff) | |
| parent | 3a065fcf9efed42ba736da7be528f2d3dec4965a (diff) | |
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-udf-2.6
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-udf-2.6:
udf: use ext2_find_next_bit
udf: Do not read inode before writing it
udf: Fix unalloc space handling in udf_update_inode
Diffstat (limited to 'fs/udf/balloc.c')
| -rw-r--r-- | fs/udf/balloc.c | 49 |
1 files changed, 1 insertions, 48 deletions
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c index ccc3ad7242d4..19626e2491c4 100644 --- a/fs/udf/balloc.c +++ b/fs/udf/balloc.c | |||
| @@ -31,55 +31,8 @@ | |||
| 31 | #define udf_clear_bit(nr, addr) ext2_clear_bit(nr, addr) | 31 | #define udf_clear_bit(nr, addr) ext2_clear_bit(nr, addr) |
| 32 | #define udf_set_bit(nr, addr) ext2_set_bit(nr, addr) | 32 | #define udf_set_bit(nr, addr) ext2_set_bit(nr, addr) |
| 33 | #define udf_test_bit(nr, addr) ext2_test_bit(nr, addr) | 33 | #define udf_test_bit(nr, addr) ext2_test_bit(nr, addr) |
| 34 | #define udf_find_first_one_bit(addr, size) find_first_one_bit(addr, size) | ||
| 35 | #define udf_find_next_one_bit(addr, size, offset) \ | 34 | #define udf_find_next_one_bit(addr, size, offset) \ |
| 36 | find_next_one_bit(addr, size, offset) | 35 | ext2_find_next_bit(addr, size, offset) |
| 37 | |||
| 38 | #define leBPL_to_cpup(x) leNUM_to_cpup(BITS_PER_LONG, x) | ||
| 39 | #define leNUM_to_cpup(x, y) xleNUM_to_cpup(x, y) | ||
| 40 | #define xleNUM_to_cpup(x, y) (le ## x ## _to_cpup(y)) | ||
| 41 | #define uintBPL_t uint(BITS_PER_LONG) | ||
| 42 | #define uint(x) xuint(x) | ||
| 43 | #define xuint(x) __le ## x | ||
| 44 | |||
| 45 | static inline int find_next_one_bit(void *addr, int size, int offset) | ||
| 46 | { | ||
| 47 | uintBPL_t *p = ((uintBPL_t *) addr) + (offset / BITS_PER_LONG); | ||
| 48 | int result = offset & ~(BITS_PER_LONG - 1); | ||
| 49 | unsigned long tmp; | ||
| 50 | |||
| 51 | if (offset >= size) | ||
| 52 | return size; | ||
| 53 | size -= result; | ||
| 54 | offset &= (BITS_PER_LONG - 1); | ||
| 55 | if (offset) { | ||
| 56 | tmp = leBPL_to_cpup(p++); | ||
| 57 | tmp &= ~0UL << offset; | ||
| 58 | if (size < BITS_PER_LONG) | ||
| 59 | goto found_first; | ||
| 60 | if (tmp) | ||
| 61 | goto found_middle; | ||
| 62 | size -= BITS_PER_LONG; | ||
| 63 | result += BITS_PER_LONG; | ||
| 64 | } | ||
| 65 | while (size & ~(BITS_PER_LONG - 1)) { | ||
| 66 | tmp = leBPL_to_cpup(p++); | ||
| 67 | if (tmp) | ||
| 68 | goto found_middle; | ||
| 69 | result += BITS_PER_LONG; | ||
| 70 | size -= BITS_PER_LONG; | ||
| 71 | } | ||
| 72 | if (!size) | ||
| 73 | return result; | ||
| 74 | tmp = leBPL_to_cpup(p); | ||
| 75 | found_first: | ||
| 76 | tmp &= ~0UL >> (BITS_PER_LONG - size); | ||
| 77 | found_middle: | ||
| 78 | return result + ffz(~tmp); | ||
| 79 | } | ||
| 80 | |||
| 81 | #define find_first_one_bit(addr, size)\ | ||
| 82 | find_next_one_bit((addr), (size), 0) | ||
| 83 | 36 | ||
| 84 | static int read_block_bitmap(struct super_block *sb, | 37 | static int read_block_bitmap(struct super_block *sb, |
| 85 | struct udf_bitmap *bitmap, unsigned int block, | 38 | struct udf_bitmap *bitmap, unsigned int block, |
