)]}'
{
  "commit": "df2cb6daa4cbc34406bc4b1ac9b9335df1083a72",
  "tree": "effcb15a6e524696a82383c74bf01a812da22b97",
  "parents": [
    "57fb233f078beb5d0437a4ae575fbd4d9eb9c738"
  ],
  "author": {
    "name": "Kent Overstreet",
    "email": "koverstreet@google.com",
    "time": "Mon Sep 10 14:33:46 2012 -0700"
  },
  "committer": {
    "name": "Kent Overstreet",
    "email": "koverstreet@google.com",
    "time": "Sat Mar 23 14:15:26 2013 -0700"
  },
  "message": "block: Avoid deadlocks with bio allocation by stacking drivers\n\nPreviously, if we ever try to allocate more than once from the same bio\nset while running under generic_make_request() (i.e. a stacking block\ndriver), we risk deadlock.\n\nThis is because of the code in generic_make_request() that converts\nrecursion to iteration; any bios we submit won\u0027t actually be submitted\n(so they can complete and eventually be freed) until after we return -\nthis means if we allocate a second bio, we\u0027re blocking the first one\nfrom ever being freed.\n\nThus if enough threads call into a stacking block driver at the same\ntime with bios that need multiple splits, and the bio_set\u0027s reserve gets\nused up, we deadlock.\n\nThis can be worked around in the driver code - we could check if we\u0027re\nrunning under generic_make_request(), then mask out __GFP_WAIT when we\ngo to allocate a bio, and if the allocation fails punt to workqueue and\nretry the allocation.\n\nBut this is tricky and not a generic solution. This patch solves it for\nall users by inverting the previously described technique. We allocate a\nrescuer workqueue for each bio_set, and then in the allocation code if\nthere are bios on current-\u003ebio_list we would be blocking, we punt them\nto the rescuer workqueue to be submitted.\n\nThis guarantees forward progress for bio allocations under\ngeneric_make_request() provided each bio is submitted before allocating\nthe next, and provided the bios are freed after they complete.\n\nNote that this doesn\u0027t do anything for allocation from other mempools.\nInstead of allocating per bio data structures from a mempool, code\nshould use bio_set\u0027s front_pad.\n\nTested it by forcing the rescue codepath to be taken (by disabling the\nfirst GFP_NOWAIT) attempt, and then ran it with bcache (which does a lot\nof arbitrary bio splitting) and verified that the rescuer was being\ninvoked.\n\nSigned-off-by: Kent Overstreet \u003ckoverstreet@google.com\u003e\nCC: Jens Axboe \u003caxboe@kernel.dk\u003e\nAcked-by: Tejun Heo \u003ctj@kernel.org\u003e\nReviewed-by: Muthukumar Ratty \u003cmuthur@gmail.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "bb5768f59b32e22fdcde250f0ae8b01eb6b69b48",
      "old_mode": 33188,
      "old_path": "fs/bio.c",
      "new_id": "73b544709945ee2109020c157b2a35b37f5839e9",
      "new_mode": 33188,
      "new_path": "fs/bio.c"
    },
    {
      "type": "modify",
      "old_id": "93d3d17a300d5d0325cd2cf87c28026ca1a310d1",
      "old_mode": 33188,
      "old_path": "include/linux/bio.h",
      "new_id": "b31036ff779f216d78b8b6ad7c7f8c9b43dacff7",
      "new_mode": 33188,
      "new_path": "include/linux/bio.h"
    }
  ]
}
