@@ -171,13 +171,6 @@ unsigned int mnt_get_count(struct mount *mnt)
171
171
#endif
172
172
}
173
173
174
- static void drop_mountpoint (struct fs_pin * p )
175
- {
176
- struct mount * m = container_of (p , struct mount , mnt_umount );
177
- pin_remove (p );
178
- mntput (& m -> mnt );
179
- }
180
-
181
174
static struct mount * alloc_vfsmnt (const char * name )
182
175
{
183
176
struct mount * mnt = kmem_cache_zalloc (mnt_cache , GFP_KERNEL );
@@ -215,7 +208,7 @@ static struct mount *alloc_vfsmnt(const char *name)
215
208
INIT_LIST_HEAD (& mnt -> mnt_slave );
216
209
INIT_HLIST_NODE (& mnt -> mnt_mp_list );
217
210
INIT_LIST_HEAD (& mnt -> mnt_umounting );
218
- init_fs_pin (& mnt -> mnt_umount , drop_mountpoint );
211
+ INIT_HLIST_HEAD (& mnt -> mnt_stuck_children );
219
212
}
220
213
return mnt ;
221
214
@@ -1087,19 +1080,22 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
1087
1080
1088
1081
static void cleanup_mnt (struct mount * mnt )
1089
1082
{
1083
+ struct hlist_node * p ;
1084
+ struct mount * m ;
1090
1085
/*
1091
- * This probably indicates that somebody messed
1092
- * up a mnt_want/drop_write() pair. If this
1093
- * happens, the filesystem was probably unable
1094
- * to make r/w->r/o transitions.
1095
- */
1096
- /*
1086
+ * The warning here probably indicates that somebody messed
1087
+ * up a mnt_want/drop_write() pair. If this happens, the
1088
+ * filesystem was probably unable to make r/w->r/o transitions.
1097
1089
* The locking used to deal with mnt_count decrement provides barriers,
1098
1090
* so mnt_get_writers() below is safe.
1099
1091
*/
1100
1092
WARN_ON (mnt_get_writers (mnt ));
1101
1093
if (unlikely (mnt -> mnt_pins .first ))
1102
1094
mnt_pin_kill (mnt );
1095
+ hlist_for_each_entry_safe (m , p , & mnt -> mnt_stuck_children , mnt_umount ) {
1096
+ hlist_del (& m -> mnt_umount );
1097
+ mntput (& m -> mnt );
1098
+ }
1103
1099
fsnotify_vfsmount_delete (& mnt -> mnt );
1104
1100
dput (mnt -> mnt .mnt_root );
1105
1101
deactivate_super (mnt -> mnt .mnt_sb );
@@ -1168,6 +1164,7 @@ static void mntput_no_expire(struct mount *mnt)
1168
1164
struct mount * p , * tmp ;
1169
1165
list_for_each_entry_safe (p , tmp , & mnt -> mnt_mounts , mnt_child ) {
1170
1166
__put_mountpoint (unhash_mnt (p ), & list );
1167
+ hlist_add_head (& p -> mnt_umount , & mnt -> mnt_stuck_children );
1171
1168
}
1172
1169
}
1173
1170
unlock_mount_hash ();
@@ -1360,6 +1357,8 @@ EXPORT_SYMBOL(may_umount);
1360
1357
static void namespace_unlock (void )
1361
1358
{
1362
1359
struct hlist_head head ;
1360
+ struct hlist_node * p ;
1361
+ struct mount * m ;
1363
1362
LIST_HEAD (list );
1364
1363
1365
1364
hlist_move_list (& unmounted , & head );
@@ -1374,7 +1373,10 @@ static void namespace_unlock(void)
1374
1373
1375
1374
synchronize_rcu_expedited ();
1376
1375
1377
- group_pin_kill (& head );
1376
+ hlist_for_each_entry_safe (m , p , & head , mnt_umount ) {
1377
+ hlist_del (& m -> mnt_umount );
1378
+ mntput (& m -> mnt );
1379
+ }
1378
1380
}
1379
1381
1380
1382
static inline void namespace_lock (void )
@@ -1461,15 +1463,14 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how)
1461
1463
1462
1464
disconnect = disconnect_mount (p , how );
1463
1465
1464
- pin_insert_group (& p -> mnt_umount , & p -> mnt_parent -> mnt ,
1465
- disconnect ? & unmounted : NULL );
1466
1466
if (mnt_has_parent (p )) {
1467
1467
mnt_add_count (p -> mnt_parent , -1 );
1468
1468
if (!disconnect ) {
1469
1469
/* Don't forget about p */
1470
1470
list_add_tail (& p -> mnt_child , & p -> mnt_parent -> mnt_mounts );
1471
1471
} else {
1472
1472
umount_mnt (p );
1473
+ hlist_add_head (& p -> mnt_umount , & unmounted );
1473
1474
}
1474
1475
}
1475
1476
change_mnt_propagation (p , MS_PRIVATE );
@@ -1622,8 +1623,8 @@ void __detach_mounts(struct dentry *dentry)
1622
1623
while (!hlist_empty (& mp -> m_list )) {
1623
1624
mnt = hlist_entry (mp -> m_list .first , struct mount , mnt_mp_list );
1624
1625
if (mnt -> mnt .mnt_flags & MNT_UMOUNT ) {
1625
- hlist_add_head (& mnt -> mnt_umount .s_list , & unmounted );
1626
1626
umount_mnt (mnt );
1627
+ hlist_add_head (& mnt -> mnt_umount , & unmounted );
1627
1628
}
1628
1629
else umount_tree (mnt , UMOUNT_CONNECTED );
1629
1630
}
0 commit comments