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

Merge git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-3.0-nmw

* git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-3.0-nmw:
GFS2: local functions should be static
GFS2: We only need one ACL getting function
GFS2: Fix multi-block allocation
GFS2: decouple quota allocations from block allocations
GFS2: split function rgblk_search
GFS2: Fix up "off by one" in the previous patch
GFS2: move toward a generic multi-block allocator
GFS2: O_(D)SYNC support for fallocate
GFS2: remove vestigial al_alloced
GFS2: combine gfs2_alloc_block and gfs2_alloc_di
GFS2: Add non-try locks back to get_local_rgrp
GFS2: f_ra is always valid in dir readahead function
GFS2: Fix very unlikley memory leak in ACL xattr code
GFS2: More automated code analysis fixes
GFS2: Add readahead to sequential directory traversal
GFS2: Fix up REQ flags

+394 -334
+5 -9
fs/gfs2/acl.c
··· 38 38 return NULL; 39 39 } 40 40 41 - static struct posix_acl *gfs2_acl_get(struct gfs2_inode *ip, int type) 41 + struct posix_acl *gfs2_get_acl(struct inode *inode, int type) 42 42 { 43 + struct gfs2_inode *ip = GFS2_I(inode); 43 44 struct posix_acl *acl; 44 45 const char *name; 45 46 char *data; ··· 66 65 acl = posix_acl_from_xattr(data, len); 67 66 kfree(data); 68 67 return acl; 69 - } 70 - 71 - struct posix_acl *gfs2_get_acl(struct inode *inode, int type) 72 - { 73 - return gfs2_acl_get(GFS2_I(inode), type); 74 68 } 75 69 76 70 static int gfs2_set_mode(struct inode *inode, umode_t mode) ··· 121 125 if (S_ISLNK(inode->i_mode)) 122 126 return 0; 123 127 124 - acl = gfs2_acl_get(dip, ACL_TYPE_DEFAULT); 128 + acl = gfs2_get_acl(&dip->i_inode, ACL_TYPE_DEFAULT); 125 129 if (IS_ERR(acl)) 126 130 return PTR_ERR(acl); 127 131 if (!acl) { ··· 162 166 unsigned int len; 163 167 int error; 164 168 165 - acl = gfs2_acl_get(ip, ACL_TYPE_ACCESS); 169 + acl = gfs2_get_acl(&ip->i_inode, ACL_TYPE_ACCESS); 166 170 if (IS_ERR(acl)) 167 171 return PTR_ERR(acl); 168 172 if (!acl) ··· 212 216 if (type < 0) 213 217 return type; 214 218 215 - acl = gfs2_acl_get(GFS2_I(inode), type); 219 + acl = gfs2_get_acl(inode, type); 216 220 if (IS_ERR(acl)) 217 221 return PTR_ERR(acl); 218 222 if (acl == NULL)
+9 -9
fs/gfs2/aops.c
··· 615 615 unsigned int data_blocks = 0, ind_blocks = 0, rblocks; 616 616 int alloc_required; 617 617 int error = 0; 618 - struct gfs2_alloc *al = NULL; 618 + struct gfs2_qadata *qa = NULL; 619 619 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 620 620 unsigned from = pos & (PAGE_CACHE_SIZE - 1); 621 621 struct page *page; ··· 639 639 gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks); 640 640 641 641 if (alloc_required) { 642 - al = gfs2_alloc_get(ip); 643 - if (!al) { 642 + qa = gfs2_qadata_get(ip); 643 + if (!qa) { 644 644 error = -ENOMEM; 645 645 goto out_unlock; 646 646 } ··· 649 649 if (error) 650 650 goto out_alloc_put; 651 651 652 - al->al_requested = data_blocks + ind_blocks; 653 - error = gfs2_inplace_reserve(ip); 652 + error = gfs2_inplace_reserve(ip, data_blocks + ind_blocks); 654 653 if (error) 655 654 goto out_qunlock; 656 655 } ··· 710 711 out_qunlock: 711 712 gfs2_quota_unlock(ip); 712 713 out_alloc_put: 713 - gfs2_alloc_put(ip); 714 + gfs2_qadata_put(ip); 714 715 } 715 716 out_unlock: 716 717 if (&ip->i_inode == sdp->sd_rindex) { ··· 847 848 struct gfs2_sbd *sdp = GFS2_SB(inode); 848 849 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); 849 850 struct buffer_head *dibh; 850 - struct gfs2_alloc *al = ip->i_alloc; 851 + struct gfs2_qadata *qa = ip->i_qadata; 851 852 unsigned int from = pos & (PAGE_CACHE_SIZE - 1); 852 853 unsigned int to = from + len; 853 854 int ret; ··· 879 880 brelse(dibh); 880 881 failed: 881 882 gfs2_trans_end(sdp); 882 - if (al) { 883 + if (ip->i_res) 883 884 gfs2_inplace_release(ip); 885 + if (qa) { 884 886 gfs2_quota_unlock(ip); 885 - gfs2_alloc_put(ip); 887 + gfs2_qadata_put(ip); 886 888 } 887 889 if (inode == sdp->sd_rindex) { 888 890 gfs2_glock_dq(&m_ip->i_gh);
+11 -15
fs/gfs2/bmap.c
··· 133 133 and write it out to disk */ 134 134 135 135 unsigned int n = 1; 136 - error = gfs2_alloc_block(ip, &block, &n); 136 + error = gfs2_alloc_blocks(ip, &block, &n, 0, NULL); 137 137 if (error) 138 138 goto out_brelse; 139 139 if (isdir) { ··· 503 503 do { 504 504 int error; 505 505 n = blks - alloced; 506 - error = gfs2_alloc_block(ip, &bn, &n); 506 + error = gfs2_alloc_blocks(ip, &bn, &n, 0, NULL); 507 507 if (error) 508 508 return error; 509 509 alloced += n; ··· 742 742 revokes = (height) ? sdp->sd_inptrs : sdp->sd_diptrs; 743 743 else if (ip->i_depth) 744 744 revokes = sdp->sd_inptrs; 745 - 746 - if (error) 747 - return error; 748 745 749 746 memset(&rlist, 0, sizeof(struct gfs2_rgrp_list)); 750 747 bstart = 0; ··· 1041 1044 lblock = (size - 1) >> sdp->sd_sb.sb_bsize_shift; 1042 1045 1043 1046 find_metapath(sdp, lblock, &mp, ip->i_height); 1044 - if (!gfs2_alloc_get(ip)) 1047 + if (!gfs2_qadata_get(ip)) 1045 1048 return -ENOMEM; 1046 1049 1047 1050 error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); ··· 1061 1064 gfs2_quota_unhold(ip); 1062 1065 1063 1066 out: 1064 - gfs2_alloc_put(ip); 1067 + gfs2_qadata_put(ip); 1065 1068 return error; 1066 1069 } 1067 1070 ··· 1163 1166 struct gfs2_inode *ip = GFS2_I(inode); 1164 1167 struct gfs2_sbd *sdp = GFS2_SB(inode); 1165 1168 struct buffer_head *dibh; 1166 - struct gfs2_alloc *al = NULL; 1169 + struct gfs2_qadata *qa = NULL; 1167 1170 int error; 1168 1171 1169 1172 if (gfs2_is_stuffed(ip) && 1170 1173 (size > (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)))) { 1171 - al = gfs2_alloc_get(ip); 1172 - if (al == NULL) 1174 + qa = gfs2_qadata_get(ip); 1175 + if (qa == NULL) 1173 1176 return -ENOMEM; 1174 1177 1175 1178 error = gfs2_quota_lock_check(ip); 1176 1179 if (error) 1177 1180 goto do_grow_alloc_put; 1178 1181 1179 - al->al_requested = 1; 1180 - error = gfs2_inplace_reserve(ip); 1182 + error = gfs2_inplace_reserve(ip, 1); 1181 1183 if (error) 1182 1184 goto do_grow_qunlock; 1183 1185 } ··· 1185 1189 if (error) 1186 1190 goto do_grow_release; 1187 1191 1188 - if (al) { 1192 + if (qa) { 1189 1193 error = gfs2_unstuff_dinode(ip, NULL); 1190 1194 if (error) 1191 1195 goto do_end_trans; ··· 1204 1208 do_end_trans: 1205 1209 gfs2_trans_end(sdp); 1206 1210 do_grow_release: 1207 - if (al) { 1211 + if (qa) { 1208 1212 gfs2_inplace_release(ip); 1209 1213 do_grow_qunlock: 1210 1214 gfs2_quota_unlock(ip); 1211 1215 do_grow_alloc_put: 1212 - gfs2_alloc_put(ip); 1216 + gfs2_qadata_put(ip); 1213 1217 } 1214 1218 return error; 1215 1219 }
+58 -6
fs/gfs2/dir.c
··· 76 76 #define IS_LEAF 1 /* Hashed (leaf) directory */ 77 77 #define IS_DINODE 2 /* Linear (stuffed dinode block) directory */ 78 78 79 + #define MAX_RA_BLOCKS 32 /* max read-ahead blocks */ 80 + 79 81 #define gfs2_disk_hash2offset(h) (((u64)(h)) >> 1) 80 82 #define gfs2_dir_offset2hash(p) ((u32)(((u64)(p)) << 1)) 81 83 ··· 823 821 struct gfs2_dirent *dent; 824 822 struct qstr name = { .name = "", .len = 0, .hash = 0 }; 825 823 826 - error = gfs2_alloc_block(ip, &bn, &n); 824 + error = gfs2_alloc_blocks(ip, &bn, &n, 0, NULL); 827 825 if (error) 828 826 return NULL; 829 827 bh = gfs2_meta_new(ip->i_gl, bn); ··· 1378 1376 return error; 1379 1377 } 1380 1378 1379 + /** 1380 + * gfs2_dir_readahead - Issue read-ahead requests for leaf blocks. 1381 + * 1382 + * Note: we can't calculate each index like dir_e_read can because we don't 1383 + * have the leaf, and therefore we don't have the depth, and therefore we 1384 + * don't have the length. So we have to just read enough ahead to make up 1385 + * for the loss of information. 1386 + */ 1387 + static void gfs2_dir_readahead(struct inode *inode, unsigned hsize, u32 index, 1388 + struct file_ra_state *f_ra) 1389 + { 1390 + struct gfs2_inode *ip = GFS2_I(inode); 1391 + struct gfs2_glock *gl = ip->i_gl; 1392 + struct buffer_head *bh; 1393 + u64 blocknr = 0, last; 1394 + unsigned count; 1395 + 1396 + /* First check if we've already read-ahead for the whole range. */ 1397 + if (index + MAX_RA_BLOCKS < f_ra->start) 1398 + return; 1399 + 1400 + f_ra->start = max((pgoff_t)index, f_ra->start); 1401 + for (count = 0; count < MAX_RA_BLOCKS; count++) { 1402 + if (f_ra->start >= hsize) /* if exceeded the hash table */ 1403 + break; 1404 + 1405 + last = blocknr; 1406 + blocknr = be64_to_cpu(ip->i_hash_cache[f_ra->start]); 1407 + f_ra->start++; 1408 + if (blocknr == last) 1409 + continue; 1410 + 1411 + bh = gfs2_getbuf(gl, blocknr, 1); 1412 + if (trylock_buffer(bh)) { 1413 + if (buffer_uptodate(bh)) { 1414 + unlock_buffer(bh); 1415 + brelse(bh); 1416 + continue; 1417 + } 1418 + bh->b_end_io = end_buffer_read_sync; 1419 + submit_bh(READA | REQ_META, bh); 1420 + continue; 1421 + } 1422 + brelse(bh); 1423 + } 1424 + } 1381 1425 1382 1426 /** 1383 1427 * dir_e_read - Reads the entries from a directory into a filldir buffer ··· 1436 1388 */ 1437 1389 1438 1390 static int dir_e_read(struct inode *inode, u64 *offset, void *opaque, 1439 - filldir_t filldir) 1391 + filldir_t filldir, struct file_ra_state *f_ra) 1440 1392 { 1441 1393 struct gfs2_inode *dip = GFS2_I(inode); 1442 1394 u32 hsize, len = 0; ··· 1450 1402 hash = gfs2_dir_offset2hash(*offset); 1451 1403 index = hash >> (32 - dip->i_depth); 1452 1404 1405 + if (dip->i_hash_cache == NULL) 1406 + f_ra->start = 0; 1453 1407 lp = gfs2_dir_get_hash_table(dip); 1454 1408 if (IS_ERR(lp)) 1455 1409 return PTR_ERR(lp); 1410 + 1411 + gfs2_dir_readahead(inode, hsize, index, f_ra); 1456 1412 1457 1413 while (index < hsize) { 1458 1414 error = gfs2_dir_read_leaf(inode, offset, opaque, filldir, ··· 1475 1423 } 1476 1424 1477 1425 int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque, 1478 - filldir_t filldir) 1426 + filldir_t filldir, struct file_ra_state *f_ra) 1479 1427 { 1480 1428 struct gfs2_inode *dip = GFS2_I(inode); 1481 1429 struct gfs2_sbd *sdp = GFS2_SB(inode); ··· 1489 1437 return 0; 1490 1438 1491 1439 if (dip->i_diskflags & GFS2_DIF_EXHASH) 1492 - return dir_e_read(inode, offset, opaque, filldir); 1440 + return dir_e_read(inode, offset, opaque, filldir, f_ra); 1493 1441 1494 1442 if (!gfs2_is_stuffed(dip)) { 1495 1443 gfs2_consist_inode(dip); ··· 1850 1798 if (!ht) 1851 1799 return -ENOMEM; 1852 1800 1853 - if (!gfs2_alloc_get(dip)) { 1801 + if (!gfs2_qadata_get(dip)) { 1854 1802 error = -ENOMEM; 1855 1803 goto out; 1856 1804 } ··· 1939 1887 gfs2_rlist_free(&rlist); 1940 1888 gfs2_quota_unhold(dip); 1941 1889 out_put: 1942 - gfs2_alloc_put(dip); 1890 + gfs2_qadata_put(dip); 1943 1891 out: 1944 1892 kfree(ht); 1945 1893 return error;
+1 -1
fs/gfs2/dir.h
··· 25 25 const struct gfs2_inode *ip); 26 26 extern int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry); 27 27 extern int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque, 28 - filldir_t filldir); 28 + filldir_t filldir, struct file_ra_state *f_ra); 29 29 extern int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename, 30 30 const struct gfs2_inode *nip, unsigned int new_type); 31 31
+2 -1
fs/gfs2/export.c
··· 99 99 struct gfs2_holder gh; 100 100 u64 offset = 0; 101 101 int error; 102 + struct file_ra_state f_ra = { .start = 0 }; 102 103 103 104 if (!dir) 104 105 return -EINVAL; ··· 119 118 if (error) 120 119 return error; 121 120 122 - error = gfs2_dir_read(dir, &offset, &gnfd, get_name_filldir); 121 + error = gfs2_dir_read(dir, &offset, &gnfd, get_name_filldir, &f_ra); 123 122 124 123 gfs2_glock_dq_uninit(&gh); 125 124
+18 -16
fs/gfs2/file.c
··· 105 105 return error; 106 106 } 107 107 108 - error = gfs2_dir_read(dir, &offset, dirent, filldir); 108 + error = gfs2_dir_read(dir, &offset, dirent, filldir, &file->f_ra); 109 109 110 110 gfs2_glock_dq_uninit(&d_gh); 111 111 ··· 365 365 u64 pos = page->index << PAGE_CACHE_SHIFT; 366 366 unsigned int data_blocks, ind_blocks, rblocks; 367 367 struct gfs2_holder gh; 368 - struct gfs2_alloc *al; 368 + struct gfs2_qadata *qa; 369 369 loff_t size; 370 370 int ret; 371 371 ··· 393 393 } 394 394 395 395 ret = -ENOMEM; 396 - al = gfs2_alloc_get(ip); 397 - if (al == NULL) 396 + qa = gfs2_qadata_get(ip); 397 + if (qa == NULL) 398 398 goto out_unlock; 399 399 400 400 ret = gfs2_quota_lock_check(ip); 401 401 if (ret) 402 402 goto out_alloc_put; 403 403 gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks); 404 - al->al_requested = data_blocks + ind_blocks; 405 - ret = gfs2_inplace_reserve(ip); 404 + ret = gfs2_inplace_reserve(ip, data_blocks + ind_blocks); 406 405 if (ret) 407 406 goto out_quota_unlock; 408 407 ··· 447 448 out_quota_unlock: 448 449 gfs2_quota_unlock(ip); 449 450 out_alloc_put: 450 - gfs2_alloc_put(ip); 451 + gfs2_qadata_put(ip); 451 452 out_unlock: 452 453 gfs2_glock_dq(&gh); 453 454 out: ··· 608 609 struct inode *inode = mapping->host; 609 610 int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC); 610 611 struct gfs2_inode *ip = GFS2_I(inode); 611 - int ret, ret1 = 0; 612 + int ret = 0, ret1 = 0; 612 613 613 614 if (mapping->nrpages) { 614 615 ret1 = filemap_fdatawrite_range(mapping, start, end); ··· 749 750 struct gfs2_inode *ip = GFS2_I(inode); 750 751 unsigned int data_blocks = 0, ind_blocks = 0, rblocks; 751 752 loff_t bytes, max_bytes; 752 - struct gfs2_alloc *al; 753 + struct gfs2_qadata *qa; 753 754 int error; 755 + const loff_t pos = offset; 756 + const loff_t count = len; 754 757 loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1); 755 758 loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift; 756 759 loff_t max_chunk_size = UINT_MAX & bsize_mask; ··· 783 782 while (len > 0) { 784 783 if (len < bytes) 785 784 bytes = len; 786 - al = gfs2_alloc_get(ip); 787 - if (!al) { 785 + qa = gfs2_qadata_get(ip); 786 + if (!qa) { 788 787 error = -ENOMEM; 789 788 goto out_unlock; 790 789 } ··· 796 795 retry: 797 796 gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks); 798 797 799 - al->al_requested = data_blocks + ind_blocks; 800 - error = gfs2_inplace_reserve(ip); 798 + error = gfs2_inplace_reserve(ip, data_blocks + ind_blocks); 801 799 if (error) { 802 800 if (error == -ENOSPC && bytes > sdp->sd_sb.sb_bsize) { 803 801 bytes >>= 1; ··· 810 810 max_bytes = bytes; 811 811 calc_max_reserv(ip, (len > max_chunk_size)? max_chunk_size: len, 812 812 &max_bytes, &data_blocks, &ind_blocks); 813 - al->al_requested = data_blocks + ind_blocks; 814 813 815 814 rblocks = RES_DINODE + ind_blocks + RES_STATFS + RES_QUOTA + 816 815 RES_RG_HDR + gfs2_rg_blocks(ip); ··· 831 832 offset += max_bytes; 832 833 gfs2_inplace_release(ip); 833 834 gfs2_quota_unlock(ip); 834 - gfs2_alloc_put(ip); 835 + gfs2_qadata_put(ip); 835 836 } 837 + 838 + if (error == 0) 839 + error = generic_write_sync(file, pos, count); 836 840 goto out_unlock; 837 841 838 842 out_trans_fail: ··· 843 841 out_qunlock: 844 842 gfs2_quota_unlock(ip); 845 843 out_alloc_put: 846 - gfs2_alloc_put(ip); 844 + gfs2_qadata_put(ip); 847 845 out_unlock: 848 846 gfs2_glock_dq(&ip->i_gh); 849 847 out_uninit:
+10 -10
fs/gfs2/incore.h
··· 244 244 245 245 #define GFS2_MIN_LVB_SIZE 32 /* Min size of LVB that gfs2 supports */ 246 246 247 - struct gfs2_alloc { 247 + struct gfs2_qadata { /* quota allocation data */ 248 248 /* Quota stuff */ 249 - struct gfs2_quota_data *al_qd[2*MAXQUOTAS]; 250 - struct gfs2_holder al_qd_ghs[2*MAXQUOTAS]; 251 - unsigned int al_qd_num; 249 + struct gfs2_quota_data *qa_qd[2*MAXQUOTAS]; 250 + struct gfs2_holder qa_qd_ghs[2*MAXQUOTAS]; 251 + unsigned int qa_qd_num; 252 + }; 252 253 253 - u32 al_requested; /* Filled in by caller of gfs2_inplace_reserve() */ 254 - u32 al_alloced; /* Filled in by gfs2_alloc_*() */ 255 - 256 - /* Filled in by gfs2_inplace_reserve() */ 257 - struct gfs2_holder al_rgd_gh; 254 + struct gfs2_blkreserv { 255 + u32 rs_requested; /* Filled in by caller of gfs2_inplace_reserve() */ 256 + struct gfs2_holder rs_rgd_gh; /* Filled in by gfs2_inplace_reserve() */ 258 257 }; 259 258 260 259 enum { ··· 274 275 struct gfs2_glock *i_gl; /* Move into i_gh? */ 275 276 struct gfs2_holder i_iopen_gh; 276 277 struct gfs2_holder i_gh; /* for prepare/commit_write only */ 277 - struct gfs2_alloc *i_alloc; 278 + struct gfs2_qadata *i_qadata; /* quota allocation data */ 279 + struct gfs2_blkreserv *i_res; /* resource group block reservation */ 278 280 struct gfs2_rgrpd *i_rgd; 279 281 u64 i_goal; /* goal block for allocations */ 280 282 struct rw_semaphore i_rw_mutex;
+37 -35
fs/gfs2/inode.c
··· 389 389 { 390 390 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 391 391 int error; 392 + int dblocks = 1; 392 393 393 - if (gfs2_alloc_get(dip) == NULL) 394 - return -ENOMEM; 394 + error = gfs2_rindex_update(sdp); 395 + if (error) 396 + fs_warn(sdp, "rindex update returns %d\n", error); 395 397 396 - dip->i_alloc->al_requested = RES_DINODE; 397 - error = gfs2_inplace_reserve(dip); 398 + error = gfs2_inplace_reserve(dip, RES_DINODE); 398 399 if (error) 399 400 goto out; 400 401 ··· 403 402 if (error) 404 403 goto out_ipreserv; 405 404 406 - error = gfs2_alloc_di(dip, no_addr, generation); 405 + error = gfs2_alloc_blocks(dip, no_addr, &dblocks, 1, generation); 407 406 408 407 gfs2_trans_end(sdp); 409 408 410 409 out_ipreserv: 411 410 gfs2_inplace_release(dip); 412 411 out: 413 - gfs2_alloc_put(dip); 414 412 return error; 415 413 } 416 414 ··· 525 525 int error; 526 526 527 527 munge_mode_uid_gid(dip, &mode, &uid, &gid); 528 - if (!gfs2_alloc_get(dip)) 528 + if (!gfs2_qadata_get(dip)) 529 529 return -ENOMEM; 530 530 531 531 error = gfs2_quota_lock(dip, uid, gid); ··· 547 547 out_quota: 548 548 gfs2_quota_unlock(dip); 549 549 out: 550 - gfs2_alloc_put(dip); 550 + gfs2_qadata_put(dip); 551 551 return error; 552 552 } 553 553 ··· 555 555 struct gfs2_inode *ip) 556 556 { 557 557 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 558 - struct gfs2_alloc *al; 558 + struct gfs2_qadata *qa; 559 559 int alloc_required; 560 560 struct buffer_head *dibh; 561 561 int error; 562 562 563 - al = gfs2_alloc_get(dip); 564 - if (!al) 563 + qa = gfs2_qadata_get(dip); 564 + if (!qa) 565 565 return -ENOMEM; 566 566 567 567 error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); ··· 576 576 if (error) 577 577 goto fail_quota_locks; 578 578 579 - al->al_requested = sdp->sd_max_dirres; 580 - 581 - error = gfs2_inplace_reserve(dip); 579 + error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres); 582 580 if (error) 583 581 goto fail_quota_locks; 584 582 ··· 617 619 gfs2_quota_unlock(dip); 618 620 619 621 fail: 620 - gfs2_alloc_put(dip); 622 + gfs2_qadata_put(dip); 621 623 return error; 622 624 } 623 625 624 - int gfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array, 626 + static int gfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array, 625 627 void *fs_info) 626 628 { 627 629 const struct xattr *xattr; ··· 726 728 brelse(bh); 727 729 728 730 gfs2_trans_end(sdp); 729 - gfs2_inplace_release(dip); 731 + /* Check if we reserved space in the rgrp. Function link_dinode may 732 + not, depending on whether alloc is required. */ 733 + if (dip->i_res) 734 + gfs2_inplace_release(dip); 730 735 gfs2_quota_unlock(dip); 731 - gfs2_alloc_put(dip); 736 + gfs2_qadata_put(dip); 732 737 mark_inode_dirty(inode); 733 738 gfs2_glock_dq_uninit_m(2, ghs); 734 739 d_instantiate(dentry, inode); ··· 876 875 error = 0; 877 876 878 877 if (alloc_required) { 879 - struct gfs2_alloc *al = gfs2_alloc_get(dip); 880 - if (!al) { 878 + struct gfs2_qadata *qa = gfs2_qadata_get(dip); 879 + 880 + if (!qa) { 881 881 error = -ENOMEM; 882 882 goto out_gunlock; 883 883 } ··· 887 885 if (error) 888 886 goto out_alloc; 889 887 890 - al->al_requested = sdp->sd_max_dirres; 891 - 892 - error = gfs2_inplace_reserve(dip); 888 + error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres); 893 889 if (error) 894 890 goto out_gunlock_q; 895 891 ··· 930 930 gfs2_quota_unlock(dip); 931 931 out_alloc: 932 932 if (alloc_required) 933 - gfs2_alloc_put(dip); 933 + gfs2_qadata_put(dip); 934 934 out_gunlock: 935 935 gfs2_glock_dq(ghs + 1); 936 936 out_child: ··· 1037 1037 struct buffer_head *bh; 1038 1038 struct gfs2_holder ghs[3]; 1039 1039 struct gfs2_rgrpd *rgd; 1040 - int error; 1040 + int error = -EROFS; 1041 1041 1042 1042 gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); 1043 1043 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1); 1044 1044 1045 1045 rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr); 1046 + if (!rgd) 1047 + goto out_inodes; 1046 1048 gfs2_holder_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, ghs + 2); 1047 1049 1048 1050 ··· 1090 1088 out_gunlock: 1091 1089 gfs2_glock_dq(ghs + 2); 1092 1090 out_rgrp: 1093 - gfs2_holder_uninit(ghs + 2); 1094 1091 gfs2_glock_dq(ghs + 1); 1095 1092 out_child: 1096 - gfs2_holder_uninit(ghs + 1); 1097 1093 gfs2_glock_dq(ghs); 1098 1094 out_parent: 1095 + gfs2_holder_uninit(ghs + 2); 1096 + out_inodes: 1097 + gfs2_holder_uninit(ghs + 1); 1099 1098 gfs2_holder_uninit(ghs); 1100 1099 return error; 1101 1100 } ··· 1353 1350 error = 0; 1354 1351 1355 1352 if (alloc_required) { 1356 - struct gfs2_alloc *al = gfs2_alloc_get(ndip); 1357 - if (!al) { 1353 + struct gfs2_qadata *qa = gfs2_qadata_get(ndip); 1354 + 1355 + if (!qa) { 1358 1356 error = -ENOMEM; 1359 1357 goto out_gunlock; 1360 1358 } ··· 1364 1360 if (error) 1365 1361 goto out_alloc; 1366 1362 1367 - al->al_requested = sdp->sd_max_dirres; 1368 - 1369 - error = gfs2_inplace_reserve(ndip); 1363 + error = gfs2_inplace_reserve(ndip, sdp->sd_max_dirres); 1370 1364 if (error) 1371 1365 goto out_gunlock_q; 1372 1366 ··· 1425 1423 gfs2_quota_unlock(ndip); 1426 1424 out_alloc: 1427 1425 if (alloc_required) 1428 - gfs2_alloc_put(ndip); 1426 + gfs2_qadata_put(ndip); 1429 1427 out_gunlock: 1430 1428 while (x--) { 1431 1429 gfs2_glock_dq(ghs + x); ··· 1586 1584 if (!(attr->ia_valid & ATTR_GID) || ogid == ngid) 1587 1585 ogid = ngid = NO_QUOTA_CHANGE; 1588 1586 1589 - if (!gfs2_alloc_get(ip)) 1587 + if (!gfs2_qadata_get(ip)) 1590 1588 return -ENOMEM; 1591 1589 1592 1590 error = gfs2_quota_lock(ip, nuid, ngid); ··· 1618 1616 out_gunlock_q: 1619 1617 gfs2_quota_unlock(ip); 1620 1618 out_alloc: 1621 - gfs2_alloc_put(ip); 1619 + gfs2_qadata_put(ip); 1622 1620 return error; 1623 1621 } 1624 1622
+1 -1
fs/gfs2/log.c
··· 626 626 if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags)) 627 627 submit_bh(WRITE_SYNC | REQ_META | REQ_PRIO, bh); 628 628 else 629 - submit_bh(WRITE_FLUSH_FUA | REQ_META | REQ_PRIO, bh); 629 + submit_bh(WRITE_FLUSH_FUA | REQ_META, bh); 630 630 wait_on_buffer(bh); 631 631 632 632 if (!buffer_uptodate(bh))
+2 -1
fs/gfs2/main.c
··· 40 40 inode_init_once(&ip->i_inode); 41 41 init_rwsem(&ip->i_rw_mutex); 42 42 INIT_LIST_HEAD(&ip->i_trunc_list); 43 - ip->i_alloc = NULL; 43 + ip->i_qadata = NULL; 44 + ip->i_res = NULL; 44 45 ip->i_hash_cache = NULL; 45 46 } 46 47
+2 -2
fs/gfs2/meta_io.c
··· 435 435 if (buffer_uptodate(first_bh)) 436 436 goto out; 437 437 if (!buffer_locked(first_bh)) 438 - ll_rw_block(READ_SYNC | REQ_META | REQ_PRIO, 1, &first_bh); 438 + ll_rw_block(READ_SYNC | REQ_META, 1, &first_bh); 439 439 440 440 dblock++; 441 441 extlen--; ··· 444 444 bh = gfs2_getbuf(gl, dblock, CREATE); 445 445 446 446 if (!buffer_uptodate(bh) && !buffer_locked(bh)) 447 - ll_rw_block(READA, 1, &bh); 447 + ll_rw_block(READA | REQ_META, 1, &bh); 448 448 brelse(bh); 449 449 dblock++; 450 450 extlen--;
+1 -1
fs/gfs2/ops_fstype.c
··· 224 224 225 225 bio->bi_end_io = end_bio_io_page; 226 226 bio->bi_private = page; 227 - submit_bio(READ_SYNC | REQ_META | REQ_PRIO, bio); 227 + submit_bio(READ_SYNC | REQ_META, bio); 228 228 wait_on_page_locked(page); 229 229 bio_put(bio); 230 230 if (!PageUptodate(page)) {
+35 -52
fs/gfs2/quota.c
··· 494 494 int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid) 495 495 { 496 496 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 497 - struct gfs2_alloc *al = ip->i_alloc; 498 - struct gfs2_quota_data **qd = al->al_qd; 497 + struct gfs2_qadata *qa = ip->i_qadata; 498 + struct gfs2_quota_data **qd = qa->qa_qd; 499 499 int error; 500 500 501 - if (gfs2_assert_warn(sdp, !al->al_qd_num) || 501 + if (gfs2_assert_warn(sdp, !qa->qa_qd_num) || 502 502 gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags))) 503 503 return -EIO; 504 504 ··· 508 508 error = qdsb_get(sdp, QUOTA_USER, ip->i_inode.i_uid, qd); 509 509 if (error) 510 510 goto out; 511 - al->al_qd_num++; 511 + qa->qa_qd_num++; 512 512 qd++; 513 513 514 514 error = qdsb_get(sdp, QUOTA_GROUP, ip->i_inode.i_gid, qd); 515 515 if (error) 516 516 goto out; 517 - al->al_qd_num++; 517 + qa->qa_qd_num++; 518 518 qd++; 519 519 520 520 if (uid != NO_QUOTA_CHANGE && uid != ip->i_inode.i_uid) { 521 521 error = qdsb_get(sdp, QUOTA_USER, uid, qd); 522 522 if (error) 523 523 goto out; 524 - al->al_qd_num++; 524 + qa->qa_qd_num++; 525 525 qd++; 526 526 } 527 527 ··· 529 529 error = qdsb_get(sdp, QUOTA_GROUP, gid, qd); 530 530 if (error) 531 531 goto out; 532 - al->al_qd_num++; 532 + qa->qa_qd_num++; 533 533 qd++; 534 534 } 535 535 ··· 542 542 void gfs2_quota_unhold(struct gfs2_inode *ip) 543 543 { 544 544 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 545 - struct gfs2_alloc *al = ip->i_alloc; 545 + struct gfs2_qadata *qa = ip->i_qadata; 546 546 unsigned int x; 547 547 548 548 gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags)); 549 549 550 - for (x = 0; x < al->al_qd_num; x++) { 551 - qdsb_put(al->al_qd[x]); 552 - al->al_qd[x] = NULL; 550 + for (x = 0; x < qa->qa_qd_num; x++) { 551 + qdsb_put(qa->qa_qd[x]); 552 + qa->qa_qd[x] = NULL; 553 553 } 554 - al->al_qd_num = 0; 554 + qa->qa_qd_num = 0; 555 555 } 556 556 557 557 static int sort_qd(const void *a, const void *b) ··· 712 712 set_buffer_uptodate(bh); 713 713 714 714 if (!buffer_uptodate(bh)) { 715 - ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh); 715 + ll_rw_block(READ | REQ_META, 1, &bh); 716 716 wait_on_buffer(bh); 717 717 if (!buffer_uptodate(bh)) 718 718 goto unlock_out; ··· 762 762 struct gfs2_quota_data *qd; 763 763 loff_t offset; 764 764 unsigned int nalloc = 0, blocks; 765 - struct gfs2_alloc *al = NULL; 766 765 int error; 767 766 768 767 gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota), ··· 791 792 nalloc++; 792 793 } 793 794 794 - al = gfs2_alloc_get(ip); 795 - if (!al) { 796 - error = -ENOMEM; 797 - goto out_gunlock; 798 - } 799 795 /* 800 796 * 1 blk for unstuffing inode if stuffed. We add this extra 801 797 * block to the reservation unconditionally. If the inode 802 798 * doesn't need unstuffing, the block will be released to the 803 799 * rgrp since it won't be allocated during the transaction 804 800 */ 805 - al->al_requested = 1; 806 801 /* +3 in the end for unstuffing block, inode size update block 807 802 * and another block in case quota straddles page boundary and 808 803 * two blocks need to be updated instead of 1 */ 809 804 blocks = num_qd * data_blocks + RES_DINODE + num_qd + 3; 810 805 811 - if (nalloc) 812 - al->al_requested += nalloc * (data_blocks + ind_blocks); 813 - error = gfs2_inplace_reserve(ip); 806 + error = gfs2_inplace_reserve(ip, 1 + 807 + (nalloc * (data_blocks + ind_blocks))); 814 808 if (error) 815 809 goto out_alloc; 816 810 ··· 832 840 out_ipres: 833 841 gfs2_inplace_release(ip); 834 842 out_alloc: 835 - gfs2_alloc_put(ip); 836 - out_gunlock: 837 843 gfs2_glock_dq_uninit(&i_gh); 838 844 out: 839 845 while (qx--) ··· 915 925 int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid) 916 926 { 917 927 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 918 - struct gfs2_alloc *al = ip->i_alloc; 928 + struct gfs2_qadata *qa = ip->i_qadata; 919 929 struct gfs2_quota_data *qd; 920 930 unsigned int x; 921 931 int error = 0; ··· 928 938 sdp->sd_args.ar_quota != GFS2_QUOTA_ON) 929 939 return 0; 930 940 931 - sort(al->al_qd, al->al_qd_num, sizeof(struct gfs2_quota_data *), 941 + sort(qa->qa_qd, qa->qa_qd_num, sizeof(struct gfs2_quota_data *), 932 942 sort_qd, NULL); 933 943 934 - for (x = 0; x < al->al_qd_num; x++) { 944 + for (x = 0; x < qa->qa_qd_num; x++) { 935 945 int force = NO_FORCE; 936 - qd = al->al_qd[x]; 946 + qd = qa->qa_qd[x]; 937 947 if (test_and_clear_bit(QDF_REFRESH, &qd->qd_flags)) 938 948 force = FORCE; 939 - error = do_glock(qd, force, &al->al_qd_ghs[x]); 949 + error = do_glock(qd, force, &qa->qa_qd_ghs[x]); 940 950 if (error) 941 951 break; 942 952 } ··· 945 955 set_bit(GIF_QD_LOCKED, &ip->i_flags); 946 956 else { 947 957 while (x--) 948 - gfs2_glock_dq_uninit(&al->al_qd_ghs[x]); 958 + gfs2_glock_dq_uninit(&qa->qa_qd_ghs[x]); 949 959 gfs2_quota_unhold(ip); 950 960 } 951 961 ··· 990 1000 991 1001 void gfs2_quota_unlock(struct gfs2_inode *ip) 992 1002 { 993 - struct gfs2_alloc *al = ip->i_alloc; 1003 + struct gfs2_qadata *qa = ip->i_qadata; 994 1004 struct gfs2_quota_data *qda[4]; 995 1005 unsigned int count = 0; 996 1006 unsigned int x; ··· 998 1008 if (!test_and_clear_bit(GIF_QD_LOCKED, &ip->i_flags)) 999 1009 goto out; 1000 1010 1001 - for (x = 0; x < al->al_qd_num; x++) { 1011 + for (x = 0; x < qa->qa_qd_num; x++) { 1002 1012 struct gfs2_quota_data *qd; 1003 1013 int sync; 1004 1014 1005 - qd = al->al_qd[x]; 1015 + qd = qa->qa_qd[x]; 1006 1016 sync = need_sync(qd); 1007 1017 1008 - gfs2_glock_dq_uninit(&al->al_qd_ghs[x]); 1018 + gfs2_glock_dq_uninit(&qa->qa_qd_ghs[x]); 1009 1019 1010 1020 if (sync && qd_trylock(qd)) 1011 1021 qda[count++] = qd; ··· 1038 1048 int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid) 1039 1049 { 1040 1050 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1041 - struct gfs2_alloc *al = ip->i_alloc; 1051 + struct gfs2_qadata *qa = ip->i_qadata; 1042 1052 struct gfs2_quota_data *qd; 1043 1053 s64 value; 1044 1054 unsigned int x; ··· 1050 1060 if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON) 1051 1061 return 0; 1052 1062 1053 - for (x = 0; x < al->al_qd_num; x++) { 1054 - qd = al->al_qd[x]; 1063 + for (x = 0; x < qa->qa_qd_num; x++) { 1064 + qd = qa->qa_qd[x]; 1055 1065 1056 1066 if (!((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) || 1057 1067 (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags)))) ··· 1089 1099 void gfs2_quota_change(struct gfs2_inode *ip, s64 change, 1090 1100 u32 uid, u32 gid) 1091 1101 { 1092 - struct gfs2_alloc *al = ip->i_alloc; 1102 + struct gfs2_qadata *qa = ip->i_qadata; 1093 1103 struct gfs2_quota_data *qd; 1094 1104 unsigned int x; 1095 1105 ··· 1098 1108 if (ip->i_diskflags & GFS2_DIF_SYSTEM) 1099 1109 return; 1100 1110 1101 - for (x = 0; x < al->al_qd_num; x++) { 1102 - qd = al->al_qd[x]; 1111 + for (x = 0; x < qa->qa_qd_num; x++) { 1112 + qd = qa->qa_qd[x]; 1103 1113 1104 1114 if ((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) || 1105 1115 (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags))) { ··· 1519 1529 unsigned int data_blocks, ind_blocks; 1520 1530 unsigned int blocks = 0; 1521 1531 int alloc_required; 1522 - struct gfs2_alloc *al; 1523 1532 loff_t offset; 1524 1533 int error; 1525 1534 ··· 1583 1594 if (gfs2_is_stuffed(ip)) 1584 1595 alloc_required = 1; 1585 1596 if (alloc_required) { 1586 - al = gfs2_alloc_get(ip); 1587 - if (al == NULL) 1588 - goto out_i; 1589 1597 gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota), 1590 1598 &data_blocks, &ind_blocks); 1591 - blocks = al->al_requested = 1 + data_blocks + ind_blocks; 1592 - error = gfs2_inplace_reserve(ip); 1599 + blocks = 1 + data_blocks + ind_blocks; 1600 + error = gfs2_inplace_reserve(ip, blocks); 1593 1601 if (error) 1594 - goto out_alloc; 1602 + goto out_i; 1595 1603 blocks += gfs2_rg_blocks(ip); 1596 1604 } 1597 1605 ··· 1603 1617 1604 1618 gfs2_trans_end(sdp); 1605 1619 out_release: 1606 - if (alloc_required) { 1620 + if (alloc_required) 1607 1621 gfs2_inplace_release(ip); 1608 - out_alloc: 1609 - gfs2_alloc_put(ip); 1610 - } 1611 1622 out_i: 1612 1623 gfs2_glock_dq_uninit(&i_gh); 1613 1624 out_q:
+161 -132
fs/gfs2/rgrp.c
··· 65 65 }; 66 66 67 67 static u32 rgblk_search(struct gfs2_rgrpd *rgd, u32 goal, 68 - unsigned char old_state, unsigned char new_state, 69 - unsigned int *n); 68 + unsigned char old_state, 69 + struct gfs2_bitmap **rbi); 70 70 71 71 /** 72 72 * gfs2_setbit - Set a bit in the bitmaps ··· 860 860 } 861 861 862 862 /** 863 - * gfs2_alloc_get - get the struct gfs2_alloc structure for an inode 863 + * gfs2_qadata_get - get the struct gfs2_qadata structure for an inode 864 864 * @ip: the incore GFS2 inode structure 865 865 * 866 - * Returns: the struct gfs2_alloc 866 + * Returns: the struct gfs2_qadata 867 867 */ 868 868 869 - struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip) 869 + struct gfs2_qadata *gfs2_qadata_get(struct gfs2_inode *ip) 870 870 { 871 871 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 872 872 int error; 873 - BUG_ON(ip->i_alloc != NULL); 874 - ip->i_alloc = kzalloc(sizeof(struct gfs2_alloc), GFP_NOFS); 873 + BUG_ON(ip->i_qadata != NULL); 874 + ip->i_qadata = kzalloc(sizeof(struct gfs2_qadata), GFP_NOFS); 875 875 error = gfs2_rindex_update(sdp); 876 876 if (error) 877 877 fs_warn(sdp, "rindex update returns %d\n", error); 878 - return ip->i_alloc; 878 + return ip->i_qadata; 879 + } 880 + 881 + /** 882 + * gfs2_blkrsv_get - get the struct gfs2_blkreserv structure for an inode 883 + * @ip: the incore GFS2 inode structure 884 + * 885 + * Returns: the struct gfs2_qadata 886 + */ 887 + 888 + static struct gfs2_blkreserv *gfs2_blkrsv_get(struct gfs2_inode *ip) 889 + { 890 + BUG_ON(ip->i_res != NULL); 891 + ip->i_res = kzalloc(sizeof(struct gfs2_blkreserv), GFP_NOFS); 892 + return ip->i_res; 879 893 } 880 894 881 895 /** ··· 904 890 905 891 static int try_rgrp_fit(const struct gfs2_rgrpd *rgd, const struct gfs2_inode *ip) 906 892 { 907 - const struct gfs2_alloc *al = ip->i_alloc; 893 + const struct gfs2_blkreserv *rs = ip->i_res; 908 894 909 895 if (rgd->rd_flags & (GFS2_RGF_NOALLOC | GFS2_RDF_ERROR)) 910 896 return 0; 911 - if (rgd->rd_free_clone >= al->al_requested) 897 + if (rgd->rd_free_clone >= rs->rs_requested) 912 898 return 1; 913 899 return 0; 900 + } 901 + 902 + static inline u32 gfs2_bi2rgd_blk(struct gfs2_bitmap *bi, u32 blk) 903 + { 904 + return (bi->bi_start * GFS2_NBBY) + blk; 914 905 } 915 906 916 907 /** ··· 931 912 u32 goal = 0, block; 932 913 u64 no_addr; 933 914 struct gfs2_sbd *sdp = rgd->rd_sbd; 934 - unsigned int n; 935 915 struct gfs2_glock *gl; 936 916 struct gfs2_inode *ip; 937 917 int error; 938 918 int found = 0; 919 + struct gfs2_bitmap *bi; 939 920 940 921 while (goal < rgd->rd_data) { 941 922 down_write(&sdp->sd_log_flush_lock); 942 - n = 1; 943 - block = rgblk_search(rgd, goal, GFS2_BLKST_UNLINKED, 944 - GFS2_BLKST_UNLINKED, &n); 923 + block = rgblk_search(rgd, goal, GFS2_BLKST_UNLINKED, &bi); 945 924 up_write(&sdp->sd_log_flush_lock); 946 925 if (block == BFITNOENT) 947 926 break; 927 + 928 + block = gfs2_bi2rgd_blk(bi, block); 948 929 /* rgblk_search can return a block < goal, so we need to 949 930 keep it marching forward. */ 950 931 no_addr = block + rgd->rd_data0; ··· 996 977 { 997 978 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 998 979 struct gfs2_rgrpd *rgd, *begin = NULL; 999 - struct gfs2_alloc *al = ip->i_alloc; 1000 - int error, rg_locked; 980 + struct gfs2_blkreserv *rs = ip->i_res; 981 + int error, rg_locked, flags = LM_FLAG_TRY; 1001 982 int loops = 0; 1002 983 1003 984 if (ip->i_rgd && rgrp_contains_block(ip->i_rgd, ip->i_goal)) ··· 1016 997 error = 0; 1017 998 } else { 1018 999 error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 1019 - LM_FLAG_TRY, &al->al_rgd_gh); 1000 + flags, &rs->rs_rgd_gh); 1020 1001 } 1021 1002 switch (error) { 1022 1003 case 0: ··· 1027 1008 if (rgd->rd_flags & GFS2_RDF_CHECK) 1028 1009 try_rgrp_unlink(rgd, last_unlinked, ip->i_no_addr); 1029 1010 if (!rg_locked) 1030 - gfs2_glock_dq_uninit(&al->al_rgd_gh); 1011 + gfs2_glock_dq_uninit(&rs->rs_rgd_gh); 1031 1012 /* fall through */ 1032 1013 case GLR_TRYFAILED: 1033 1014 rgd = gfs2_rgrpd_get_next(rgd); 1034 - if (rgd == begin) 1015 + if (rgd == begin) { 1016 + flags = 0; 1035 1017 loops++; 1018 + } 1036 1019 break; 1037 1020 default: 1038 1021 return error; ··· 1044 1023 return -ENOSPC; 1045 1024 } 1046 1025 1026 + static void gfs2_blkrsv_put(struct gfs2_inode *ip) 1027 + { 1028 + BUG_ON(ip->i_res == NULL); 1029 + kfree(ip->i_res); 1030 + ip->i_res = NULL; 1031 + } 1032 + 1047 1033 /** 1048 1034 * gfs2_inplace_reserve - Reserve space in the filesystem 1049 1035 * @ip: the inode to reserve space for ··· 1058 1030 * Returns: errno 1059 1031 */ 1060 1032 1061 - int gfs2_inplace_reserve(struct gfs2_inode *ip) 1033 + int gfs2_inplace_reserve(struct gfs2_inode *ip, u32 requested) 1062 1034 { 1063 1035 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1064 - struct gfs2_alloc *al = ip->i_alloc; 1036 + struct gfs2_blkreserv *rs; 1065 1037 int error = 0; 1066 1038 u64 last_unlinked = NO_BLOCK; 1067 1039 int tries = 0; 1068 1040 1069 - if (gfs2_assert_warn(sdp, al->al_requested)) 1070 - return -EINVAL; 1041 + rs = gfs2_blkrsv_get(ip); 1042 + if (!rs) 1043 + return -ENOMEM; 1044 + 1045 + rs->rs_requested = requested; 1046 + if (gfs2_assert_warn(sdp, requested)) { 1047 + error = -EINVAL; 1048 + goto out; 1049 + } 1071 1050 1072 1051 do { 1073 1052 error = get_local_rgrp(ip, &last_unlinked); ··· 1091 1056 gfs2_log_flush(sdp, NULL); 1092 1057 } while (tries++ < 3); 1093 1058 1059 + out: 1060 + if (error) 1061 + gfs2_blkrsv_put(ip); 1094 1062 return error; 1095 1063 } 1096 1064 ··· 1106 1068 1107 1069 void gfs2_inplace_release(struct gfs2_inode *ip) 1108 1070 { 1109 - struct gfs2_alloc *al = ip->i_alloc; 1071 + struct gfs2_blkreserv *rs = ip->i_res; 1110 1072 1111 - if (al->al_rgd_gh.gh_gl) 1112 - gfs2_glock_dq_uninit(&al->al_rgd_gh); 1073 + gfs2_blkrsv_put(ip); 1074 + if (rs->rs_rgd_gh.gh_gl) 1075 + gfs2_glock_dq_uninit(&rs->rs_rgd_gh); 1113 1076 } 1114 1077 1115 1078 /** ··· 1147 1108 } 1148 1109 1149 1110 /** 1150 - * rgblk_search - find a block in @old_state, change allocation 1151 - * state to @new_state 1111 + * rgblk_search - find a block in @state 1152 1112 * @rgd: the resource group descriptor 1153 1113 * @goal: the goal block within the RG (start here to search for avail block) 1154 - * @old_state: GFS2_BLKST_XXX the before-allocation state to find 1155 - * @new_state: GFS2_BLKST_XXX the after-allocation block state 1156 - * @n: The extent length 1114 + * @state: GFS2_BLKST_XXX the before-allocation state to find 1115 + * @dinode: TRUE if the first block we allocate is for a dinode 1116 + * @rbi: address of the pointer to the bitmap containing the block found 1157 1117 * 1158 - * Walk rgrp's bitmap to find bits that represent a block in @old_state. 1159 - * Add the found bitmap buffer to the transaction. 1160 - * Set the found bits to @new_state to change block's allocation state. 1118 + * Walk rgrp's bitmap to find bits that represent a block in @state. 1161 1119 * 1162 1120 * This function never fails, because we wouldn't call it unless we 1163 1121 * know (from reservation results, etc.) that a block is available. 1164 1122 * 1165 - * Scope of @goal and returned block is just within rgrp, not the whole 1166 - * filesystem. 1123 + * Scope of @goal is just within rgrp, not the whole filesystem. 1124 + * Scope of @returned block is just within bitmap, not the whole filesystem. 1167 1125 * 1168 - * Returns: the block number allocated 1126 + * Returns: the block number found relative to the bitmap rbi 1169 1127 */ 1170 1128 1171 1129 static u32 rgblk_search(struct gfs2_rgrpd *rgd, u32 goal, 1172 - unsigned char old_state, unsigned char new_state, 1173 - unsigned int *n) 1130 + unsigned char state, 1131 + struct gfs2_bitmap **rbi) 1174 1132 { 1175 1133 struct gfs2_bitmap *bi = NULL; 1176 1134 const u32 length = rgd->rd_length; 1177 1135 u32 blk = BFITNOENT; 1178 1136 unsigned int buf, x; 1179 - const unsigned int elen = *n; 1180 1137 const u8 *buffer = NULL; 1181 1138 1182 - *n = 0; 1139 + *rbi = NULL; 1183 1140 /* Find bitmap block that contains bits for goal block */ 1184 1141 for (buf = 0; buf < length; buf++) { 1185 1142 bi = rgd->rd_bits + buf; ··· 1198 1163 bi = rgd->rd_bits + buf; 1199 1164 1200 1165 if (test_bit(GBF_FULL, &bi->bi_flags) && 1201 - (old_state == GFS2_BLKST_FREE)) 1166 + (state == GFS2_BLKST_FREE)) 1202 1167 goto skip; 1203 1168 1204 1169 /* The GFS2_BLKST_UNLINKED state doesn't apply to the clone 1205 1170 bitmaps, so we must search the originals for that. */ 1206 1171 buffer = bi->bi_bh->b_data + bi->bi_offset; 1207 1172 WARN_ON(!buffer_uptodate(bi->bi_bh)); 1208 - if (old_state != GFS2_BLKST_UNLINKED && bi->bi_clone) 1173 + if (state != GFS2_BLKST_UNLINKED && bi->bi_clone) 1209 1174 buffer = bi->bi_clone + bi->bi_offset; 1210 1175 1211 - blk = gfs2_bitfit(buffer, bi->bi_len, goal, old_state); 1176 + blk = gfs2_bitfit(buffer, bi->bi_len, goal, state); 1212 1177 if (blk != BFITNOENT) 1213 1178 break; 1214 1179 1215 - if ((goal == 0) && (old_state == GFS2_BLKST_FREE)) 1180 + if ((goal == 0) && (state == GFS2_BLKST_FREE)) 1216 1181 set_bit(GBF_FULL, &bi->bi_flags); 1217 1182 1218 1183 /* Try next bitmap block (wrap back to rgrp header if at end) */ ··· 1222 1187 goal = 0; 1223 1188 } 1224 1189 1225 - if (blk == BFITNOENT) 1226 - return blk; 1190 + if (blk != BFITNOENT) 1191 + *rbi = bi; 1227 1192 1228 - *n = 1; 1229 - if (old_state == new_state) 1230 - goto out; 1193 + return blk; 1194 + } 1231 1195 1196 + /** 1197 + * gfs2_alloc_extent - allocate an extent from a given bitmap 1198 + * @rgd: the resource group descriptor 1199 + * @bi: the bitmap within the rgrp 1200 + * @blk: the block within the bitmap 1201 + * @dinode: TRUE if the first block we allocate is for a dinode 1202 + * @n: The extent length 1203 + * 1204 + * Add the found bitmap buffer to the transaction. 1205 + * Set the found bits to @new_state to change block's allocation state. 1206 + * Returns: starting block number of the extent (fs scope) 1207 + */ 1208 + static u64 gfs2_alloc_extent(struct gfs2_rgrpd *rgd, struct gfs2_bitmap *bi, 1209 + u32 blk, bool dinode, unsigned int *n) 1210 + { 1211 + const unsigned int elen = *n; 1212 + u32 goal; 1213 + const u8 *buffer = NULL; 1214 + 1215 + *n = 0; 1216 + buffer = bi->bi_bh->b_data + bi->bi_offset; 1232 1217 gfs2_trans_add_bh(rgd->rd_gl, bi->bi_bh, 1); 1233 1218 gfs2_setbit(rgd, bi->bi_bh->b_data, bi->bi_clone, bi->bi_offset, 1234 - bi, blk, new_state); 1219 + bi, blk, dinode ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); 1220 + (*n)++; 1235 1221 goal = blk; 1236 1222 while (*n < elen) { 1237 1223 goal++; ··· 1262 1206 GFS2_BLKST_FREE) 1263 1207 break; 1264 1208 gfs2_setbit(rgd, bi->bi_bh->b_data, bi->bi_clone, bi->bi_offset, 1265 - bi, goal, new_state); 1209 + bi, goal, GFS2_BLKST_USED); 1266 1210 (*n)++; 1267 1211 } 1268 - out: 1269 - return (bi->bi_start * GFS2_NBBY) + blk; 1212 + blk = gfs2_bi2rgd_blk(bi, blk); 1213 + rgd->rd_last_alloc = blk + *n - 1; 1214 + return rgd->rd_data0 + blk; 1270 1215 } 1271 1216 1272 1217 /** ··· 1355 1298 } 1356 1299 1357 1300 /** 1358 - * gfs2_alloc_block - Allocate one or more blocks 1301 + * gfs2_alloc_blocks - Allocate one or more blocks of data and/or a dinode 1359 1302 * @ip: the inode to allocate the block for 1360 1303 * @bn: Used to return the starting block number 1361 - * @n: requested number of blocks/extent length (value/result) 1304 + * @ndata: requested number of blocks/extent length (value/result) 1305 + * @dinode: 1 if we're allocating a dinode block, else 0 1306 + * @generation: the generation number of the inode 1362 1307 * 1363 1308 * Returns: 0 or error 1364 1309 */ 1365 1310 1366 - int gfs2_alloc_block(struct gfs2_inode *ip, u64 *bn, unsigned int *n) 1311 + int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *nblocks, 1312 + bool dinode, u64 *generation) 1367 1313 { 1368 1314 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1369 1315 struct buffer_head *dibh; 1370 - struct gfs2_alloc *al = ip->i_alloc; 1371 1316 struct gfs2_rgrpd *rgd; 1372 - u32 goal, blk; 1373 - u64 block; 1317 + unsigned int ndata; 1318 + u32 goal, blk; /* block, within the rgrp scope */ 1319 + u64 block; /* block, within the file system scope */ 1374 1320 int error; 1321 + struct gfs2_bitmap *bi; 1375 1322 1376 1323 /* Only happens if there is a bug in gfs2, return something distinctive 1377 1324 * to ensure that it is noticed. 1378 1325 */ 1379 - if (al == NULL) 1326 + if (ip->i_res == NULL) 1380 1327 return -ECANCELED; 1381 1328 1382 1329 rgd = ip->i_rgd; 1383 1330 1384 - if (rgrp_contains_block(rgd, ip->i_goal)) 1331 + if (!dinode && rgrp_contains_block(rgd, ip->i_goal)) 1385 1332 goal = ip->i_goal - rgd->rd_data0; 1386 1333 else 1387 1334 goal = rgd->rd_last_alloc; 1388 1335 1389 - blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED, n); 1336 + blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, &bi); 1390 1337 1391 1338 /* Since all blocks are reserved in advance, this shouldn't happen */ 1392 1339 if (blk == BFITNOENT) 1393 1340 goto rgrp_error; 1394 1341 1395 - rgd->rd_last_alloc = blk; 1396 - block = rgd->rd_data0 + blk; 1397 - ip->i_goal = block + *n - 1; 1398 - error = gfs2_meta_inode_buffer(ip, &dibh); 1399 - if (error == 0) { 1400 - struct gfs2_dinode *di = (struct gfs2_dinode *)dibh->b_data; 1401 - gfs2_trans_add_bh(ip->i_gl, dibh, 1); 1402 - di->di_goal_meta = di->di_goal_data = cpu_to_be64(ip->i_goal); 1403 - brelse(dibh); 1342 + block = gfs2_alloc_extent(rgd, bi, blk, dinode, nblocks); 1343 + ndata = *nblocks; 1344 + if (dinode) 1345 + ndata--; 1346 + 1347 + if (!dinode) { 1348 + ip->i_goal = block + ndata - 1; 1349 + error = gfs2_meta_inode_buffer(ip, &dibh); 1350 + if (error == 0) { 1351 + struct gfs2_dinode *di = 1352 + (struct gfs2_dinode *)dibh->b_data; 1353 + gfs2_trans_add_bh(ip->i_gl, dibh, 1); 1354 + di->di_goal_meta = di->di_goal_data = 1355 + cpu_to_be64(ip->i_goal); 1356 + brelse(dibh); 1357 + } 1404 1358 } 1405 - if (rgd->rd_free < *n) 1359 + if (rgd->rd_free < *nblocks) 1406 1360 goto rgrp_error; 1407 1361 1408 - rgd->rd_free -= *n; 1409 - 1410 - gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); 1411 - gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); 1412 - 1413 - al->al_alloced += *n; 1414 - 1415 - gfs2_statfs_change(sdp, 0, -(s64)*n, 0); 1416 - gfs2_quota_change(ip, *n, ip->i_inode.i_uid, ip->i_inode.i_gid); 1417 - 1418 - rgd->rd_free_clone -= *n; 1419 - trace_gfs2_block_alloc(ip, block, *n, GFS2_BLKST_USED); 1420 - *bn = block; 1421 - return 0; 1422 - 1423 - rgrp_error: 1424 - gfs2_rgrp_error(rgd); 1425 - return -EIO; 1426 - } 1427 - 1428 - /** 1429 - * gfs2_alloc_di - Allocate a dinode 1430 - * @dip: the directory that the inode is going in 1431 - * @bn: the block number which is allocated 1432 - * @generation: the generation number of the inode 1433 - * 1434 - * Returns: 0 on success or error 1435 - */ 1436 - 1437 - int gfs2_alloc_di(struct gfs2_inode *dip, u64 *bn, u64 *generation) 1438 - { 1439 - struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 1440 - struct gfs2_alloc *al = dip->i_alloc; 1441 - struct gfs2_rgrpd *rgd = dip->i_rgd; 1442 - u32 blk; 1443 - u64 block; 1444 - unsigned int n = 1; 1445 - 1446 - blk = rgblk_search(rgd, rgd->rd_last_alloc, 1447 - GFS2_BLKST_FREE, GFS2_BLKST_DINODE, &n); 1448 - 1449 - /* Since all blocks are reserved in advance, this shouldn't happen */ 1450 - if (blk == BFITNOENT) 1451 - goto rgrp_error; 1452 - 1453 - rgd->rd_last_alloc = blk; 1454 - block = rgd->rd_data0 + blk; 1455 - if (rgd->rd_free == 0) 1456 - goto rgrp_error; 1457 - 1458 - rgd->rd_free--; 1459 - rgd->rd_dinodes++; 1460 - *generation = rgd->rd_igeneration++; 1461 - if (*generation == 0) 1362 + rgd->rd_free -= *nblocks; 1363 + if (dinode) { 1364 + rgd->rd_dinodes++; 1462 1365 *generation = rgd->rd_igeneration++; 1366 + if (*generation == 0) 1367 + *generation = rgd->rd_igeneration++; 1368 + } 1369 + 1463 1370 gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); 1464 1371 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); 1465 1372 1466 - al->al_alloced++; 1373 + gfs2_statfs_change(sdp, 0, -(s64)*nblocks, dinode ? 1 : 0); 1374 + if (dinode) 1375 + gfs2_trans_add_unrevoke(sdp, block, 1); 1467 1376 1468 - gfs2_statfs_change(sdp, 0, -1, +1); 1469 - gfs2_trans_add_unrevoke(sdp, block, 1); 1377 + /* 1378 + * This needs reviewing to see why we cannot do the quota change 1379 + * at this point in the dinode case. 1380 + */ 1381 + if (ndata) 1382 + gfs2_quota_change(ip, ndata, ip->i_inode.i_uid, 1383 + ip->i_inode.i_gid); 1470 1384 1471 - rgd->rd_free_clone--; 1472 - trace_gfs2_block_alloc(dip, block, 1, GFS2_BLKST_DINODE); 1385 + rgd->rd_free_clone -= *nblocks; 1386 + trace_gfs2_block_alloc(ip, block, *nblocks, 1387 + dinode ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); 1473 1388 *bn = block; 1474 1389 return 0; 1475 1390
+8 -8
fs/gfs2/rgrp.h
··· 28 28 extern int gfs2_rgrp_go_lock(struct gfs2_holder *gh); 29 29 extern void gfs2_rgrp_go_unlock(struct gfs2_holder *gh); 30 30 31 - extern struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip); 32 - static inline void gfs2_alloc_put(struct gfs2_inode *ip) 31 + extern struct gfs2_qadata *gfs2_qadata_get(struct gfs2_inode *ip); 32 + static inline void gfs2_qadata_put(struct gfs2_inode *ip) 33 33 { 34 - BUG_ON(ip->i_alloc == NULL); 35 - kfree(ip->i_alloc); 36 - ip->i_alloc = NULL; 34 + BUG_ON(ip->i_qadata == NULL); 35 + kfree(ip->i_qadata); 36 + ip->i_qadata = NULL; 37 37 } 38 38 39 - extern int gfs2_inplace_reserve(struct gfs2_inode *ip); 39 + extern int gfs2_inplace_reserve(struct gfs2_inode *ip, u32 requested); 40 40 extern void gfs2_inplace_release(struct gfs2_inode *ip); 41 41 42 - extern int gfs2_alloc_block(struct gfs2_inode *ip, u64 *bn, unsigned int *n); 43 - extern int gfs2_alloc_di(struct gfs2_inode *ip, u64 *bn, u64 *generation); 42 + extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n, 43 + bool dinode, u64 *generation); 44 44 45 45 extern void __gfs2_free_blocks(struct gfs2_inode *ip, u64 bstart, u32 blen, int meta); 46 46 extern void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen);
+7 -7
fs/gfs2/super.c
··· 1399 1399 static int gfs2_dinode_dealloc(struct gfs2_inode *ip) 1400 1400 { 1401 1401 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1402 - struct gfs2_alloc *al; 1402 + struct gfs2_qadata *qa; 1403 1403 struct gfs2_rgrpd *rgd; 1404 + struct gfs2_holder gh; 1404 1405 int error; 1405 1406 1406 1407 if (gfs2_get_inode_blocks(&ip->i_inode) != 1) { ··· 1409 1408 return -EIO; 1410 1409 } 1411 1410 1412 - al = gfs2_alloc_get(ip); 1413 - if (!al) 1411 + qa = gfs2_qadata_get(ip); 1412 + if (!qa) 1414 1413 return -ENOMEM; 1415 1414 1416 1415 error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); ··· 1424 1423 goto out_qs; 1425 1424 } 1426 1425 1427 - error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, 1428 - &al->al_rgd_gh); 1426 + error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, &gh); 1429 1427 if (error) 1430 1428 goto out_qs; 1431 1429 ··· 1440 1440 gfs2_trans_end(sdp); 1441 1441 1442 1442 out_rg_gunlock: 1443 - gfs2_glock_dq_uninit(&al->al_rgd_gh); 1443 + gfs2_glock_dq_uninit(&gh); 1444 1444 out_qs: 1445 1445 gfs2_quota_unhold(ip); 1446 1446 out: 1447 - gfs2_alloc_put(ip); 1447 + gfs2_qadata_put(ip); 1448 1448 return error; 1449 1449 } 1450 1450
+3 -3
fs/gfs2/trans.h
··· 30 30 * block, or all of the blocks in the rg, whichever is smaller */ 31 31 static inline unsigned int gfs2_rg_blocks(const struct gfs2_inode *ip) 32 32 { 33 - const struct gfs2_alloc *al = ip->i_alloc; 34 - if (al->al_requested < ip->i_rgd->rd_length) 35 - return al->al_requested + 1; 33 + const struct gfs2_blkreserv *rs = ip->i_res; 34 + if (rs->rs_requested < ip->i_rgd->rd_length) 35 + return rs->rs_requested + 1; 36 36 return ip->i_rgd->rd_length; 37 37 } 38 38
+23 -25
fs/gfs2/xattr.c
··· 321 321 struct gfs2_ea_header *ea, 322 322 struct gfs2_ea_header *prev, int leave) 323 323 { 324 - struct gfs2_alloc *al; 324 + struct gfs2_qadata *qa; 325 325 int error; 326 326 327 - al = gfs2_alloc_get(ip); 328 - if (!al) 327 + qa = gfs2_qadata_get(ip); 328 + if (!qa) 329 329 return -ENOMEM; 330 330 331 331 error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); ··· 336 336 337 337 gfs2_quota_unhold(ip); 338 338 out_alloc: 339 - gfs2_alloc_put(ip); 339 + gfs2_qadata_put(ip); 340 340 return error; 341 341 } 342 342 ··· 549 549 goto out; 550 550 551 551 error = gfs2_ea_get_copy(ip, &el, data, len); 552 - if (error == 0) 553 - error = len; 554 - *ppdata = data; 552 + if (error < 0) 553 + kfree(data); 554 + else 555 + *ppdata = data; 555 556 out: 556 557 brelse(el.el_bh); 557 558 return error; ··· 610 609 u64 block; 611 610 int error; 612 611 613 - error = gfs2_alloc_block(ip, &block, &n); 612 + error = gfs2_alloc_blocks(ip, &block, &n, 0, NULL); 614 613 if (error) 615 614 return error; 616 615 gfs2_trans_add_unrevoke(sdp, block, 1); ··· 672 671 int mh_size = sizeof(struct gfs2_meta_header); 673 672 unsigned int n = 1; 674 673 675 - error = gfs2_alloc_block(ip, &block, &n); 674 + error = gfs2_alloc_blocks(ip, &block, &n, 0, NULL); 676 675 if (error) 677 676 return error; 678 677 gfs2_trans_add_unrevoke(sdp, block, 1); ··· 709 708 unsigned int blks, 710 709 ea_skeleton_call_t skeleton_call, void *private) 711 710 { 712 - struct gfs2_alloc *al; 711 + struct gfs2_qadata *qa; 713 712 struct buffer_head *dibh; 714 713 int error; 715 714 716 - al = gfs2_alloc_get(ip); 717 - if (!al) 715 + qa = gfs2_qadata_get(ip); 716 + if (!qa) 718 717 return -ENOMEM; 719 718 720 719 error = gfs2_quota_lock_check(ip); 721 720 if (error) 722 721 goto out; 723 722 724 - al->al_requested = blks; 725 - 726 - error = gfs2_inplace_reserve(ip); 723 + error = gfs2_inplace_reserve(ip, blks); 727 724 if (error) 728 725 goto out_gunlock_q; 729 726 ··· 750 751 out_gunlock_q: 751 752 gfs2_quota_unlock(ip); 752 753 out: 753 - gfs2_alloc_put(ip); 754 + gfs2_qadata_put(ip); 754 755 return error; 755 756 } 756 757 ··· 990 991 } else { 991 992 u64 blk; 992 993 unsigned int n = 1; 993 - error = gfs2_alloc_block(ip, &blk, &n); 994 + error = gfs2_alloc_blocks(ip, &blk, &n, 0, NULL); 994 995 if (error) 995 996 return error; 996 997 gfs2_trans_add_unrevoke(sdp, blk, 1); ··· 1434 1435 static int ea_dealloc_block(struct gfs2_inode *ip) 1435 1436 { 1436 1437 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1437 - struct gfs2_alloc *al = ip->i_alloc; 1438 1438 struct gfs2_rgrpd *rgd; 1439 1439 struct buffer_head *dibh; 1440 + struct gfs2_holder gh; 1440 1441 int error; 1441 1442 1442 1443 rgd = gfs2_blk2rgrpd(sdp, ip->i_eattr); ··· 1445 1446 return -EIO; 1446 1447 } 1447 1448 1448 - error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, 1449 - &al->al_rgd_gh); 1449 + error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, &gh); 1450 1450 if (error) 1451 1451 return error; 1452 1452 ··· 1469 1471 gfs2_trans_end(sdp); 1470 1472 1471 1473 out_gunlock: 1472 - gfs2_glock_dq_uninit(&al->al_rgd_gh); 1474 + gfs2_glock_dq_uninit(&gh); 1473 1475 return error; 1474 1476 } 1475 1477 ··· 1482 1484 1483 1485 int gfs2_ea_dealloc(struct gfs2_inode *ip) 1484 1486 { 1485 - struct gfs2_alloc *al; 1487 + struct gfs2_qadata *qa; 1486 1488 int error; 1487 1489 1488 - al = gfs2_alloc_get(ip); 1489 - if (!al) 1490 + qa = gfs2_qadata_get(ip); 1491 + if (!qa) 1490 1492 return -ENOMEM; 1491 1493 1492 1494 error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); ··· 1508 1510 out_quota: 1509 1511 gfs2_quota_unhold(ip); 1510 1512 out_alloc: 1511 - gfs2_alloc_put(ip); 1513 + gfs2_qadata_put(ip); 1512 1514 return error; 1513 1515 } 1514 1516