[Devel] [PATCH RHEL8 COMMIT] ve/tty: vtty -- Drop TTY_PINNED_BY_OTHER bit

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jul 26 20:15:27 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-305.3.1.vz8.7.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-305.3.1.el8
------>
commit 09a43deec7e5b1ba02e935a249f30a8e41bb1e5b
Author: Cyrill Gorcunov <gorcunov at virtuozzo.com>
Date:   Mon Jul 26 20:15:27 2021 +0300

    ve/tty: vtty -- Drop TTY_PINNED_BY_OTHER bit
    
    This bit was introduced during our vttys code rework but eventually
    we don't need it, plain comparision with slave vtty driver is enough.
    So lets drop it off since it might conflict with some new tty bits
    in future.
    
    Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
    
    Reviewed-by: Vladimir Davydov <vdavydov at virtuozzo.com>
    
    https://jira.sw.ru/browse/PSBM-132299
    
    (cherry-picked from ba9b6c7897be3a591342fe102dd3e4ef6e105a2c)
    Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
---
 drivers/tty/n_tty.c |  4 ++--
 drivers/tty/pty.c   | 11 +++++------
 include/linux/tty.h |  3 ---
 include/linux/ve.h  |  1 +
 4 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 202ef49efe88..ede54ee1b9a1 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -49,6 +49,7 @@
 #include <linux/module.h>
 #include <linux/ratelimit.h>
 #include <linux/vmalloc.h>
+#include <linux/ve.h>
 
 
 /* number of characters left in xmit buffer before select has we have room */
@@ -2324,8 +2325,7 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file,
 		}
 #ifdef CONFIG_VE
 		if (tty_hung_up_p(file) ||
-		    (tty->link && !tty->link->count &&
-		     !(test_bit(TTY_PINNED_BY_OTHER, &tty->link->flags)))) {
+		 (tty->link && !tty->link->count && !vtty_is_master(tty->link))) {
 #else
 		if (tty_hung_up_p(file) || (tty->link && !tty->link->count)) {
 #endif
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 78ab6562e4d8..8d2e8fa4ac6d 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -639,6 +639,11 @@ static struct file_operations vtty_fops;
 #define MAX_NR_VTTY_CONSOLES	(12)
 #define vtty_match_index(idx)	((idx) >= 0 && (idx) < MAX_NR_VTTY_CONSOLES)
 
+bool vtty_is_master(struct tty_struct *tty)
+{
+	return tty->driver == vttym_driver;
+}
+
 typedef struct {
 	envid_t			veid;
 	struct tty_struct	*vttys[MAX_NR_VTTY_CONSOLES];
@@ -820,12 +825,6 @@ static int vtty_install(struct tty_driver *driver, struct tty_struct *tty)
 	tty->link = peer;
 	peer->link = tty;
 
-	/*
-	 * Defer master closing if a slave peer
-	 * will be alive at this moment.
-	 */
-	set_bit(TTY_PINNED_BY_OTHER, &peer->flags);
-
 	vtty_map_set(map, tty);
 	return 0;
 
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 91cbc2188b4a..808fbfe86f85 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -367,9 +367,6 @@ struct tty_file_private {
 #define TTY_HUPPED 		18	/* Post driver->hangup() */
 #define TTY_HUPPING		19	/* Hangup in progress */
 #define TTY_LDISC_HALTED	22	/* Line discipline is halted */
-#ifdef CONFIG_VE
-#define TTY_PINNED_BY_OTHER	24	/* TTY is pinned by other link end, defer closing */
-#endif
 
 /* Values for tty->flow_change */
 #define TTY_THROTTLE_SAFE 1
diff --git a/include/linux/ve.h b/include/linux/ve.h
index 73a7216e7246..8dca4a65a209 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -210,6 +210,7 @@ extern struct tty_driver *vtty_console_driver(int *index);
 extern int vtty_open_master(envid_t veid, int idx);
 extern void vtty_release(struct tty_struct *tty, struct tty_struct *o_tty,
 			int *tty_closing, int *o_tty_closing);
+extern bool vtty_is_master(struct tty_struct *tty);
 #endif /* CONFIG_TTY */
 
 extern struct cgroup *cgroup_get_ve_root1(struct cgroup *cgrp);


More information about the Devel mailing list