diff options
-rw-r--r-- | fs/lockd/svcsubs.c | 32 | ||||
-rw-r--r-- | fs/nfsd/nfsctl.c | 15 | ||||
-rw-r--r-- | include/linux/lockd/lockd.h | 2 |
3 files changed, 34 insertions, 15 deletions
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index d1c48b539df8..198b4e55b373 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c | |||
@@ -373,13 +373,16 @@ nlmsvc_free_host_resources(struct nlm_host *host) | |||
373 | } | 373 | } |
374 | } | 374 | } |
375 | 375 | ||
376 | /* | 376 | /** |
377 | * Remove all locks held for clients | 377 | * nlmsvc_invalidate_all - remove all locks held for clients |
378 | * | ||
379 | * Release all locks held by NFS clients. | ||
380 | * | ||
378 | */ | 381 | */ |
379 | void | 382 | void |
380 | nlmsvc_invalidate_all(void) | 383 | nlmsvc_invalidate_all(void) |
381 | { | 384 | { |
382 | /* Release all locks held by NFS clients. | 385 | /* |
383 | * Previously, the code would call | 386 | * Previously, the code would call |
384 | * nlmsvc_free_host_resources for each client in | 387 | * nlmsvc_free_host_resources for each client in |
385 | * turn, which is about as inefficient as it gets. | 388 | * turn, which is about as inefficient as it gets. |
@@ -396,6 +399,12 @@ nlmsvc_match_sb(void *datap, struct nlm_file *file) | |||
396 | return sb == file->f_file->f_path.mnt->mnt_sb; | 399 | return sb == file->f_file->f_path.mnt->mnt_sb; |
397 | } | 400 | } |
398 | 401 | ||
402 | /** | ||
403 | * nlmsvc_unlock_all_by_sb - release locks held on this file system | ||
404 | * @sb: super block | ||
405 | * | ||
406 | * Release all locks held by clients accessing this file system. | ||
407 | */ | ||
399 | int | 408 | int |
400 | nlmsvc_unlock_all_by_sb(struct super_block *sb) | 409 | nlmsvc_unlock_all_by_sb(struct super_block *sb) |
401 | { | 410 | { |
@@ -409,17 +418,22 @@ EXPORT_SYMBOL_GPL(nlmsvc_unlock_all_by_sb); | |||
409 | static int | 418 | static int |
410 | nlmsvc_match_ip(void *datap, struct nlm_host *host) | 419 | nlmsvc_match_ip(void *datap, struct nlm_host *host) |
411 | { | 420 | { |
412 | __be32 *server_addr = datap; | 421 | return nlm_cmp_addr(&host->h_saddr, datap); |
413 | |||
414 | return host->h_saddr.sin_addr.s_addr == *server_addr; | ||
415 | } | 422 | } |
416 | 423 | ||
424 | /** | ||
425 | * nlmsvc_unlock_all_by_ip - release local locks by IP address | ||
426 | * @server_addr: server's IP address as seen by clients | ||
427 | * | ||
428 | * Release all locks held by clients accessing this host | ||
429 | * via the passed in IP address. | ||
430 | */ | ||
417 | int | 431 | int |
418 | nlmsvc_unlock_all_by_ip(__be32 server_addr) | 432 | nlmsvc_unlock_all_by_ip(struct sockaddr *server_addr) |
419 | { | 433 | { |
420 | int ret; | 434 | int ret; |
421 | ret = nlm_traverse_files(&server_addr, nlmsvc_match_ip, NULL); | ||
422 | return ret ? -EIO : 0; | ||
423 | 435 | ||
436 | ret = nlm_traverse_files(server_addr, nlmsvc_match_ip, NULL); | ||
437 | return ret ? -EIO : 0; | ||
424 | } | 438 | } |
425 | EXPORT_SYMBOL_GPL(nlmsvc_unlock_all_by_ip); | 439 | EXPORT_SYMBOL_GPL(nlmsvc_unlock_all_by_ip); |
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 2c2eb8796c10..1955a2702e60 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -310,9 +310,12 @@ static ssize_t write_getfd(struct file *file, char *buf, size_t size) | |||
310 | 310 | ||
311 | static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) | 311 | static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) |
312 | { | 312 | { |
313 | __be32 server_ip; | 313 | struct sockaddr_in sin = { |
314 | char *fo_path, c; | 314 | .sin_family = AF_INET, |
315 | }; | ||
315 | int b1, b2, b3, b4; | 316 | int b1, b2, b3, b4; |
317 | char c; | ||
318 | char *fo_path; | ||
316 | 319 | ||
317 | /* sanity check */ | 320 | /* sanity check */ |
318 | if (size == 0) | 321 | if (size == 0) |
@@ -326,11 +329,13 @@ static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) | |||
326 | return -EINVAL; | 329 | return -EINVAL; |
327 | 330 | ||
328 | /* get ipv4 address */ | 331 | /* get ipv4 address */ |
329 | if (sscanf(fo_path, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) != 4) | 332 | if (sscanf(fo_path, NIPQUAD_FMT "%c", &b1, &b2, &b3, &b4, &c) != 4) |
333 | return -EINVAL; | ||
334 | if (b1 > 255 || b2 > 255 || b3 > 255 || b4 > 255) | ||
330 | return -EINVAL; | 335 | return -EINVAL; |
331 | server_ip = htonl((((((b1<<8)|b2)<<8)|b3)<<8)|b4); | 336 | sin.sin_addr.s_addr = htonl((b1 << 24) | (b2 << 16) | (b3 << 8) | b4); |
332 | 337 | ||
333 | return nlmsvc_unlock_all_by_ip(server_ip); | 338 | return nlmsvc_unlock_all_by_ip((struct sockaddr *)&sin); |
334 | } | 339 | } |
335 | 340 | ||
336 | static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size) | 341 | static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size) |
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h index f81f9dd5f147..dbb87ab282e8 100644 --- a/include/linux/lockd/lockd.h +++ b/include/linux/lockd/lockd.h | |||
@@ -226,7 +226,7 @@ void nlmsvc_invalidate_all(void); | |||
226 | * Cluster failover support | 226 | * Cluster failover support |
227 | */ | 227 | */ |
228 | int nlmsvc_unlock_all_by_sb(struct super_block *sb); | 228 | int nlmsvc_unlock_all_by_sb(struct super_block *sb); |
229 | int nlmsvc_unlock_all_by_ip(__be32 server_addr); | 229 | int nlmsvc_unlock_all_by_ip(struct sockaddr *server_addr); |
230 | 230 | ||
231 | static inline struct inode *nlmsvc_file_inode(struct nlm_file *file) | 231 | static inline struct inode *nlmsvc_file_inode(struct nlm_file *file) |
232 | { | 232 | { |