On Fri, Jun 10, 2016 at 06:31:16PM +0300, Cyrill Gorcunov wrote: > > > > Come to think of it, is this really necessary? Can't we just allocate > > vtty_map in vtty_open_master and return master tty w/o open slave? Any > > write/read will put the caller to sleep anyway. > > Hmm. You know currently we keep slaves in the map as reference point > (because master peer may be never opened during whole container lifetime). > Letme think if we can do that. > > Thanks for comments!
You know, with the patch which implements offline management, ie [PATCH rh7] vtty: Don't free console mapping until no clients left we don't need the completion at all indeed. Thus. Lets do a single patch for all our needs. I rebased it on pcs7 kernel so it won't depend on anything else. --- From: Cyrill Gorcunov <[email protected]> Subject: [PATCH rh7 v2] vtty: Don't free console mapping until no clients left Currently on container's stop we free vtty mapping in a force way so that if there is active console hooked from the node it become unusable since then. It was easier to work with when we've been reworking virtual console code. Now lets make console fully functional as it was in pcs6: when opened it must survice container start/stop cycle and checkpoint/restore as well. For this sake we: - drop ve_hook code, it no longer needed - free console @map on final close of the last tty opened https://jira.sw.ru/browse/PSBM-39463 Signed-off-by: Cyrill Gorcunov <[email protected]> CC: Vladimir Davydov <[email protected]> CC: Konstantin Khorenko <[email protected]> CC: Igor Sukhih <[email protected]> CC: Pavel Emelyanov <[email protected]> --- drivers/tty/pty.c | 49 +++++++++++++++---------------------------------- kernel/ve/vecalls.c | 6 +++--- 2 files changed, 18 insertions(+), 37 deletions(-) Index: linux-pcs7.git/drivers/tty/pty.c =================================================================== --- linux-pcs7.git.orig/drivers/tty/pty.c +++ linux-pcs7.git/drivers/tty/pty.c @@ -901,6 +901,13 @@ static void vtty_map_set(vtty_map_t *map map->vttys[tty->index] = tty; } +static void vtty_map_free(vtty_map_t *map) +{ + lockdep_assert_held(&tty_mutex); + idr_remove(&vtty_idr, map->veid); + kfree(map); +} + static void vtty_map_clear(struct tty_struct *tty) { vtty_map_t *map = tty->driver_data; @@ -908,28 +915,20 @@ static void vtty_map_clear(struct tty_st lockdep_assert_held(&tty_mutex); if (map) { struct tty_struct *p = map->vttys[tty->index]; + int i; WARN_ON(p != (tty->driver == vttys_driver ? tty : tty->link)); map->vttys[tty->index] = NULL; tty->driver_data = tty->link->driver_data = NULL; - } -} - -static void vtty_map_free(vtty_map_t *map) -{ - int i; - lockdep_assert_held(&tty_mutex); + for (i = 0; i < MAX_NR_VTTY_CONSOLES; i++) { + if (map->vttys[i]) + break; + } - for (i = 0; i < MAX_NR_VTTY_CONSOLES; i++) { - struct tty_struct *tty = map->vttys[i]; - if (!tty) - continue; - tty->driver_data = tty->link->driver_data = NULL; + if (i >= MAX_NR_VTTY_CONSOLES) + vtty_map_free(map); } - - idr_remove(&vtty_idr, map->veid); - kfree(map); } static vtty_map_t *vtty_map_alloc(envid_t veid) @@ -939,6 +938,7 @@ static vtty_map_t *vtty_map_alloc(envid_ lockdep_assert_held(&tty_mutex); if (map) { map->veid = veid; + init_completion(&map->work); veid = idr_alloc(&vtty_idr, map, veid, veid + 1, GFP_KERNEL); if (veid < 0) { kfree(map); @@ -1209,24 +1209,6 @@ void vtty_release(struct tty_struct *tty *o_tty_closing = 0; } -static void ve_vtty_fini(void *data) -{ - struct ve_struct *ve = data; - vtty_map_t *map; - - mutex_lock(&tty_mutex); - map = vtty_map_lookup(ve->veid); - if (map) - vtty_map_free(map); - mutex_unlock(&tty_mutex); -} - -static struct ve_hook vtty_hook = { - .fini = ve_vtty_fini, - .priority = HOOK_PRIO_DEFAULT, - .owner = THIS_MODULE, -}; - static int __init vtty_init(void) { #define VTTY_DRIVER_ALLOC_FLAGS \ @@ -1279,7 +1261,6 @@ static int __init vtty_init(void) if (tty_register_driver(vttys_driver)) panic(pr_fmt("Can't register slave vtty driver\n")); - ve_hook_register(VE_SS_CHAIN, &vtty_hook); tty_default_fops(&vtty_fops); return 0; } Index: linux-pcs7.git/kernel/ve/vecalls.c =================================================================== --- linux-pcs7.git.orig/kernel/ve/vecalls.c +++ linux-pcs7.git/kernel/ve/vecalls.c @@ -990,6 +990,9 @@ static int ve_configure(envid_t veid, un struct ve_struct *ve; int err = -ENOKEY; + if (key == VE_CONFIGURE_OPEN_TTY) + return vtty_open_master(veid, val); + ve = get_ve_by_id(veid); if (!ve) return -EINVAL; @@ -998,9 +1001,6 @@ static int ve_configure(envid_t veid, un case VE_CONFIGURE_OS_RELEASE: err = init_ve_osrelease(ve, data); break; - case VE_CONFIGURE_OPEN_TTY: - err = vtty_open_master(ve->veid, val); - break; } put_ve(ve); _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
