]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - fs/afs/cmservice.c
smack: use pernet operations for hook registration
[mirror_ubuntu-artful-kernel.git] / fs / afs / cmservice.c
index d764236072b192d33a0b8eedb3821d7391991067..3062cceb5c2aebcc4a15e3c52d1b26ecea82f20d 100644 (file)
@@ -24,65 +24,86 @@ static int afs_deliver_cb_callback(struct afs_call *);
 static int afs_deliver_cb_probe_uuid(struct afs_call *);
 static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *);
 static void afs_cm_destructor(struct afs_call *);
+static void SRXAFSCB_CallBack(struct work_struct *);
+static void SRXAFSCB_InitCallBackState(struct work_struct *);
+static void SRXAFSCB_Probe(struct work_struct *);
+static void SRXAFSCB_ProbeUuid(struct work_struct *);
+static void SRXAFSCB_TellMeAboutYourself(struct work_struct *);
+
+#define CM_NAME(name) \
+       const char afs_SRXCB##name##_name[] __tracepoint_string =       \
+               "CB." #name
 
 /*
  * CB.CallBack operation type
  */
+static CM_NAME(CallBack);
 static const struct afs_call_type afs_SRXCBCallBack = {
-       .name           = "CB.CallBack",
+       .name           = afs_SRXCBCallBack_name,
        .deliver        = afs_deliver_cb_callback,
        .abort_to_error = afs_abort_to_error,
        .destructor     = afs_cm_destructor,
+       .work           = SRXAFSCB_CallBack,
 };
 
 /*
  * CB.InitCallBackState operation type
  */
+static CM_NAME(InitCallBackState);
 static const struct afs_call_type afs_SRXCBInitCallBackState = {
-       .name           = "CB.InitCallBackState",
+       .name           = afs_SRXCBInitCallBackState_name,
        .deliver        = afs_deliver_cb_init_call_back_state,
        .abort_to_error = afs_abort_to_error,
        .destructor     = afs_cm_destructor,
+       .work           = SRXAFSCB_InitCallBackState,
 };
 
 /*
  * CB.InitCallBackState3 operation type
  */
+static CM_NAME(InitCallBackState3);
 static const struct afs_call_type afs_SRXCBInitCallBackState3 = {
-       .name           = "CB.InitCallBackState3",
+       .name           = afs_SRXCBInitCallBackState3_name,
        .deliver        = afs_deliver_cb_init_call_back_state3,
        .abort_to_error = afs_abort_to_error,
        .destructor     = afs_cm_destructor,
+       .work           = SRXAFSCB_InitCallBackState,
 };
 
 /*
  * CB.Probe operation type
  */
+static CM_NAME(Probe);
 static const struct afs_call_type afs_SRXCBProbe = {
-       .name           = "CB.Probe",
+       .name           = afs_SRXCBProbe_name,
        .deliver        = afs_deliver_cb_probe,
        .abort_to_error = afs_abort_to_error,
        .destructor     = afs_cm_destructor,
+       .work           = SRXAFSCB_Probe,
 };
 
 /*
  * CB.ProbeUuid operation type
  */
+static CM_NAME(ProbeUuid);
 static const struct afs_call_type afs_SRXCBProbeUuid = {
-       .name           = "CB.ProbeUuid",
+       .name           = afs_SRXCBProbeUuid_name,
        .deliver        = afs_deliver_cb_probe_uuid,
        .abort_to_error = afs_abort_to_error,
        .destructor     = afs_cm_destructor,
+       .work           = SRXAFSCB_ProbeUuid,
 };
 
 /*
  * CB.TellMeAboutYourself operation type
  */
+static CM_NAME(TellMeAboutYourself);
 static const struct afs_call_type afs_SRXCBTellMeAboutYourself = {
-       .name           = "CB.TellMeAboutYourself",
+       .name           = afs_SRXCBTellMeAboutYourself_name,
        .deliver        = afs_deliver_cb_tell_me_about_yourself,
        .abort_to_error = afs_abort_to_error,
        .destructor     = afs_cm_destructor,
+       .work           = SRXAFSCB_TellMeAboutYourself,
 };
 
 /*
@@ -153,6 +174,7 @@ static void SRXAFSCB_CallBack(struct work_struct *work)
        afs_send_empty_reply(call);
 
        afs_break_callbacks(call->server, call->count, call->request);
+       afs_put_call(call);
        _leave("");
 }
 
@@ -165,7 +187,6 @@ static int afs_deliver_cb_callback(struct afs_call *call)
        struct afs_callback *cb;
        struct afs_server *server;
        __be32 *bp;
-       u32 tmp;
        int ret, loop;
 
        _enter("{%u}", call->unmarshall);
@@ -227,9 +248,9 @@ static int afs_deliver_cb_callback(struct afs_call *call)
                if (ret < 0)
                        return ret;
 
-               tmp = ntohl(call->tmp);
-               _debug("CB count: %u", tmp);
-               if (tmp != call->count && tmp != 0)
+               call->count2 = ntohl(call->tmp);
+               _debug("CB count: %u", call->count2);
+               if (call->count2 != call->count && call->count2 != 0)
                        return -EBADMSG;
                call->offset = 0;
                call->unmarshall++;
@@ -237,14 +258,14 @@ static int afs_deliver_cb_callback(struct afs_call *call)
        case 4:
                _debug("extract CB array");
                ret = afs_extract_data(call, call->buffer,
-                                      call->count * 3 * 4, false);
+                                      call->count2 * 3 * 4, false);
                if (ret < 0)
                        return ret;
 
                _debug("unmarshall CB array");
                cb = call->request;
                bp = call->buffer;
-               for (loop = call->count; loop > 0; loop--, cb++) {
+               for (loop = call->count2; loop > 0; loop--, cb++) {
                        cb->version     = ntohl(*bp++);
                        cb->expiry      = ntohl(*bp++);
                        cb->type        = ntohl(*bp++);
@@ -274,9 +295,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
                return -ENOTCONN;
        call->server = server;
 
-       INIT_WORK(&call->work, SRXAFSCB_CallBack);
-       queue_work(afs_wq, &call->work);
-       return 0;
+       return afs_queue_call_work(call);
 }
 
 /*
@@ -290,6 +309,7 @@ static void SRXAFSCB_InitCallBackState(struct work_struct *work)
 
        afs_init_callback_state(call->server);
        afs_send_empty_reply(call);
+       afs_put_call(call);
        _leave("");
 }
 
@@ -320,9 +340,7 @@ static int afs_deliver_cb_init_call_back_state(struct afs_call *call)
                return -ENOTCONN;
        call->server = server;
 
-       INIT_WORK(&call->work, SRXAFSCB_InitCallBackState);
-       queue_work(afs_wq, &call->work);
-       return 0;
+       return afs_queue_call_work(call);
 }
 
 /*
@@ -332,7 +350,7 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
 {
        struct sockaddr_rxrpc srx;
        struct afs_server *server;
-       struct afs_uuid *r;
+       struct uuid_v1 *r;
        unsigned loop;
        __be32 *b;
        int ret;
@@ -362,15 +380,15 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
                }
 
                _debug("unmarshall UUID");
-               call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL);
+               call->request = kmalloc(sizeof(struct uuid_v1), GFP_KERNEL);
                if (!call->request)
                        return -ENOMEM;
 
                b = call->buffer;
                r = call->request;
-               r->time_low                     = ntohl(b[0]);
-               r->time_mid                     = ntohl(b[1]);
-               r->time_hi_and_version          = ntohl(b[2]);
+               r->time_low                     = b[0];
+               r->time_mid                     = htons(ntohl(b[1]));
+               r->time_hi_and_version          = htons(ntohl(b[2]));
                r->clock_seq_hi_and_reserved    = ntohl(b[3]);
                r->clock_seq_low                = ntohl(b[4]);
 
@@ -394,9 +412,7 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
                return -ENOTCONN;
        call->server = server;
 
-       INIT_WORK(&call->work, SRXAFSCB_InitCallBackState);
-       queue_work(afs_wq, &call->work);
-       return 0;
+       return afs_queue_call_work(call);
 }
 
 /*
@@ -408,6 +424,7 @@ static void SRXAFSCB_Probe(struct work_struct *work)
 
        _enter("");
        afs_send_empty_reply(call);
+       afs_put_call(call);
        _leave("");
 }
 
@@ -427,9 +444,7 @@ static int afs_deliver_cb_probe(struct afs_call *call)
        /* no unmarshalling required */
        call->state = AFS_CALL_REPLYING;
 
-       INIT_WORK(&call->work, SRXAFSCB_Probe);
-       queue_work(afs_wq, &call->work);
-       return 0;
+       return afs_queue_call_work(call);
 }
 
 /*
@@ -438,7 +453,7 @@ static int afs_deliver_cb_probe(struct afs_call *call)
 static void SRXAFSCB_ProbeUuid(struct work_struct *work)
 {
        struct afs_call *call = container_of(work, struct afs_call, work);
-       struct afs_uuid *r = call->request;
+       struct uuid_v1 *r = call->request;
 
        struct {
                __be32  match;
@@ -452,6 +467,7 @@ static void SRXAFSCB_ProbeUuid(struct work_struct *work)
                reply.match = htonl(1);
 
        afs_send_simple_reply(call, &reply, sizeof(reply));
+       afs_put_call(call);
        _leave("");
 }
 
@@ -460,7 +476,7 @@ static void SRXAFSCB_ProbeUuid(struct work_struct *work)
  */
 static int afs_deliver_cb_probe_uuid(struct afs_call *call)
 {
-       struct afs_uuid *r;
+       struct uuid_v1 *r;
        unsigned loop;
        __be32 *b;
        int ret;
@@ -486,15 +502,15 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)
                }
 
                _debug("unmarshall UUID");
-               call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL);
+               call->request = kmalloc(sizeof(struct uuid_v1), GFP_KERNEL);
                if (!call->request)
                        return -ENOMEM;
 
                b = call->buffer;
                r = call->request;
-               r->time_low                     = ntohl(b[0]);
-               r->time_mid                     = ntohl(b[1]);
-               r->time_hi_and_version          = ntohl(b[2]);
+               r->time_low                     = b[0];
+               r->time_mid                     = htons(ntohl(b[1]));
+               r->time_hi_and_version          = htons(ntohl(b[2]));
                r->clock_seq_hi_and_reserved    = ntohl(b[3]);
                r->clock_seq_low                = ntohl(b[4]);
 
@@ -510,9 +526,7 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)
 
        call->state = AFS_CALL_REPLYING;
 
-       INIT_WORK(&call->work, SRXAFSCB_ProbeUuid);
-       queue_work(afs_wq, &call->work);
-       return 0;
+       return afs_queue_call_work(call);
 }
 
 /*
@@ -554,9 +568,9 @@ static void SRXAFSCB_TellMeAboutYourself(struct work_struct *work)
        memset(&reply, 0, sizeof(reply));
        reply.ia.nifs = htonl(nifs);
 
-       reply.ia.uuid[0] = htonl(afs_uuid.time_low);
-       reply.ia.uuid[1] = htonl(afs_uuid.time_mid);
-       reply.ia.uuid[2] = htonl(afs_uuid.time_hi_and_version);
+       reply.ia.uuid[0] = afs_uuid.time_low;
+       reply.ia.uuid[1] = htonl(ntohs(afs_uuid.time_mid));
+       reply.ia.uuid[2] = htonl(ntohs(afs_uuid.time_hi_and_version));
        reply.ia.uuid[3] = htonl((s8) afs_uuid.clock_seq_hi_and_reserved);
        reply.ia.uuid[4] = htonl((s8) afs_uuid.clock_seq_low);
        for (loop = 0; loop < 6; loop++)
@@ -574,7 +588,7 @@ static void SRXAFSCB_TellMeAboutYourself(struct work_struct *work)
        reply.cap.capcount = htonl(1);
        reply.cap.caps[0] = htonl(AFS_CAP_ERROR_TRANSLATION);
        afs_send_simple_reply(call, &reply, sizeof(reply));
-
+       afs_put_call(call);
        _leave("");
 }
 
@@ -594,7 +608,5 @@ static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *call)
        /* no unmarshalling required */
        call->state = AFS_CALL_REPLYING;
 
-       INIT_WORK(&call->work, SRXAFSCB_TellMeAboutYourself);
-       queue_work(afs_wq, &call->work);
-       return 0;
+       return afs_queue_call_work(call);
 }