drbd: let drbd_free_ee implicitly free any digest
authorLars Ellenberg <lars.ellenberg@linbit.com>
Wed, 11 Aug 2010 18:42:55 +0000 (20:42 +0200)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Thu, 14 Oct 2010 16:38:16 +0000 (18:38 +0200)
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_receiver.c
drivers/block/drbd/drbd_worker.c

index b0cbfa1437752ee1428440563479afd675401b7a..3a941744f0694f7d94d988c133fdf5c19f9ceff8 100644 (file)
@@ -796,12 +796,16 @@ enum {
         * if any of those fail, we set this flag atomically
         * from the endio callback */
        __EE_WAS_ERROR,
+
+       /* This ee has a pointer to a digest instead of a block id */
+       __EE_HAS_DIGEST,
 };
 #define EE_CALL_AL_COMPLETE_IO (1<<__EE_CALL_AL_COMPLETE_IO)
 #define EE_MAY_SET_IN_SYNC     (1<<__EE_MAY_SET_IN_SYNC)
 #define EE_IS_BARRIER          (1<<__EE_IS_BARRIER)
 #define        EE_RESUBMITTED         (1<<__EE_RESUBMITTED)
 #define EE_WAS_ERROR           (1<<__EE_WAS_ERROR)
+#define EE_HAS_DIGEST          (1<<__EE_HAS_DIGEST)
 
 /* global flag bits */
 enum {
index 0b03e3174f760f771e1d46c6eba4b4d450a4f78c..2f9320be4906df4ce713d8da86cc4a136a4770e6 100644 (file)
@@ -377,6 +377,8 @@ struct drbd_epoch_entry *drbd_alloc_ee(struct drbd_conf *mdev,
 
 void drbd_free_ee(struct drbd_conf *mdev, struct drbd_epoch_entry *e)
 {
+       if (e->flags & EE_HAS_DIGEST)
+               kfree(e->digest);
        drbd_pp_free(mdev, e->pages);
        D_ASSERT(atomic_read(&e->pending_bios) == 0);
        D_ASSERT(hlist_unhashed(&e->colision));
@@ -2094,10 +2096,12 @@ static int receive_DataRequest(struct drbd_conf *mdev, struct p_header *h)
                di->digest_size = digest_size;
                di->digest = (((char *)di)+sizeof(struct digest_info));
 
+               e->digest = di;
+               e->flags |= EE_HAS_DIGEST;
+
                if (drbd_recv(mdev, di->digest, digest_size) != digest_size)
                        goto out_free_e;
 
-               e->digest = di;
                if (h->command == P_CSUM_RS_REQUEST) {
                        D_ASSERT(mdev->agreed_pro_version >= 89);
                        e->w.cb = w_e_end_csum_rs_req;
@@ -2159,7 +2163,6 @@ static int receive_DataRequest(struct drbd_conf *mdev, struct p_header *h)
                return TRUE;
 
 out_free_e:
-       kfree(di);
        put_ldev(mdev);
        drbd_free_ee(mdev, e);
        return FALSE;
index f979e22cc6fb35f46a8bbfd41a24fd84b5c63e69..48452fe83603c76b356b13ed8ec847bf0b32bfef 100644 (file)
@@ -1052,9 +1052,6 @@ int w_e_end_csum_rs_req(struct drbd_conf *mdev, struct drbd_work *w, int cancel)
        }
 
        dec_unacked(mdev);
-
-       kfree(di);
-
        move_to_net_ee_or_free(mdev, e);
 
        if (unlikely(!ok))
@@ -1145,9 +1142,6 @@ int w_e_end_ov_reply(struct drbd_conf *mdev, struct drbd_work *w, int cancel)
        }
 
        dec_unacked(mdev);
-
-       kfree(di);
-
        if (!eq)
                drbd_ov_oos_found(mdev, e->sector, e->size);
        else