Lines Matching refs:s

11 static void hpfs_claim_alloc(struct super_block *s, secno sec)  in hpfs_claim_alloc()  argument
13 struct hpfs_sb_info *sbi = hpfs_sb(s); in hpfs_claim_alloc()
16 hpfs_error(s, "free count underflow, allocating sector %08x", sec); in hpfs_claim_alloc()
24 static void hpfs_claim_free(struct super_block *s, secno sec) in hpfs_claim_free() argument
26 struct hpfs_sb_info *sbi = hpfs_sb(s); in hpfs_claim_free()
29 hpfs_error(s, "free count overflow, freeing sector %08x", sec); in hpfs_claim_free()
37 static void hpfs_claim_dirband_alloc(struct super_block *s, secno sec) in hpfs_claim_dirband_alloc() argument
39 struct hpfs_sb_info *sbi = hpfs_sb(s); in hpfs_claim_dirband_alloc()
42 hpfs_error(s, "dirband free count underflow, allocating sector %08x", sec); in hpfs_claim_dirband_alloc()
50 static void hpfs_claim_dirband_free(struct super_block *s, secno sec) in hpfs_claim_dirband_free() argument
52 struct hpfs_sb_info *sbi = hpfs_sb(s); in hpfs_claim_dirband_free()
55 hpfs_error(s, "dirband free count overflow, freeing sector %08x", sec); in hpfs_claim_dirband_free()
68 static int chk_if_allocated(struct super_block *s, secno sec, char *msg) in chk_if_allocated() argument
72 if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "chk"))) goto fail; in chk_if_allocated()
74 hpfs_error(s, "sector '%s' - %08x not allocated in bitmap", msg, sec); in chk_if_allocated()
78 …if (sec >= hpfs_sb(s)->sb_dirband_start && sec < hpfs_sb(s)->sb_dirband_start + hpfs_sb(s)->sb_dir… in chk_if_allocated()
79 unsigned ssec = (sec - hpfs_sb(s)->sb_dirband_start) / 4; in chk_if_allocated()
80 if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) goto fail; in chk_if_allocated()
82 hpfs_error(s, "sector '%s' - %08x not allocated in directory bitmap", msg, sec); in chk_if_allocated()
99 int hpfs_chk_sectors(struct super_block *s, secno start, int len, char *msg) in hpfs_chk_sectors() argument
102 start + len > hpfs_sb(s)->sb_fs_size) { in hpfs_chk_sectors()
103 hpfs_error(s, "sector(s) '%s' badly placed at %08x", msg, start); in hpfs_chk_sectors()
106 if (hpfs_sb(s)->sb_chk>=2) { in hpfs_chk_sectors()
109 if (chk_if_allocated(s, start + i, msg)) return 1; in hpfs_chk_sectors()
114 static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigned forward) in alloc_in_bmp() argument
125 hpfs_error(s, "Bad allocation size: %d", n); in alloc_in_bmp()
129 if (!(bmp = hpfs_map_bitmap(s, near >> 14, &qbh, "aib"))) goto uls; in alloc_in_bmp()
131 if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) goto uls; in alloc_in_bmp()
180 …if (hpfs_sb(s)->sb_chk && ((ret >> 14) != (bs >> 14) || (le32_to_cpu(bmp[(ret & 0x3fff) >> 5]) | ~… in alloc_in_bmp()
181 hpfs_error(s, "Allocation doesn't work! Wanted %d, allocated at %08x", n, ret); in alloc_in_bmp()
202 secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forward) in hpfs_alloc_sector() argument
207 struct hpfs_sb_info *sbi = hpfs_sb(s); in hpfs_alloc_sector()
216 if ((sec = alloc_in_bmp(s, near, n, f_p ? forward : forward/4))) goto ret; in hpfs_alloc_sector()
230 if (near_bmp+i < n_bmps && ((sec = alloc_in_bmp(s, (near_bmp+i) << 14, n, forward)))) { in hpfs_alloc_sector()
235 if (near_bmp-i-1 >= 0 && ((sec = alloc_in_bmp(s, (near_bmp-i-1) << 14, n, forward)))) { in hpfs_alloc_sector()
240 if (near_bmp+i >= n_bmps && ((sec = alloc_in_bmp(s, (near_bmp+i-n_bmps) << 14, n, forward)))) { in hpfs_alloc_sector()
245 …if (i == 1 && sbi->sb_c_bitmap != -1 && ((sec = alloc_in_bmp(s, (sbi->sb_c_bitmap) << 14, n, forwa… in hpfs_alloc_sector()
261 hpfs_claim_alloc(s, sec + i); in hpfs_alloc_sector()
266 if (!hpfs_alloc_if_possible(s, sec + n + i)) { in hpfs_alloc_sector()
267 …hpfs_error(s, "Prealloc doesn't work! Wanted %d, allocated at %08x, can't allocate %d", forward, s… in hpfs_alloc_sector()
276 static secno alloc_in_dirband(struct super_block *s, secno near) in alloc_in_dirband() argument
280 struct hpfs_sb_info *sbi = hpfs_sb(s); in alloc_in_dirband()
287 sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0); in alloc_in_dirband()
289 hpfs_claim_dirband_alloc(s, sec); in alloc_in_dirband()
295 int hpfs_alloc_if_possible(struct super_block *s, secno sec) in hpfs_alloc_if_possible() argument
299 if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "aip"))) goto end; in hpfs_alloc_if_possible()
304 hpfs_claim_alloc(s, sec); in hpfs_alloc_if_possible()
314 void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) in hpfs_free_sectors() argument
318 struct hpfs_sb_info *sbi = hpfs_sb(s); in hpfs_free_sectors()
322 hpfs_error(s, "Trying to free reserved sector %08x", sec); in hpfs_free_sectors()
328 if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "free"))) { in hpfs_free_sectors()
333 hpfs_error(s, "sector %08x not allocated", sec); in hpfs_free_sectors()
338 hpfs_claim_free(s, sec); in hpfs_free_sectors()
358 int hpfs_check_free_dnodes(struct super_block *s, int n) in hpfs_check_free_dnodes() argument
360 int n_bmps = (hpfs_sb(s)->sb_fs_size + 0x4000 - 1) >> 14; in hpfs_check_free_dnodes()
361 int b = hpfs_sb(s)->sb_c_bitmap & 0x0fffffff; in hpfs_check_free_dnodes()
365 if ((bmp = hpfs_map_dnode_bitmap(s, &qbh))) { in hpfs_check_free_dnodes()
377 if (hpfs_sb(s)->sb_c_bitmap != -1) { in hpfs_check_free_dnodes()
378 bmp = hpfs_map_bitmap(s, b, &qbh, "chkdn1"); in hpfs_check_free_dnodes()
384 bmp = hpfs_map_bitmap(s, i, &qbh, "chkdn2"); in hpfs_check_free_dnodes()
404 void hpfs_free_dnode(struct super_block *s, dnode_secno dno) in hpfs_free_dnode() argument
406 if (hpfs_sb(s)->sb_chk) if (dno & 3) { in hpfs_free_dnode()
407 hpfs_error(s, "hpfs_free_dnode: dnode %08x not aligned", dno); in hpfs_free_dnode()
410 if (dno < hpfs_sb(s)->sb_dirband_start || in hpfs_free_dnode()
411 dno >= hpfs_sb(s)->sb_dirband_start + hpfs_sb(s)->sb_dirband_size) { in hpfs_free_dnode()
412 hpfs_free_sectors(s, dno, 4); in hpfs_free_dnode()
416 unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4; in hpfs_free_dnode()
417 if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { in hpfs_free_dnode()
423 hpfs_claim_dirband_free(s, dno); in hpfs_free_dnode()
427 struct dnode *hpfs_alloc_dnode(struct super_block *s, secno near, in hpfs_alloc_dnode() argument
431 if (hpfs_get_free_dnodes(s) > FREE_DNODES_ADD) { in hpfs_alloc_dnode()
432 if (!(*dno = alloc_in_dirband(s, near))) in hpfs_alloc_dnode()
433 if (!(*dno = hpfs_alloc_sector(s, near, 4, 0))) return NULL; in hpfs_alloc_dnode()
435 if (!(*dno = hpfs_alloc_sector(s, near, 4, 0))) in hpfs_alloc_dnode()
436 if (!(*dno = alloc_in_dirband(s, near))) return NULL; in hpfs_alloc_dnode()
438 if (!(d = hpfs_get_4sectors(s, *dno, qbh))) { in hpfs_alloc_dnode()
439 hpfs_free_dnode(s, *dno); in hpfs_alloc_dnode()
453 struct fnode *hpfs_alloc_fnode(struct super_block *s, secno near, fnode_secno *fno, in hpfs_alloc_fnode() argument
457 if (!(*fno = hpfs_alloc_sector(s, near, 1, FNODE_ALLOC_FWD))) return NULL; in hpfs_alloc_fnode()
458 if (!(f = hpfs_get_sector(s, *fno, bh))) { in hpfs_alloc_fnode()
459 hpfs_free_sectors(s, *fno, 1); in hpfs_alloc_fnode()
470 struct anode *hpfs_alloc_anode(struct super_block *s, secno near, anode_secno *ano, in hpfs_alloc_anode() argument
474 if (!(*ano = hpfs_alloc_sector(s, near, 1, ANODE_ALLOC_FWD))) return NULL; in hpfs_alloc_anode()
475 if (!(a = hpfs_get_sector(s, *ano, bh))) { in hpfs_alloc_anode()
476 hpfs_free_sectors(s, *ano, 1); in hpfs_alloc_anode()
502 static int do_trim(struct super_block *s, secno start, unsigned len, secno limit_start, secno limit… in do_trim() argument
517 err = sb_issue_discard(s, start, end - start, GFP_NOFS, 0); in do_trim()
524 int hpfs_trim_fs(struct super_block *s, u64 start, u64 end, u64 minlen, unsigned *result) in hpfs_trim_fs() argument
527 struct hpfs_sb_info *sbi = hpfs_sb(s); in hpfs_trim_fs()
540 hpfs_lock(s); in hpfs_trim_fs()
541 if (s->s_flags & MS_RDONLY) { in hpfs_trim_fs()
545 if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { in hpfs_trim_fs()
551 err = do_trim(s, sbi->sb_dirband_start + idx * 4, len * 4, start, end, minlen, result); in hpfs_trim_fs()
556 hpfs_unlock(s); in hpfs_trim_fs()
561 hpfs_lock(s); in hpfs_trim_fs()
562 if (s->s_flags & MS_RDONLY) { in hpfs_trim_fs()
566 if (!(bmp = hpfs_map_bitmap(s, start_bmp, &qbh, "trim"))) { in hpfs_trim_fs()
572 err = do_trim(s, (start_bmp << 14) + idx, len, start, end, minlen, result); in hpfs_trim_fs()
577 hpfs_unlock(s); in hpfs_trim_fs()