)]}'
{
  "commit": "6d45d93ead319423099b82a4efd775bc0f159121",
  "tree": "6af9a92a7e9ef38aac856233d7721e3dfaefbd3e",
  "parents": [
    "012abeea669ea49636cf952d13298bb68654146a"
  ],
  "author": {
    "name": "Mikulas Patocka",
    "email": "mpatocka@redhat.com",
    "time": "Fri Oct 16 23:18:14 2009 +0100"
  },
  "committer": {
    "name": "Alasdair G Kergon",
    "email": "agk@redhat.com",
    "time": "Fri Oct 16 23:18:14 2009 +0100"
  },
  "message": "dm snapshot: sort by chunk size to fix race\n\nAvoid a race causing corruption when snapshots of the same origin have\ndifferent chunk sizes by sorting the internal list of snapshots by chunk\nsize, largest first.\n  https://bugzilla.redhat.com/show_bug.cgi?id\u003d182659\n\nFor example, let\u0027s have two snapshots with different chunk sizes. The\nfirst snapshot (1) has small chunk size and the second snapshot (2) has\nlarge chunk size.  Let\u0027s have chunks A, B, C in these snapshots:\nsnapshot1: \u003d\u003d\u003d\u003dA\u003d\u003d\u003d\u003d   \u003d\u003d\u003d\u003dB\u003d\u003d\u003d\u003d\nsnapshot2: \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003dC\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\n(Chunk size is a power of 2. Chunks are aligned.)\n\nA write to the origin at a position within A and C comes along. It\ntriggers reallocation of A, then reallocation of C and links them\ntogether using A as the \u0027primary\u0027 exception.\n\nThen another write to the origin comes along at a position within B and\nC.  It creates pending exception for B.  C already has a reallocation in\nprogress and it already has a primary exception (A), so nothing is done\nto it: B and C are not linked.\n\nIf the reallocation of B finishes before the reallocation of C, because\nthere is no link with the pending exception for C it does not know to\nwait for it and, the second write is dispatched to the origin and causes\ndata corruption in the chunk C in snapshot2.\n\nTo avoid this situation, we maintain snapshots sorted in descending\norder of chunk size.  This leads to a guaranteed ordering on the links\nbetween the pending exceptions and avoids the problem explained above -\nboth A and B now get linked to C.\n\nCc: stable@kernel.org\nSigned-off-by: Mikulas Patocka \u003cmpatocka@redhat.com\u003e\nSigned-off-by: Alasdair G Kergon \u003cagk@redhat.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "57f1bf7f3b7a1d4ffd18f51563a2d5c52b0693ad",
      "old_mode": 33188,
      "old_path": "drivers/md/dm-snap.c",
      "new_id": "3a53a5a9bec8fd5d092dbb12230d29fd3551261d",
      "new_mode": 33188,
      "new_path": "drivers/md/dm-snap.c"
    }
  ]
}
