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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'gfs2-v6.1-rc7-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2

Pull gfs2 updtaes from Andreas Gruenbacher:

- Revert a change to delete_work_func() that has gone wrong in commit
c412a97cf6c5 ("gfs2: Use TRY lock in gfs2_inode_lookup for UNLINKED
inodes").

- Avoid dequeuing GL_ASYNC glock holders twice by first checking if the
holder is still queued.

- gfs2: Always check the inode size of inline inodes when reading in
inodes to prevent corrupt filesystem images from causing weid errors.

- Properly handle a race between gfs2_create_inode() and
gfs2_inode_lookup() that causes insert_inode_locked4() to return
-EBUSY.

- Fix and clean up the interaction between gfs2_create_inode() and
gfs2_evict_inode() by completely handling the inode deallocation and
destruction in gfs2_evict_inode().

- Remove support for glock holder auto-demotion as we have no current
plans of using this feature again.

- And a few more minor cleanups and clarifications.

* tag 'gfs2-v6.1-rc7-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2:
gfs2: Remove support for glock holder auto-demotion (2)
gfs2: Remove support for glock holder auto-demotion
gfs2: Minor gfs2_try_evict cleanup
gfs2: Partially revert gfs2_inode_lookup change
gfs2: Add gfs2_inode_lookup comment
gfs2: Uninline and improve glock_{set,clear}_object
gfs2: Simply dequeue iopen glock in gfs2_evict_inode
gfs2: Clean up after gfs2_create_inode rework
gfs2: Avoid dequeuing GL_ASYNC glock holders twice
gfs2: Make gfs2_glock_hold return its glock argument
gfs2: Always check inode size of inline inodes
gfs2: Cosmetic gfs2_dinode_{in,out} cleanup
gfs2: Handle -EBUSY result of insert_inode_locked4
gfs2: Fix and clean up create / evict interaction
gfs2: Clean up initialization of "ip" in gfs2_create_inode
gfs2: Get rid of ghs[] in gfs2_create_inode
gfs2: Add extra error check in alloc_dinode

+234 -333
-2
fs/gfs2/aops.c
··· 427 427 return error; 428 428 429 429 kaddr = kmap_atomic(page); 430 - if (dsize > gfs2_max_stuffed_size(ip)) 431 - dsize = gfs2_max_stuffed_size(ip); 432 430 memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize); 433 431 memset(kaddr + dsize, 0, PAGE_SIZE - dsize); 434 432 kunmap_atomic(kaddr);
-3
fs/gfs2/bmap.c
··· 61 61 void *kaddr = kmap(page); 62 62 u64 dsize = i_size_read(inode); 63 63 64 - if (dsize > gfs2_max_stuffed_size(ip)) 65 - dsize = gfs2_max_stuffed_size(ip); 66 - 67 64 memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize); 68 65 memset(kaddr + dsize, 0, PAGE_SIZE - dsize); 69 66 kunmap(page);
+1 -2
fs/gfs2/file.c
··· 1445 1445 1446 1446 static void __flock_holder_uninit(struct file *file, struct gfs2_holder *fl_gh) 1447 1447 { 1448 - struct gfs2_glock *gl = fl_gh->gh_gl; 1448 + struct gfs2_glock *gl = gfs2_glock_hold(fl_gh->gh_gl); 1449 1449 1450 1450 /* 1451 1451 * Make sure gfs2_glock_put() won't sleep under the file->f_lock 1452 1452 * spinlock. 1453 1453 */ 1454 1454 1455 - gfs2_glock_hold(gl); 1456 1455 spin_lock(&file->f_lock); 1457 1456 gfs2_holder_uninit(fl_gh); 1458 1457 spin_unlock(&file->f_lock);
+99 -170
fs/gfs2/glock.c
··· 186 186 * 187 187 */ 188 188 189 - void gfs2_glock_hold(struct gfs2_glock *gl) 189 + struct gfs2_glock *gfs2_glock_hold(struct gfs2_glock *gl) 190 190 { 191 191 GLOCK_BUG_ON(gl, __lockref_is_dead(&gl->gl_lockref)); 192 192 lockref_get(&gl->gl_lockref); 193 + return gl; 193 194 } 194 195 195 196 /** ··· 206 205 207 206 if (gl->gl_state == LM_ST_UNLOCKED) 208 207 return 0; 209 - /* 210 - * Note that demote_ok is used for the lru process of disposing of 211 - * glocks. For this purpose, we don't care if the glock's holders 212 - * have the HIF_MAY_DEMOTE flag set or not. If someone is using 213 - * them, don't demote. 214 - */ 215 208 if (!list_empty(&gl->gl_holders)) 216 209 return 0; 217 210 if (glops->go_demote_ok) ··· 388 393 struct gfs2_holder *gh, *tmp; 389 394 390 395 list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) { 391 - if (!test_bit(HIF_WAIT, &gh->gh_iflags)) 396 + if (test_bit(HIF_HOLDER, &gh->gh_iflags)) 392 397 continue; 393 398 if (ret & LM_OUT_ERROR) 394 399 gh->gh_error = -EIO; ··· 399 404 list_del_init(&gh->gh_list); 400 405 trace_gfs2_glock_queue(gh, 0); 401 406 gfs2_holder_wake(gh); 402 - } 403 - } 404 - 405 - /** 406 - * demote_incompat_holders - demote incompatible demoteable holders 407 - * @gl: the glock we want to promote 408 - * @current_gh: the newly promoted holder 409 - * 410 - * We're passing the newly promoted holder in @current_gh, but actually, any of 411 - * the strong holders would do. 412 - */ 413 - static void demote_incompat_holders(struct gfs2_glock *gl, 414 - struct gfs2_holder *current_gh) 415 - { 416 - struct gfs2_holder *gh, *tmp; 417 - 418 - /* 419 - * Demote incompatible holders before we make ourselves eligible. 420 - * (This holder may or may not allow auto-demoting, but we don't want 421 - * to demote the new holder before it's even granted.) 422 - */ 423 - list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) { 424 - /* 425 - * Since holders are at the front of the list, we stop when we 426 - * find the first non-holder. 427 - */ 428 - if (!test_bit(HIF_HOLDER, &gh->gh_iflags)) 429 - return; 430 - if (gh == current_gh) 431 - continue; 432 - if (test_bit(HIF_MAY_DEMOTE, &gh->gh_iflags) && 433 - !may_grant(gl, current_gh, gh)) { 434 - /* 435 - * We should not recurse into do_promote because 436 - * __gfs2_glock_dq only calls handle_callback, 437 - * gfs2_glock_add_to_lru and __gfs2_glock_queue_work. 438 - */ 439 - __gfs2_glock_dq(gh); 440 - } 441 407 } 442 408 } 443 409 ··· 415 459 gh = list_first_entry(&gl->gl_holders, struct gfs2_holder, 416 460 gh_list); 417 461 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) 418 - return gh; 419 - } 420 - return NULL; 421 - } 422 - 423 - /** 424 - * find_first_strong_holder - find the first non-demoteable holder 425 - * @gl: the glock 426 - * 427 - * Find the first holder that doesn't have the HIF_MAY_DEMOTE flag set. 428 - */ 429 - static inline struct gfs2_holder * 430 - find_first_strong_holder(struct gfs2_glock *gl) 431 - { 432 - struct gfs2_holder *gh; 433 - 434 - list_for_each_entry(gh, &gl->gl_holders, gh_list) { 435 - if (!test_bit(HIF_HOLDER, &gh->gh_iflags)) 436 - return NULL; 437 - if (!test_bit(HIF_MAY_DEMOTE, &gh->gh_iflags)) 438 462 return gh; 439 463 } 440 464 return NULL; ··· 476 540 static int do_promote(struct gfs2_glock *gl) 477 541 { 478 542 struct gfs2_holder *gh, *current_gh; 479 - bool incompat_holders_demoted = false; 480 543 481 - current_gh = find_first_strong_holder(gl); 544 + current_gh = find_first_holder(gl); 482 545 list_for_each_entry(gh, &gl->gl_holders, gh_list) { 483 546 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) 484 547 continue; ··· 496 561 set_bit(HIF_HOLDER, &gh->gh_iflags); 497 562 trace_gfs2_promote(gh); 498 563 gfs2_holder_wake(gh); 499 - if (!incompat_holders_demoted) { 564 + if (!current_gh) 500 565 current_gh = gh; 501 - demote_incompat_holders(gl, current_gh); 502 - incompat_holders_demoted = true; 503 - } 504 566 } 505 567 return 0; 506 568 } ··· 859 927 return; 860 928 } 861 929 930 + /** 931 + * glock_set_object - set the gl_object field of a glock 932 + * @gl: the glock 933 + * @object: the object 934 + */ 935 + void glock_set_object(struct gfs2_glock *gl, void *object) 936 + { 937 + void *prev_object; 938 + 939 + spin_lock(&gl->gl_lockref.lock); 940 + prev_object = gl->gl_object; 941 + gl->gl_object = object; 942 + spin_unlock(&gl->gl_lockref.lock); 943 + if (gfs2_assert_warn(gl->gl_name.ln_sbd, prev_object == NULL)) { 944 + pr_warn("glock=%u/%llx\n", 945 + gl->gl_name.ln_type, 946 + (unsigned long long)gl->gl_name.ln_number); 947 + gfs2_dump_glock(NULL, gl, true); 948 + } 949 + } 950 + 951 + /** 952 + * glock_clear_object - clear the gl_object field of a glock 953 + * @gl: the glock 954 + */ 955 + void glock_clear_object(struct gfs2_glock *gl, void *object) 956 + { 957 + void *prev_object; 958 + 959 + spin_lock(&gl->gl_lockref.lock); 960 + prev_object = gl->gl_object; 961 + gl->gl_object = NULL; 962 + spin_unlock(&gl->gl_lockref.lock); 963 + if (gfs2_assert_warn(gl->gl_name.ln_sbd, 964 + prev_object == object || prev_object == NULL)) { 965 + pr_warn("glock=%u/%llx\n", 966 + gl->gl_name.ln_type, 967 + (unsigned long long)gl->gl_name.ln_number); 968 + gfs2_dump_glock(NULL, gl, true); 969 + } 970 + } 971 + 862 972 void gfs2_inode_remember_delete(struct gfs2_glock *gl, u64 generation) 863 973 { 864 974 struct gfs2_inode_lvb *ri = (void *)gl->gl_lksb.sb_lvbptr; ··· 954 980 ip = NULL; 955 981 spin_unlock(&gl->gl_lockref.lock); 956 982 if (ip) { 957 - struct gfs2_glock *inode_gl = NULL; 958 - 959 983 gl->gl_no_formal_ino = ip->i_no_formal_ino; 960 984 set_bit(GIF_DEFERRED_DELETE, &ip->i_flags); 961 985 d_prune_aliases(&ip->i_inode); ··· 963 991 spin_lock(&gl->gl_lockref.lock); 964 992 ip = gl->gl_object; 965 993 if (ip) { 966 - inode_gl = ip->i_gl; 967 - lockref_get(&inode_gl->gl_lockref); 968 994 clear_bit(GIF_DEFERRED_DELETE, &ip->i_flags); 995 + if (!igrab(&ip->i_inode)) 996 + ip = NULL; 969 997 } 970 998 spin_unlock(&gl->gl_lockref.lock); 971 - if (inode_gl) { 972 - gfs2_glock_poke(inode_gl); 973 - gfs2_glock_put(inode_gl); 999 + if (ip) { 1000 + gfs2_glock_poke(ip->i_gl); 1001 + iput(&ip->i_inode); 974 1002 } 975 1003 evicted = !ip; 976 1004 } ··· 1011 1039 if (gfs2_queue_delete_work(gl, 5 * HZ)) 1012 1040 return; 1013 1041 } 1042 + goto out; 1014 1043 } 1015 1044 1016 1045 inode = gfs2_lookup_by_inum(sdp, no_addr, gl->gl_no_formal_ino, ··· 1024 1051 d_prune_aliases(inode); 1025 1052 iput(inode); 1026 1053 } 1054 + out: 1027 1055 gfs2_glock_put(gl); 1028 1056 } 1029 1057 ··· 1230 1256 struct gfs2_holder *gh, unsigned long ip) 1231 1257 { 1232 1258 INIT_LIST_HEAD(&gh->gh_list); 1233 - gh->gh_gl = gl; 1259 + gh->gh_gl = gfs2_glock_hold(gl); 1234 1260 gh->gh_ip = ip; 1235 1261 gh->gh_owner_pid = get_pid(task_pid(current)); 1236 1262 gh->gh_state = state; 1237 1263 gh->gh_flags = flags; 1238 1264 gh->gh_iflags = 0; 1239 - gfs2_glock_hold(gl); 1240 1265 } 1241 1266 1242 1267 /** ··· 1469 1496 if (test_bit(GLF_LOCK, &gl->gl_flags)) { 1470 1497 struct gfs2_holder *current_gh; 1471 1498 1472 - current_gh = find_first_strong_holder(gl); 1499 + current_gh = find_first_holder(gl); 1473 1500 try_futile = !may_grant(gl, current_gh, gh); 1474 1501 } 1475 1502 if (test_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags)) ··· 1480 1507 if (likely(gh2->gh_owner_pid != gh->gh_owner_pid)) 1481 1508 continue; 1482 1509 if (gh->gh_gl->gl_ops->go_type == LM_TYPE_FLOCK) 1483 - continue; 1484 - if (test_bit(HIF_MAY_DEMOTE, &gh2->gh_iflags)) 1485 1510 continue; 1486 1511 if (!pid_is_meaningful(gh2)) 1487 1512 continue; ··· 1590 1619 static void __gfs2_glock_dq(struct gfs2_holder *gh) 1591 1620 { 1592 1621 struct gfs2_glock *gl = gh->gh_gl; 1593 - struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; 1594 1622 unsigned delay = 0; 1595 1623 int fast_path = 0; 1596 1624 1597 1625 /* 1598 - * This while loop is similar to function demote_incompat_holders: 1599 - * If the glock is due to be demoted (which may be from another node 1600 - * or even if this holder is GL_NOCACHE), the weak holders are 1601 - * demoted as well, allowing the glock to be demoted. 1626 + * This holder should not be cached, so mark it for demote. 1627 + * Note: this should be done before the check for needs_demote 1628 + * below. 1602 1629 */ 1603 - while (gh) { 1604 - /* 1605 - * If we're in the process of file system withdraw, we cannot 1606 - * just dequeue any glocks until our journal is recovered, lest 1607 - * we introduce file system corruption. We need two exceptions 1608 - * to this rule: We need to allow unlocking of nondisk glocks 1609 - * and the glock for our own journal that needs recovery. 1610 - */ 1611 - if (test_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags) && 1612 - glock_blocked_by_withdraw(gl) && 1613 - gh->gh_gl != sdp->sd_jinode_gl) { 1614 - sdp->sd_glock_dqs_held++; 1615 - spin_unlock(&gl->gl_lockref.lock); 1616 - might_sleep(); 1617 - wait_on_bit(&sdp->sd_flags, SDF_WITHDRAW_RECOVERY, 1618 - TASK_UNINTERRUPTIBLE); 1619 - spin_lock(&gl->gl_lockref.lock); 1620 - } 1630 + if (gh->gh_flags & GL_NOCACHE) 1631 + handle_callback(gl, LM_ST_UNLOCKED, 0, false); 1621 1632 1622 - /* 1623 - * This holder should not be cached, so mark it for demote. 1624 - * Note: this should be done before the check for needs_demote 1625 - * below. 1626 - */ 1627 - if (gh->gh_flags & GL_NOCACHE) 1628 - handle_callback(gl, LM_ST_UNLOCKED, 0, false); 1633 + list_del_init(&gh->gh_list); 1634 + clear_bit(HIF_HOLDER, &gh->gh_iflags); 1635 + trace_gfs2_glock_queue(gh, 0); 1629 1636 1630 - list_del_init(&gh->gh_list); 1631 - clear_bit(HIF_HOLDER, &gh->gh_iflags); 1632 - trace_gfs2_glock_queue(gh, 0); 1633 - 1634 - /* 1635 - * If there hasn't been a demote request we are done. 1636 - * (Let the remaining holders, if any, keep holding it.) 1637 - */ 1638 - if (!needs_demote(gl)) { 1639 - if (list_empty(&gl->gl_holders)) 1640 - fast_path = 1; 1641 - break; 1642 - } 1643 - /* 1644 - * If we have another strong holder (we cannot auto-demote) 1645 - * we are done. It keeps holding it until it is done. 1646 - */ 1647 - if (find_first_strong_holder(gl)) 1648 - break; 1649 - 1650 - /* 1651 - * If we have a weak holder at the head of the list, it 1652 - * (and all others like it) must be auto-demoted. If there 1653 - * are no more weak holders, we exit the while loop. 1654 - */ 1655 - gh = find_first_holder(gl); 1637 + /* 1638 + * If there hasn't been a demote request we are done. 1639 + * (Let the remaining holders, if any, keep holding it.) 1640 + */ 1641 + if (!needs_demote(gl)) { 1642 + if (list_empty(&gl->gl_holders)) 1643 + fast_path = 1; 1656 1644 } 1657 1645 1658 1646 if (!test_bit(GLF_LFLUSH, &gl->gl_flags) && demote_ok(gl)) ··· 1635 1705 void gfs2_glock_dq(struct gfs2_holder *gh) 1636 1706 { 1637 1707 struct gfs2_glock *gl = gh->gh_gl; 1708 + struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; 1638 1709 1639 1710 spin_lock(&gl->gl_lockref.lock); 1711 + if (!gfs2_holder_queued(gh)) { 1712 + /* 1713 + * May have already been dequeued because the locking request 1714 + * was GL_ASYNC and it has failed in the meantime. 1715 + */ 1716 + goto out; 1717 + } 1718 + 1640 1719 if (list_is_first(&gh->gh_list, &gl->gl_holders) && 1641 1720 !test_bit(HIF_HOLDER, &gh->gh_iflags)) { 1642 1721 spin_unlock(&gl->gl_lockref.lock); ··· 1654 1715 spin_lock(&gl->gl_lockref.lock); 1655 1716 } 1656 1717 1718 + /* 1719 + * If we're in the process of file system withdraw, we cannot just 1720 + * dequeue any glocks until our journal is recovered, lest we introduce 1721 + * file system corruption. We need two exceptions to this rule: We need 1722 + * to allow unlocking of nondisk glocks and the glock for our own 1723 + * journal that needs recovery. 1724 + */ 1725 + if (test_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags) && 1726 + glock_blocked_by_withdraw(gl) && 1727 + gh->gh_gl != sdp->sd_jinode_gl) { 1728 + sdp->sd_glock_dqs_held++; 1729 + spin_unlock(&gl->gl_lockref.lock); 1730 + might_sleep(); 1731 + wait_on_bit(&sdp->sd_flags, SDF_WITHDRAW_RECOVERY, 1732 + TASK_UNINTERRUPTIBLE); 1733 + spin_lock(&gl->gl_lockref.lock); 1734 + } 1735 + 1657 1736 __gfs2_glock_dq(gh); 1737 + out: 1658 1738 spin_unlock(&gl->gl_lockref.lock); 1659 1739 } 1660 1740 ··· 1845 1887 delay = holdtime - now; 1846 1888 if (test_bit(GLF_REPLY_PENDING, &gl->gl_flags)) 1847 1889 delay = gl->gl_hold_time; 1848 - } 1849 - /* 1850 - * Note 1: We cannot call demote_incompat_holders from handle_callback 1851 - * or gfs2_set_demote due to recursion problems like: gfs2_glock_dq -> 1852 - * handle_callback -> demote_incompat_holders -> gfs2_glock_dq 1853 - * Plus, we only want to demote the holders if the request comes from 1854 - * a remote cluster node because local holder conflicts are resolved 1855 - * elsewhere. 1856 - * 1857 - * Note 2: if a remote node wants this glock in EX mode, lock_dlm will 1858 - * request that we set our state to UNLOCKED. Here we mock up a holder 1859 - * to make it look like someone wants the lock EX locally. Any SH 1860 - * and DF requests should be able to share the lock without demoting. 1861 - * 1862 - * Note 3: We only want to demote the demoteable holders when there 1863 - * are no more strong holders. The demoteable holders might as well 1864 - * keep the glock until the last strong holder is done with it. 1865 - */ 1866 - if (!find_first_strong_holder(gl)) { 1867 - struct gfs2_holder mock_gh = { 1868 - .gh_gl = gl, 1869 - .gh_state = (state == LM_ST_UNLOCKED) ? 1870 - LM_ST_EXCLUSIVE : state, 1871 - .gh_iflags = BIT(HIF_HOLDER) 1872 - }; 1873 - 1874 - demote_incompat_holders(gl, &mock_gh); 1875 1890 } 1876 1891 handle_callback(gl, state, delay, true); 1877 1892 __gfs2_glock_queue_work(gl, delay); ··· 2237 2306 *p++ = 'H'; 2238 2307 if (test_bit(HIF_WAIT, &iflags)) 2239 2308 *p++ = 'W'; 2240 - if (test_bit(HIF_MAY_DEMOTE, &iflags)) 2241 - *p++ = 'D'; 2242 2309 if (flags & GL_SKIP) 2243 2310 *p++ = 's'; 2244 2311 *p = 0;
+4 -61
fs/gfs2/glock.h
··· 156 156 list_for_each_entry(gh, &gl->gl_holders, gh_list) { 157 157 if (!test_bit(HIF_HOLDER, &gh->gh_iflags)) 158 158 break; 159 - if (test_bit(HIF_MAY_DEMOTE, &gh->gh_iflags)) 160 - continue; 161 159 if (gh->gh_owner_pid == pid) 162 160 goto out; 163 161 } ··· 194 196 extern int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, 195 197 const struct gfs2_glock_operations *glops, 196 198 int create, struct gfs2_glock **glp); 197 - extern void gfs2_glock_hold(struct gfs2_glock *gl); 199 + extern struct gfs2_glock *gfs2_glock_hold(struct gfs2_glock *gl); 198 200 extern void gfs2_glock_put(struct gfs2_glock *gl); 199 201 extern void gfs2_glock_queue_put(struct gfs2_glock *gl); 200 202 ··· 286 288 extern void gfs2_register_debugfs(void); 287 289 extern void gfs2_unregister_debugfs(void); 288 290 291 + extern void glock_set_object(struct gfs2_glock *gl, void *object); 292 + extern void glock_clear_object(struct gfs2_glock *gl, void *object); 293 + 289 294 extern const struct lm_lockops gfs2_dlm_ops; 290 295 291 296 static inline void gfs2_holder_mark_uninitialized(struct gfs2_holder *gh) ··· 304 303 static inline bool gfs2_holder_queued(struct gfs2_holder *gh) 305 304 { 306 305 return !list_empty(&gh->gh_list); 307 - } 308 - 309 - /** 310 - * glock_set_object - set the gl_object field of a glock 311 - * @gl: the glock 312 - * @object: the object 313 - */ 314 - static inline void glock_set_object(struct gfs2_glock *gl, void *object) 315 - { 316 - spin_lock(&gl->gl_lockref.lock); 317 - if (gfs2_assert_warn(gl->gl_name.ln_sbd, gl->gl_object == NULL)) 318 - gfs2_dump_glock(NULL, gl, true); 319 - gl->gl_object = object; 320 - spin_unlock(&gl->gl_lockref.lock); 321 - } 322 - 323 - /** 324 - * glock_clear_object - clear the gl_object field of a glock 325 - * @gl: the glock 326 - * @object: the object 327 - * 328 - * I'd love to similarly add this: 329 - * else if (gfs2_assert_warn(gl->gl_sbd, gl->gl_object == object)) 330 - * gfs2_dump_glock(NULL, gl, true); 331 - * Unfortunately, that's not possible because as soon as gfs2_delete_inode 332 - * frees the block in the rgrp, another process can reassign it for an I_NEW 333 - * inode in gfs2_create_inode because that calls new_inode, not gfs2_iget. 334 - * That means gfs2_delete_inode may subsequently try to call this function 335 - * for a glock that's already pointing to a brand new inode. If we clear the 336 - * new inode's gl_object, we'll introduce metadata corruption. Function 337 - * gfs2_delete_inode calls clear_inode which calls gfs2_clear_inode which also 338 - * tries to clear gl_object, so it's more than just gfs2_delete_inode. 339 - * 340 - */ 341 - static inline void glock_clear_object(struct gfs2_glock *gl, void *object) 342 - { 343 - spin_lock(&gl->gl_lockref.lock); 344 - if (gl->gl_object == object) 345 - gl->gl_object = NULL; 346 - spin_unlock(&gl->gl_lockref.lock); 347 - } 348 - 349 - static inline void gfs2_holder_allow_demote(struct gfs2_holder *gh) 350 - { 351 - struct gfs2_glock *gl = gh->gh_gl; 352 - 353 - spin_lock(&gl->gl_lockref.lock); 354 - set_bit(HIF_MAY_DEMOTE, &gh->gh_iflags); 355 - spin_unlock(&gl->gl_lockref.lock); 356 - } 357 - 358 - static inline void gfs2_holder_disallow_demote(struct gfs2_holder *gh) 359 - { 360 - struct gfs2_glock *gl = gh->gh_gl; 361 - 362 - spin_lock(&gl->gl_lockref.lock); 363 - clear_bit(HIF_MAY_DEMOTE, &gh->gh_iflags); 364 - spin_unlock(&gl->gl_lockref.lock); 365 306 } 366 307 367 308 extern void gfs2_inode_remember_delete(struct gfs2_glock *gl, u64 generation);
+24 -20
fs/gfs2/glops.c
··· 397 397 struct timespec64 atime; 398 398 u16 height, depth; 399 399 umode_t mode = be32_to_cpu(str->di_mode); 400 - bool is_new = ip->i_inode.i_state & I_NEW; 400 + struct inode *inode = &ip->i_inode; 401 + bool is_new = inode->i_state & I_NEW; 401 402 402 403 if (unlikely(ip->i_no_addr != be64_to_cpu(str->di_num.no_addr))) 403 404 goto corrupt; 404 - if (unlikely(!is_new && inode_wrong_type(&ip->i_inode, mode))) 405 + if (unlikely(!is_new && inode_wrong_type(inode, mode))) 405 406 goto corrupt; 406 407 ip->i_no_formal_ino = be64_to_cpu(str->di_num.no_formal_ino); 407 - ip->i_inode.i_mode = mode; 408 + inode->i_mode = mode; 408 409 if (is_new) { 409 - ip->i_inode.i_rdev = 0; 410 + inode->i_rdev = 0; 410 411 switch (mode & S_IFMT) { 411 412 case S_IFBLK: 412 413 case S_IFCHR: 413 - ip->i_inode.i_rdev = MKDEV(be32_to_cpu(str->di_major), 414 - be32_to_cpu(str->di_minor)); 414 + inode->i_rdev = MKDEV(be32_to_cpu(str->di_major), 415 + be32_to_cpu(str->di_minor)); 415 416 break; 416 417 } 417 418 } 418 419 419 - i_uid_write(&ip->i_inode, be32_to_cpu(str->di_uid)); 420 - i_gid_write(&ip->i_inode, be32_to_cpu(str->di_gid)); 421 - set_nlink(&ip->i_inode, be32_to_cpu(str->di_nlink)); 422 - i_size_write(&ip->i_inode, be64_to_cpu(str->di_size)); 423 - gfs2_set_inode_blocks(&ip->i_inode, be64_to_cpu(str->di_blocks)); 420 + i_uid_write(inode, be32_to_cpu(str->di_uid)); 421 + i_gid_write(inode, be32_to_cpu(str->di_gid)); 422 + set_nlink(inode, be32_to_cpu(str->di_nlink)); 423 + i_size_write(inode, be64_to_cpu(str->di_size)); 424 + gfs2_set_inode_blocks(inode, be64_to_cpu(str->di_blocks)); 424 425 atime.tv_sec = be64_to_cpu(str->di_atime); 425 426 atime.tv_nsec = be32_to_cpu(str->di_atime_nsec); 426 - if (timespec64_compare(&ip->i_inode.i_atime, &atime) < 0) 427 - ip->i_inode.i_atime = atime; 428 - ip->i_inode.i_mtime.tv_sec = be64_to_cpu(str->di_mtime); 429 - ip->i_inode.i_mtime.tv_nsec = be32_to_cpu(str->di_mtime_nsec); 430 - ip->i_inode.i_ctime.tv_sec = be64_to_cpu(str->di_ctime); 431 - ip->i_inode.i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec); 427 + if (timespec64_compare(&inode->i_atime, &atime) < 0) 428 + inode->i_atime = atime; 429 + inode->i_mtime.tv_sec = be64_to_cpu(str->di_mtime); 430 + inode->i_mtime.tv_nsec = be32_to_cpu(str->di_mtime_nsec); 431 + inode->i_ctime.tv_sec = be64_to_cpu(str->di_ctime); 432 + inode->i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec); 432 433 433 434 ip->i_goal = be64_to_cpu(str->di_goal_meta); 434 435 ip->i_generation = be64_to_cpu(str->di_generation); ··· 437 436 ip->i_diskflags = be32_to_cpu(str->di_flags); 438 437 ip->i_eattr = be64_to_cpu(str->di_eattr); 439 438 /* i_diskflags and i_eattr must be set before gfs2_set_inode_flags() */ 440 - gfs2_set_inode_flags(&ip->i_inode); 439 + gfs2_set_inode_flags(inode); 441 440 height = be16_to_cpu(str->di_height); 442 441 if (unlikely(height > GFS2_MAX_META_HEIGHT)) 443 442 goto corrupt; ··· 449 448 ip->i_depth = (u8)depth; 450 449 ip->i_entries = be32_to_cpu(str->di_entries); 451 450 452 - if (S_ISREG(ip->i_inode.i_mode)) 453 - gfs2_set_aops(&ip->i_inode); 451 + if (gfs2_is_stuffed(ip) && inode->i_size > gfs2_max_stuffed_size(ip)) 452 + goto corrupt; 453 + 454 + if (S_ISREG(inode->i_mode)) 455 + gfs2_set_aops(inode); 454 456 455 457 return 0; 456 458 corrupt:
-1
fs/gfs2/incore.h
··· 252 252 253 253 enum { 254 254 /* States */ 255 - HIF_MAY_DEMOTE = 1, 256 255 HIF_HOLDER = 6, /* Set for gh that "holds" the glock */ 257 256 HIF_WAIT = 10, 258 257 };
+37 -27
fs/gfs2/inode.c
··· 142 142 if (unlikely(error)) 143 143 goto fail; 144 144 145 + /* 146 + * The only caller that sets @blktype to GFS2_BLKST_UNLINKED is 147 + * delete_work_func(). Make sure not to cancel the delete work 148 + * from within itself here. 149 + */ 145 150 if (blktype == GFS2_BLKST_UNLINKED) 146 151 extra_flags |= LM_FLAG_TRY; 147 152 else ··· 408 403 goto out_ipreserv; 409 404 410 405 error = gfs2_alloc_blocks(ip, &ip->i_no_addr, dblocks, 1, &ip->i_generation); 406 + if (error) 407 + goto out_trans_end; 408 + 411 409 ip->i_no_formal_ino = ip->i_generation; 412 410 ip->i_inode.i_ino = ip->i_no_addr; 413 411 ip->i_goal = ip->i_no_addr; 412 + if (*dblocks > 1) 413 + ip->i_eattr = ip->i_no_addr + 1; 414 414 415 + out_trans_end: 415 416 gfs2_trans_end(sdp); 416 - 417 417 out_ipreserv: 418 418 gfs2_inplace_release(ip); 419 419 out_quota: ··· 596 586 * @size: The initial size of the inode (ignored for directories) 597 587 * @excl: Force fail if inode exists 598 588 * 589 + * FIXME: Change to allocate the disk blocks and write them out in the same 590 + * transaction. That way, we can no longer end up in a situation in which an 591 + * inode is allocated, the node crashes, and the block looks like a valid 592 + * inode. (With atomic creates in place, we will also no longer need to zero 593 + * the link count and dirty the inode here on failure.) 594 + * 599 595 * Returns: 0 on success, or error code 600 596 */ 601 597 ··· 612 596 { 613 597 const struct qstr *name = &dentry->d_name; 614 598 struct posix_acl *default_acl, *acl; 615 - struct gfs2_holder ghs[2]; 599 + struct gfs2_holder d_gh, gh; 616 600 struct inode *inode = NULL; 617 601 struct gfs2_inode *dip = GFS2_I(dir), *ip; 618 602 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 619 603 struct gfs2_glock *io_gl; 620 - int error, free_vfs_inode = 1; 604 + int error; 621 605 u32 aflags = 0; 622 606 unsigned blocks = 1; 623 607 struct gfs2_diradd da = { .bh = NULL, .save_loc = 1, }; ··· 633 617 if (error) 634 618 goto fail; 635 619 636 - error = gfs2_glock_nq_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); 620 + error = gfs2_glock_nq_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, &d_gh); 637 621 if (error) 638 622 goto fail; 639 - gfs2_holder_mark_uninitialized(ghs + 1); 623 + gfs2_holder_mark_uninitialized(&gh); 640 624 641 625 error = create_ok(dip, name, mode); 642 626 if (error) ··· 658 642 else 659 643 error = finish_no_open(file, NULL); 660 644 } 661 - gfs2_glock_dq_uninit(ghs); 645 + gfs2_glock_dq_uninit(&d_gh); 662 646 goto fail; 663 647 } else if (error != -ENOENT) { 664 648 goto fail_gunlock; ··· 672 656 error = -ENOMEM; 673 657 if (!inode) 674 658 goto fail_gunlock; 659 + ip = GFS2_I(inode); 675 660 676 661 error = posix_acl_create(dir, &mode, &default_acl, &acl); 677 662 if (error) 678 663 goto fail_gunlock; 679 664 680 - ip = GFS2_I(inode); 681 665 error = gfs2_qa_get(ip); 682 666 if (error) 683 667 goto fail_free_acls; ··· 739 723 goto fail_free_inode; 740 724 gfs2_cancel_delete_work(io_gl); 741 725 726 + retry: 742 727 error = insert_inode_locked4(inode, ip->i_no_addr, iget_test, &ip->i_no_addr); 743 - BUG_ON(error); 728 + if (error == -EBUSY) 729 + goto retry; 730 + if (error) 731 + goto fail_gunlock2; 744 732 745 733 error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT | GL_NOPID, 746 734 &ip->i_iopen_gh); 747 735 if (error) 748 736 goto fail_gunlock2; 749 737 750 - error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_SKIP, ghs + 1); 738 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_SKIP, &gh); 751 739 if (error) 752 740 goto fail_gunlock3; 753 741 ··· 759 739 if (error) 760 740 goto fail_gunlock3; 761 741 762 - if (blocks > 1) { 763 - ip->i_eattr = ip->i_no_addr + 1; 742 + if (blocks > 1) 764 743 gfs2_init_xattr(ip); 765 - } 766 744 init_dinode(dip, ip, symname); 767 745 gfs2_trans_end(sdp); 768 746 ··· 768 750 glock_set_object(io_gl, ip); 769 751 gfs2_set_iop(inode); 770 752 771 - free_vfs_inode = 0; /* After this point, the inode is no longer 772 - considered free. Any failures need to undo 773 - the gfs2 structures. */ 774 753 if (default_acl) { 775 754 error = __gfs2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); 776 755 if (error) ··· 800 785 file->f_mode |= FMODE_CREATED; 801 786 error = finish_open(file, dentry, gfs2_open_common); 802 787 } 803 - gfs2_glock_dq_uninit(ghs); 788 + gfs2_glock_dq_uninit(&d_gh); 804 789 gfs2_qa_put(ip); 805 - gfs2_glock_dq_uninit(ghs + 1); 790 + gfs2_glock_dq_uninit(&gh); 806 791 gfs2_glock_put(io_gl); 807 792 gfs2_qa_put(dip); 808 793 unlock_new_inode(inode); ··· 816 801 fail_gunlock2: 817 802 gfs2_glock_put(io_gl); 818 803 fail_free_inode: 819 - if (ip->i_gl) { 820 - if (free_vfs_inode) /* else evict will do the put for us */ 821 - gfs2_glock_put(ip->i_gl); 822 - } 823 804 gfs2_rs_deltree(&ip->i_res); 824 805 gfs2_qa_put(ip); 825 806 fail_free_acls: ··· 823 812 posix_acl_release(acl); 824 813 fail_gunlock: 825 814 gfs2_dir_no_add(&da); 826 - gfs2_glock_dq_uninit(ghs); 815 + gfs2_glock_dq_uninit(&d_gh); 827 816 if (!IS_ERR_OR_NULL(inode)) { 817 + set_bit(GIF_ALLOC_FAILED, &ip->i_flags); 828 818 clear_nlink(inode); 829 - if (!free_vfs_inode) 819 + if (ip->i_no_addr) 830 820 mark_inode_dirty(inode); 831 - set_bit(free_vfs_inode ? GIF_FREE_VFS_INODE : GIF_ALLOC_FAILED, 832 - &GFS2_I(inode)->i_flags); 833 821 if (inode->i_state & I_NEW) 834 822 iget_failed(inode); 835 823 else 836 824 iput(inode); 837 825 } 838 - if (gfs2_holder_initialized(ghs + 1)) 839 - gfs2_glock_dq_uninit(ghs + 1); 826 + if (gfs2_holder_initialized(&gh)) 827 + gfs2_glock_dq_uninit(&gh); 840 828 fail: 841 829 gfs2_qa_put(dip); 842 830 return error;
+6
fs/gfs2/meta_io.c
··· 442 442 struct buffer_head *bh; 443 443 int ty; 444 444 445 + if (!ip->i_gl) { 446 + /* This can only happen during incomplete inode creation. */ 447 + BUG_ON(!test_bit(GIF_ALLOC_FAILED, &ip->i_flags)); 448 + return; 449 + } 450 + 445 451 gfs2_ail1_wipe(sdp, bstart, blen); 446 452 while (blen) { 447 453 ty = REMOVE_META;
+48 -36
fs/gfs2/super.c
··· 379 379 380 380 void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf) 381 381 { 382 + const struct inode *inode = &ip->i_inode; 382 383 struct gfs2_dinode *str = buf; 383 384 384 385 str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC); ··· 387 386 str->di_header.mh_format = cpu_to_be32(GFS2_FORMAT_DI); 388 387 str->di_num.no_addr = cpu_to_be64(ip->i_no_addr); 389 388 str->di_num.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino); 390 - str->di_mode = cpu_to_be32(ip->i_inode.i_mode); 391 - str->di_uid = cpu_to_be32(i_uid_read(&ip->i_inode)); 392 - str->di_gid = cpu_to_be32(i_gid_read(&ip->i_inode)); 393 - str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink); 394 - str->di_size = cpu_to_be64(i_size_read(&ip->i_inode)); 395 - str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode)); 396 - str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec); 397 - str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec); 398 - str->di_ctime = cpu_to_be64(ip->i_inode.i_ctime.tv_sec); 389 + str->di_mode = cpu_to_be32(inode->i_mode); 390 + str->di_uid = cpu_to_be32(i_uid_read(inode)); 391 + str->di_gid = cpu_to_be32(i_gid_read(inode)); 392 + str->di_nlink = cpu_to_be32(inode->i_nlink); 393 + str->di_size = cpu_to_be64(i_size_read(inode)); 394 + str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(inode)); 395 + str->di_atime = cpu_to_be64(inode->i_atime.tv_sec); 396 + str->di_mtime = cpu_to_be64(inode->i_mtime.tv_sec); 397 + str->di_ctime = cpu_to_be64(inode->i_ctime.tv_sec); 399 398 400 399 str->di_goal_meta = cpu_to_be64(ip->i_goal); 401 400 str->di_goal_data = cpu_to_be64(ip->i_goal); ··· 403 402 404 403 str->di_flags = cpu_to_be32(ip->i_diskflags); 405 404 str->di_height = cpu_to_be16(ip->i_height); 406 - str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) && 405 + str->di_payload_format = cpu_to_be32(S_ISDIR(inode->i_mode) && 407 406 !(ip->i_diskflags & GFS2_DIF_EXHASH) ? 408 407 GFS2_FORMAT_DE : 0); 409 408 str->di_depth = cpu_to_be16(ip->i_depth); 410 409 str->di_entries = cpu_to_be32(ip->i_entries); 411 410 412 411 str->di_eattr = cpu_to_be64(ip->i_eattr); 413 - str->di_atime_nsec = cpu_to_be32(ip->i_inode.i_atime.tv_nsec); 414 - str->di_mtime_nsec = cpu_to_be32(ip->i_inode.i_mtime.tv_nsec); 415 - str->di_ctime_nsec = cpu_to_be32(ip->i_inode.i_ctime.tv_nsec); 412 + str->di_atime_nsec = cpu_to_be32(inode->i_atime.tv_nsec); 413 + str->di_mtime_nsec = cpu_to_be32(inode->i_mtime.tv_nsec); 414 + str->di_ctime_nsec = cpu_to_be32(inode->i_ctime.tv_nsec); 416 415 } 417 416 418 417 /** ··· 475 474 int need_unlock = 0; 476 475 int need_endtrans = 0; 477 476 int ret; 477 + 478 + if (unlikely(!ip->i_gl)) { 479 + /* This can only happen during incomplete inode creation. */ 480 + BUG_ON(!test_bit(GIF_ALLOC_FAILED, &ip->i_flags)); 481 + return; 482 + } 478 483 479 484 if (unlikely(gfs2_withdrawn(sdp))) 480 485 return; ··· 934 927 { 935 928 struct gfs2_inode *ip = GFS2_I(inode); 936 929 937 - if (!test_bit(GIF_FREE_VFS_INODE, &ip->i_flags) && 938 - inode->i_nlink && 930 + if (inode->i_nlink && 939 931 gfs2_holder_initialized(&ip->i_iopen_gh)) { 940 932 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl; 941 933 if (test_bit(GLF_DEMOTE, &gl->gl_flags)) ··· 1082 1076 struct inode *inode = &ip->i_inode; 1083 1077 struct gfs2_glock *gl = ip->i_gl; 1084 1078 1085 - truncate_inode_pages(gfs2_glock2aspace(ip->i_gl), 0); 1079 + if (unlikely(!gl)) { 1080 + /* This can only happen during incomplete inode creation. */ 1081 + BUG_ON(!test_bit(GIF_ALLOC_FAILED, &ip->i_flags)); 1082 + return; 1083 + } 1084 + 1085 + truncate_inode_pages(gfs2_glock2aspace(gl), 0); 1086 1086 truncate_inode_pages(&inode->i_data, 0); 1087 1087 1088 1088 if (atomic_read(&gl->gl_revokes) == 0) { ··· 1230 1218 struct gfs2_sbd *sdp = sb->s_fs_info; 1231 1219 int ret; 1232 1220 1233 - if (test_bit(GIF_ALLOC_FAILED, &ip->i_flags)) { 1234 - BUG_ON(!gfs2_glock_is_locked_by_me(ip->i_gl)); 1221 + if (unlikely(test_bit(GIF_ALLOC_FAILED, &ip->i_flags))) 1235 1222 goto should_delete; 1236 - } 1237 1223 1238 1224 if (test_bit(GIF_DEFERRED_DELETE, &ip->i_flags)) 1239 1225 return SHOULD_DEFER_EVICTION; ··· 1304 1294 goto out; 1305 1295 } 1306 1296 1307 - /* We're about to clear the bitmap for the dinode, but as soon as we 1308 - do, gfs2_create_inode can create another inode at the same block 1309 - location and try to set gl_object again. We clear gl_object here so 1310 - that subsequent inode creates don't see an old gl_object. */ 1311 - glock_clear_object(ip->i_gl, ip); 1297 + if (ip->i_gl) 1298 + gfs2_inode_remember_delete(ip->i_gl, ip->i_no_formal_ino); 1299 + 1300 + /* 1301 + * As soon as we clear the bitmap for the dinode, gfs2_create_inode() 1302 + * can get called to recreate it, or even gfs2_inode_lookup() if the 1303 + * inode was recreated on another node in the meantime. 1304 + * 1305 + * However, inserting the new inode into the inode hash table will not 1306 + * succeed until the old inode is removed, and that only happens after 1307 + * ->evict_inode() returns. The new inode is attached to its inode and 1308 + * iopen glocks after inserting it into the inode hash table, so at 1309 + * that point we can be sure that both glocks are unused. 1310 + */ 1311 + 1312 1312 ret = gfs2_dinode_dealloc(ip); 1313 - gfs2_inode_remember_delete(ip->i_gl, ip->i_no_formal_ino); 1314 1313 out: 1315 1314 return ret; 1316 1315 } ··· 1386 1367 struct gfs2_holder gh; 1387 1368 int ret; 1388 1369 1389 - if (test_bit(GIF_FREE_VFS_INODE, &ip->i_flags)) { 1390 - clear_inode(inode); 1391 - return; 1392 - } 1393 - 1394 - if (inode->i_nlink || sb_rdonly(sb)) 1370 + if (inode->i_nlink || sb_rdonly(sb) || !ip->i_no_addr) 1395 1371 goto out; 1396 1372 1397 1373 gfs2_holder_mark_uninitialized(&gh); ··· 1419 1405 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl; 1420 1406 1421 1407 glock_clear_object(gl, ip); 1422 - if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) { 1423 - ip->i_iopen_gh.gh_flags |= GL_NOCACHE; 1424 - gfs2_glock_dq(&ip->i_iopen_gh); 1425 - } 1426 1408 gfs2_glock_hold(gl); 1427 - gfs2_holder_uninit(&ip->i_iopen_gh); 1409 + ip->i_iopen_gh.gh_flags |= GL_NOCACHE; 1410 + gfs2_glock_dq_uninit(&ip->i_iopen_gh); 1428 1411 gfs2_glock_put_eventually(gl); 1429 1412 } 1430 1413 if (ip->i_gl) { ··· 1440 1429 ip = alloc_inode_sb(sb, gfs2_inode_cachep, GFP_KERNEL); 1441 1430 if (!ip) 1442 1431 return NULL; 1432 + ip->i_no_addr = 0; 1443 1433 ip->i_flags = 0; 1444 1434 ip->i_gl = NULL; 1445 1435 gfs2_holder_mark_uninitialized(&ip->i_iopen_gh);
+15 -11
fs/gfs2/xattr.c
··· 1412 1412 ip->i_eattr = 0; 1413 1413 gfs2_add_inode_blocks(&ip->i_inode, -1); 1414 1414 1415 - error = gfs2_meta_inode_buffer(ip, &dibh); 1416 - if (!error) { 1417 - gfs2_trans_add_meta(ip->i_gl, dibh); 1418 - gfs2_dinode_out(ip, dibh->b_data); 1419 - brelse(dibh); 1415 + if (likely(!test_bit(GIF_ALLOC_FAILED, &ip->i_flags))) { 1416 + error = gfs2_meta_inode_buffer(ip, &dibh); 1417 + if (!error) { 1418 + gfs2_trans_add_meta(ip->i_gl, dibh); 1419 + gfs2_dinode_out(ip, dibh->b_data); 1420 + brelse(dibh); 1421 + } 1420 1422 } 1421 1423 1422 1424 gfs2_trans_end(sdp); ··· 1447 1445 if (error) 1448 1446 return error; 1449 1447 1450 - error = ea_foreach(ip, ea_dealloc_unstuffed, NULL); 1451 - if (error) 1452 - goto out_quota; 1453 - 1454 - if (ip->i_diskflags & GFS2_DIF_EA_INDIRECT) { 1455 - error = ea_dealloc_indirect(ip); 1448 + if (likely(!test_bit(GIF_ALLOC_FAILED, &ip->i_flags))) { 1449 + error = ea_foreach(ip, ea_dealloc_unstuffed, NULL); 1456 1450 if (error) 1457 1451 goto out_quota; 1452 + 1453 + if (ip->i_diskflags & GFS2_DIF_EA_INDIRECT) { 1454 + error = ea_dealloc_indirect(ip); 1455 + if (error) 1456 + goto out_quota; 1457 + } 1458 1458 } 1459 1459 1460 1460 error = ea_dealloc_block(ip);