Lines Matching refs:sec

12 static void hpfs_claim_alloc(struct super_block *s, secno sec)
17 hpfs_error(s, "free count underflow, allocating sector %08x", sec);
25 static void hpfs_claim_free(struct super_block *s, secno sec)
30 hpfs_error(s, "free count overflow, freeing sector %08x", sec);
38 static void hpfs_claim_dirband_alloc(struct super_block *s, secno sec)
43 hpfs_error(s, "dirband free count underflow, allocating sector %08x", sec);
51 static void hpfs_claim_dirband_free(struct super_block *s, secno sec)
56 hpfs_error(s, "dirband free count overflow, freeing sector %08x", sec);
69 static int chk_if_allocated(struct super_block *s, secno sec, char *msg)
73 if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "chk"))) goto fail;
74 if ((le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) >> (sec & 0x1f)) & 1) {
75 hpfs_error(s, "sector '%s' - %08x not allocated in bitmap", msg, sec);
79 if (sec >= hpfs_sb(s)->sb_dirband_start && sec < hpfs_sb(s)->sb_dirband_start + hpfs_sb(s)->sb_dirband_size) {
80 unsigned ssec = (sec - hpfs_sb(s)->sb_dirband_start) / 4;
83 hpfs_error(s, "sector '%s' - %08x not allocated in directory bitmap", msg, sec);
205 secno sec;
217 if ((sec = alloc_in_bmp(s, near, n, f_p ? forward : forward/4))) goto ret;
222 if ((sec = alloc_in_bmp(s, b<<14, n, f_p ? forward : forward/2))) {
226 if (b > 0x10000000) if ((sec = alloc_in_bmp(s, (b&0xfffffff)<<14, n, f_p ? forward : 0))) goto ret;
231 if (near_bmp+i < n_bmps && ((sec = alloc_in_bmp(s, (near_bmp+i) << 14, n, forward)))) {
236 if (near_bmp-i-1 >= 0 && ((sec = alloc_in_bmp(s, (near_bmp-i-1) << 14, n, forward)))) {
241 if (near_bmp+i >= n_bmps && ((sec = alloc_in_bmp(s, (near_bmp+i-n_bmps) << 14, n, forward)))) {
246 if (i == 1 && sbi->sb_c_bitmap != -1 && ((sec = alloc_in_bmp(s, (sbi->sb_c_bitmap) << 14, n, forward)))) {
257 sec = 0;
259 if (sec) {
262 hpfs_claim_alloc(s, sec + i);
265 if (sec && f_p) {
267 if (!hpfs_alloc_if_possible(s, sec + n + i)) {
268 hpfs_error(s, "Prealloc doesn't work! Wanted %d, allocated at %08x, can't allocate %d", forward, sec, i);
269 sec = 0;
274 return sec;
280 secno sec;
288 sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0);
289 if (!sec) return 0;
290 hpfs_claim_dirband_alloc(s, sec);
291 return ((sec & 0x3fff) << 2) + sbi->sb_dirband_start;
296 int hpfs_alloc_if_possible(struct super_block *s, secno sec)
300 if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "aip"))) goto end;
301 if (le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) & (1 << (sec & 0x1f))) {
302 bmp[(sec & 0x3fff) >> 5] &= cpu_to_le32(~(1 << (sec & 0x1f)));
305 hpfs_claim_alloc(s, sec);
315 void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n)
322 if (sec < 0x12) {
323 hpfs_error(s, "Trying to free reserved sector %08x", sec);
329 if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "free"))) {
333 if ((le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) >> (sec & 0x1f) & 1)) {
334 hpfs_error(s, "sector %08x not allocated", sec);
338 bmp[(sec & 0x3fff) >> 5] |= cpu_to_le32(1 << (sec & 0x1f));
339 hpfs_claim_free(s, sec);
345 if (!(++sec & 0x3fff)) {