libceph: grab snapc in ceph_osdc_alloc_request()
[cascardo/linux.git] / net / ceph / osd_client.c
index 32355d9..ccb9539 100644 (file)
@@ -354,9 +354,11 @@ EXPORT_SYMBOL(ceph_osdc_get_request);
 
 void ceph_osdc_put_request(struct ceph_osd_request *req)
 {
-       dout("%s %p (was %d)\n", __func__, req,
-            atomic_read(&req->r_kref.refcount));
-       kref_put(&req->r_kref, ceph_osdc_release_request);
+       if (req) {
+               dout("%s %p (was %d)\n", __func__, req,
+                    atomic_read(&req->r_kref.refcount));
+               kref_put(&req->r_kref, ceph_osdc_release_request);
+       }
 }
 EXPORT_SYMBOL(ceph_osdc_put_request);
 
@@ -389,6 +391,8 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
        req->r_osdc = osdc;
        req->r_mempool = use_mempool;
        req->r_num_ops = num_ops;
+       req->r_snapid = CEPH_NOSNAP;
+       req->r_snapc = ceph_get_snap_context(snapc);
 
        kref_init(&req->r_kref);
        init_completion(&req->r_completion);
@@ -1087,10 +1091,8 @@ static void put_osd(struct ceph_osd *osd)
        dout("put_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref),
             atomic_read(&osd->o_ref) - 1);
        if (atomic_dec_and_test(&osd->o_ref)) {
-               struct ceph_auth_client *ac = osd->o_osdc->client->monc.auth;
-
                if (osd->o_auth.authorizer)
-                       ceph_auth_destroy_authorizer(ac, osd->o_auth.authorizer);
+                       ceph_auth_destroy_authorizer(osd->o_auth.authorizer);
                kfree(osd);
        }
 }
@@ -2457,7 +2459,7 @@ void ceph_osdc_build_request(struct ceph_osd_request *req, u64 off,
        unsigned int i;
 
        req->r_snapid = snap_id;
-       req->r_snapc = ceph_get_snap_context(snapc);
+       WARN_ON(snapc != req->r_snapc);
 
        /* encode request */
        msg->hdr.version = cpu_to_le16(4);
@@ -2508,7 +2510,7 @@ void ceph_osdc_build_request(struct ceph_osd_request *req, u64 off,
        ceph_encode_64(&p, req->r_snapc ? req->r_snapc->seq : 0);
        ceph_encode_32(&p, req->r_snapc ? req->r_snapc->num_snaps : 0);
        if (req->r_snapc) {
-               for (i = 0; i < snapc->num_snaps; i++) {
+               for (i = 0; i < req->r_snapc->num_snaps; i++) {
                        ceph_encode_64(&p, req->r_snapc->snaps[i]);
                }
        }
@@ -2984,7 +2986,7 @@ static struct ceph_auth_handshake *get_authorizer(struct ceph_connection *con,
        struct ceph_auth_handshake *auth = &o->o_auth;
 
        if (force_new && auth->authorizer) {
-               ceph_auth_destroy_authorizer(ac, auth->authorizer);
+               ceph_auth_destroy_authorizer(auth->authorizer);
                auth->authorizer = NULL;
        }
        if (!auth->authorizer) {