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

Merge tag 'gfs2-for-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2

Pull gfs2 updates from Andreas Gruenbacher:

- Fix the code that cleans up left-over unlinked files.

Various fixes and minor improvements in deleting files cached or held
open remotely.

- Simplify the use of dlm's DLM_LKF_QUECVT flag.

- A few other minor cleanups.

* tag 'gfs2-for-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2: (21 commits)
gfs2: Prevent inode creation race
gfs2: Only defer deletes when we have an iopen glock
gfs2: Simplify DLM_LKF_QUECVT use
gfs2: gfs2_evict_inode clarification
gfs2: Make gfs2_inode_refresh static
gfs2: Use get_random_u32 in gfs2_orlov_skip
gfs2: Randomize GLF_VERIFY_DELETE work delay
gfs2: Use mod_delayed_work in gfs2_queue_try_to_evict
gfs2: Update to the evict / remote delete documentation
gfs2: Call gfs2_queue_verify_delete from gfs2_evict_inode
gfs2: Clean up delete work processing
gfs2: Minor delete_work_func cleanup
gfs2: Return enum evict_behavior from gfs2_upgrade_iopen_glock
gfs2: Rename dinode_demise to evict_behavior
gfs2: Rename GIF_{DEFERRED -> DEFER}_DELETE
gfs2: Faster gfs2_upgrade_iopen_glock wakeups
KMSAN: uninit-value in inode_go_dump (5)
gfs2: Fix unlinked inode cleanup
gfs2: Allow immediate GLF_VERIFY_DELETE work
gfs2: Initialize gl_no_formal_ino earlier
...

+142 -114
+41 -66
fs/gfs2/glock.c
··· 35 35 #include <linux/rhashtable.h> 36 36 #include <linux/pid_namespace.h> 37 37 #include <linux/file.h> 38 + #include <linux/random.h> 38 39 39 40 #include "gfs2.h" 40 41 #include "incore.h" ··· 563 562 gl->gl_tchange = jiffies; 564 563 } 565 564 566 - static void gfs2_set_demote(struct gfs2_glock *gl) 565 + static void gfs2_set_demote(int nr, struct gfs2_glock *gl) 567 566 { 568 567 struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; 569 568 570 - set_bit(GLF_DEMOTE, &gl->gl_flags); 569 + set_bit(nr, &gl->gl_flags); 571 570 smp_mb(); 572 571 wake_up(&sdp->sd_async_glock_wait); 573 572 } ··· 959 958 gfs2_holder_uninit(&gh); 960 959 } 961 960 962 - static bool gfs2_try_evict(struct gfs2_glock *gl) 961 + static void gfs2_try_evict(struct gfs2_glock *gl) 963 962 { 964 963 struct gfs2_inode *ip; 965 - bool evicted = false; 966 964 967 965 /* 968 966 * If there is contention on the iopen glock and we have an inode, try 969 - * to grab and release the inode so that it can be evicted. This will 970 - * allow the remote node to go ahead and delete the inode without us 971 - * having to do it, which will avoid rgrp glock thrashing. 967 + * to grab and release the inode so that it can be evicted. The 968 + * GIF_DEFER_DELETE flag indicates to gfs2_evict_inode() that the inode 969 + * should not be deleted locally. This will allow the remote node to 970 + * go ahead and delete the inode without us having to do it, which will 971 + * avoid rgrp glock thrashing. 972 972 * 973 973 * The remote node is likely still holding the corresponding inode 974 974 * glock, so it will run before we get to verify that the delete has 975 - * happened below. 975 + * happened below. (Verification is triggered by the call to 976 + * gfs2_queue_verify_delete() in gfs2_evict_inode().) 976 977 */ 977 978 spin_lock(&gl->gl_lockref.lock); 978 979 ip = gl->gl_object; ··· 982 979 ip = NULL; 983 980 spin_unlock(&gl->gl_lockref.lock); 984 981 if (ip) { 985 - gl->gl_no_formal_ino = ip->i_no_formal_ino; 986 - set_bit(GIF_DEFERRED_DELETE, &ip->i_flags); 982 + wait_on_inode(&ip->i_inode); 983 + if (is_bad_inode(&ip->i_inode)) { 984 + iput(&ip->i_inode); 985 + ip = NULL; 986 + } 987 + } 988 + if (ip) { 989 + set_bit(GIF_DEFER_DELETE, &ip->i_flags); 987 990 d_prune_aliases(&ip->i_inode); 988 991 iput(&ip->i_inode); 989 992 ··· 997 988 spin_lock(&gl->gl_lockref.lock); 998 989 ip = gl->gl_object; 999 990 if (ip) { 1000 - clear_bit(GIF_DEFERRED_DELETE, &ip->i_flags); 991 + clear_bit(GIF_DEFER_DELETE, &ip->i_flags); 1001 992 if (!igrab(&ip->i_inode)) 1002 993 ip = NULL; 1003 994 } ··· 1006 997 gfs2_glock_poke(ip->i_gl); 1007 998 iput(&ip->i_inode); 1008 999 } 1009 - evicted = !ip; 1010 1000 } 1011 - return evicted; 1012 1001 } 1013 1002 1014 1003 bool gfs2_queue_try_to_evict(struct gfs2_glock *gl) ··· 1015 1008 1016 1009 if (test_and_set_bit(GLF_TRY_TO_EVICT, &gl->gl_flags)) 1017 1010 return false; 1018 - return queue_delayed_work(sdp->sd_delete_wq, 1019 - &gl->gl_delete, 0); 1011 + return !mod_delayed_work(sdp->sd_delete_wq, &gl->gl_delete, 0); 1020 1012 } 1021 1013 1022 - static bool gfs2_queue_verify_evict(struct gfs2_glock *gl) 1014 + bool gfs2_queue_verify_delete(struct gfs2_glock *gl, bool later) 1023 1015 { 1024 1016 struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; 1017 + unsigned long delay; 1025 1018 1026 - if (test_and_set_bit(GLF_VERIFY_EVICT, &gl->gl_flags)) 1019 + if (test_and_set_bit(GLF_VERIFY_DELETE, &gl->gl_flags)) 1027 1020 return false; 1028 - return queue_delayed_work(sdp->sd_delete_wq, 1029 - &gl->gl_delete, 5 * HZ); 1021 + delay = later ? HZ + get_random_long() % (HZ * 9) : 0; 1022 + return queue_delayed_work(sdp->sd_delete_wq, &gl->gl_delete, delay); 1030 1023 } 1031 1024 1032 1025 static void delete_work_func(struct work_struct *work) ··· 1034 1027 struct delayed_work *dwork = to_delayed_work(work); 1035 1028 struct gfs2_glock *gl = container_of(dwork, struct gfs2_glock, gl_delete); 1036 1029 struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; 1037 - struct inode *inode; 1038 - u64 no_addr = gl->gl_name.ln_number; 1030 + bool verify_delete = test_and_clear_bit(GLF_VERIFY_DELETE, &gl->gl_flags); 1039 1031 1040 - if (test_and_clear_bit(GLF_TRY_TO_EVICT, &gl->gl_flags)) { 1041 - /* 1042 - * If we can evict the inode, give the remote node trying to 1043 - * delete the inode some time before verifying that the delete 1044 - * has happened. Otherwise, if we cause contention on the inode glock 1045 - * immediately, the remote node will think that we still have 1046 - * the inode in use, and so it will give up waiting. 1047 - * 1048 - * If we can't evict the inode, signal to the remote node that 1049 - * the inode is still in use. We'll later try to delete the 1050 - * inode locally in gfs2_evict_inode. 1051 - * 1052 - * FIXME: We only need to verify that the remote node has 1053 - * deleted the inode because nodes before this remote delete 1054 - * rework won't cooperate. At a later time, when we no longer 1055 - * care about compatibility with such nodes, we can skip this 1056 - * step entirely. 1057 - */ 1058 - if (gfs2_try_evict(gl)) { 1059 - if (test_bit(SDF_KILL, &sdp->sd_flags)) 1060 - goto out; 1061 - if (gfs2_queue_verify_evict(gl)) 1062 - return; 1063 - } 1064 - goto out; 1065 - } 1032 + if (test_and_clear_bit(GLF_TRY_TO_EVICT, &gl->gl_flags)) 1033 + gfs2_try_evict(gl); 1066 1034 1067 - if (test_and_clear_bit(GLF_VERIFY_EVICT, &gl->gl_flags)) { 1035 + if (verify_delete) { 1036 + u64 no_addr = gl->gl_name.ln_number; 1037 + struct inode *inode; 1038 + 1068 1039 inode = gfs2_lookup_by_inum(sdp, no_addr, gl->gl_no_formal_ino, 1069 1040 GFS2_BLKST_UNLINKED); 1070 1041 if (IS_ERR(inode)) { 1071 1042 if (PTR_ERR(inode) == -EAGAIN && 1072 1043 !test_bit(SDF_KILL, &sdp->sd_flags) && 1073 - gfs2_queue_verify_evict(gl)) 1044 + gfs2_queue_verify_delete(gl, true)) 1074 1045 return; 1075 1046 } else { 1076 1047 d_prune_aliases(inode); ··· 1056 1071 } 1057 1072 } 1058 1073 1059 - out: 1060 1074 gfs2_glock_put(gl); 1061 1075 } 1062 1076 ··· 1084 1100 1085 1101 if (!delay) { 1086 1102 clear_bit(GLF_PENDING_DEMOTE, &gl->gl_flags); 1087 - gfs2_set_demote(gl); 1103 + gfs2_set_demote(GLF_DEMOTE, gl); 1088 1104 } 1089 1105 } 1090 1106 run_queue(gl, 0); ··· 1426 1442 static void request_demote(struct gfs2_glock *gl, unsigned int state, 1427 1443 unsigned long delay, bool remote) 1428 1444 { 1429 - if (delay) 1430 - set_bit(GLF_PENDING_DEMOTE, &gl->gl_flags); 1431 - else 1432 - gfs2_set_demote(gl); 1445 + gfs2_set_demote(delay ? GLF_PENDING_DEMOTE : GLF_DEMOTE, gl); 1433 1446 if (gl->gl_demote_state == LM_ST_EXCLUSIVE) { 1434 1447 gl->gl_demote_state = state; 1435 1448 gl->gl_demote_time = jiffies; ··· 1616 1635 return test_bit(HIF_WAIT, &gh->gh_iflags) ? 0 : 1; 1617 1636 } 1618 1637 1619 - static inline bool needs_demote(struct gfs2_glock *gl) 1620 - { 1621 - return (test_bit(GLF_DEMOTE, &gl->gl_flags) || 1622 - test_bit(GLF_PENDING_DEMOTE, &gl->gl_flags)); 1623 - } 1624 - 1625 1638 static void __gfs2_glock_dq(struct gfs2_holder *gh) 1626 1639 { 1627 1640 struct gfs2_glock *gl = gh->gh_gl; ··· 1624 1649 1625 1650 /* 1626 1651 * 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. 1652 + * Note: this should be done before the glock_needs_demote 1653 + * check below. 1629 1654 */ 1630 1655 if (gh->gh_flags & GL_NOCACHE) 1631 1656 request_demote(gl, LM_ST_UNLOCKED, 0, false); ··· 1638 1663 * If there hasn't been a demote request we are done. 1639 1664 * (Let the remaining holders, if any, keep holding it.) 1640 1665 */ 1641 - if (!needs_demote(gl)) { 1666 + if (!glock_needs_demote(gl)) { 1642 1667 if (list_empty(&gl->gl_holders)) 1643 1668 fast_path = 1; 1644 1669 } ··· 2092 2117 void gfs2_cancel_delete_work(struct gfs2_glock *gl) 2093 2118 { 2094 2119 clear_bit(GLF_TRY_TO_EVICT, &gl->gl_flags); 2095 - clear_bit(GLF_VERIFY_EVICT, &gl->gl_flags); 2120 + clear_bit(GLF_VERIFY_DELETE, &gl->gl_flags); 2096 2121 if (cancel_delayed_work(&gl->gl_delete)) 2097 2122 gfs2_glock_put(gl); 2098 2123 } ··· 2345 2370 *p++ = 'N'; 2346 2371 if (test_bit(GLF_TRY_TO_EVICT, gflags)) 2347 2372 *p++ = 'e'; 2348 - if (test_bit(GLF_VERIFY_EVICT, gflags)) 2373 + if (test_bit(GLF_VERIFY_DELETE, gflags)) 2349 2374 *p++ = 'E'; 2350 2375 *p = 0; 2351 2376 return buf;
+7
fs/gfs2/glock.h
··· 245 245 void gfs2_glock_cb(struct gfs2_glock *gl, unsigned int state); 246 246 void gfs2_glock_complete(struct gfs2_glock *gl, int ret); 247 247 bool gfs2_queue_try_to_evict(struct gfs2_glock *gl); 248 + bool gfs2_queue_verify_delete(struct gfs2_glock *gl, bool later); 248 249 void gfs2_cancel_delete_work(struct gfs2_glock *gl); 249 250 void gfs2_flush_delete_work(struct gfs2_sbd *sdp); 250 251 void gfs2_gl_hash_clear(struct gfs2_sbd *sdp); ··· 284 283 285 284 void gfs2_inode_remember_delete(struct gfs2_glock *gl, u64 generation); 286 285 bool gfs2_inode_already_deleted(struct gfs2_glock *gl, u64 generation); 286 + 287 + static inline bool glock_needs_demote(struct gfs2_glock *gl) 288 + { 289 + return (test_bit(GLF_DEMOTE, &gl->gl_flags) || 290 + test_bit(GLF_PENDING_DEMOTE, &gl->gl_flags)); 291 + } 287 292 288 293 #endif /* __GLOCK_DOT_H__ */
+9 -2
fs/gfs2/glops.c
··· 470 470 * Returns: errno 471 471 */ 472 472 473 - int gfs2_inode_refresh(struct gfs2_inode *ip) 473 + static int gfs2_inode_refresh(struct gfs2_inode *ip) 474 474 { 475 475 struct buffer_head *dibh; 476 476 int error; ··· 494 494 static int inode_go_instantiate(struct gfs2_glock *gl) 495 495 { 496 496 struct gfs2_inode *ip = gl->gl_object; 497 + struct gfs2_glock *io_gl; 498 + int error; 497 499 498 500 if (!ip) /* no inode to populate - read it in later */ 499 501 return 0; 500 502 501 - return gfs2_inode_refresh(ip); 503 + error = gfs2_inode_refresh(ip); 504 + if (error) 505 + return error; 506 + io_gl = ip->i_iopen_gh.gh_gl; 507 + io_gl->gl_no_formal_ino = ip->i_no_formal_ino; 508 + return 0; 502 509 } 503 510 504 511 static int inode_go_held(struct gfs2_holder *gh)
+2 -2
fs/gfs2/incore.h
··· 329 329 GLF_BLOCKING = 15, 330 330 GLF_UNLOCKED = 16, /* Wait for glock to be unlocked */ 331 331 GLF_TRY_TO_EVICT = 17, /* iopen glocks only */ 332 - GLF_VERIFY_EVICT = 18, /* iopen glocks only */ 332 + GLF_VERIFY_DELETE = 18, /* iopen glocks only */ 333 333 }; 334 334 335 335 struct gfs2_glock { ··· 376 376 GIF_SW_PAGED = 3, 377 377 GIF_FREE_VFS_INODE = 5, 378 378 GIF_GLOP_PENDING = 6, 379 - GIF_DEFERRED_DELETE = 7, 379 + GIF_DEFER_DELETE = 7, 380 380 }; 381 381 382 382 struct gfs2_inode {
+1
fs/gfs2/inode.c
··· 750 750 if (error) 751 751 goto fail_free_inode; 752 752 gfs2_cancel_delete_work(io_gl); 753 + io_gl->gl_no_formal_ino = ip->i_no_formal_ino; 753 754 754 755 retry: 755 756 error = insert_inode_locked4(inode, ip->i_no_addr, iget_test, &ip->i_no_addr);
-2
fs/gfs2/inode.h
··· 93 93 u64 no_formal_ino, 94 94 unsigned int blktype); 95 95 96 - int gfs2_inode_refresh(struct gfs2_inode *ip); 97 - 98 96 struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, 99 97 int is_root); 100 98 int gfs2_permission(struct mnt_idmap *idmap,
+25 -4
fs/gfs2/lock_dlm.c
··· 224 224 return -1; 225 225 } 226 226 227 + /* Taken from fs/dlm/lock.c. */ 228 + 229 + static bool middle_conversion(int cur, int req) 230 + { 231 + return (cur == DLM_LOCK_PR && req == DLM_LOCK_CW) || 232 + (cur == DLM_LOCK_CW && req == DLM_LOCK_PR); 233 + } 234 + 235 + static bool down_conversion(int cur, int req) 236 + { 237 + return !middle_conversion(cur, req) && req < cur; 238 + } 239 + 227 240 static u32 make_flags(struct gfs2_glock *gl, const unsigned int gfs_flags, 228 - const int req) 241 + const int cur, const int req) 229 242 { 230 243 u32 lkf = 0; 231 244 ··· 264 251 265 252 if (!test_bit(GLF_INITIAL, &gl->gl_flags)) { 266 253 lkf |= DLM_LKF_CONVERT; 267 - if (test_bit(GLF_BLOCKING, &gl->gl_flags)) 254 + 255 + /* 256 + * The DLM_LKF_QUECVT flag needs to be set for "first come, 257 + * first served" semantics, but it must only be set for 258 + * "upward" lock conversions or else DLM will reject the 259 + * request as invalid. 260 + */ 261 + if (!down_conversion(cur, req)) 268 262 lkf |= DLM_LKF_QUECVT; 269 263 } 270 264 ··· 291 271 unsigned int flags) 292 272 { 293 273 struct lm_lockstruct *ls = &gl->gl_name.ln_sbd->sd_lockstruct; 294 - int req; 274 + int cur, req; 295 275 u32 lkf; 296 276 char strname[GDLM_STRNAME_BYTES] = ""; 297 277 int error; 298 278 279 + cur = make_mode(gl->gl_name.ln_sbd, gl->gl_state); 299 280 req = make_mode(gl->gl_name.ln_sbd, req_state); 300 - lkf = make_flags(gl, flags, req); 281 + lkf = make_flags(gl, flags, cur, req); 301 282 gfs2_glstats_inc(gl, GFS2_LKS_DCOUNT); 302 283 gfs2_sbstats_inc(gl, GFS2_LKS_DCOUNT); 303 284 if (test_bit(GLF_INITIAL, &gl->gl_flags)) {
+2 -4
fs/gfs2/rgrp.c
··· 1879 1879 */ 1880 1880 ip = gl->gl_object; 1881 1881 1882 - if (ip || !gfs2_queue_try_to_evict(gl)) 1882 + if (ip || !gfs2_queue_verify_delete(gl, false)) 1883 1883 gfs2_glock_put(gl); 1884 1884 else 1885 1885 found++; ··· 1987 1987 static u32 gfs2_orlov_skip(const struct gfs2_inode *ip) 1988 1988 { 1989 1989 const struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1990 - u32 skip; 1991 1990 1992 - get_random_bytes(&skip, sizeof(skip)); 1993 - return skip % sdp->sd_rgrps; 1991 + return get_random_u32() % sdp->sd_rgrps; 1994 1992 } 1995 1993 1996 1994 static bool gfs2_select_rgrp(struct gfs2_rgrpd **pos, const struct gfs2_rgrpd *begin)
+55 -34
fs/gfs2/super.c
··· 44 44 #include "xattr.h" 45 45 #include "lops.h" 46 46 47 - enum dinode_demise { 48 - SHOULD_DELETE_DINODE, 49 - SHOULD_NOT_DELETE_DINODE, 50 - SHOULD_DEFER_EVICTION, 47 + enum evict_behavior { 48 + EVICT_SHOULD_DELETE, 49 + EVICT_SHOULD_SKIP_DELETE, 50 + EVICT_SHOULD_DEFER_DELETE, 51 51 }; 52 52 53 53 /** ··· 1030 1030 if (inode->i_nlink && 1031 1031 gfs2_holder_initialized(&ip->i_iopen_gh)) { 1032 1032 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl; 1033 - if (test_bit(GLF_DEMOTE, &gl->gl_flags)) 1033 + if (glock_needs_demote(gl)) 1034 1034 clear_nlink(inode); 1035 1035 } 1036 1036 ··· 1045 1045 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl; 1046 1046 1047 1047 gfs2_glock_hold(gl); 1048 - if (!gfs2_queue_try_to_evict(gl)) 1048 + if (!gfs2_queue_verify_delete(gl, true)) 1049 1049 gfs2_glock_put_async(gl); 1050 1050 return 0; 1051 1051 } ··· 1257 1257 gfs2_glock_put(gl); 1258 1258 } 1259 1259 1260 - static bool gfs2_upgrade_iopen_glock(struct inode *inode) 1260 + static enum evict_behavior gfs2_upgrade_iopen_glock(struct inode *inode) 1261 1261 { 1262 1262 struct gfs2_inode *ip = GFS2_I(inode); 1263 1263 struct gfs2_sbd *sdp = GFS2_SB(inode); ··· 1272 1272 * exclusive access to the iopen glock here. 1273 1273 * 1274 1274 * Otherwise, the other nodes holding the lock will be notified about 1275 - * our locking request. If they do not have the inode open, they are 1276 - * expected to evict the cached inode and release the lock, allowing us 1277 - * to proceed. 1275 + * our locking request (see iopen_go_callback()). If they do not have 1276 + * the inode open, they are expected to evict the cached inode and 1277 + * release the lock, allowing us to proceed. 1278 1278 * 1279 1279 * Otherwise, if they cannot evict the inode, they are expected to poke 1280 1280 * the inode glock (note: not the iopen glock). We will notice that ··· 1290 1290 gfs2_holder_reinit(LM_ST_EXCLUSIVE, GL_ASYNC | GL_NOCACHE, gh); 1291 1291 error = gfs2_glock_nq(gh); 1292 1292 if (error) 1293 - return false; 1293 + return EVICT_SHOULD_SKIP_DELETE; 1294 1294 1295 1295 wait_event_interruptible_timeout(sdp->sd_async_glock_wait, 1296 1296 !test_bit(HIF_WAIT, &gh->gh_iflags) || 1297 - test_bit(GLF_DEMOTE, &ip->i_gl->gl_flags), 1297 + glock_needs_demote(ip->i_gl), 1298 1298 5 * HZ); 1299 1299 if (!test_bit(HIF_HOLDER, &gh->gh_iflags)) { 1300 1300 gfs2_glock_dq(gh); 1301 - return false; 1301 + if (glock_needs_demote(ip->i_gl)) 1302 + return EVICT_SHOULD_SKIP_DELETE; 1303 + return EVICT_SHOULD_DEFER_DELETE; 1302 1304 } 1303 - return gfs2_glock_holder_ready(gh) == 0; 1305 + error = gfs2_glock_holder_ready(gh); 1306 + if (error) 1307 + return EVICT_SHOULD_SKIP_DELETE; 1308 + return EVICT_SHOULD_DELETE; 1304 1309 } 1305 1310 1306 1311 /** ··· 1318 1313 * 1319 1314 * Returns: the fate of the dinode 1320 1315 */ 1321 - static enum dinode_demise evict_should_delete(struct inode *inode, 1322 - struct gfs2_holder *gh) 1316 + static enum evict_behavior evict_should_delete(struct inode *inode, 1317 + struct gfs2_holder *gh) 1323 1318 { 1324 1319 struct gfs2_inode *ip = GFS2_I(inode); 1325 1320 struct super_block *sb = inode->i_sb; ··· 1329 1324 if (unlikely(test_bit(GIF_ALLOC_FAILED, &ip->i_flags))) 1330 1325 goto should_delete; 1331 1326 1332 - if (test_bit(GIF_DEFERRED_DELETE, &ip->i_flags)) 1333 - return SHOULD_DEFER_EVICTION; 1327 + if (test_bit(GIF_DEFER_DELETE, &ip->i_flags)) 1328 + return EVICT_SHOULD_DEFER_DELETE; 1334 1329 1335 1330 /* Deletes should never happen under memory pressure anymore. */ 1336 1331 if (WARN_ON_ONCE(current->flags & PF_MEMALLOC)) 1337 - return SHOULD_DEFER_EVICTION; 1332 + return EVICT_SHOULD_DEFER_DELETE; 1338 1333 1339 1334 /* Must not read inode block until block type has been verified */ 1340 1335 ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_SKIP, gh); ··· 1342 1337 glock_clear_object(ip->i_iopen_gh.gh_gl, ip); 1343 1338 ip->i_iopen_gh.gh_flags |= GL_NOCACHE; 1344 1339 gfs2_glock_dq_uninit(&ip->i_iopen_gh); 1345 - return SHOULD_DEFER_EVICTION; 1340 + return EVICT_SHOULD_DEFER_DELETE; 1346 1341 } 1347 1342 1348 1343 if (gfs2_inode_already_deleted(ip->i_gl, ip->i_no_formal_ino)) 1349 - return SHOULD_NOT_DELETE_DINODE; 1344 + return EVICT_SHOULD_SKIP_DELETE; 1350 1345 ret = gfs2_check_blk_type(sdp, ip->i_no_addr, GFS2_BLKST_UNLINKED); 1351 1346 if (ret) 1352 - return SHOULD_NOT_DELETE_DINODE; 1347 + return EVICT_SHOULD_SKIP_DELETE; 1353 1348 1354 1349 ret = gfs2_instantiate(gh); 1355 1350 if (ret) 1356 - return SHOULD_NOT_DELETE_DINODE; 1351 + return EVICT_SHOULD_SKIP_DELETE; 1357 1352 1358 1353 /* 1359 1354 * The inode may have been recreated in the meantime. 1360 1355 */ 1361 1356 if (inode->i_nlink) 1362 - return SHOULD_NOT_DELETE_DINODE; 1357 + return EVICT_SHOULD_SKIP_DELETE; 1363 1358 1364 1359 should_delete: 1365 1360 if (gfs2_holder_initialized(&ip->i_iopen_gh) && 1366 1361 test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) { 1367 - if (!gfs2_upgrade_iopen_glock(inode)) { 1362 + enum evict_behavior behavior = 1363 + gfs2_upgrade_iopen_glock(inode); 1364 + 1365 + if (behavior != EVICT_SHOULD_DELETE) { 1368 1366 gfs2_holder_uninit(&ip->i_iopen_gh); 1369 - return SHOULD_NOT_DELETE_DINODE; 1367 + return behavior; 1370 1368 } 1371 1369 } 1372 - return SHOULD_DELETE_DINODE; 1370 + return EVICT_SHOULD_DELETE; 1373 1371 } 1374 1372 1375 1373 /** ··· 1483 1475 struct gfs2_sbd *sdp = sb->s_fs_info; 1484 1476 struct gfs2_inode *ip = GFS2_I(inode); 1485 1477 struct gfs2_holder gh; 1478 + enum evict_behavior behavior; 1486 1479 int ret; 1487 1480 1481 + gfs2_holder_mark_uninitialized(&gh); 1488 1482 if (inode->i_nlink || sb_rdonly(sb) || !ip->i_no_addr) 1489 1483 goto out; 1490 1484 ··· 1498 1488 if (!sdp->sd_jdesc) 1499 1489 goto out; 1500 1490 1501 - gfs2_holder_mark_uninitialized(&gh); 1502 - ret = evict_should_delete(inode, &gh); 1503 - if (ret == SHOULD_DEFER_EVICTION) 1504 - goto out; 1505 - if (ret == SHOULD_DELETE_DINODE) 1491 + behavior = evict_should_delete(inode, &gh); 1492 + if (behavior == EVICT_SHOULD_DEFER_DELETE && 1493 + !test_bit(SDF_KILL, &sdp->sd_flags)) { 1494 + struct gfs2_glock *io_gl = ip->i_iopen_gh.gh_gl; 1495 + 1496 + if (io_gl) { 1497 + gfs2_glock_hold(io_gl); 1498 + if (!gfs2_queue_verify_delete(io_gl, true)) 1499 + gfs2_glock_put(io_gl); 1500 + goto out; 1501 + } 1502 + behavior = EVICT_SHOULD_DELETE; 1503 + } 1504 + if (behavior == EVICT_SHOULD_DELETE) 1506 1505 ret = evict_unlinked_inode(inode); 1507 1506 else 1508 1507 ret = evict_linked_inode(inode); ··· 1519 1500 if (gfs2_rs_active(&ip->i_res)) 1520 1501 gfs2_rs_deltree(&ip->i_res); 1521 1502 1522 - if (gfs2_holder_initialized(&gh)) 1523 - gfs2_glock_dq_uninit(&gh); 1524 1503 if (ret && ret != GLR_TRYFAILED && ret != -EROFS) 1525 1504 fs_warn(sdp, "gfs2_evict_inode: %d\n", ret); 1526 1505 out: 1506 + if (gfs2_holder_initialized(&gh)) 1507 + gfs2_glock_dq_uninit(&gh); 1527 1508 truncate_inode_pages_final(&inode->i_data); 1528 1509 if (ip->i_qadata) 1529 1510 gfs2_assert_warn(sdp, ip->i_qadata->qa_ref == 0); ··· 1556 1537 if (!ip) 1557 1538 return NULL; 1558 1539 ip->i_no_addr = 0; 1540 + ip->i_no_formal_ino = 0; 1559 1541 ip->i_flags = 0; 1560 1542 ip->i_gl = NULL; 1561 1543 gfs2_holder_mark_uninitialized(&ip->i_iopen_gh); 1562 1544 memset(&ip->i_res, 0, sizeof(ip->i_res)); 1563 1545 RB_CLEAR_NODE(&ip->i_res.rs_node); 1546 + ip->i_diskflags = 0; 1564 1547 ip->i_rahead = 0; 1565 1548 return &ip->i_inode; 1566 1549 }