diff options
author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2012-04-25 10:22:54 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-05-31 20:29:42 -0400 |
commit | 24452239094a8b52f54fd4403f6e177837cecf67 (patch) | |
tree | 4eac5ff5946cb30416ff23157ea861cdfbc1ca96 /fs/lockd/svc.c | |
parent | dbf9b5d74ceae787607e3d7db626fffa8be3c03d (diff) |
LockD: service creation function introduced
This function creates service if it doesn't exist, or increases usage
counter if it does, and returns a pointer to it. The usage counter will
be droppepd by svc_destroy() later in lockd_up().
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/lockd/svc.c')
-rw-r--r-- | fs/lockd/svc.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 71c6c3122d35..ad11ea777581 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c | |||
@@ -291,21 +291,20 @@ static void lockd_down_net(struct svc_serv *serv, struct net *net) | |||
291 | } | 291 | } |
292 | } | 292 | } |
293 | 293 | ||
294 | /* | 294 | static struct svc_serv *lockd_create_svc(void) |
295 | * Bring up the lockd process if it's not already up. | ||
296 | */ | ||
297 | int lockd_up(struct net *net) | ||
298 | { | 295 | { |
299 | struct svc_serv *serv; | 296 | struct svc_serv *serv; |
300 | int error = 0; | ||
301 | 297 | ||
302 | mutex_lock(&nlmsvc_mutex); | ||
303 | /* | 298 | /* |
304 | * Check whether we're already up and running. | 299 | * Check whether we're already up and running. |
305 | */ | 300 | */ |
306 | if (nlmsvc_rqst) { | 301 | if (nlmsvc_rqst) { |
307 | error = lockd_up_net(nlmsvc_rqst->rq_server, net); | 302 | /* |
308 | goto out; | 303 | * Note: increase service usage, because later in case of error |
304 | * svc_destroy() will be called. | ||
305 | */ | ||
306 | svc_get(nlmsvc_rqst->rq_server); | ||
307 | return nlmsvc_rqst->rq_server; | ||
309 | } | 308 | } |
310 | 309 | ||
311 | /* | 310 | /* |
@@ -316,11 +315,28 @@ int lockd_up(struct net *net) | |||
316 | printk(KERN_WARNING | 315 | printk(KERN_WARNING |
317 | "lockd_up: no pid, %d users??\n", nlmsvc_users); | 316 | "lockd_up: no pid, %d users??\n", nlmsvc_users); |
318 | 317 | ||
319 | error = -ENOMEM; | ||
320 | serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, NULL); | 318 | serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, NULL); |
321 | if (!serv) { | 319 | if (!serv) { |
322 | printk(KERN_WARNING "lockd_up: create service failed\n"); | 320 | printk(KERN_WARNING "lockd_up: create service failed\n"); |
323 | goto out; | 321 | return ERR_PTR(-ENOMEM); |
322 | } | ||
323 | return serv; | ||
324 | } | ||
325 | |||
326 | /* | ||
327 | * Bring up the lockd process if it's not already up. | ||
328 | */ | ||
329 | int lockd_up(struct net *net) | ||
330 | { | ||
331 | struct svc_serv *serv; | ||
332 | int error = 0; | ||
333 | |||
334 | mutex_lock(&nlmsvc_mutex); | ||
335 | |||
336 | serv = lockd_create_svc(); | ||
337 | if (IS_ERR(serv)) { | ||
338 | error = PTR_ERR(serv); | ||
339 | goto err_create; | ||
324 | } | 340 | } |
325 | 341 | ||
326 | error = lockd_up_net(serv, net); | 342 | error = lockd_up_net(serv, net); |
@@ -360,9 +376,9 @@ int lockd_up(struct net *net) | |||
360 | */ | 376 | */ |
361 | err_net: | 377 | err_net: |
362 | svc_destroy(serv); | 378 | svc_destroy(serv); |
363 | out: | ||
364 | if (!error) | 379 | if (!error) |
365 | nlmsvc_users++; | 380 | nlmsvc_users++; |
381 | err_create: | ||
366 | mutex_unlock(&nlmsvc_mutex); | 382 | mutex_unlock(&nlmsvc_mutex); |
367 | return error; | 383 | return error; |
368 | 384 | ||