#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/nfs_fs.h>
#include <linux/kthread.h>
#include <linux/module.h>
#include <linux/random.h>
#include <linux/ratelimit.h>
#include <linux/workqueue.h>
#include <linux/bitops.h>
#include <linux/jiffies.h>
#include <linux/sched/mm.h>
#include <linux/sunrpc/clnt.h>
#include "nfs4_fs.h"
#include "callback.h"
#include "delegation.h"
#include "internal.h"
#include "nfs4idmap.h"
#include "nfs4session.h"
#include "pnfs.h"
#include "netns.h"
#include "nfs4trace.h"
#define NFSDBG_FACILITY …
#define OPENOWNER_POOL_SIZE …
static void nfs4_state_start_reclaim_reboot(struct nfs_client *clp);
const nfs4_stateid zero_stateid = …;
const nfs4_stateid invalid_stateid = …;
const nfs4_stateid current_stateid = …;
static DEFINE_MUTEX(nfs_clid_init_mutex);
static int nfs4_setup_state_renewal(struct nfs_client *clp)
{ … }
int nfs4_init_clientid(struct nfs_client *clp, const struct cred *cred)
{ … }
int nfs40_discover_server_trunking(struct nfs_client *clp,
struct nfs_client **result,
const struct cred *cred)
{ … }
const struct cred *nfs4_get_machine_cred(struct nfs_client *clp)
{ … }
static void nfs4_root_machine_cred(struct nfs_client *clp)
{ … }
static const struct cred *
nfs4_get_renew_cred_server_locked(struct nfs_server *server)
{ … }
const struct cred *nfs4_get_renew_cred(struct nfs_client *clp)
{ … }
static void nfs4_end_drain_slot_table(struct nfs4_slot_table *tbl)
{ … }
static void nfs4_end_drain_session(struct nfs_client *clp)
{ … }
static int nfs4_drain_slot_tbl(struct nfs4_slot_table *tbl)
{ … }
static int nfs4_begin_drain_session(struct nfs_client *clp)
{ … }
#if defined(CONFIG_NFS_V4_1)
static void nfs41_finish_session_reset(struct nfs_client *clp)
{ … }
int nfs41_init_clientid(struct nfs_client *clp, const struct cred *cred)
{ … }
int nfs41_discover_server_trunking(struct nfs_client *clp,
struct nfs_client **result,
const struct cred *cred)
{ … }
#endif
const struct cred *nfs4_get_clid_cred(struct nfs_client *clp)
{ … }
static struct nfs4_state_owner *
nfs4_find_state_owner_locked(struct nfs_server *server, const struct cred *cred)
{ … }
static struct nfs4_state_owner *
nfs4_insert_state_owner_locked(struct nfs4_state_owner *new)
{ … }
static void
nfs4_remove_state_owner_locked(struct nfs4_state_owner *sp)
{ … }
static void
nfs4_init_seqid_counter(struct nfs_seqid_counter *sc)
{ … }
static void
nfs4_destroy_seqid_counter(struct nfs_seqid_counter *sc)
{ … }
static struct nfs4_state_owner *
nfs4_alloc_state_owner(struct nfs_server *server,
const struct cred *cred,
gfp_t gfp_flags)
{ … }
static void
nfs4_reset_state_owner(struct nfs4_state_owner *sp)
{ … }
static void nfs4_free_state_owner(struct nfs4_state_owner *sp)
{ … }
static void nfs4_gc_state_owners(struct nfs_server *server)
{ … }
struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server,
const struct cred *cred,
gfp_t gfp_flags)
{ … }
void nfs4_put_state_owner(struct nfs4_state_owner *sp)
{ … }
void nfs4_purge_state_owners(struct nfs_server *server, struct list_head *head)
{ … }
void nfs4_free_state_owners(struct list_head *head)
{ … }
static struct nfs4_state *
nfs4_alloc_open_state(void)
{ … }
void
nfs4_state_set_mode_locked(struct nfs4_state *state, fmode_t fmode)
{ … }
static struct nfs4_state *
__nfs4_find_state_byowner(struct inode *inode, struct nfs4_state_owner *owner)
{ … }
static void
nfs4_free_open_state(struct nfs4_state *state)
{ … }
struct nfs4_state *
nfs4_get_open_state(struct inode *inode, struct nfs4_state_owner *owner)
{ … }
void nfs4_put_open_state(struct nfs4_state *state)
{ … }
static void __nfs4_close(struct nfs4_state *state,
fmode_t fmode, gfp_t gfp_mask, int wait)
{ … }
void nfs4_close_state(struct nfs4_state *state, fmode_t fmode)
{ … }
void nfs4_close_sync(struct nfs4_state *state, fmode_t fmode)
{ … }
static struct nfs4_lock_state *
__nfs4_find_lock_state(struct nfs4_state *state,
fl_owner_t owner, fl_owner_t owner2)
{ … }
static struct nfs4_lock_state *nfs4_alloc_lock_state(struct nfs4_state *state, fl_owner_t owner)
{ … }
void nfs4_free_lock_state(struct nfs_server *server, struct nfs4_lock_state *lsp)
{ … }
static struct nfs4_lock_state *nfs4_get_lock_state(struct nfs4_state *state, fl_owner_t owner)
{ … }
void nfs4_put_lock_state(struct nfs4_lock_state *lsp)
{ … }
static void nfs4_fl_copy_lock(struct file_lock *dst, struct file_lock *src)
{ … }
static void nfs4_fl_release_lock(struct file_lock *fl)
{ … }
static const struct file_lock_operations nfs4_fl_lock_ops = …;
int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl)
{ … }
static int nfs4_copy_lock_stateid(nfs4_stateid *dst,
struct nfs4_state *state,
const struct nfs_lock_context *l_ctx)
{ … }
bool nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state)
{ … }
int nfs4_select_rw_stateid(struct nfs4_state *state,
fmode_t fmode, const struct nfs_lock_context *l_ctx,
nfs4_stateid *dst, const struct cred **cred)
{ … }
struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter, gfp_t gfp_mask)
{ … }
void nfs_release_seqid(struct nfs_seqid *seqid)
{ … }
void nfs_free_seqid(struct nfs_seqid *seqid)
{ … }
static void nfs_increment_seqid(int status, struct nfs_seqid *seqid)
{ … }
void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid)
{ … }
void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid)
{ … }
int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task)
{ … }
static int nfs4_run_state_manager(void *);
static void nfs4_clear_state_manager_bit(struct nfs_client *clp)
{ … }
void nfs4_schedule_state_manager(struct nfs_client *clp)
{ … }
void nfs4_schedule_lease_recovery(struct nfs_client *clp)
{ … }
EXPORT_SYMBOL_GPL(…);
int nfs4_schedule_migration_recovery(const struct nfs_server *server)
{ … }
EXPORT_SYMBOL_GPL(…);
void nfs4_schedule_lease_moved_recovery(struct nfs_client *clp)
{ … }
EXPORT_SYMBOL_GPL(…);
int nfs4_wait_clnt_recover(struct nfs_client *clp)
{ … }
int nfs4_client_recover_expired_lease(struct nfs_client *clp)
{ … }
static void nfs40_handle_cb_pathdown(struct nfs_client *clp)
{ … }
void nfs4_schedule_path_down_recovery(struct nfs_client *clp)
{ … }
static int nfs4_state_mark_reclaim_reboot(struct nfs_client *clp, struct nfs4_state *state)
{ … }
int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state)
{ … }
int nfs4_schedule_stateid_recovery(const struct nfs_server *server, struct nfs4_state *state)
{ … }
EXPORT_SYMBOL_GPL(…);
static struct nfs4_lock_state *
nfs_state_find_lock_state_by_stateid(struct nfs4_state *state,
const nfs4_stateid *stateid)
{ … }
static bool nfs_state_lock_state_matches_stateid(struct nfs4_state *state,
const nfs4_stateid *stateid)
{ … }
void nfs_inode_find_state_and_recover(struct inode *inode,
const nfs4_stateid *stateid)
{ … }
static void nfs4_state_mark_open_context_bad(struct nfs4_state *state, int err)
{ … }
static void nfs4_state_mark_recovery_failed(struct nfs4_state *state, int error)
{ … }
static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_recovery_ops *ops)
{ … }
#ifdef CONFIG_NFS_V4_2
static void nfs42_complete_copies(struct nfs4_state_owner *sp, struct nfs4_state *state)
{ … }
#else
static inline void nfs42_complete_copies(struct nfs4_state_owner *sp,
struct nfs4_state *state)
{
}
#endif
static int __nfs4_reclaim_open_state(struct nfs4_state_owner *sp, struct nfs4_state *state,
const struct nfs4_state_recovery_ops *ops,
int *lost_locks)
{ … }
static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp,
const struct nfs4_state_recovery_ops *ops,
int *lost_locks)
{ … }
static void nfs4_clear_open_state(struct nfs4_state *state)
{ … }
static void nfs4_reset_seqids(struct nfs_server *server,
int (*mark_reclaim)(struct nfs_client *clp, struct nfs4_state *state))
{ … }
static void nfs4_state_mark_reclaim_helper(struct nfs_client *clp,
int (*mark_reclaim)(struct nfs_client *clp, struct nfs4_state *state))
{ … }
static void nfs4_state_start_reclaim_reboot(struct nfs_client *clp)
{ … }
static int nfs4_reclaim_complete(struct nfs_client *clp,
const struct nfs4_state_recovery_ops *ops,
const struct cred *cred)
{ … }
static void nfs4_clear_reclaim_server(struct nfs_server *server)
{ … }
static int nfs4_state_clear_reclaim_reboot(struct nfs_client *clp)
{ … }
static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp)
{ … }
static void nfs4_state_start_reclaim_nograce(struct nfs_client *clp)
{ … }
static int nfs4_recovery_handle_error(struct nfs_client *clp, int error)
{ … }
static int nfs4_do_reclaim(struct nfs_client *clp, const struct nfs4_state_recovery_ops *ops)
{ … }
static int nfs4_check_lease(struct nfs_client *clp)
{ … }
static int nfs4_handle_reclaim_lease_error(struct nfs_client *clp, int status)
{ … }
static int nfs4_establish_lease(struct nfs_client *clp)
{ … }
static int nfs4_reclaim_lease(struct nfs_client *clp)
{ … }
static int nfs4_purge_lease(struct nfs_client *clp)
{ … }
static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred)
{ … }
static int nfs4_handle_migration(struct nfs_client *clp)
{ … }
static int nfs4_handle_lease_moved(struct nfs_client *clp)
{ … }
int nfs4_discover_server_trunking(struct nfs_client *clp,
struct nfs_client **result)
{ … }
#ifdef CONFIG_NFS_V4_1
void nfs4_schedule_session_recovery(struct nfs4_session *session, int err)
{ … }
EXPORT_SYMBOL_GPL(…);
void nfs41_notify_server(struct nfs_client *clp)
{ … }
static void nfs4_reset_all_state(struct nfs_client *clp)
{ … }
static void nfs41_handle_server_reboot(struct nfs_client *clp)
{ … }
static void nfs41_handle_all_state_revoked(struct nfs_client *clp)
{ … }
static void nfs41_handle_some_state_revoked(struct nfs_client *clp)
{ … }
static void nfs41_handle_recallable_state_revoked(struct nfs_client *clp)
{ … }
static void nfs41_handle_backchannel_fault(struct nfs_client *clp)
{ … }
static void nfs41_handle_cb_path_down(struct nfs_client *clp)
{ … }
void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags,
bool recovery)
{ … }
static int nfs4_reset_session(struct nfs_client *clp)
{ … }
static int nfs4_bind_conn_to_session(struct nfs_client *clp)
{ … }
static void nfs4_layoutreturn_any_run(struct nfs_client *clp)
{ … }
#else
static int nfs4_reset_session(struct nfs_client *clp) { return 0; }
static int nfs4_bind_conn_to_session(struct nfs_client *clp)
{
return 0;
}
static void nfs4_layoutreturn_any_run(struct nfs_client *clp)
{
}
#endif
static void nfs4_state_manager(struct nfs_client *clp)
{ … }
static int nfs4_run_state_manager(void *ptr)
{ … }