fscache.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* NFS filesystem cache interface
  2. *
  3. * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/kernel.h>
  13. #include <linux/sched.h>
  14. #include <linux/mm.h>
  15. #include <linux/nfs_fs.h>
  16. #include <linux/nfs_fs_sb.h>
  17. #include <linux/in6.h>
  18. #include <linux/seq_file.h>
  19. #include "internal.h"
  20. #include "fscache.h"
  21. #define NFSDBG_FACILITY NFSDBG_FSCACHE
  22. /*
  23. * Get the per-client index cookie for an NFS client if the appropriate mount
  24. * flag was set
  25. * - We always try and get an index cookie for the client, but get filehandle
  26. * cookies on a per-superblock basis, depending on the mount flags
  27. */
  28. void nfs_fscache_get_client_cookie(struct nfs_client *clp)
  29. {
  30. /* create a cache index for looking up filehandles */
  31. clp->fscache = fscache_acquire_cookie(nfs_fscache_netfs.primary_index,
  32. &nfs_fscache_server_index_def,
  33. clp);
  34. dfprintk(FSCACHE, "NFS: get client cookie (0x%p/0x%p)\n",
  35. clp, clp->fscache);
  36. }
  37. /*
  38. * Dispose of a per-client cookie
  39. */
  40. void nfs_fscache_release_client_cookie(struct nfs_client *clp)
  41. {
  42. dfprintk(FSCACHE, "NFS: releasing client cookie (0x%p/0x%p)\n",
  43. clp, clp->fscache);
  44. fscache_relinquish_cookie(clp->fscache, 0);
  45. clp->fscache = NULL;
  46. }