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.

setup_mnt(): primitive for connecting a mount to filesystem

Take the identical logics in vfs_create_mount() and clone_mnt() into
a new helper that takes an empty struct mount and attaches it to
given dentry (sub)tree.

Should be called once in the lifetime of every mount, prior to making
it visible in any data structures.

After that point ->mnt_root and ->mnt_sb never change; ->mnt_root
is a counting reference to dentry and ->mnt_sb - an active reference
to superblock.

Mount remains associated with that dentry tree all the way until
the call of cleanup_mnt(), when the refcount eventually drops
to zero.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 5d132cfa 7f954a6f

+17 -17
+17 -17
fs/namespace.c
··· 1196 1196 touch_mnt_namespace(n); 1197 1197 } 1198 1198 1199 + static void setup_mnt(struct mount *m, struct dentry *root) 1200 + { 1201 + struct super_block *s = root->d_sb; 1202 + 1203 + atomic_inc(&s->s_active); 1204 + m->mnt.mnt_sb = s; 1205 + m->mnt.mnt_root = dget(root); 1206 + m->mnt_mountpoint = m->mnt.mnt_root; 1207 + m->mnt_parent = m; 1208 + 1209 + lock_mount_hash(); 1210 + list_add_tail(&m->mnt_instance, &s->s_mounts); 1211 + unlock_mount_hash(); 1212 + } 1213 + 1199 1214 /** 1200 1215 * vfs_create_mount - Create a mount for a configured superblock 1201 1216 * @fc: The configuration context with the superblock attached ··· 1234 1219 if (fc->sb_flags & SB_KERNMOUNT) 1235 1220 mnt->mnt.mnt_flags = MNT_INTERNAL; 1236 1221 1237 - atomic_inc(&fc->root->d_sb->s_active); 1238 - mnt->mnt.mnt_sb = fc->root->d_sb; 1239 - mnt->mnt.mnt_root = dget(fc->root); 1240 - mnt->mnt_mountpoint = mnt->mnt.mnt_root; 1241 - mnt->mnt_parent = mnt; 1222 + setup_mnt(mnt, fc->root); 1242 1223 1243 - lock_mount_hash(); 1244 - list_add_tail(&mnt->mnt_instance, &mnt->mnt.mnt_sb->s_mounts); 1245 - unlock_mount_hash(); 1246 1224 return &mnt->mnt; 1247 1225 } 1248 1226 EXPORT_SYMBOL(vfs_create_mount); ··· 1293 1285 static struct mount *clone_mnt(struct mount *old, struct dentry *root, 1294 1286 int flag) 1295 1287 { 1296 - struct super_block *sb = old->mnt.mnt_sb; 1297 1288 struct mount *mnt; 1298 1289 int err; 1299 1290 ··· 1317 1310 if (mnt->mnt_group_id) 1318 1311 set_mnt_shared(mnt); 1319 1312 1320 - atomic_inc(&sb->s_active); 1321 1313 mnt->mnt.mnt_idmap = mnt_idmap_get(mnt_idmap(&old->mnt)); 1322 1314 1323 - mnt->mnt.mnt_sb = sb; 1324 - mnt->mnt.mnt_root = dget(root); 1325 - mnt->mnt_mountpoint = mnt->mnt.mnt_root; 1326 - mnt->mnt_parent = mnt; 1327 - lock_mount_hash(); 1328 - list_add_tail(&mnt->mnt_instance, &sb->s_mounts); 1329 - unlock_mount_hash(); 1315 + setup_mnt(mnt, root); 1330 1316 1331 1317 if (flag & CL_PRIVATE) // we are done with it 1332 1318 return mnt;