)]}'
{
  "commit": "65b770468e98941e45e19780dff9283e663e6b8b",
  "tree": "d6984bb568587433cc7f6d7c3bf65287bbad28ef",
  "parents": [
    "18eac1cc100fa2afd5f39085aae6b694e417734b"
  ],
  "author": {
    "name": "Linus Torvalds",
    "email": "torvalds@linux-foundation.org",
    "time": "Mon Aug 03 11:11:19 2009 -0700"
  },
  "committer": {
    "name": "Greg Kroah-Hartman",
    "email": "gregkh@suse.de",
    "time": "Tue Aug 04 13:46:30 2009 -0700"
  },
  "message": "tty-ldisc: turn ldisc user count into a proper refcount\n\nBy using the user count for the actual lifetime rules, we can get rid of\nthe silly \"wait_for_idle\" logic, because any busy ldisc will\nautomatically stay around until the last user releases it.  This avoids\na host of odd issues, and simplifies the code.\n\nSo now, when the last ldisc reference is dropped, we just release the\nldisc operations struct reference, and free the ldisc.\n\nIt looks obvious enough, and it does work for me, but the counting\n_could_ be off. It probably isn\u0027t (bad counting in the new version would\ngenerally imply that the old code did something really bad, like free an\nldisc with a non-zero count), but it does need some testing, and\npreferably somebody looking at it.\n\nWith this change, both \u0027tty_ldisc_put()\u0027 and \u0027tty_ldisc_deref()\u0027 are\njust aliases for the new ref-counting \u0027put_ldisc()\u0027. Both of them\ndecrement the ldisc user count and free it if it goes down to zero.\nThey\u0027re identical functions, in other words.\n\nBut the reason they still exist as sepate functions is that one of them\nwas exported (tty_ldisc_deref) and had a stupid name (so I don\u0027t want to\nuse it as the main name), and the other one was used in multiple places\n(and I didn\u0027t want to make the patch larger just to rename the users).\n\nIn addition to the refcounting, I did do some minimal cleanup. For\nexample, now \"tty_ldisc_try()\" actually returns the ldisc it got under\nthe lock, rather than returning true/false and then the caller would\nlook up the ldisc again (now without the protection of the lock).\n\nThat said, there\u0027s tons of dubious use of \u0027tty-\u003eldisc\u0027 without obviously\nproper locking or refcounting left. I expressly did _not_ want to try to\nfix it all, keeping the patch minimal. There may or may not be bugs in\nthat kind of code, but they wouldn\u0027t be _new_ bugs.\n\nThat said, even if the bugs aren\u0027t new, the timing and lifetime will\nchange. For example, some silly code may depend on the \u0027tty-\u003eldisc\u0027\npointer not changing because they hold a refcount on the \u0027ldisc\u0027. And\nthat\u0027s no longer true - if you hold a ref on the ldisc, the \u0027ldisc\u0027\nitself is safe, but tty-\u003eldisc may change.\n\nSo the proper locking (remains) to hold tty-\u003eldisc_mutex if you expect\ntty-\u003eldisc to be stable. That\u0027s not really a _new_ rule, but it\u0027s an\nexample of something that the old code might have unintentionally\ndepended on and hidden bugs.\n\nWhatever. The patch _looks_ sensible to me. The only users of\nldisc-\u003eusers are:\n - get_ldisc() - atomically increment the count\n\n - put_ldisc() - atomically decrements the count and releases if zero\n\n - tty_ldisc_try_get() - creates the ldisc, and sets the count to 1.\n   The ldisc should then either be released, or be attached to a tty.\n\nSigned-off-by: Linus Torvalds \u003ctorvalds@linux-foundation.org\u003e\nTested-by: OGAWA Hirofumi \u003chirofumi@mail.parknet.co.jp\u003e\nTested-by: Sergey Senozhatsky \u003csergey.senozhatsky@mail.by\u003e\nAcked-by: Alan Cox \u003calan@linux.intel.com\u003e\nSigned-off-by: Greg Kroah-Hartman \u003cgregkh@suse.de\u003e\n\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "fd175e60aad5801e27299b2cdb1fcb9c41906550",
      "old_mode": 33188,
      "old_path": "drivers/char/tty_ldisc.c",
      "new_id": "be55dfcf59ac68d496fb54cdd9769601455af304",
      "new_mode": 33188,
      "new_path": "drivers/char/tty_ldisc.c"
    }
  ]
}
