Skip to content

Commit aaa9c10

Browse files
committed
Merge tag 'rxrpc-rewrite-20170109' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
David Howells says: ==================== afs: Refcount afs_call struct These patches provide some tracepoints for AFS and fix a potential leak by adding refcounting to the afs_call struct. The patches are: (1) Add some tracepoints for logging incoming calls and monitoring notifications from AF_RXRPC and data reception. (2) Get rid of afs_wait_mode as it didn't turn out to be as useful as initially expected. It can be brought back later if needed. This clears some stuff out that I don't then need to fix up in (4). (3) Allow listen(..., 0) to be used to disable listening. This makes shutting down the AFS cache manager server in the kernel much easier and the accounting simpler as we can then be sure that (a) all preallocated afs_call structs are relesed and (b) no new incoming calls are going to be started. For the moment, listening cannot be reenabled. (4) Add refcounting to the afs_call struct to fix a potential multiple release detected by static checking and add a tracepoint to follow the lifecycle of afs_call objects. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 7351788 + 341f741 commit aaa9c10

File tree

13 files changed

+442
-242
lines changed

13 files changed

+442
-242
lines changed

fs/afs/callback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ void afs_dispatch_give_up_callbacks(struct work_struct *work)
343343
* had callbacks entirely, and the server will call us later to break
344344
* them
345345
*/
346-
afs_fs_give_up_callbacks(server, &afs_async_call);
346+
afs_fs_give_up_callbacks(server, true);
347347
}
348348

349349
/*

fs/afs/cmservice.c

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,65 +24,86 @@ static int afs_deliver_cb_callback(struct afs_call *);
2424
static int afs_deliver_cb_probe_uuid(struct afs_call *);
2525
static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *);
2626
static void afs_cm_destructor(struct afs_call *);
27+
static void SRXAFSCB_CallBack(struct work_struct *);
28+
static void SRXAFSCB_InitCallBackState(struct work_struct *);
29+
static void SRXAFSCB_Probe(struct work_struct *);
30+
static void SRXAFSCB_ProbeUuid(struct work_struct *);
31+
static void SRXAFSCB_TellMeAboutYourself(struct work_struct *);
32+
33+
#define CM_NAME(name) \
34+
const char afs_SRXCB##name##_name[] __tracepoint_string = \
35+
"CB." #name
2736

2837
/*
2938
* CB.CallBack operation type
3039
*/
40+
static CM_NAME(CallBack);
3141
static const struct afs_call_type afs_SRXCBCallBack = {
32-
.name = "CB.CallBack",
42+
.name = afs_SRXCBCallBack_name,
3343
.deliver = afs_deliver_cb_callback,
3444
.abort_to_error = afs_abort_to_error,
3545
.destructor = afs_cm_destructor,
46+
.work = SRXAFSCB_CallBack,
3647
};
3748

3849
/*
3950
* CB.InitCallBackState operation type
4051
*/
52+
static CM_NAME(InitCallBackState);
4153
static const struct afs_call_type afs_SRXCBInitCallBackState = {
42-
.name = "CB.InitCallBackState",
54+
.name = afs_SRXCBInitCallBackState_name,
4355
.deliver = afs_deliver_cb_init_call_back_state,
4456
.abort_to_error = afs_abort_to_error,
4557
.destructor = afs_cm_destructor,
58+
.work = SRXAFSCB_InitCallBackState,
4659
};
4760

4861
/*
4962
* CB.InitCallBackState3 operation type
5063
*/
64+
static CM_NAME(InitCallBackState3);
5165
static const struct afs_call_type afs_SRXCBInitCallBackState3 = {
52-
.name = "CB.InitCallBackState3",
66+
.name = afs_SRXCBInitCallBackState3_name,
5367
.deliver = afs_deliver_cb_init_call_back_state3,
5468
.abort_to_error = afs_abort_to_error,
5569
.destructor = afs_cm_destructor,
70+
.work = SRXAFSCB_InitCallBackState,
5671
};
5772

5873
/*
5974
* CB.Probe operation type
6075
*/
76+
static CM_NAME(Probe);
6177
static const struct afs_call_type afs_SRXCBProbe = {
62-
.name = "CB.Probe",
78+
.name = afs_SRXCBProbe_name,
6379
.deliver = afs_deliver_cb_probe,
6480
.abort_to_error = afs_abort_to_error,
6581
.destructor = afs_cm_destructor,
82+
.work = SRXAFSCB_Probe,
6683
};
6784

6885
/*
6986
* CB.ProbeUuid operation type
7087
*/
88+
static CM_NAME(ProbeUuid);
7189
static const struct afs_call_type afs_SRXCBProbeUuid = {
72-
.name = "CB.ProbeUuid",
90+
.name = afs_SRXCBProbeUuid_name,
7391
.deliver = afs_deliver_cb_probe_uuid,
7492
.abort_to_error = afs_abort_to_error,
7593
.destructor = afs_cm_destructor,
94+
.work = SRXAFSCB_ProbeUuid,
7695
};
7796

7897
/*
7998
* CB.TellMeAboutYourself operation type
8099
*/
100+
static CM_NAME(TellMeAboutYourself);
81101
static const struct afs_call_type afs_SRXCBTellMeAboutYourself = {
82-
.name = "CB.TellMeAboutYourself",
102+
.name = afs_SRXCBTellMeAboutYourself_name,
83103
.deliver = afs_deliver_cb_tell_me_about_yourself,
84104
.abort_to_error = afs_abort_to_error,
85105
.destructor = afs_cm_destructor,
106+
.work = SRXAFSCB_TellMeAboutYourself,
86107
};
87108

88109
/*
@@ -153,6 +174,7 @@ static void SRXAFSCB_CallBack(struct work_struct *work)
153174
afs_send_empty_reply(call);
154175

155176
afs_break_callbacks(call->server, call->count, call->request);
177+
afs_put_call(call);
156178
_leave("");
157179
}
158180

@@ -274,9 +296,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
274296
return -ENOTCONN;
275297
call->server = server;
276298

277-
INIT_WORK(&call->work, SRXAFSCB_CallBack);
278-
queue_work(afs_wq, &call->work);
279-
return 0;
299+
return afs_queue_call_work(call);
280300
}
281301

282302
/*
@@ -290,6 +310,7 @@ static void SRXAFSCB_InitCallBackState(struct work_struct *work)
290310

291311
afs_init_callback_state(call->server);
292312
afs_send_empty_reply(call);
313+
afs_put_call(call);
293314
_leave("");
294315
}
295316

@@ -320,9 +341,7 @@ static int afs_deliver_cb_init_call_back_state(struct afs_call *call)
320341
return -ENOTCONN;
321342
call->server = server;
322343

323-
INIT_WORK(&call->work, SRXAFSCB_InitCallBackState);
324-
queue_work(afs_wq, &call->work);
325-
return 0;
344+
return afs_queue_call_work(call);
326345
}
327346

328347
/*
@@ -394,9 +413,7 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
394413
return -ENOTCONN;
395414
call->server = server;
396415

397-
INIT_WORK(&call->work, SRXAFSCB_InitCallBackState);
398-
queue_work(afs_wq, &call->work);
399-
return 0;
416+
return afs_queue_call_work(call);
400417
}
401418

402419
/*
@@ -408,6 +425,7 @@ static void SRXAFSCB_Probe(struct work_struct *work)
408425

409426
_enter("");
410427
afs_send_empty_reply(call);
428+
afs_put_call(call);
411429
_leave("");
412430
}
413431

@@ -427,9 +445,7 @@ static int afs_deliver_cb_probe(struct afs_call *call)
427445
/* no unmarshalling required */
428446
call->state = AFS_CALL_REPLYING;
429447

430-
INIT_WORK(&call->work, SRXAFSCB_Probe);
431-
queue_work(afs_wq, &call->work);
432-
return 0;
448+
return afs_queue_call_work(call);
433449
}
434450

435451
/*
@@ -452,6 +468,7 @@ static void SRXAFSCB_ProbeUuid(struct work_struct *work)
452468
reply.match = htonl(1);
453469

454470
afs_send_simple_reply(call, &reply, sizeof(reply));
471+
afs_put_call(call);
455472
_leave("");
456473
}
457474

@@ -510,9 +527,7 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)
510527

511528
call->state = AFS_CALL_REPLYING;
512529

513-
INIT_WORK(&call->work, SRXAFSCB_ProbeUuid);
514-
queue_work(afs_wq, &call->work);
515-
return 0;
530+
return afs_queue_call_work(call);
516531
}
517532

518533
/*
@@ -574,7 +589,7 @@ static void SRXAFSCB_TellMeAboutYourself(struct work_struct *work)
574589
reply.cap.capcount = htonl(1);
575590
reply.cap.caps[0] = htonl(AFS_CAP_ERROR_TRANSLATION);
576591
afs_send_simple_reply(call, &reply, sizeof(reply));
577-
592+
afs_put_call(call);
578593
_leave("");
579594
}
580595

@@ -594,7 +609,5 @@ static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *call)
594609
/* no unmarshalling required */
595610
call->state = AFS_CALL_REPLYING;
596611

597-
INIT_WORK(&call->work, SRXAFSCB_TellMeAboutYourself);
598-
queue_work(afs_wq, &call->work);
599-
return 0;
612+
return afs_queue_call_work(call);
600613
}

0 commit comments

Comments
 (0)