Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'gfs2-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2

Pull GFS2 updates from Bob Peterson:
"Here is a list of patches we've accumulated for GFS2 for the current
upstream merge window.

Most of the patches fix GFS2 quotas, which were not properly enforced.
There's another that adds me as a GFS2 co-maintainer, and a couple
patches that fix a kernel panic doing splice_write on GFS2 as well as
a few correctness patches"

* tag 'gfs2-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2:
gfs2: fix quota refresh race in do_glock()
gfs2: incorrect check for debugfs returns
gfs2: allow fallocate to max out quotas/fs efficiently
gfs2: allow quota_check and inplace_reserve to return available blocks
gfs2: perform quota checks against allocation parameters
GFS2: Move gfs2_file_splice_write outside of #ifdef
GFS2: Allocate reservation during splice_write
GFS2: gfs2_set_acl(): Cache "no acl" as well
Add myself (Bob Peterson) as a maintainer of GFS2

+187 -98
+2 -2
MAINTAINERS
··· 4337 4337 4338 4338 GFS2 FILE SYSTEM 4339 4339 M: Steven Whitehouse <swhiteho@redhat.com> 4340 + M: Bob Peterson <rpeterso@redhat.com> 4340 4341 L: cluster-devel@redhat.com 4341 4342 W: http://sources.redhat.com/cluster/ 4342 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-3.0-fixes.git 4343 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-3.0-nmw.git 4343 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git 4344 4344 S: Supported 4345 4345 F: Documentation/filesystems/gfs2*.txt 4346 4346 F: fs/gfs2/
+1 -5
fs/gfs2/acl.c
··· 110 110 error = __gfs2_xattr_set(inode, name, data, len, 0, GFS2_EATYPE_SYS); 111 111 if (error) 112 112 goto out; 113 - 114 - if (acl) 115 - set_cached_acl(inode, type, acl); 116 - else 117 - forget_cached_acl(inode, type); 113 + set_cached_acl(inode, type, acl); 118 114 out: 119 115 kfree(data); 120 116 return error;
+3 -3
fs/gfs2/aops.c
··· 671 671 672 672 if (alloc_required) { 673 673 struct gfs2_alloc_parms ap = { .aflags = 0, }; 674 - error = gfs2_quota_lock_check(ip); 674 + requested = data_blocks + ind_blocks; 675 + ap.target = requested; 676 + error = gfs2_quota_lock_check(ip, &ap); 675 677 if (error) 676 678 goto out_unlock; 677 679 678 - requested = data_blocks + ind_blocks; 679 - ap.target = requested; 680 680 error = gfs2_inplace_reserve(ip, &ap); 681 681 if (error) 682 682 goto out_qunlock;
+1 -1
fs/gfs2/bmap.c
··· 1224 1224 1225 1225 if (gfs2_is_stuffed(ip) && 1226 1226 (size > (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)))) { 1227 - error = gfs2_quota_lock_check(ip); 1227 + error = gfs2_quota_lock_check(ip, &ap); 1228 1228 if (error) 1229 1229 return error; 1230 1230
+71 -30
fs/gfs2/file.c
··· 428 428 if (ret) 429 429 goto out_unlock; 430 430 431 - ret = gfs2_quota_lock_check(ip); 432 - if (ret) 433 - goto out_unlock; 434 431 gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks); 435 432 ap.target = data_blocks + ind_blocks; 433 + ret = gfs2_quota_lock_check(ip, &ap); 434 + if (ret) 435 + goto out_unlock; 436 436 ret = gfs2_inplace_reserve(ip, &ap); 437 437 if (ret) 438 438 goto out_quota_unlock; ··· 764 764 brelse(dibh); 765 765 return error; 766 766 } 767 - 768 - static void calc_max_reserv(struct gfs2_inode *ip, loff_t max, loff_t *len, 769 - unsigned int *data_blocks, unsigned int *ind_blocks) 767 + /** 768 + * calc_max_reserv() - Reverse of write_calc_reserv. Given a number of 769 + * blocks, determine how many bytes can be written. 770 + * @ip: The inode in question. 771 + * @len: Max cap of bytes. What we return in *len must be <= this. 772 + * @data_blocks: Compute and return the number of data blocks needed 773 + * @ind_blocks: Compute and return the number of indirect blocks needed 774 + * @max_blocks: The total blocks available to work with. 775 + * 776 + * Returns: void, but @len, @data_blocks and @ind_blocks are filled in. 777 + */ 778 + static void calc_max_reserv(struct gfs2_inode *ip, loff_t *len, 779 + unsigned int *data_blocks, unsigned int *ind_blocks, 780 + unsigned int max_blocks) 770 781 { 782 + loff_t max = *len; 771 783 const struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 772 - unsigned int max_blocks = ip->i_rgd->rd_free_clone; 773 784 unsigned int tmp, max_data = max_blocks - 3 * (sdp->sd_max_height - 1); 774 785 775 786 for (tmp = max_data; tmp > sdp->sd_diptrs;) { 776 787 tmp = DIV_ROUND_UP(tmp, sdp->sd_inptrs); 777 788 max_data -= tmp; 778 789 } 779 - /* This calculation isn't the exact reverse of gfs2_write_calc_reserve, 780 - so it might end up with fewer data blocks */ 781 - if (max_data <= *data_blocks) 782 - return; 790 + 783 791 *data_blocks = max_data; 784 792 *ind_blocks = max_blocks - max_data; 785 793 *len = ((loff_t)max_data - 3) << sdp->sd_sb.sb_bsize_shift; ··· 804 796 struct gfs2_inode *ip = GFS2_I(inode); 805 797 struct gfs2_alloc_parms ap = { .aflags = 0, }; 806 798 unsigned int data_blocks = 0, ind_blocks = 0, rblocks; 807 - loff_t bytes, max_bytes; 799 + loff_t bytes, max_bytes, max_blks = UINT_MAX; 808 800 int error; 809 801 const loff_t pos = offset; 810 802 const loff_t count = len; ··· 826 818 827 819 gfs2_size_hint(file, offset, len); 828 820 821 + gfs2_write_calc_reserv(ip, PAGE_SIZE, &data_blocks, &ind_blocks); 822 + ap.min_target = data_blocks + ind_blocks; 823 + 829 824 while (len > 0) { 830 825 if (len < bytes) 831 826 bytes = len; ··· 837 826 offset += bytes; 838 827 continue; 839 828 } 840 - error = gfs2_quota_lock_check(ip); 829 + 830 + /* We need to determine how many bytes we can actually 831 + * fallocate without exceeding quota or going over the 832 + * end of the fs. We start off optimistically by assuming 833 + * we can write max_bytes */ 834 + max_bytes = (len > max_chunk_size) ? max_chunk_size : len; 835 + 836 + /* Since max_bytes is most likely a theoretical max, we 837 + * calculate a more realistic 'bytes' to serve as a good 838 + * starting point for the number of bytes we may be able 839 + * to write */ 840 + gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks); 841 + ap.target = data_blocks + ind_blocks; 842 + 843 + error = gfs2_quota_lock_check(ip, &ap); 841 844 if (error) 842 845 return error; 843 - retry: 844 - gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks); 846 + /* ap.allowed tells us how many blocks quota will allow 847 + * us to write. Check if this reduces max_blks */ 848 + if (ap.allowed && ap.allowed < max_blks) 849 + max_blks = ap.allowed; 845 850 846 - ap.target = data_blocks + ind_blocks; 847 851 error = gfs2_inplace_reserve(ip, &ap); 848 - if (error) { 849 - if (error == -ENOSPC && bytes > sdp->sd_sb.sb_bsize) { 850 - bytes >>= 1; 851 - bytes &= bsize_mask; 852 - if (bytes == 0) 853 - bytes = sdp->sd_sb.sb_bsize; 854 - goto retry; 855 - } 852 + if (error) 856 853 goto out_qunlock; 857 - } 858 - max_bytes = bytes; 859 - calc_max_reserv(ip, (len > max_chunk_size)? max_chunk_size: len, 860 - &max_bytes, &data_blocks, &ind_blocks); 854 + 855 + /* check if the selected rgrp limits our max_blks further */ 856 + if (ap.allowed && ap.allowed < max_blks) 857 + max_blks = ap.allowed; 858 + 859 + /* Almost done. Calculate bytes that can be written using 860 + * max_blks. We also recompute max_bytes, data_blocks and 861 + * ind_blocks */ 862 + calc_max_reserv(ip, &max_bytes, &data_blocks, 863 + &ind_blocks, max_blks); 861 864 862 865 rblocks = RES_DINODE + ind_blocks + RES_STATFS + RES_QUOTA + 863 866 RES_RG_HDR + gfs2_rg_blocks(ip, data_blocks + ind_blocks); ··· 953 928 gfs2_holder_uninit(&gh); 954 929 mutex_unlock(&inode->i_mutex); 955 930 return ret; 931 + } 932 + 933 + static ssize_t gfs2_file_splice_write(struct pipe_inode_info *pipe, 934 + struct file *out, loff_t *ppos, 935 + size_t len, unsigned int flags) 936 + { 937 + int error; 938 + struct gfs2_inode *ip = GFS2_I(out->f_mapping->host); 939 + 940 + error = gfs2_rs_alloc(ip); 941 + if (error) 942 + return (ssize_t)error; 943 + 944 + gfs2_size_hint(out, *ppos, len); 945 + 946 + return iter_file_splice_write(pipe, out, ppos, len, flags); 956 947 } 957 948 958 949 #ifdef CONFIG_GFS2_FS_LOCKING_DLM ··· 1117 1076 .lock = gfs2_lock, 1118 1077 .flock = gfs2_flock, 1119 1078 .splice_read = generic_file_splice_read, 1120 - .splice_write = iter_file_splice_write, 1079 + .splice_write = gfs2_file_splice_write, 1121 1080 .setlease = simple_nosetlease, 1122 1081 .fallocate = gfs2_fallocate, 1123 1082 }; ··· 1147 1106 .release = gfs2_release, 1148 1107 .fsync = gfs2_fsync, 1149 1108 .splice_read = generic_file_splice_read, 1150 - .splice_write = iter_file_splice_write, 1109 + .splice_write = gfs2_file_splice_write, 1151 1110 .setlease = generic_setlease, 1152 1111 .fallocate = gfs2_fallocate, 1153 1112 };
+29 -20
fs/gfs2/glock.c
··· 2047 2047 2048 2048 int gfs2_create_debugfs_file(struct gfs2_sbd *sdp) 2049 2049 { 2050 - sdp->debugfs_dir = debugfs_create_dir(sdp->sd_table_name, gfs2_root); 2051 - if (!sdp->debugfs_dir) 2052 - return -ENOMEM; 2053 - sdp->debugfs_dentry_glocks = debugfs_create_file("glocks", 2054 - S_IFREG | S_IRUGO, 2055 - sdp->debugfs_dir, sdp, 2056 - &gfs2_glocks_fops); 2057 - if (!sdp->debugfs_dentry_glocks) 2058 - goto fail; 2050 + struct dentry *dent; 2059 2051 2060 - sdp->debugfs_dentry_glstats = debugfs_create_file("glstats", 2061 - S_IFREG | S_IRUGO, 2062 - sdp->debugfs_dir, sdp, 2063 - &gfs2_glstats_fops); 2064 - if (!sdp->debugfs_dentry_glstats) 2052 + dent = debugfs_create_dir(sdp->sd_table_name, gfs2_root); 2053 + if (IS_ERR_OR_NULL(dent)) 2065 2054 goto fail; 2055 + sdp->debugfs_dir = dent; 2066 2056 2067 - sdp->debugfs_dentry_sbstats = debugfs_create_file("sbstats", 2068 - S_IFREG | S_IRUGO, 2069 - sdp->debugfs_dir, sdp, 2070 - &gfs2_sbstats_fops); 2071 - if (!sdp->debugfs_dentry_sbstats) 2057 + dent = debugfs_create_file("glocks", 2058 + S_IFREG | S_IRUGO, 2059 + sdp->debugfs_dir, sdp, 2060 + &gfs2_glocks_fops); 2061 + if (IS_ERR_OR_NULL(dent)) 2072 2062 goto fail; 2063 + sdp->debugfs_dentry_glocks = dent; 2064 + 2065 + dent = debugfs_create_file("glstats", 2066 + S_IFREG | S_IRUGO, 2067 + sdp->debugfs_dir, sdp, 2068 + &gfs2_glstats_fops); 2069 + if (IS_ERR_OR_NULL(dent)) 2070 + goto fail; 2071 + sdp->debugfs_dentry_glstats = dent; 2072 + 2073 + dent = debugfs_create_file("sbstats", 2074 + S_IFREG | S_IRUGO, 2075 + sdp->debugfs_dir, sdp, 2076 + &gfs2_sbstats_fops); 2077 + if (IS_ERR_OR_NULL(dent)) 2078 + goto fail; 2079 + sdp->debugfs_dentry_sbstats = dent; 2073 2080 2074 2081 return 0; 2075 2082 fail: 2076 2083 gfs2_delete_debugfs_file(sdp); 2077 - return -ENOMEM; 2084 + return dent ? PTR_ERR(dent) : -ENOMEM; 2078 2085 } 2079 2086 2080 2087 void gfs2_delete_debugfs_file(struct gfs2_sbd *sdp) ··· 2107 2100 int gfs2_register_debugfs(void) 2108 2101 { 2109 2102 gfs2_root = debugfs_create_dir("gfs2", NULL); 2103 + if (IS_ERR(gfs2_root)) 2104 + return PTR_ERR(gfs2_root); 2110 2105 return gfs2_root ? 0 : -ENOMEM; 2111 2106 } 2112 2107
+3 -1
fs/gfs2/incore.h
··· 301 301 * to the allocation code. 302 302 */ 303 303 struct gfs2_alloc_parms { 304 - u32 target; 304 + u64 target; 305 + u32 min_target; 305 306 u32 aflags; 307 + u64 allowed; 306 308 }; 307 309 308 310 enum {
+10 -8
fs/gfs2/inode.c
··· 382 382 struct gfs2_alloc_parms ap = { .target = *dblocks, .aflags = flags, }; 383 383 int error; 384 384 385 - error = gfs2_quota_lock_check(ip); 385 + error = gfs2_quota_lock_check(ip, &ap); 386 386 if (error) 387 387 goto out; 388 388 ··· 525 525 int error; 526 526 527 527 if (da->nr_blocks) { 528 - error = gfs2_quota_lock_check(dip); 528 + error = gfs2_quota_lock_check(dip, &ap); 529 529 if (error) 530 530 goto fail_quota_locks; 531 531 ··· 953 953 954 954 if (da.nr_blocks) { 955 955 struct gfs2_alloc_parms ap = { .target = da.nr_blocks, }; 956 - error = gfs2_quota_lock_check(dip); 956 + error = gfs2_quota_lock_check(dip, &ap); 957 957 if (error) 958 958 goto out_gunlock; 959 959 ··· 1470 1470 1471 1471 if (da.nr_blocks) { 1472 1472 struct gfs2_alloc_parms ap = { .target = da.nr_blocks, }; 1473 - error = gfs2_quota_lock_check(ndip); 1473 + error = gfs2_quota_lock_check(ndip, &ap); 1474 1474 if (error) 1475 1475 goto out_gunlock; 1476 1476 ··· 1669 1669 kuid_t ouid, nuid; 1670 1670 kgid_t ogid, ngid; 1671 1671 int error; 1672 + struct gfs2_alloc_parms ap; 1672 1673 1673 1674 ouid = inode->i_uid; 1674 1675 ogid = inode->i_gid; ··· 1697 1696 if (error) 1698 1697 goto out; 1699 1698 1699 + ap.target = gfs2_get_inode_blocks(&ip->i_inode); 1700 + 1700 1701 if (!uid_eq(ouid, NO_UID_QUOTA_CHANGE) || 1701 1702 !gid_eq(ogid, NO_GID_QUOTA_CHANGE)) { 1702 - error = gfs2_quota_check(ip, nuid, ngid); 1703 + error = gfs2_quota_check(ip, nuid, ngid, &ap); 1703 1704 if (error) 1704 1705 goto out_gunlock_q; 1705 1706 } ··· 1716 1713 1717 1714 if (!uid_eq(ouid, NO_UID_QUOTA_CHANGE) || 1718 1715 !gid_eq(ogid, NO_GID_QUOTA_CHANGE)) { 1719 - u64 blocks = gfs2_get_inode_blocks(&ip->i_inode); 1720 - gfs2_quota_change(ip, -blocks, ouid, ogid); 1721 - gfs2_quota_change(ip, blocks, nuid, ngid); 1716 + gfs2_quota_change(ip, -ap.target, ouid, ogid); 1717 + gfs2_quota_change(ip, ap.target, nuid, ngid); 1722 1718 } 1723 1719 1724 1720 out_end_trans:
+44 -18
fs/gfs2/quota.c
··· 923 923 if (error) 924 924 return error; 925 925 926 + if (test_and_clear_bit(QDF_REFRESH, &qd->qd_flags)) 927 + force_refresh = FORCE; 928 + 926 929 qd->qd_qb = *(struct gfs2_quota_lvb *)qd->qd_gl->gl_lksb.sb_lvbptr; 927 930 928 931 if (force_refresh || qd->qd_qb.qb_magic != cpu_to_be32(GFS2_MAGIC)) { ··· 977 974 sizeof(struct gfs2_quota_data *), sort_qd, NULL); 978 975 979 976 for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) { 980 - int force = NO_FORCE; 981 977 qd = ip->i_res->rs_qa_qd[x]; 982 - if (test_and_clear_bit(QDF_REFRESH, &qd->qd_flags)) 983 - force = FORCE; 984 - error = do_glock(qd, force, &ip->i_res->rs_qa_qd_ghs[x]); 978 + error = do_glock(qd, NO_FORCE, &ip->i_res->rs_qa_qd_ghs[x]); 985 979 if (error) 986 980 break; 987 981 } ··· 1094 1094 return 0; 1095 1095 } 1096 1096 1097 - int gfs2_quota_check(struct gfs2_inode *ip, kuid_t uid, kgid_t gid) 1097 + /** 1098 + * gfs2_quota_check - check if allocating new blocks will exceed quota 1099 + * @ip: The inode for which this check is being performed 1100 + * @uid: The uid to check against 1101 + * @gid: The gid to check against 1102 + * @ap: The allocation parameters. ap->target contains the requested 1103 + * blocks. ap->min_target, if set, contains the minimum blks 1104 + * requested. 1105 + * 1106 + * Returns: 0 on success. 1107 + * min_req = ap->min_target ? ap->min_target : ap->target; 1108 + * quota must allow atleast min_req blks for success and 1109 + * ap->allowed is set to the number of blocks allowed 1110 + * 1111 + * -EDQUOT otherwise, quota violation. ap->allowed is set to number 1112 + * of blocks available. 1113 + */ 1114 + int gfs2_quota_check(struct gfs2_inode *ip, kuid_t uid, kgid_t gid, 1115 + struct gfs2_alloc_parms *ap) 1098 1116 { 1099 1117 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1100 1118 struct gfs2_quota_data *qd; 1101 - s64 value; 1119 + s64 value, warn, limit; 1102 1120 unsigned int x; 1103 1121 int error = 0; 1104 1122 1123 + ap->allowed = UINT_MAX; /* Assume we are permitted a whole lot */ 1105 1124 if (!test_bit(GIF_QD_LOCKED, &ip->i_flags)) 1106 1125 return 0; 1107 1126 ··· 1134 1115 qid_eq(qd->qd_id, make_kqid_gid(gid)))) 1135 1116 continue; 1136 1117 1118 + warn = (s64)be64_to_cpu(qd->qd_qb.qb_warn); 1119 + limit = (s64)be64_to_cpu(qd->qd_qb.qb_limit); 1137 1120 value = (s64)be64_to_cpu(qd->qd_qb.qb_value); 1138 1121 spin_lock(&qd_lock); 1139 1122 value += qd->qd_change; 1140 1123 spin_unlock(&qd_lock); 1141 1124 1142 - if (be64_to_cpu(qd->qd_qb.qb_limit) && (s64)be64_to_cpu(qd->qd_qb.qb_limit) < value) { 1143 - print_message(qd, "exceeded"); 1144 - quota_send_warning(qd->qd_id, 1145 - sdp->sd_vfs->s_dev, QUOTA_NL_BHARDWARN); 1146 - 1147 - error = -EDQUOT; 1148 - break; 1149 - } else if (be64_to_cpu(qd->qd_qb.qb_warn) && 1150 - (s64)be64_to_cpu(qd->qd_qb.qb_warn) < value && 1125 + if (limit > 0 && (limit - value) < ap->allowed) 1126 + ap->allowed = limit - value; 1127 + /* If we can't meet the target */ 1128 + if (limit && limit < (value + (s64)ap->target)) { 1129 + /* If no min_target specified or we don't meet 1130 + * min_target, return -EDQUOT */ 1131 + if (!ap->min_target || ap->min_target > ap->allowed) { 1132 + print_message(qd, "exceeded"); 1133 + quota_send_warning(qd->qd_id, 1134 + sdp->sd_vfs->s_dev, 1135 + QUOTA_NL_BHARDWARN); 1136 + error = -EDQUOT; 1137 + break; 1138 + } 1139 + } else if (warn && warn < value && 1151 1140 time_after_eq(jiffies, qd->qd_last_warn + 1152 - gfs2_tune_get(sdp, 1153 - gt_quota_warn_period) * HZ)) { 1141 + gfs2_tune_get(sdp, gt_quota_warn_period) 1142 + * HZ)) { 1154 1143 quota_send_warning(qd->qd_id, 1155 1144 sdp->sd_vfs->s_dev, QUOTA_NL_BSOFTWARN); 1156 1145 error = print_message(qd, "warning"); 1157 1146 qd->qd_last_warn = jiffies; 1158 1147 } 1159 1148 } 1160 - 1161 1149 return error; 1162 1150 } 1163 1151
+5 -3
fs/gfs2/quota.h
··· 24 24 extern int gfs2_quota_lock(struct gfs2_inode *ip, kuid_t uid, kgid_t gid); 25 25 extern void gfs2_quota_unlock(struct gfs2_inode *ip); 26 26 27 - extern int gfs2_quota_check(struct gfs2_inode *ip, kuid_t uid, kgid_t gid); 27 + extern int gfs2_quota_check(struct gfs2_inode *ip, kuid_t uid, kgid_t gid, 28 + struct gfs2_alloc_parms *ap); 28 29 extern void gfs2_quota_change(struct gfs2_inode *ip, s64 change, 29 30 kuid_t uid, kgid_t gid); 30 31 ··· 38 37 39 38 extern void gfs2_wake_up_statfs(struct gfs2_sbd *sdp); 40 39 41 - static inline int gfs2_quota_lock_check(struct gfs2_inode *ip) 40 + static inline int gfs2_quota_lock_check(struct gfs2_inode *ip, 41 + struct gfs2_alloc_parms *ap) 42 42 { 43 43 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 44 44 int ret; ··· 50 48 return ret; 51 49 if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON) 52 50 return 0; 53 - ret = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid); 51 + ret = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid, ap); 54 52 if (ret) 55 53 gfs2_quota_unlock(ip); 56 54 return ret;
+15 -5
fs/gfs2/rgrp.c
··· 1946 1946 * @ip: the inode to reserve space for 1947 1947 * @ap: the allocation parameters 1948 1948 * 1949 - * Returns: errno 1949 + * We try our best to find an rgrp that has at least ap->target blocks 1950 + * available. After a couple of passes (loops == 2), the prospects of finding 1951 + * such an rgrp diminish. At this stage, we return the first rgrp that has 1952 + * atleast ap->min_target blocks available. Either way, we set ap->allowed to 1953 + * the number of blocks available in the chosen rgrp. 1954 + * 1955 + * Returns: 0 on success, 1956 + * -ENOMEM if a suitable rgrp can't be found 1957 + * errno otherwise 1950 1958 */ 1951 1959 1952 - int gfs2_inplace_reserve(struct gfs2_inode *ip, const struct gfs2_alloc_parms *ap) 1960 + int gfs2_inplace_reserve(struct gfs2_inode *ip, struct gfs2_alloc_parms *ap) 1953 1961 { 1954 1962 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1955 1963 struct gfs2_rgrpd *begin = NULL; ··· 2020 2012 /* Skip unuseable resource groups */ 2021 2013 if ((rs->rs_rbm.rgd->rd_flags & (GFS2_RGF_NOALLOC | 2022 2014 GFS2_RDF_ERROR)) || 2023 - (ap->target > rs->rs_rbm.rgd->rd_extfail_pt)) 2015 + (loops == 0 && ap->target > rs->rs_rbm.rgd->rd_extfail_pt)) 2024 2016 goto skip_rgrp; 2025 2017 2026 2018 if (sdp->sd_args.ar_rgrplvb) ··· 2035 2027 goto check_rgrp; 2036 2028 2037 2029 /* If rgrp has enough free space, use it */ 2038 - if (rs->rs_rbm.rgd->rd_free_clone >= ap->target) { 2030 + if (rs->rs_rbm.rgd->rd_free_clone >= ap->target || 2031 + (loops == 2 && ap->min_target && 2032 + rs->rs_rbm.rgd->rd_free_clone >= ap->min_target)) { 2039 2033 ip->i_rgd = rs->rs_rbm.rgd; 2034 + ap->allowed = ip->i_rgd->rd_free_clone; 2040 2035 return 0; 2041 2036 } 2042 - 2043 2037 check_rgrp: 2044 2038 /* Check for unlinked inodes which can be reclaimed */ 2045 2039 if (rs->rs_rbm.rgd->rd_flags & GFS2_RDF_CHECK)
+2 -1
fs/gfs2/rgrp.h
··· 41 41 extern struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip); 42 42 43 43 #define GFS2_AF_ORLOV 1 44 - extern int gfs2_inplace_reserve(struct gfs2_inode *ip, const struct gfs2_alloc_parms *ap); 44 + extern int gfs2_inplace_reserve(struct gfs2_inode *ip, 45 + struct gfs2_alloc_parms *ap); 45 46 extern void gfs2_inplace_release(struct gfs2_inode *ip); 46 47 47 48 extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n,
+1 -1
fs/gfs2/xattr.c
··· 732 732 if (error) 733 733 return error; 734 734 735 - error = gfs2_quota_lock_check(ip); 735 + error = gfs2_quota_lock_check(ip, &ap); 736 736 if (error) 737 737 return error; 738 738