Skip to content

Commit a7c9f30

Browse files
committed
mnt: Read mount images early
Mappings from mount id to namespace will be required to remove ghosts on restore failure. Signed-off-by: Pavel Emelyanov <[email protected]>
1 parent b0e23c3 commit a7c9f30

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

include/mount.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ extern int depopulate_roots_yard(void);
118118
extern int rst_get_mnt_root(int mnt_id, char *path, int plen);
119119
extern int ext_mount_add(char *key, char *val);
120120
extern int mntns_maybe_create_roots(void);
121+
extern int read_mnt_ns_img(void);
121122
extern void cleanup_mnt_ns(void);
122123

123124
#endif /* __CR_MOUNT_H__ */

mount.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,7 +2509,7 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
25092509
return -1;
25102510
}
25112511

2512-
static int read_mnt_ns_img(void)
2512+
int read_mnt_ns_img(void)
25132513
{
25142514
struct mount_info *pms = NULL;
25152515
struct ns_id *nsid;
@@ -2673,9 +2673,6 @@ static int populate_mnt_ns(void)
26732673
struct mount_info *pms;
26742674
struct ns_id *nsid;
26752675

2676-
if (read_mnt_ns_img())
2677-
return -1;
2678-
26792676
pms = mnt_build_tree(mntinfo);
26802677
if (!pms)
26812678
return -1;

namespaces.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,8 +1324,13 @@ int prepare_namespace_before_tasks(void)
13241324
if (mntns_maybe_create_roots())
13251325
goto err_mnt;
13261326

1327+
if (read_mnt_ns_img())
1328+
goto err_img;
1329+
13271330
return 0;
13281331

1332+
err_img:
1333+
cleanup_mnt_ns();
13291334
err_mnt:
13301335
/*
13311336
* Nothing, netns' descriptor will be closed

0 commit comments

Comments
 (0)