Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 127469
b: refs/heads/master
c: b39b897
h: refs/heads/master
i:
  127467: 312d989
v: v3
  • Loading branch information
Chuck Lever authored and J. Bruce Fields committed Jan 6, 2009
1 parent ba70125 commit 95611d5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 92fd91b998a5216a6d6606704e71d541a180216c
refs/heads/master: b39b897c259fc1fd1998505f2b1d4ec1f115bce1
38 changes: 26 additions & 12 deletions trunk/fs/lockd/mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,30 @@ static void nsm_init_private(struct nsm_handle *nsm)
*p = nsm_addr_in(nsm)->sin_addr.s_addr;
}

static struct nsm_handle *nsm_create_handle(const struct sockaddr *sap,
const size_t salen,
const char *hostname,
const size_t hostname_len)
{
struct nsm_handle *new;

new = kzalloc(sizeof(*new) + hostname_len + 1, GFP_KERNEL);
if (unlikely(new == NULL))
return NULL;

atomic_set(&new->sm_count, 1);
new->sm_name = (char *)(new + 1);
memcpy(nsm_addr(new), sap, salen);
new->sm_addrlen = salen;
nsm_init_private(new);
nsm_display_address((const struct sockaddr *)&new->sm_addr,
new->sm_addrbuf, sizeof(new->sm_addrbuf));
memcpy(new->sm_name, hostname, hostname_len);
new->sm_name[hostname_len] = '\0';

return new;
}

/**
* nsm_get_handle - Find or create a cached nsm_handle
* @sap: pointer to socket address of handle to find
Expand Down Expand Up @@ -295,19 +319,9 @@ struct nsm_handle *nsm_get_handle(const struct sockaddr *sap,
}
spin_unlock(&nsm_lock);

nsm = kzalloc(sizeof(*nsm) + hostname_len + 1, GFP_KERNEL);
if (nsm == NULL)
nsm = nsm_create_handle(sap, salen, hostname, hostname_len);
if (unlikely(nsm == NULL))
return NULL;

memcpy(nsm_addr(nsm), sap, salen);
nsm->sm_addrlen = salen;
nsm->sm_name = (char *) (nsm + 1);
memcpy(nsm->sm_name, hostname, hostname_len);
nsm->sm_name[hostname_len] = '\0';
nsm_init_private(nsm);
nsm_display_address((struct sockaddr *)&nsm->sm_addr,
nsm->sm_addrbuf, sizeof(nsm->sm_addrbuf));
atomic_set(&nsm->sm_count, 1);
goto retry;

found:
Expand Down

0 comments on commit 95611d5

Please sign in to comment.