ceph: avoid repeatedly adding inode to mdsc->snap_flush_list
authorYan, Zheng <[email protected]>
Mon, 11 Feb 2019 07:18:52 +0000 (15:18 +0800)
committerIlya Dryomov <[email protected]>
Mon, 18 Feb 2019 17:08:29 +0000 (18:08 +0100)
Otherwise, mdsc->snap_flush_list may get corrupted.

Cc: [email protected]
Signed-off-by: "Yan, Zheng" <[email protected]>
Reviewed-by: Ilya Dryomov <[email protected]>
Signed-off-by: Ilya Dryomov <[email protected]>
fs/ceph/snap.c

index 041c27ea8de155a0002bdb5af25eb2fc5f8e6efa..f74193da0e092b09254fec756bde39f5bfed649d 100644 (file)
@@ -616,7 +616,8 @@ int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
             capsnap->size);
 
        spin_lock(&mdsc->snap_flush_lock);
-       list_add_tail(&ci->i_snap_flush_item, &mdsc->snap_flush_list);
+       if (list_empty(&ci->i_snap_flush_item))
+               list_add_tail(&ci->i_snap_flush_item, &mdsc->snap_flush_list);
        spin_unlock(&mdsc->snap_flush_lock);
        return 1;  /* caller may want to ceph_flush_snaps */
 }