sheepdog: fix vdi object update after live snapshot
commitb544c1aba8681c2fe5d6715fbd37cf6caf1bc7bb
authorHitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Fri, 6 Jun 2014 04:35:11 +0000 (6 13:35 +0900)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 6 Jun 2014 12:53:55 +0000 (6 14:53 +0200)
tree88e449eb666a95692dbf100c7b9f53f7cb0018d7
parent405a27640b33c31ccef4001b3f3936b8c9d2218f
sheepdog: fix vdi object update after live snapshot

sheepdog driver should decide a write request is COW or not based on inode
object which is active when the write request is issued.

Example of wrong inode update path in the previous driver:
1. drier issues an ordinal write request to an existing object
2. user creates a snapshot of the VDI before the write request is completed
3. the respones for the request is RDONLY, because the VDI is already a snapshot
4. the driver reload an inode object of the new active VDI, then issues a write
   request again
5. the second write request can be completed
6. driver decide the request is COW or not with the below conditional branch:
      if (s->inode.data_vdi_id[idx] != s->inode.vdi_id) {
7. the ID of the written object and VID of the new active VDI is different, so
   the driver updates data_vdi_id[idx] and writes inode object
8. the existing object cannot be seen by the new active VDI, it results object
   leaking

Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Liu Yuan <namei.unix@gmail.com>
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/sheepdog.c