.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
---|
3 | 4 | * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. |
---|
4 | | - * |
---|
5 | | - * This copyrighted material is made available to anyone wishing to use, |
---|
6 | | - * modify, copy, or redistribute it subject to the terms and conditions |
---|
7 | | - * of the GNU General Public License version 2. |
---|
8 | 5 | */ |
---|
9 | 6 | |
---|
10 | 7 | /* |
---|
.. | .. |
---|
75 | 72 | #include "trans.h" |
---|
76 | 73 | #include "bmap.h" |
---|
77 | 74 | #include "util.h" |
---|
78 | | - |
---|
79 | | -#define IS_LEAF 1 /* Hashed (leaf) directory */ |
---|
80 | | -#define IS_DINODE 2 /* Linear (stuffed dinode block) directory */ |
---|
81 | 75 | |
---|
82 | 76 | #define MAX_RA_BLOCKS 32 /* max read-ahead blocks */ |
---|
83 | 77 | |
---|
.. | .. |
---|
360 | 354 | |
---|
361 | 355 | hc = kmalloc(hsize, GFP_NOFS | __GFP_NOWARN); |
---|
362 | 356 | if (hc == NULL) |
---|
363 | | - hc = __vmalloc(hsize, GFP_NOFS, PAGE_KERNEL); |
---|
| 357 | + hc = __vmalloc(hsize, GFP_NOFS); |
---|
364 | 358 | |
---|
365 | 359 | if (hc == NULL) |
---|
366 | 360 | return ERR_PTR(-ENOMEM); |
---|
.. | .. |
---|
506 | 500 | * For now the most important thing is to check that the various sizes |
---|
507 | 501 | * are correct. |
---|
508 | 502 | */ |
---|
509 | | -static int gfs2_check_dirent(struct gfs2_dirent *dent, unsigned int offset, |
---|
| 503 | +static int gfs2_check_dirent(struct gfs2_sbd *sdp, |
---|
| 504 | + struct gfs2_dirent *dent, unsigned int offset, |
---|
510 | 505 | unsigned int size, unsigned int len, int first) |
---|
511 | 506 | { |
---|
512 | 507 | const char *msg = "gfs2_dirent too small"; |
---|
.. | .. |
---|
528 | 523 | goto error; |
---|
529 | 524 | return 0; |
---|
530 | 525 | error: |
---|
531 | | - pr_warn("%s: %s (%s)\n", |
---|
| 526 | + fs_warn(sdp, "%s: %s (%s)\n", |
---|
532 | 527 | __func__, msg, first ? "first in block" : "not first in block"); |
---|
533 | 528 | return -EIO; |
---|
534 | 529 | } |
---|
535 | 530 | |
---|
536 | | -static int gfs2_dirent_offset(const void *buf) |
---|
| 531 | +static int gfs2_dirent_offset(struct gfs2_sbd *sdp, const void *buf) |
---|
537 | 532 | { |
---|
538 | 533 | const struct gfs2_meta_header *h = buf; |
---|
539 | 534 | int offset; |
---|
.. | .. |
---|
552 | 547 | } |
---|
553 | 548 | return offset; |
---|
554 | 549 | wrong_type: |
---|
555 | | - pr_warn("%s: wrong block type %u\n", __func__, be32_to_cpu(h->mh_type)); |
---|
| 550 | + fs_warn(sdp, "%s: wrong block type %u\n", __func__, |
---|
| 551 | + be32_to_cpu(h->mh_type)); |
---|
556 | 552 | return -1; |
---|
557 | 553 | } |
---|
558 | 554 | |
---|
.. | .. |
---|
566 | 562 | unsigned size; |
---|
567 | 563 | int ret = 0; |
---|
568 | 564 | |
---|
569 | | - ret = gfs2_dirent_offset(buf); |
---|
| 565 | + ret = gfs2_dirent_offset(GFS2_SB(inode), buf); |
---|
570 | 566 | if (ret < 0) |
---|
571 | 567 | goto consist_inode; |
---|
572 | 568 | |
---|
.. | .. |
---|
574 | 570 | prev = NULL; |
---|
575 | 571 | dent = buf + offset; |
---|
576 | 572 | size = be16_to_cpu(dent->de_rec_len); |
---|
577 | | - if (gfs2_check_dirent(dent, offset, size, len, 1)) |
---|
| 573 | + if (gfs2_check_dirent(GFS2_SB(inode), dent, offset, size, len, 1)) |
---|
578 | 574 | goto consist_inode; |
---|
579 | 575 | do { |
---|
580 | 576 | ret = scan(dent, name, opaque); |
---|
.. | .. |
---|
586 | 582 | prev = dent; |
---|
587 | 583 | dent = buf + offset; |
---|
588 | 584 | size = be16_to_cpu(dent->de_rec_len); |
---|
589 | | - if (gfs2_check_dirent(dent, offset, size, len, 0)) |
---|
| 585 | + if (gfs2_check_dirent(GFS2_SB(inode), dent, offset, size, |
---|
| 586 | + len, 0)) |
---|
590 | 587 | goto consist_inode; |
---|
591 | 588 | } while(1); |
---|
592 | 589 | |
---|
.. | .. |
---|
750 | 747 | struct gfs2_dirent *dent; |
---|
751 | 748 | dent = gfs2_dirent_scan(inode, bh->b_data, bh->b_size, |
---|
752 | 749 | gfs2_dirent_find_offset, name, ptr); |
---|
753 | | - if (!dent || IS_ERR(dent)) |
---|
| 750 | + if (IS_ERR_OR_NULL(dent)) |
---|
754 | 751 | return dent; |
---|
755 | 752 | return do_init_dirent(inode, dent, name, bh, |
---|
756 | 753 | (unsigned)(ptr - (void *)dent)); |
---|
.. | .. |
---|
854 | 851 | return ERR_PTR(error); |
---|
855 | 852 | dent = gfs2_dirent_scan(inode, bh->b_data, bh->b_size, scan, name, NULL); |
---|
856 | 853 | got_dent: |
---|
857 | | - if (unlikely(dent == NULL || IS_ERR(dent))) { |
---|
| 854 | + if (IS_ERR_OR_NULL(dent)) { |
---|
858 | 855 | brelse(bh); |
---|
859 | 856 | bh = NULL; |
---|
860 | 857 | } |
---|
.. | .. |
---|
880 | 877 | if (!bh) |
---|
881 | 878 | return NULL; |
---|
882 | 879 | |
---|
883 | | - gfs2_trans_add_unrevoke(GFS2_SB(inode), bn, 1); |
---|
| 880 | + gfs2_trans_remove_revoke(GFS2_SB(inode), bn, 1); |
---|
884 | 881 | gfs2_trans_add_meta(ip->i_gl, bh); |
---|
885 | 882 | gfs2_metatype_set(bh, GFS2_METATYPE_LF, GFS2_FORMAT_LF); |
---|
886 | 883 | leaf = (struct gfs2_leaf *)bh->b_data; |
---|
.. | .. |
---|
1043 | 1040 | len = BIT(dip->i_depth - be16_to_cpu(oleaf->lf_depth)); |
---|
1044 | 1041 | half_len = len >> 1; |
---|
1045 | 1042 | if (!half_len) { |
---|
1046 | | - pr_warn("i_depth %u lf_depth %u index %u\n", |
---|
| 1043 | + fs_warn(GFS2_SB(inode), "i_depth %u lf_depth %u index %u\n", |
---|
1047 | 1044 | dip->i_depth, be16_to_cpu(oleaf->lf_depth), index); |
---|
1048 | 1045 | gfs2_consist_inode(dip); |
---|
1049 | 1046 | error = -EIO; |
---|
.. | .. |
---|
1169 | 1166 | |
---|
1170 | 1167 | hc2 = kmalloc_array(hsize_bytes, 2, GFP_NOFS | __GFP_NOWARN); |
---|
1171 | 1168 | if (hc2 == NULL) |
---|
1172 | | - hc2 = __vmalloc(hsize_bytes * 2, GFP_NOFS, PAGE_KERNEL); |
---|
| 1169 | + hc2 = __vmalloc(hsize_bytes * 2, GFP_NOFS); |
---|
1173 | 1170 | |
---|
1174 | 1171 | if (!hc2) |
---|
1175 | 1172 | return -ENOMEM; |
---|
.. | .. |
---|
1330 | 1327 | if (size < KMALLOC_MAX_SIZE) |
---|
1331 | 1328 | ptr = kmalloc(size, GFP_NOFS | __GFP_NOWARN); |
---|
1332 | 1329 | if (!ptr) |
---|
1333 | | - ptr = __vmalloc(size, GFP_NOFS, PAGE_KERNEL); |
---|
| 1330 | + ptr = __vmalloc(size, GFP_NOFS); |
---|
1334 | 1331 | return ptr; |
---|
1335 | 1332 | } |
---|
1336 | 1333 | |
---|
.. | .. |
---|
1351 | 1348 | if (!sdp->sd_args.ar_loccookie) |
---|
1352 | 1349 | continue; |
---|
1353 | 1350 | offset = (char *)(darr[i]) - |
---|
1354 | | - (bh->b_data + gfs2_dirent_offset(bh->b_data)); |
---|
| 1351 | + (bh->b_data + gfs2_dirent_offset(sdp, bh->b_data)); |
---|
1355 | 1352 | offset /= GFS2_MIN_DIRENT_SIZE; |
---|
1356 | 1353 | offset += leaf_nr * sdp->sd_max_dents_per_leaf; |
---|
1357 | 1354 | if (offset >= GFS2_USE_HASH_FLAG || |
---|
.. | .. |
---|
1463 | 1460 | sort_offset : entries, copied); |
---|
1464 | 1461 | out_free: |
---|
1465 | 1462 | for(i = 0; i < leaf; i++) |
---|
1466 | | - if (larr[i]) |
---|
1467 | | - brelse(larr[i]); |
---|
| 1463 | + brelse(larr[i]); |
---|
1468 | 1464 | kvfree(larr); |
---|
1469 | 1465 | out: |
---|
1470 | 1466 | return error; |
---|
.. | .. |
---|
1991 | 1987 | |
---|
1992 | 1988 | ht = kzalloc(size, GFP_NOFS | __GFP_NOWARN); |
---|
1993 | 1989 | if (ht == NULL) |
---|
1994 | | - ht = __vmalloc(size, GFP_NOFS | __GFP_NOWARN | __GFP_ZERO, |
---|
1995 | | - PAGE_KERNEL); |
---|
| 1990 | + ht = __vmalloc(size, GFP_NOFS | __GFP_NOWARN | __GFP_ZERO); |
---|
1996 | 1991 | if (!ht) |
---|
1997 | 1992 | return -ENOMEM; |
---|
1998 | 1993 | |
---|
.. | .. |
---|
2018 | 2013 | l_blocks++; |
---|
2019 | 2014 | } |
---|
2020 | 2015 | |
---|
2021 | | - gfs2_rlist_alloc(&rlist, LM_ST_EXCLUSIVE); |
---|
| 2016 | + gfs2_rlist_alloc(&rlist); |
---|
2022 | 2017 | |
---|
2023 | 2018 | for (x = 0; x < rlist.rl_rgrps; x++) { |
---|
2024 | 2019 | struct gfs2_rgrpd *rgd = gfs2_glock2rgrp(rlist.rl_ghs[x].gh_gl); |
---|
.. | .. |
---|
2032 | 2027 | |
---|
2033 | 2028 | error = gfs2_trans_begin(sdp, |
---|
2034 | 2029 | rg_blocks + (DIV_ROUND_UP(size, sdp->sd_jbsize) + 1) + |
---|
2035 | | - RES_DINODE + RES_STATFS + RES_QUOTA, l_blocks); |
---|
| 2030 | + RES_DINODE + RES_STATFS + RES_QUOTA, RES_DINODE + |
---|
| 2031 | + l_blocks); |
---|
2036 | 2032 | if (error) |
---|
2037 | 2033 | goto out_rg_gunlock; |
---|
2038 | 2034 | |
---|
2039 | 2035 | bh = leaf_bh; |
---|
2040 | 2036 | |
---|
2041 | 2037 | for (blk = leaf_no; blk; blk = nblk) { |
---|
| 2038 | + struct gfs2_rgrpd *rgd; |
---|
| 2039 | + |
---|
2042 | 2040 | if (blk != leaf_no) { |
---|
2043 | 2041 | error = get_leaf(dip, blk, &bh); |
---|
2044 | 2042 | if (error) |
---|
.. | .. |
---|
2049 | 2047 | if (blk != leaf_no) |
---|
2050 | 2048 | brelse(bh); |
---|
2051 | 2049 | |
---|
2052 | | - gfs2_free_meta(dip, blk, 1); |
---|
| 2050 | + rgd = gfs2_blk2rgrpd(sdp, blk, true); |
---|
| 2051 | + gfs2_free_meta(dip, rgd, blk, 1); |
---|
2053 | 2052 | gfs2_add_inode_blocks(&dip->i_inode, -1); |
---|
2054 | 2053 | } |
---|
2055 | 2054 | |
---|