ceph: properly queue cap snap for newly created snap realm
authorYan, Zheng <zyan@redhat.com>
Fri, 22 Sep 2017 01:26:57 +0000 (09:26 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 2 Oct 2017 14:18:01 +0000 (16:18 +0200)
commit 3ae0bebc "ceph: queue cap snap only when snap realm's
context changes" introduced a regression: we may not call
queue_realm_cap_snaps() for newly created snap realm. This
regression allows unflushed snapshot data to be overwritten.

Link: http://tracker.ceph.com/issues/21483
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/snap.c

index 1ffc8b426c1c4c9f444c5eda57cc803ca5016783..7fc0b850c35279646a6eb48a595870a2ce9d6cfd 100644 (file)
@@ -374,12 +374,10 @@ static int build_snap_context(struct ceph_snap_realm *realm,
             realm->ino, realm, snapc, snapc->seq,
             (unsigned int) snapc->num_snaps);
 
-       if (realm->cached_context) {
-               ceph_put_snap_context(realm->cached_context);
-               /* queue realm for cap_snap creation */
-               list_add_tail(&realm->dirty_item, dirty_realms);
-       }
+       ceph_put_snap_context(realm->cached_context);
        realm->cached_context = snapc;
+       /* queue realm for cap_snap creation */
+       list_add_tail(&realm->dirty_item, dirty_realms);
        return 0;
 
 fail: