Lines Matching +full:page +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0
20 u32 offset, u32 *max) in hfsplus_block_allocate() argument
23 struct page *page; in hfsplus_block_allocate() local
34 hfs_dbg(BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len); in hfsplus_block_allocate()
35 mutex_lock(&sbi->alloc_mutex); in hfsplus_block_allocate()
36 mapping = sbi->alloc_file->i_mapping; in hfsplus_block_allocate()
37 page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL); in hfsplus_block_allocate()
38 if (IS_ERR(page)) { in hfsplus_block_allocate()
42 pptr = kmap_local_page(page); in hfsplus_block_allocate()
43 curr = pptr + (offset & (PAGE_CACHE_BITS - 1)) / 32; in hfsplus_block_allocate()
44 i = offset % 32; in hfsplus_block_allocate()
45 offset &= ~(PAGE_CACHE_BITS - 1); in hfsplus_block_allocate()
46 if ((size ^ offset) / PAGE_CACHE_BITS) in hfsplus_block_allocate()
49 end = pptr + ((size + 31) & (PAGE_CACHE_BITS - 1)) / 32; in hfsplus_block_allocate()
78 offset += PAGE_CACHE_BITS; in hfsplus_block_allocate()
79 if (offset >= size) in hfsplus_block_allocate()
81 page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, in hfsplus_block_allocate()
83 if (IS_ERR(page)) { in hfsplus_block_allocate()
87 curr = pptr = kmap_local_page(page); in hfsplus_block_allocate()
88 if ((size ^ offset) / PAGE_CACHE_BITS) in hfsplus_block_allocate()
91 end = pptr + ((size + 31) & (PAGE_CACHE_BITS - 1)) / 32; in hfsplus_block_allocate()
98 start = offset + (curr - pptr) * 32 + i; in hfsplus_block_allocate()
104 len = min(size - start, len); in hfsplus_block_allocate()
110 if (!--len || n & mask) in hfsplus_block_allocate()
113 if (!--len) in hfsplus_block_allocate()
127 len -= 32; in hfsplus_block_allocate()
129 set_page_dirty(page); in hfsplus_block_allocate()
131 offset += PAGE_CACHE_BITS; in hfsplus_block_allocate()
132 page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, in hfsplus_block_allocate()
134 if (IS_ERR(page)) { in hfsplus_block_allocate()
138 pptr = kmap_local_page(page); in hfsplus_block_allocate()
153 set_page_dirty(page); in hfsplus_block_allocate()
155 *max = offset + (curr - pptr) * 32 + i - start; in hfsplus_block_allocate()
156 sbi->free_blocks -= *max; in hfsplus_block_allocate()
158 hfs_dbg(BITMAP, "-> %u,%u\n", start, *max); in hfsplus_block_allocate()
160 mutex_unlock(&sbi->alloc_mutex); in hfsplus_block_allocate()
164 int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count) in hfsplus_block_free() argument
167 struct page *page; in hfsplus_block_free() local
177 hfs_dbg(BITMAP, "block_free: %u,%u\n", offset, count); in hfsplus_block_free()
179 if ((offset + count) > sbi->total_blocks) in hfsplus_block_free()
180 return -ENOENT; in hfsplus_block_free()
182 mutex_lock(&sbi->alloc_mutex); in hfsplus_block_free()
183 mapping = sbi->alloc_file->i_mapping; in hfsplus_block_free()
184 pnr = offset / PAGE_CACHE_BITS; in hfsplus_block_free()
185 page = read_mapping_page(mapping, pnr, NULL); in hfsplus_block_free()
186 if (IS_ERR(page)) in hfsplus_block_free()
188 pptr = kmap_local_page(page); in hfsplus_block_free()
189 curr = pptr + (offset & (PAGE_CACHE_BITS - 1)) / 32; in hfsplus_block_free()
194 i = offset % 32; in hfsplus_block_free()
196 int j = 32 - i; in hfsplus_block_free()
204 count -= j; in hfsplus_block_free()
213 count -= 32; in hfsplus_block_free()
217 set_page_dirty(page); in hfsplus_block_free()
219 page = read_mapping_page(mapping, ++pnr, NULL); in hfsplus_block_free()
220 if (IS_ERR(page)) in hfsplus_block_free()
222 pptr = kmap_local_page(page); in hfsplus_block_free()
233 set_page_dirty(page); in hfsplus_block_free()
235 sbi->free_blocks += len; in hfsplus_block_free()
237 mutex_unlock(&sbi->alloc_mutex); in hfsplus_block_free()
242 pr_crit("unable to mark blocks free: error %ld\n", PTR_ERR(page)); in hfsplus_block_free()
243 mutex_unlock(&sbi->alloc_mutex); in hfsplus_block_free()
245 return -EIO; in hfsplus_block_free()