[Devel] [RFC rh7 v6] ve/tty: vt -- Implement per VE support for console and terminals

Cyrill Gorcunov gorcunov at virtuozzo.com
Mon Aug 31 11:07:07 PDT 2015


On Mon, Aug 31, 2015 at 08:19:50PM +0300, Vladimir Davydov wrote:

OK, to all prev comments, thank you!

> > +		tty = tty_init_dev(vttys_driver, idx);
> > +		if (IS_ERR(tty))
> > +			goto err_install;
> 
> So we have master:0 slave:1 here, right?

yes

> 
> > +		tty->count--;
> 
> master:0 slave:0

yes

> 
> > +		tty_unlock(tty);
> > +		tty = tty->link;
> > +	}
> > +
> > +	/* One master at a time */
> > +	if (tty->count >= 1) {
> > +		ret = -EBUSY;
> > +		goto err_install;
> > +	}
> > +
> > +	vtty_drop_context();
> > +
> > +	WARN_ON(!test_bit(TTY_LDISC, &tty->flags));
> > +
> > +	/*
> > +	 * We're the master peer so increment
> > +	 * slave counter as well.
> > +	 */
> > +	tty_add_file(tty, file);
> > +	tty->count++;
> 
> If we just created the pair:
> 	master:1 slave:0
> otherwise:
> 	master:1 slave:1+nusers

 	master:1 slave:nusers, there is no additional +1 on it yet

> 
> > +	tty->link->count++;
> 
> If we just created the pair:
> 	master:1 slave:1	- that's correct
> otherwise:
> 	master:1 slave:2+nusers	- that's not correct, slave count must
> 				  be equal to 1+nusers here

The vtty_install, which creates a new peer, always return slave tty
with configuration master:0 slave:1. We have two scenario possible

1) Open master from node creating a new tty pair

	tty = tty_init_dev() 		=> master: 0 slave: 1
	tty->count--; 			=> master: 0 slave: 0

	tty = tty->link; 		now tty points to master

	tty->count++; 			=> master: 1 slave: 0
	tty->link->count++; 		=> master: 1 slave: 1

2) Open master from the node but with alreasy existing pair

	tty = vtty_lookup() 		=> master: 0 slave: n

	vtty_lookup cares about the driver so tty points to master from lookup

	tty->count++; 			=> master: 1 slave: n
 	tty->link->count++; 		=> master: 1 slave: n+1

IOW when master get opened it always increment the counter
of a slave peer, which gonna be decremented back in tty_release
once master is closed. What I'm missing?

> 
> I think we only want to increment tty->link->count here if the pari was
> just created. Therefore, to fix this, you can just drop this increment
> along with the tty->count decrement after tty_init_dev.
> 

OK to the rest of comms.



More information about the Devel mailing list