Skip to content

Commit c8c23c4

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
NSM: Release nsmhandle in nlm_destroy_host
The nsm_handle's reference count is bumped in nlm_lookup_host(). It should be decremented in nlm_destroy_host() to make it easier to see the balance of these two operations. Move the nsm_release() call to fs/lockd/host.c. The h_nsmhandle pointer is set in nlm_lookup_host(), and never cleared. The nlm_destroy_host() function is never called for the same nlm_host twice, so h_nsmhandle won't ever be NULL when nsm_unmonitor() is called. All references to the nlm_host are gone before it is freed. We can skip making h_nsmhandle NULL just before the nlm_host is deallocated. It's also likely we can remove the h_nsmhandle NULL check in nlmsvc_is_client() as well, but we can do that later when rearchitect- ing the nlm_host cache. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
1 parent 1e49323 commit c8c23c4

3 files changed

Lines changed: 3 additions & 11 deletions

File tree

‎fs/lockd/host.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static struct nsm_handle *nsm_find(const struct sockaddr *sap,
3737
const char *hostname,
3838
const size_t hostname_len,
3939
const int create);
40+
static void nsm_release(struct nsm_handle *nsm);
4041

4142
struct nlm_lookup_host_info {
4243
const int server; /* search for server|client */
@@ -263,10 +264,8 @@ nlm_destroy_host(struct nlm_host *host)
263264
BUG_ON(!list_empty(&host->h_lockowners));
264265
BUG_ON(atomic_read(&host->h_count));
265266

266-
/*
267-
* Release NSM handle and unmonitor host.
268-
*/
269267
nsm_unmonitor(host);
268+
nsm_release(host->h_nsmhandle);
270269

271270
clnt = host->h_rpcclnt;
272271
if (clnt != NULL)
@@ -711,8 +710,7 @@ static struct nsm_handle *nsm_find(const struct sockaddr *sap,
711710
/*
712711
* Release an NSM handle
713712
*/
714-
void
715-
nsm_release(struct nsm_handle *nsm)
713+
static void nsm_release(struct nsm_handle *nsm)
716714
{
717715
if (!nsm)
718716
return;

‎fs/lockd/mon.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ nsm_unmonitor(struct nlm_host *host)
117117
struct nsm_res res;
118118
int status = 0;
119119

120-
if (nsm == NULL)
121-
return 0;
122-
host->h_nsmhandle = NULL;
123-
124120
if (atomic_read(&nsm->sm_count) == 1
125121
&& nsm->sm_monitored && !nsm->sm_sticky) {
126122
dprintk("lockd: nsm_unmonitor(%s)\n", nsm->sm_name);
@@ -132,7 +128,6 @@ nsm_unmonitor(struct nlm_host *host)
132128
else
133129
nsm->sm_monitored = 0;
134130
}
135-
nsm_release(nsm);
136131
return status;
137132
}
138133

‎include/linux/lockd/lockd.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ void nlm_release_host(struct nlm_host *);
240240
void nlm_shutdown_hosts(void);
241241
extern void nlm_host_rebooted(const struct sockaddr_in *, const char *,
242242
unsigned int, u32);
243-
void nsm_release(struct nsm_handle *);
244243

245244
/*
246245
* Host monitoring

0 commit comments

Comments
 (0)