You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge tag 'nfs-for-3.10-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Pull NFS client bugfixes and cleanups from Trond Myklebust: - NLM: stable fix for NFSv2/v3 blocking locks - NFSv4.x: stable fixes for the delegation recall error handling code - NFSv4.x: Security flavour negotiation fixes and cleanups by Chuck Lever - SUNRPC: A number of RPCSEC_GSS fixes and cleanups also from Chuck - NFSv4.x assorted state management and reboot recovery bugfixes - NFSv4.1: In cases where we have already looked up a file, and hold a valid filehandle, use the new open-by-filehandle operation instead of opening by name. - Allow the NFSv4.1 callback thread to freeze - NFSv4.x: ensure that file unlock waits for readahead to complete - NFSv4.1: ensure that the RPC layer doesn't override the NFS session table size negotiation by limiting the number of slots. - NFSv4.x: Fix SETATTR spec compatibility issues * tag 'nfs-for-3.10-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (67 commits) NFSv4: Warn once about servers that incorrectly apply open mode to setattr NFSv4: Servers should only check SETATTR stateid open mode on size change NFSv4: Don't recheck permissions on open in case of recovery cached open NFSv4.1: Don't do a delegated open for NFS4_OPEN_CLAIM_DELEG_CUR_FH modes NFSv4.1: Use the more efficient open_noattr call for open-by-filehandle NFS: Retry SETCLIENTID with AUTH_SYS instead of AUTH_NONE NFSv4: Ensure that we clear the NFS_OPEN_STATE flag when appropriate LOCKD: Ensure that nlmclnt_block resets block->b_status after a server reboot NFSv4: Ensure the LOCK call cannot use the delegation stateid NFSv4: Use the open stateid if the delegation has the wrong mode nfs: Send atime and mtime as a 64bit value NFSv4: Record the OPEN create mode used in the nfs4_opendata structure NFSv4.1: Set the RPC_CLNT_CREATE_INFINITE_SLOTS flag for NFSv4.1 transports SUNRPC: Allow rpc_create() to request that TCP slots be unlimited SUNRPC: Fix a livelock problem in the xprt->backlog queue NFSv4: Fix handling of revoked delegations by setattr NFSv4 release the sequence id in the return on close case nfs: remove unnecessary check for NULL inode->i_flock from nfs_delegation_claim_locks NFS: Ensure that NFS file unlock waits for readahead to complete NFS: Add functionality to allow waiting on all outstanding reads to complete ...
This commit is contained in:
@@ -144,6 +144,9 @@ int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout)
|
||||
timeout);
|
||||
if (ret < 0)
|
||||
return -ERESTARTSYS;
|
||||
/* Reset the lock status after a server reboot so we resend */
|
||||
if (block->b_status == nlm_lck_denied_grace_period)
|
||||
block->b_status = nlm_lck_blocked;
|
||||
req->a_res.status = block->b_status;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -550,9 +550,6 @@ again:
|
||||
status = nlmclnt_block(block, req, NLMCLNT_POLL_TIMEOUT);
|
||||
if (status < 0)
|
||||
break;
|
||||
/* Resend the blocking lock request after a server reboot */
|
||||
if (resp->status == nlm_lck_denied_grace_period)
|
||||
continue;
|
||||
if (resp->status != nlm_lck_blocked)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -125,6 +125,9 @@ nfs41_callback_svc(void *vrqstp)
|
||||
set_freezable();
|
||||
|
||||
while (!kthread_should_stop()) {
|
||||
if (try_to_freeze())
|
||||
continue;
|
||||
|
||||
prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE);
|
||||
spin_lock_bh(&serv->sv_cb_lock);
|
||||
if (!list_empty(&serv->sv_cb_list)) {
|
||||
|
||||
@@ -500,7 +500,7 @@ __be32 nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy,
|
||||
&args->craa_type_mask))
|
||||
pnfs_recall_all_layouts(cps->clp);
|
||||
if (flags)
|
||||
nfs_expire_all_delegation_types(cps->clp, flags);
|
||||
nfs_expire_unused_delegation_types(cps->clp, flags);
|
||||
out:
|
||||
dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
|
||||
return status;
|
||||
|
||||
@@ -593,6 +593,8 @@ int nfs_create_rpc_client(struct nfs_client *clp,
|
||||
args.flags |= RPC_CLNT_CREATE_DISCRTRY;
|
||||
if (test_bit(NFS_CS_NORESVPORT, &clp->cl_flags))
|
||||
args.flags |= RPC_CLNT_CREATE_NONPRIVPORT;
|
||||
if (test_bit(NFS_CS_INFINITE_SLOTS, &clp->cl_flags))
|
||||
args.flags |= RPC_CLNT_CREATE_INFINITE_SLOTS;
|
||||
|
||||
if (!IS_ERR(clp->cl_rpcclient))
|
||||
return 0;
|
||||
|
||||
+82
-39
@@ -64,17 +64,15 @@ int nfs4_have_delegation(struct inode *inode, fmode_t flags)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_state *state)
|
||||
static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid)
|
||||
{
|
||||
struct inode *inode = state->inode;
|
||||
struct file_lock *fl;
|
||||
int status = 0;
|
||||
|
||||
if (inode->i_flock == NULL)
|
||||
return 0;
|
||||
|
||||
if (inode->i_flock == NULL)
|
||||
goto out;
|
||||
|
||||
/* Protect inode->i_flock using the file locks lock */
|
||||
lock_flocks();
|
||||
for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
|
||||
@@ -83,7 +81,7 @@ static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_
|
||||
if (nfs_file_open_context(fl->fl_file) != ctx)
|
||||
continue;
|
||||
unlock_flocks();
|
||||
status = nfs4_lock_delegation_recall(state, fl);
|
||||
status = nfs4_lock_delegation_recall(fl, state, stateid);
|
||||
if (status < 0)
|
||||
goto out;
|
||||
lock_flocks();
|
||||
@@ -120,7 +118,7 @@ again:
|
||||
seq = raw_seqcount_begin(&sp->so_reclaim_seqcount);
|
||||
err = nfs4_open_delegation_recall(ctx, state, stateid);
|
||||
if (!err)
|
||||
err = nfs_delegation_claim_locks(ctx, state);
|
||||
err = nfs_delegation_claim_locks(ctx, state, stateid);
|
||||
if (!err && read_seqcount_retry(&sp->so_reclaim_seqcount, seq))
|
||||
err = -EAGAIN;
|
||||
mutex_unlock(&sp->so_delegreturn_mutex);
|
||||
@@ -389,6 +387,24 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
static bool nfs_delegation_need_return(struct nfs_delegation *delegation)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if (test_and_clear_bit(NFS_DELEGATION_RETURN, &delegation->flags))
|
||||
ret = true;
|
||||
if (test_and_clear_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags) && !ret) {
|
||||
struct inode *inode;
|
||||
|
||||
spin_lock(&delegation->lock);
|
||||
inode = delegation->inode;
|
||||
if (inode && list_empty(&NFS_I(inode)->open_files))
|
||||
ret = true;
|
||||
spin_unlock(&delegation->lock);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs_client_return_marked_delegations - return previously marked delegations
|
||||
* @clp: nfs_client to process
|
||||
@@ -411,8 +427,7 @@ restart:
|
||||
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
|
||||
list_for_each_entry_rcu(delegation, &server->delegations,
|
||||
super_list) {
|
||||
if (!test_and_clear_bit(NFS_DELEGATION_RETURN,
|
||||
&delegation->flags))
|
||||
if (!nfs_delegation_need_return(delegation))
|
||||
continue;
|
||||
inode = nfs_delegation_grab_inode(delegation);
|
||||
if (inode == NULL)
|
||||
@@ -471,6 +486,13 @@ int nfs4_inode_return_delegation(struct inode *inode)
|
||||
return err;
|
||||
}
|
||||
|
||||
static void nfs_mark_return_if_closed_delegation(struct nfs_server *server,
|
||||
struct nfs_delegation *delegation)
|
||||
{
|
||||
set_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags);
|
||||
set_bit(NFS4CLNT_DELEGRETURN, &server->nfs_client->cl_state);
|
||||
}
|
||||
|
||||
static void nfs_mark_return_delegation(struct nfs_server *server,
|
||||
struct nfs_delegation *delegation)
|
||||
{
|
||||
@@ -478,6 +500,45 @@ static void nfs_mark_return_delegation(struct nfs_server *server,
|
||||
set_bit(NFS4CLNT_DELEGRETURN, &server->nfs_client->cl_state);
|
||||
}
|
||||
|
||||
static bool nfs_server_mark_return_all_delegations(struct nfs_server *server)
|
||||
{
|
||||
struct nfs_delegation *delegation;
|
||||
bool ret = false;
|
||||
|
||||
list_for_each_entry_rcu(delegation, &server->delegations, super_list) {
|
||||
nfs_mark_return_delegation(server, delegation);
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void nfs_client_mark_return_all_delegations(struct nfs_client *clp)
|
||||
{
|
||||
struct nfs_server *server;
|
||||
|
||||
rcu_read_lock();
|
||||
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link)
|
||||
nfs_server_mark_return_all_delegations(server);
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
static void nfs_delegation_run_state_manager(struct nfs_client *clp)
|
||||
{
|
||||
if (test_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state))
|
||||
nfs4_schedule_state_manager(clp);
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs_expire_all_delegations
|
||||
* @clp: client to process
|
||||
*
|
||||
*/
|
||||
void nfs_expire_all_delegations(struct nfs_client *clp)
|
||||
{
|
||||
nfs_client_mark_return_all_delegations(clp);
|
||||
nfs_delegation_run_state_manager(clp);
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs_super_return_all_delegations - return delegations for one superblock
|
||||
* @sb: sb to process
|
||||
@@ -486,24 +547,22 @@ static void nfs_mark_return_delegation(struct nfs_server *server,
|
||||
void nfs_server_return_all_delegations(struct nfs_server *server)
|
||||
{
|
||||
struct nfs_client *clp = server->nfs_client;
|
||||
struct nfs_delegation *delegation;
|
||||
bool need_wait;
|
||||
|
||||
if (clp == NULL)
|
||||
return;
|
||||
|
||||
rcu_read_lock();
|
||||
list_for_each_entry_rcu(delegation, &server->delegations, super_list) {
|
||||
spin_lock(&delegation->lock);
|
||||
set_bit(NFS_DELEGATION_RETURN, &delegation->flags);
|
||||
spin_unlock(&delegation->lock);
|
||||
}
|
||||
need_wait = nfs_server_mark_return_all_delegations(server);
|
||||
rcu_read_unlock();
|
||||
|
||||
if (nfs_client_return_marked_delegations(clp) != 0)
|
||||
if (need_wait) {
|
||||
nfs4_schedule_state_manager(clp);
|
||||
nfs4_wait_clnt_recover(clp);
|
||||
}
|
||||
}
|
||||
|
||||
static void nfs_mark_return_all_delegation_types(struct nfs_server *server,
|
||||
static void nfs_mark_return_unused_delegation_types(struct nfs_server *server,
|
||||
fmode_t flags)
|
||||
{
|
||||
struct nfs_delegation *delegation;
|
||||
@@ -512,27 +571,21 @@ static void nfs_mark_return_all_delegation_types(struct nfs_server *server,
|
||||
if ((delegation->type == (FMODE_READ|FMODE_WRITE)) && !(flags & FMODE_WRITE))
|
||||
continue;
|
||||
if (delegation->type & flags)
|
||||
nfs_mark_return_delegation(server, delegation);
|
||||
nfs_mark_return_if_closed_delegation(server, delegation);
|
||||
}
|
||||
}
|
||||
|
||||
static void nfs_client_mark_return_all_delegation_types(struct nfs_client *clp,
|
||||
static void nfs_client_mark_return_unused_delegation_types(struct nfs_client *clp,
|
||||
fmode_t flags)
|
||||
{
|
||||
struct nfs_server *server;
|
||||
|
||||
rcu_read_lock();
|
||||
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link)
|
||||
nfs_mark_return_all_delegation_types(server, flags);
|
||||
nfs_mark_return_unused_delegation_types(server, flags);
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
static void nfs_delegation_run_state_manager(struct nfs_client *clp)
|
||||
{
|
||||
if (test_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state))
|
||||
nfs4_schedule_state_manager(clp);
|
||||
}
|
||||
|
||||
void nfs_remove_bad_delegation(struct inode *inode)
|
||||
{
|
||||
struct nfs_delegation *delegation;
|
||||
@@ -546,27 +599,17 @@ void nfs_remove_bad_delegation(struct inode *inode)
|
||||
EXPORT_SYMBOL_GPL(nfs_remove_bad_delegation);
|
||||
|
||||
/**
|
||||
* nfs_expire_all_delegation_types
|
||||
* nfs_expire_unused_delegation_types
|
||||
* @clp: client to process
|
||||
* @flags: delegation types to expire
|
||||
*
|
||||
*/
|
||||
void nfs_expire_all_delegation_types(struct nfs_client *clp, fmode_t flags)
|
||||
void nfs_expire_unused_delegation_types(struct nfs_client *clp, fmode_t flags)
|
||||
{
|
||||
nfs_client_mark_return_all_delegation_types(clp, flags);
|
||||
nfs_client_mark_return_unused_delegation_types(clp, flags);
|
||||
nfs_delegation_run_state_manager(clp);
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs_expire_all_delegations
|
||||
* @clp: client to process
|
||||
*
|
||||
*/
|
||||
void nfs_expire_all_delegations(struct nfs_client *clp)
|
||||
{
|
||||
nfs_expire_all_delegation_types(clp, FMODE_READ|FMODE_WRITE);
|
||||
}
|
||||
|
||||
static void nfs_mark_return_unreferenced_delegations(struct nfs_server *server)
|
||||
{
|
||||
struct nfs_delegation *delegation;
|
||||
@@ -574,7 +617,7 @@ static void nfs_mark_return_unreferenced_delegations(struct nfs_server *server)
|
||||
list_for_each_entry_rcu(delegation, &server->delegations, super_list) {
|
||||
if (test_and_clear_bit(NFS_DELEGATION_REFERENCED, &delegation->flags))
|
||||
continue;
|
||||
nfs_mark_return_delegation(server, delegation);
|
||||
nfs_mark_return_if_closed_delegation(server, delegation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -28,6 +28,7 @@ struct nfs_delegation {
|
||||
enum {
|
||||
NFS_DELEGATION_NEED_RECLAIM = 0,
|
||||
NFS_DELEGATION_RETURN,
|
||||
NFS_DELEGATION_RETURN_IF_CLOSED,
|
||||
NFS_DELEGATION_REFERENCED,
|
||||
NFS_DELEGATION_RETURNING,
|
||||
};
|
||||
@@ -41,7 +42,7 @@ void nfs_inode_return_delegation_noreclaim(struct inode *inode);
|
||||
struct inode *nfs_delegation_find_inode(struct nfs_client *clp, const struct nfs_fh *fhandle);
|
||||
void nfs_server_return_all_delegations(struct nfs_server *);
|
||||
void nfs_expire_all_delegations(struct nfs_client *clp);
|
||||
void nfs_expire_all_delegation_types(struct nfs_client *clp, fmode_t flags);
|
||||
void nfs_expire_unused_delegation_types(struct nfs_client *clp, fmode_t flags);
|
||||
void nfs_expire_unreferenced_delegations(struct nfs_client *clp);
|
||||
int nfs_client_return_marked_delegations(struct nfs_client *clp);
|
||||
int nfs_delegations_present(struct nfs_client *clp);
|
||||
@@ -53,7 +54,7 @@ void nfs_delegation_reap_unclaimed(struct nfs_client *clp);
|
||||
/* NFSv4 delegation-related procedures */
|
||||
int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid, int issync);
|
||||
int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid);
|
||||
int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl);
|
||||
int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, const nfs4_stateid *stateid);
|
||||
bool nfs4_copy_delegation_stateid(nfs4_stateid *dst, struct inode *inode, fmode_t flags);
|
||||
|
||||
void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);
|
||||
|
||||
@@ -1486,6 +1486,8 @@ static int nfs4_lookup_revalidate(struct dentry *dentry, unsigned int flags)
|
||||
goto no_open;
|
||||
if (d_mountpoint(dentry))
|
||||
goto no_open;
|
||||
if (NFS_SB(dentry->d_sb)->caps & NFS_CAP_ATOMIC_OPEN_V1)
|
||||
goto no_open;
|
||||
|
||||
inode = dentry->d_inode;
|
||||
parent = dget_parent(dentry);
|
||||
|
||||
@@ -744,6 +744,7 @@ static int
|
||||
do_unlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
|
||||
{
|
||||
struct inode *inode = filp->f_mapping->host;
|
||||
struct nfs_lock_context *l_ctx;
|
||||
int status;
|
||||
|
||||
/*
|
||||
@@ -752,6 +753,14 @@ do_unlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
|
||||
*/
|
||||
nfs_sync_mapping(filp->f_mapping);
|
||||
|
||||
l_ctx = nfs_get_lock_context(nfs_file_open_context(filp));
|
||||
if (!IS_ERR(l_ctx)) {
|
||||
status = nfs_iocounter_wait(&l_ctx->io_count);
|
||||
nfs_put_lock_context(l_ctx);
|
||||
if (status < 0)
|
||||
return status;
|
||||
}
|
||||
|
||||
/* NOTE: special case
|
||||
* If we're signalled while cleaning up locks on process exit, we
|
||||
* still need to complete the unlock.
|
||||
|
||||
+5
-3
@@ -561,20 +561,22 @@ static void nfs_init_lock_context(struct nfs_lock_context *l_ctx)
|
||||
l_ctx->lockowner.l_owner = current->files;
|
||||
l_ctx->lockowner.l_pid = current->tgid;
|
||||
INIT_LIST_HEAD(&l_ctx->list);
|
||||
nfs_iocounter_init(&l_ctx->io_count);
|
||||
}
|
||||
|
||||
static struct nfs_lock_context *__nfs_find_lock_context(struct nfs_open_context *ctx)
|
||||
{
|
||||
struct nfs_lock_context *pos;
|
||||
struct nfs_lock_context *head = &ctx->lock_context;
|
||||
struct nfs_lock_context *pos = head;
|
||||
|
||||
list_for_each_entry(pos, &ctx->lock_context.list, list) {
|
||||
do {
|
||||
if (pos->lockowner.l_owner != current->files)
|
||||
continue;
|
||||
if (pos->lockowner.l_pid != current->tgid)
|
||||
continue;
|
||||
atomic_inc(&pos->count);
|
||||
return pos;
|
||||
}
|
||||
} while ((pos = list_entry(pos->list.next, typeof(*pos), list)) != head);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -229,6 +229,13 @@ extern void nfs_pgheader_init(struct nfs_pageio_descriptor *desc,
|
||||
struct nfs_pgio_header *hdr,
|
||||
void (*release)(struct nfs_pgio_header *hdr));
|
||||
void nfs_set_pgio_error(struct nfs_pgio_header *hdr, int error, loff_t pos);
|
||||
int nfs_iocounter_wait(struct nfs_io_counter *c);
|
||||
|
||||
static inline void nfs_iocounter_init(struct nfs_io_counter *c)
|
||||
{
|
||||
c->flags = 0;
|
||||
atomic_set(&c->io_count, 0);
|
||||
}
|
||||
|
||||
/* nfs2xdr.c */
|
||||
extern struct rpc_procinfo nfs_procedures[];
|
||||
|
||||
+14
-2
@@ -36,6 +36,7 @@ enum nfs4_client_state {
|
||||
|
||||
struct nfs4_minor_version_ops {
|
||||
u32 minor_version;
|
||||
unsigned init_caps;
|
||||
|
||||
int (*call_sync)(struct rpc_clnt *clnt,
|
||||
struct nfs_server *server,
|
||||
@@ -143,12 +144,14 @@ struct nfs4_lock_state {
|
||||
enum {
|
||||
LK_STATE_IN_USE,
|
||||
NFS_DELEGATED_STATE, /* Current stateid is delegation */
|
||||
NFS_OPEN_STATE, /* OPEN stateid is set */
|
||||
NFS_O_RDONLY_STATE, /* OPEN stateid has read-only state */
|
||||
NFS_O_WRONLY_STATE, /* OPEN stateid has write-only state */
|
||||
NFS_O_RDWR_STATE, /* OPEN stateid has read/write state */
|
||||
NFS_STATE_RECLAIM_REBOOT, /* OPEN stateid server rebooted */
|
||||
NFS_STATE_RECLAIM_NOGRACE, /* OPEN stateid needs to recover state */
|
||||
NFS_STATE_POSIX_LOCKS, /* Posix locks are supported */
|
||||
NFS_STATE_RECOVERY_FAILED, /* OPEN stateid state recovery failed */
|
||||
};
|
||||
|
||||
struct nfs4_state {
|
||||
@@ -233,6 +236,10 @@ extern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *, struct qstr
|
||||
extern int nfs4_proc_secinfo(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
|
||||
extern int nfs4_release_lockowner(struct nfs4_lock_state *);
|
||||
extern const struct xattr_handler *nfs4_xattr_handlers[];
|
||||
extern int nfs4_set_rw_stateid(nfs4_stateid *stateid,
|
||||
const struct nfs_open_context *ctx,
|
||||
const struct nfs_lock_context *l_ctx,
|
||||
fmode_t fmode);
|
||||
|
||||
#if defined(CONFIG_NFS_V4_1)
|
||||
static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *server)
|
||||
@@ -347,13 +354,13 @@ extern int nfs4_wait_clnt_recover(struct nfs_client *clp);
|
||||
extern int nfs4_client_recover_expired_lease(struct nfs_client *clp);
|
||||
extern void nfs4_schedule_state_manager(struct nfs_client *);
|
||||
extern void nfs4_schedule_path_down_recovery(struct nfs_client *clp);
|
||||
extern void nfs4_schedule_stateid_recovery(const struct nfs_server *, struct nfs4_state *);
|
||||
extern int nfs4_schedule_stateid_recovery(const struct nfs_server *, struct nfs4_state *);
|
||||
extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags);
|
||||
extern void nfs41_handle_server_scope(struct nfs_client *,
|
||||
struct nfs41_server_scope **);
|
||||
extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp);
|
||||
extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl);
|
||||
extern void nfs4_select_rw_stateid(nfs4_stateid *, struct nfs4_state *,
|
||||
extern int nfs4_select_rw_stateid(nfs4_stateid *, struct nfs4_state *,
|
||||
fmode_t, const struct nfs_lockowner *);
|
||||
|
||||
extern struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter, gfp_t gfp_mask);
|
||||
@@ -412,6 +419,11 @@ static inline bool nfs4_stateid_match(const nfs4_stateid *dst, const nfs4_statei
|
||||
return memcmp(dst, src, sizeof(*dst)) == 0;
|
||||
}
|
||||
|
||||
static inline bool nfs4_valid_open_stateid(const struct nfs4_state *state)
|
||||
{
|
||||
return test_bit(NFS_STATE_RECOVERY_FAILED, &state->flags) == 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define nfs4_close_state(a, b) do { } while (0)
|
||||
|
||||
+18
-12
@@ -198,8 +198,12 @@ struct nfs_client *nfs4_init_client(struct nfs_client *clp,
|
||||
/* Check NFS protocol revision and initialize RPC op vector */
|
||||
clp->rpc_ops = &nfs_v4_clientops;
|
||||
|
||||
if (clp->cl_minorversion != 0)
|
||||
__set_bit(NFS_CS_INFINITE_SLOTS, &clp->cl_flags);
|
||||
__set_bit(NFS_CS_DISCRTRY, &clp->cl_flags);
|
||||
error = nfs_create_rpc_client(clp, timeparms, authflavour);
|
||||
error = nfs_create_rpc_client(clp, timeparms, RPC_AUTH_GSS_KRB5I);
|
||||
if (error == -EINVAL)
|
||||
error = nfs_create_rpc_client(clp, timeparms, RPC_AUTH_NULL);
|
||||
if (error < 0)
|
||||
goto error;
|
||||
|
||||
@@ -730,6 +734,19 @@ static int nfs4_server_common_setup(struct nfs_server *server,
|
||||
if (error < 0)
|
||||
goto out;
|
||||
|
||||
/* Set the basic capabilities */
|
||||
server->caps |= server->nfs_client->cl_mvops->init_caps;
|
||||
if (server->flags & NFS_MOUNT_NORDIRPLUS)
|
||||
server->caps &= ~NFS_CAP_READDIRPLUS;
|
||||
/*
|
||||
* Don't use NFS uid/gid mapping if we're using AUTH_SYS or lower
|
||||
* authentication.
|
||||
*/
|
||||
if (nfs4_disable_idmapping &&
|
||||
server->client->cl_auth->au_flavor == RPC_AUTH_UNIX)
|
||||
server->caps |= NFS_CAP_UIDGID_NOMAP;
|
||||
|
||||
|
||||
/* Probe the root fh to retrieve its FSID and filehandle */
|
||||
error = nfs4_get_rootfh(server, mntfh);
|
||||
if (error < 0)
|
||||
@@ -773,9 +790,6 @@ static int nfs4_init_server(struct nfs_server *server,
|
||||
|
||||
/* Initialise the client representation from the mount data */
|
||||
server->flags = data->flags;
|
||||
server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR|NFS_CAP_POSIX_LOCK;
|
||||
if (!(data->flags & NFS_MOUNT_NORDIRPLUS))
|
||||
server->caps |= NFS_CAP_READDIRPLUS;
|
||||
server->options = data->options;
|
||||
|
||||
/* Get a client record */
|
||||
@@ -792,13 +806,6 @@ static int nfs4_init_server(struct nfs_server *server,
|
||||
if (error < 0)
|
||||
goto error;
|
||||
|
||||
/*
|
||||
* Don't use NFS uid/gid mapping if we're using AUTH_SYS or lower
|
||||
* authentication.
|
||||
*/
|
||||
if (nfs4_disable_idmapping && data->auth_flavors[0] == RPC_AUTH_UNIX)
|
||||
server->caps |= NFS_CAP_UIDGID_NOMAP;
|
||||
|
||||
if (data->rsize)
|
||||
server->rsize = nfs_block_size(data->rsize, NULL);
|
||||
if (data->wsize)
|
||||
@@ -876,7 +883,6 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
|
||||
|
||||
/* Initialise the client representation from the parent server */
|
||||
nfs_server_copy_userdata(server, parent_server);
|
||||
server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR;
|
||||
|
||||
/* Get a client representation.
|
||||
* Note: NFSv4 always uses TCP, */
|
||||
|
||||
+27
-7
@@ -158,11 +158,14 @@ static int filelayout_async_handle_error(struct rpc_task *task,
|
||||
case -NFS4ERR_OPENMODE:
|
||||
if (state == NULL)
|
||||
break;
|
||||
nfs4_schedule_stateid_recovery(mds_server, state);
|
||||
if (nfs4_schedule_stateid_recovery(mds_server, state) < 0)
|
||||
goto out_bad_stateid;
|
||||
goto wait_on_recovery;
|
||||
case -NFS4ERR_EXPIRED:
|
||||
if (state != NULL)
|
||||
nfs4_schedule_stateid_recovery(mds_server, state);
|
||||
if (state != NULL) {
|
||||
if (nfs4_schedule_stateid_recovery(mds_server, state) < 0)
|
||||
goto out_bad_stateid;
|
||||
}
|
||||
nfs4_schedule_lease_recovery(mds_client);
|
||||
goto wait_on_recovery;
|
||||
/* DS session errors */
|
||||
@@ -226,6 +229,9 @@ reset:
|
||||
out:
|
||||
task->tk_status = 0;
|
||||
return -EAGAIN;
|
||||
out_bad_stateid:
|
||||
task->tk_status = -EIO;
|
||||
return 0;
|
||||
wait_on_recovery:
|
||||
rpc_sleep_on(&mds_client->cl_rpcwaitq, task, NULL);
|
||||
if (test_bit(NFS4CLNT_MANAGER_RUNNING, &mds_client->cl_state) == 0)
|
||||
@@ -299,6 +305,10 @@ static void filelayout_read_prepare(struct rpc_task *task, void *data)
|
||||
{
|
||||
struct nfs_read_data *rdata = data;
|
||||
|
||||
if (unlikely(test_bit(NFS_CONTEXT_BAD, &rdata->args.context->flags))) {
|
||||
rpc_exit(task, -EIO);
|
||||
return;
|
||||
}
|
||||
if (filelayout_reset_to_mds(rdata->header->lseg)) {
|
||||
dprintk("%s task %u reset io to MDS\n", __func__, task->tk_pid);
|
||||
filelayout_reset_read(rdata);
|
||||
@@ -307,10 +317,13 @@ static void filelayout_read_prepare(struct rpc_task *task, void *data)
|
||||
}
|
||||
rdata->read_done_cb = filelayout_read_done_cb;
|
||||
|
||||
nfs41_setup_sequence(rdata->ds_clp->cl_session,
|
||||
if (nfs41_setup_sequence(rdata->ds_clp->cl_session,
|
||||
&rdata->args.seq_args,
|
||||
&rdata->res.seq_res,
|
||||
task);
|
||||
task))
|
||||
return;
|
||||
nfs4_set_rw_stateid(&rdata->args.stateid, rdata->args.context,
|
||||
rdata->args.lock_context, FMODE_READ);
|
||||
}
|
||||
|
||||
static void filelayout_read_call_done(struct rpc_task *task, void *data)
|
||||
@@ -401,16 +414,23 @@ static void filelayout_write_prepare(struct rpc_task *task, void *data)
|
||||
{
|
||||
struct nfs_write_data *wdata = data;
|
||||
|
||||
if (unlikely(test_bit(NFS_CONTEXT_BAD, &wdata->args.context->flags))) {
|
||||
rpc_exit(task, -EIO);
|
||||
return;
|
||||
}
|
||||
if (filelayout_reset_to_mds(wdata->header->lseg)) {
|
||||
dprintk("%s task %u reset io to MDS\n", __func__, task->tk_pid);
|
||||
filelayout_reset_write(wdata);
|
||||
rpc_exit(task, 0);
|
||||
return;
|
||||
}
|
||||
nfs41_setup_sequence(wdata->ds_clp->cl_session,
|
||||
if (nfs41_setup_sequence(wdata->ds_clp->cl_session,
|
||||
&wdata->args.seq_args,
|
||||
&wdata->res.seq_res,
|
||||
task);
|
||||
task))
|
||||
return;
|
||||
nfs4_set_rw_stateid(&wdata->args.stateid, wdata->args.context,
|
||||
wdata->args.lock_context, FMODE_WRITE);
|
||||
}
|
||||
|
||||
static void filelayout_write_call_done(struct rpc_task *task, void *data)
|
||||
|
||||
+23
-18
@@ -134,33 +134,38 @@ static size_t nfs_parse_server_name(char *string, size_t len,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs_find_best_sec - Find a security mechanism supported locally
|
||||
* @flavors: List of security tuples returned by SECINFO procedure
|
||||
*
|
||||
* Return the pseudoflavor of the first security mechanism in
|
||||
* "flavors" that is locally supported. Return RPC_AUTH_UNIX if
|
||||
* no matching flavor is found in the array. The "flavors" array
|
||||
* is searched in the order returned from the server, per RFC 3530
|
||||
* recommendation.
|
||||
*/
|
||||
rpc_authflavor_t nfs_find_best_sec(struct nfs4_secinfo_flavors *flavors)
|
||||
{
|
||||
struct gss_api_mech *mech;
|
||||
struct xdr_netobj oid;
|
||||
int i;
|
||||
rpc_authflavor_t pseudoflavor = RPC_AUTH_UNIX;
|
||||
rpc_authflavor_t pseudoflavor;
|
||||
struct nfs4_secinfo4 *secinfo;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < flavors->num_flavors; i++) {
|
||||
struct nfs4_secinfo_flavor *flavor;
|
||||
flavor = &flavors->flavors[i];
|
||||
secinfo = &flavors->flavors[i];
|
||||
|
||||
if (flavor->flavor == RPC_AUTH_NULL || flavor->flavor == RPC_AUTH_UNIX) {
|
||||
pseudoflavor = flavor->flavor;
|
||||
break;
|
||||
} else if (flavor->flavor == RPC_AUTH_GSS) {
|
||||
oid.len = flavor->gss.sec_oid4.len;
|
||||
oid.data = flavor->gss.sec_oid4.data;
|
||||
mech = gss_mech_get_by_OID(&oid);
|
||||
if (!mech)
|
||||
continue;
|
||||
pseudoflavor = gss_svc_to_pseudoflavor(mech, flavor->gss.service);
|
||||
gss_mech_put(mech);
|
||||
switch (secinfo->flavor) {
|
||||
case RPC_AUTH_NULL:
|
||||
case RPC_AUTH_UNIX:
|
||||
case RPC_AUTH_GSS:
|
||||
pseudoflavor = rpcauth_get_pseudoflavor(secinfo->flavor,
|
||||
&secinfo->flavor_info);
|
||||
if (pseudoflavor != RPC_AUTH_MAXFLAVOR)
|
||||
return pseudoflavor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return pseudoflavor;
|
||||
return RPC_AUTH_UNIX;
|
||||
}
|
||||
|
||||
static rpc_authflavor_t nfs4_negotiate_security(struct inode *inode, struct qstr *name)
|
||||
|
||||
+376
-183
File diff suppressed because it is too large
Load Diff
+77
-64
@@ -154,18 +154,6 @@ struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp)
|
||||
return cred;
|
||||
}
|
||||
|
||||
static void nfs4_clear_machine_cred(struct nfs_client *clp)
|
||||
{
|
||||
struct rpc_cred *cred;
|
||||
|
||||
spin_lock(&clp->cl_lock);
|
||||
cred = clp->cl_machine_cred;
|
||||
clp->cl_machine_cred = NULL;
|
||||
spin_unlock(&clp->cl_lock);
|
||||
if (cred != NULL)
|
||||
put_rpccred(cred);
|
||||
}
|
||||
|
||||
static struct rpc_cred *
|
||||
nfs4_get_renew_cred_server_locked(struct nfs_server *server)
|
||||
{
|
||||
@@ -699,6 +687,8 @@ __nfs4_find_state_byowner(struct inode *inode, struct nfs4_state_owner *owner)
|
||||
list_for_each_entry(state, &nfsi->open_states, inode_states) {
|
||||
if (state->owner != owner)
|
||||
continue;
|
||||
if (!nfs4_valid_open_stateid(state))
|
||||
continue;
|
||||
if (atomic_inc_not_zero(&state->count))
|
||||
return state;
|
||||
}
|
||||
@@ -987,13 +977,14 @@ int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool nfs4_copy_lock_stateid(nfs4_stateid *dst, struct nfs4_state *state,
|
||||
static int nfs4_copy_lock_stateid(nfs4_stateid *dst,
|
||||
struct nfs4_state *state,
|
||||
const struct nfs_lockowner *lockowner)
|
||||
{
|
||||
struct nfs4_lock_state *lsp;
|
||||
fl_owner_t fl_owner;
|
||||
pid_t fl_pid;
|
||||
bool ret = false;
|
||||
int ret = -ENOENT;
|
||||
|
||||
|
||||
if (lockowner == NULL)
|
||||
@@ -1008,7 +999,10 @@ static bool nfs4_copy_lock_stateid(nfs4_stateid *dst, struct nfs4_state *state,
|
||||
lsp = __nfs4_find_lock_state(state, fl_owner, fl_pid, NFS4_ANY_LOCK_TYPE);
|
||||
if (lsp != NULL && test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) != 0) {
|
||||
nfs4_stateid_copy(dst, &lsp->ls_stateid);
|
||||
ret = true;
|
||||
ret = 0;
|
||||
smp_rmb();
|
||||
if (!list_empty(&lsp->ls_seqid.list))
|
||||
ret = -EWOULDBLOCK;
|
||||
}
|
||||
spin_unlock(&state->state_lock);
|
||||
nfs4_put_lock_state(lsp);
|
||||
@@ -1016,28 +1010,44 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state)
|
||||
static int nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state)
|
||||
{
|
||||
const nfs4_stateid *src;
|
||||
int ret;
|
||||
int seq;
|
||||
|
||||
do {
|
||||
src = &zero_stateid;
|
||||
seq = read_seqbegin(&state->seqlock);
|
||||
nfs4_stateid_copy(dst, &state->stateid);
|
||||
if (test_bit(NFS_OPEN_STATE, &state->flags))
|
||||
src = &state->open_stateid;
|
||||
nfs4_stateid_copy(dst, src);
|
||||
ret = 0;
|
||||
smp_rmb();
|
||||
if (!list_empty(&state->owner->so_seqid.list))
|
||||
ret = -EWOULDBLOCK;
|
||||
} while (read_seqretry(&state->seqlock, seq));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Byte-range lock aware utility to initialize the stateid of read/write
|
||||
* requests.
|
||||
*/
|
||||
void nfs4_select_rw_stateid(nfs4_stateid *dst, struct nfs4_state *state,
|
||||
int nfs4_select_rw_stateid(nfs4_stateid *dst, struct nfs4_state *state,
|
||||
fmode_t fmode, const struct nfs_lockowner *lockowner)
|
||||
{
|
||||
int ret = 0;
|
||||
if (nfs4_copy_delegation_stateid(dst, state->inode, fmode))
|
||||
return;
|
||||
if (nfs4_copy_lock_stateid(dst, state, lockowner))
|
||||
return;
|
||||
nfs4_copy_open_stateid(dst, state);
|
||||
goto out;
|
||||
ret = nfs4_copy_lock_stateid(dst, state, lockowner);
|
||||
if (ret != -ENOENT)
|
||||
goto out;
|
||||
ret = nfs4_copy_open_stateid(dst, state);
|
||||
out:
|
||||
if (nfs_server_capable(state->inode, NFS_CAP_STATEID_NFSV41))
|
||||
dst->seqid = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter, gfp_t gfp_mask)
|
||||
@@ -1286,14 +1296,17 @@ static int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_s
|
||||
return 1;
|
||||
}
|
||||
|
||||
void nfs4_schedule_stateid_recovery(const struct nfs_server *server, struct nfs4_state *state)
|
||||
int nfs4_schedule_stateid_recovery(const struct nfs_server *server, struct nfs4_state *state)
|
||||
{
|
||||
struct nfs_client *clp = server->nfs_client;
|
||||
|
||||
if (!nfs4_valid_open_stateid(state))
|
||||
return -EBADF;
|
||||
nfs4_state_mark_reclaim_nograce(clp, state);
|
||||
dprintk("%s: scheduling stateid recovery for server %s\n", __func__,
|
||||
clp->cl_hostname);
|
||||
nfs4_schedule_state_manager(clp);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nfs4_schedule_stateid_recovery);
|
||||
|
||||
@@ -1323,6 +1336,27 @@ void nfs_inode_find_state_and_recover(struct inode *inode,
|
||||
nfs4_schedule_state_manager(clp);
|
||||
}
|
||||
|
||||
static void nfs4_state_mark_open_context_bad(struct nfs4_state *state)
|
||||
{
|
||||
struct inode *inode = state->inode;
|
||||
struct nfs_inode *nfsi = NFS_I(inode);
|
||||
struct nfs_open_context *ctx;
|
||||
|
||||
spin_lock(&inode->i_lock);
|
||||
list_for_each_entry(ctx, &nfsi->open_files, list) {
|
||||
if (ctx->state != state)
|
||||
continue;
|
||||
set_bit(NFS_CONTEXT_BAD, &ctx->flags);
|
||||
}
|
||||
spin_unlock(&inode->i_lock);
|
||||
}
|
||||
|
||||
static void nfs4_state_mark_recovery_failed(struct nfs4_state *state, int error)
|
||||
{
|
||||
set_bit(NFS_STATE_RECOVERY_FAILED, &state->flags);
|
||||
nfs4_state_mark_open_context_bad(state);
|
||||
}
|
||||
|
||||
|
||||
static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_recovery_ops *ops)
|
||||
{
|
||||
@@ -1398,6 +1432,8 @@ restart:
|
||||
list_for_each_entry(state, &sp->so_states, open_states) {
|
||||
if (!test_and_clear_bit(ops->state_flag_bit, &state->flags))
|
||||
continue;
|
||||
if (!nfs4_valid_open_stateid(state))
|
||||
continue;
|
||||
if (state->state == 0)
|
||||
continue;
|
||||
atomic_inc(&state->count);
|
||||
@@ -1430,11 +1466,10 @@ restart:
|
||||
* Open state on this file cannot be recovered
|
||||
* All we can do is revert to using the zero stateid.
|
||||
*/
|
||||
memset(&state->stateid, 0,
|
||||
sizeof(state->stateid));
|
||||
/* Mark the file as being 'closed' */
|
||||
state->state = 0;
|
||||
nfs4_state_mark_recovery_failed(state, status);
|
||||
break;
|
||||
case -EAGAIN:
|
||||
ssleep(1);
|
||||
case -NFS4ERR_ADMIN_REVOKED:
|
||||
case -NFS4ERR_STALE_STATEID:
|
||||
case -NFS4ERR_BAD_STATEID:
|
||||
@@ -1696,6 +1731,10 @@ static int nfs4_check_lease(struct nfs_client *clp)
|
||||
}
|
||||
status = ops->renew_lease(clp, cred);
|
||||
put_rpccred(cred);
|
||||
if (status == -ETIMEDOUT) {
|
||||
set_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state);
|
||||
return 0;
|
||||
}
|
||||
out:
|
||||
return nfs4_recovery_handle_error(clp, status);
|
||||
}
|
||||
@@ -1725,10 +1764,6 @@ static int nfs4_handle_reclaim_lease_error(struct nfs_client *clp, int status)
|
||||
clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
|
||||
return -EPERM;
|
||||
case -EACCES:
|
||||
if (clp->cl_machine_cred == NULL)
|
||||
return -EACCES;
|
||||
/* Handle case where the user hasn't set up machine creds */
|
||||
nfs4_clear_machine_cred(clp);
|
||||
case -NFS4ERR_DELAY:
|
||||
case -ETIMEDOUT:
|
||||
case -EAGAIN:
|
||||
@@ -1823,31 +1858,18 @@ int nfs4_discover_server_trunking(struct nfs_client *clp,
|
||||
{
|
||||
const struct nfs4_state_recovery_ops *ops =
|
||||
clp->cl_mvops->reboot_recovery_ops;
|
||||
rpc_authflavor_t *flavors, flav, save;
|
||||
struct rpc_clnt *clnt;
|
||||
struct rpc_cred *cred;
|
||||
int i, len, status;
|
||||
int i, status;
|
||||
|
||||
dprintk("NFS: %s: testing '%s'\n", __func__, clp->cl_hostname);
|
||||
|
||||
len = NFS_MAX_SECFLAVORS;
|
||||
flavors = kcalloc(len, sizeof(*flavors), GFP_KERNEL);
|
||||
if (flavors == NULL) {
|
||||
status = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
len = rpcauth_list_flavors(flavors, len);
|
||||
if (len < 0) {
|
||||
status = len;
|
||||
goto out_free;
|
||||
}
|
||||
clnt = clp->cl_rpcclient;
|
||||
save = clnt->cl_auth->au_flavor;
|
||||
i = 0;
|
||||
|
||||
mutex_lock(&nfs_clid_init_mutex);
|
||||
status = -ENOENT;
|
||||
again:
|
||||
status = -ENOENT;
|
||||
cred = ops->get_clid_cred(clp);
|
||||
if (cred == NULL)
|
||||
goto out_unlock;
|
||||
@@ -1857,12 +1879,6 @@ again:
|
||||
switch (status) {
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case -EACCES:
|
||||
if (clp->cl_machine_cred == NULL)
|
||||
break;
|
||||
/* Handle case where the user hasn't set up machine creds */
|
||||
nfs4_clear_machine_cred(clp);
|
||||
case -NFS4ERR_DELAY:
|
||||
case -ETIMEDOUT:
|
||||
case -EAGAIN:
|
||||
@@ -1871,17 +1887,12 @@ again:
|
||||
dprintk("NFS: %s after status %d, retrying\n",
|
||||
__func__, status);
|
||||
goto again;
|
||||
|
||||
case -EACCES:
|
||||
if (i++)
|
||||
break;
|
||||
case -NFS4ERR_CLID_INUSE:
|
||||
case -NFS4ERR_WRONGSEC:
|
||||
status = -EPERM;
|
||||
if (i >= len)
|
||||
break;
|
||||
|
||||
flav = flavors[i++];
|
||||
if (flav == save)
|
||||
flav = flavors[i++];
|
||||
clnt = rpc_clone_client_set_auth(clnt, flav);
|
||||
clnt = rpc_clone_client_set_auth(clnt, RPC_AUTH_UNIX);
|
||||
if (IS_ERR(clnt)) {
|
||||
status = PTR_ERR(clnt);
|
||||
break;
|
||||
@@ -1903,13 +1914,15 @@ again:
|
||||
case -NFS4ERR_NOT_SAME: /* FixMe: implement recovery
|
||||
* in nfs4_exchange_id */
|
||||
status = -EKEYEXPIRED;
|
||||
break;
|
||||
default:
|
||||
pr_warn("NFS: %s unhandled error %d. Exiting with error EIO\n",
|
||||
__func__, status);
|
||||
status = -EIO;
|
||||
}
|
||||
|
||||
out_unlock:
|
||||
mutex_unlock(&nfs_clid_init_mutex);
|
||||
out_free:
|
||||
kfree(flavors);
|
||||
out:
|
||||
dprintk("NFS: %s: status = %d\n", __func__, status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -252,6 +252,8 @@ struct dentry *nfs4_try_mount(int flags, const char *dev_name,
|
||||
|
||||
dfprintk(MOUNT, "--> nfs4_try_mount()\n");
|
||||
|
||||
if (data->auth_flavors[0] == RPC_AUTH_MAXFLAVOR)
|
||||
data->auth_flavors[0] = RPC_AUTH_UNIX;
|
||||
export_path = data->nfs_server.export_path;
|
||||
data->nfs_server.export_path = "/";
|
||||
root_mnt = nfs_do_root_mount(&nfs4_remote_fs_type, flags, mount_info,
|
||||
|
||||
+78
-98
@@ -530,14 +530,10 @@ static int nfs4_stat_to_errno(int);
|
||||
decode_setclientid_maxsz)
|
||||
#define NFS4_enc_setclientid_confirm_sz \
|
||||
(compound_encode_hdr_maxsz + \
|
||||
encode_setclientid_confirm_maxsz + \
|
||||
encode_putrootfh_maxsz + \
|
||||
encode_fsinfo_maxsz)
|
||||
encode_setclientid_confirm_maxsz)
|
||||
#define NFS4_dec_setclientid_confirm_sz \
|
||||
(compound_decode_hdr_maxsz + \
|
||||
decode_setclientid_confirm_maxsz + \
|
||||
decode_putrootfh_maxsz + \
|
||||
decode_fsinfo_maxsz)
|
||||
decode_setclientid_confirm_maxsz)
|
||||
#define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \
|
||||
encode_sequence_maxsz + \
|
||||
encode_putfh_maxsz + \
|
||||
@@ -1058,8 +1054,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const
|
||||
if (iap->ia_valid & ATTR_ATIME_SET) {
|
||||
bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET;
|
||||
*p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME);
|
||||
*p++ = cpu_to_be32(0);
|
||||
*p++ = cpu_to_be32(iap->ia_atime.tv_sec);
|
||||
p = xdr_encode_hyper(p, (s64)iap->ia_atime.tv_sec);
|
||||
*p++ = cpu_to_be32(iap->ia_atime.tv_nsec);
|
||||
}
|
||||
else if (iap->ia_valid & ATTR_ATIME) {
|
||||
@@ -1069,8 +1064,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const
|
||||
if (iap->ia_valid & ATTR_MTIME_SET) {
|
||||
bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET;
|
||||
*p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME);
|
||||
*p++ = cpu_to_be32(0);
|
||||
*p++ = cpu_to_be32(iap->ia_mtime.tv_sec);
|
||||
p = xdr_encode_hyper(p, (s64)iap->ia_mtime.tv_sec);
|
||||
*p++ = cpu_to_be32(iap->ia_mtime.tv_nsec);
|
||||
}
|
||||
else if (iap->ia_valid & ATTR_MTIME) {
|
||||
@@ -1366,33 +1360,28 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena
|
||||
|
||||
static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg)
|
||||
{
|
||||
struct iattr dummy;
|
||||
__be32 *p;
|
||||
struct nfs_client *clp;
|
||||
|
||||
p = reserve_space(xdr, 4);
|
||||
switch(arg->open_flags & O_EXCL) {
|
||||
case 0:
|
||||
switch(arg->createmode) {
|
||||
case NFS4_CREATE_UNCHECKED:
|
||||
*p = cpu_to_be32(NFS4_CREATE_UNCHECKED);
|
||||
encode_attrs(xdr, arg->u.attrs, arg->server);
|
||||
break;
|
||||
default:
|
||||
clp = arg->server->nfs_client;
|
||||
if (clp->cl_mvops->minor_version > 0) {
|
||||
if (nfs4_has_persistent_session(clp)) {
|
||||
*p = cpu_to_be32(NFS4_CREATE_GUARDED);
|
||||
encode_attrs(xdr, arg->u.attrs, arg->server);
|
||||
} else {
|
||||
struct iattr dummy;
|
||||
|
||||
*p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1);
|
||||
encode_nfs4_verifier(xdr, &arg->u.verifier);
|
||||
dummy.ia_valid = 0;
|
||||
encode_attrs(xdr, &dummy, arg->server);
|
||||
}
|
||||
} else {
|
||||
*p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE);
|
||||
encode_nfs4_verifier(xdr, &arg->u.verifier);
|
||||
}
|
||||
case NFS4_CREATE_GUARDED:
|
||||
*p = cpu_to_be32(NFS4_CREATE_GUARDED);
|
||||
encode_attrs(xdr, arg->u.attrs, arg->server);
|
||||
break;
|
||||
case NFS4_CREATE_EXCLUSIVE:
|
||||
*p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE);
|
||||
encode_nfs4_verifier(xdr, &arg->u.verifier);
|
||||
break;
|
||||
case NFS4_CREATE_EXCLUSIVE4_1:
|
||||
*p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1);
|
||||
encode_nfs4_verifier(xdr, &arg->u.verifier);
|
||||
dummy.ia_valid = 0;
|
||||
encode_attrs(xdr, &dummy, arg->server);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1459,6 +1448,23 @@ static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struc
|
||||
encode_string(xdr, name->len, name->name);
|
||||
}
|
||||
|
||||
static inline void encode_claim_fh(struct xdr_stream *xdr)
|
||||
{
|
||||
__be32 *p;
|
||||
|
||||
p = reserve_space(xdr, 4);
|
||||
*p = cpu_to_be32(NFS4_OPEN_CLAIM_FH);
|
||||
}
|
||||
|
||||
static inline void encode_claim_delegate_cur_fh(struct xdr_stream *xdr, const nfs4_stateid *stateid)
|
||||
{
|
||||
__be32 *p;
|
||||
|
||||
p = reserve_space(xdr, 4);
|
||||
*p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH);
|
||||
encode_nfs4_stateid(xdr, stateid);
|
||||
}
|
||||
|
||||
static void encode_open(struct xdr_stream *xdr, const struct nfs_openargs *arg, struct compound_hdr *hdr)
|
||||
{
|
||||
encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr);
|
||||
@@ -1474,6 +1480,12 @@ static void encode_open(struct xdr_stream *xdr, const struct nfs_openargs *arg,
|
||||
case NFS4_OPEN_CLAIM_DELEGATE_CUR:
|
||||
encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation);
|
||||
break;
|
||||
case NFS4_OPEN_CLAIM_FH:
|
||||
encode_claim_fh(xdr);
|
||||
break;
|
||||
case NFS4_OPEN_CLAIM_DELEG_CUR_FH:
|
||||
encode_claim_delegate_cur_fh(xdr, &arg->u.delegation);
|
||||
break;
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
@@ -1506,35 +1518,12 @@ static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
|
||||
encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr);
|
||||
}
|
||||
|
||||
static void encode_open_stateid(struct xdr_stream *xdr,
|
||||
const struct nfs_open_context *ctx,
|
||||
const struct nfs_lock_context *l_ctx,
|
||||
fmode_t fmode,
|
||||
int zero_seqid)
|
||||
{
|
||||
nfs4_stateid stateid;
|
||||
|
||||
if (ctx->state != NULL) {
|
||||
const struct nfs_lockowner *lockowner = NULL;
|
||||
|
||||
if (l_ctx != NULL)
|
||||
lockowner = &l_ctx->lockowner;
|
||||
nfs4_select_rw_stateid(&stateid, ctx->state,
|
||||
fmode, lockowner);
|
||||
if (zero_seqid)
|
||||
stateid.seqid = 0;
|
||||
encode_nfs4_stateid(xdr, &stateid);
|
||||
} else
|
||||
encode_nfs4_stateid(xdr, &zero_stateid);
|
||||
}
|
||||
|
||||
static void encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args, struct compound_hdr *hdr)
|
||||
{
|
||||
__be32 *p;
|
||||
|
||||
encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr);
|
||||
encode_open_stateid(xdr, args->context, args->lock_context,
|
||||
FMODE_READ, hdr->minorversion);
|
||||
encode_nfs4_stateid(xdr, &args->stateid);
|
||||
|
||||
p = reserve_space(xdr, 12);
|
||||
p = xdr_encode_hyper(p, args->offset);
|
||||
@@ -1670,8 +1659,7 @@ static void encode_write(struct xdr_stream *xdr, const struct nfs_writeargs *arg
|
||||
__be32 *p;
|
||||
|
||||
encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr);
|
||||
encode_open_stateid(xdr, args->context, args->lock_context,
|
||||
FMODE_WRITE, hdr->minorversion);
|
||||
encode_nfs4_stateid(xdr, &args->stateid);
|
||||
|
||||
p = reserve_space(xdr, 16);
|
||||
p = xdr_encode_hyper(p, args->offset);
|
||||
@@ -2609,12 +2597,9 @@ static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req,
|
||||
struct compound_hdr hdr = {
|
||||
.nops = 0,
|
||||
};
|
||||
const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME };
|
||||
|
||||
encode_compound_hdr(xdr, req, &hdr);
|
||||
encode_setclientid_confirm(xdr, arg, &hdr);
|
||||
encode_putrootfh(xdr, &hdr);
|
||||
encode_fsinfo(xdr, lease_bitmap, &hdr);
|
||||
encode_nops(&hdr);
|
||||
}
|
||||
|
||||
@@ -3497,8 +3482,11 @@ static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path)
|
||||
if (n == 0)
|
||||
goto root_path;
|
||||
dprintk("pathname4: ");
|
||||
path->ncomponents = 0;
|
||||
while (path->ncomponents < n) {
|
||||
if (n > NFS4_PATHNAME_MAXCOMPONENTS) {
|
||||
dprintk("cannot parse %d components in path\n", n);
|
||||
goto out_eio;
|
||||
}
|
||||
for (path->ncomponents = 0; path->ncomponents < n; path->ncomponents++) {
|
||||
struct nfs4_string *component = &path->components[path->ncomponents];
|
||||
status = decode_opaque_inline(xdr, &component->len, &component->data);
|
||||
if (unlikely(status != 0))
|
||||
@@ -3507,12 +3495,6 @@ static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path)
|
||||
pr_cont("%s%.*s ",
|
||||
(path->ncomponents != n ? "/ " : ""),
|
||||
component->len, component->data);
|
||||
if (path->ncomponents < NFS4_PATHNAME_MAXCOMPONENTS)
|
||||
path->ncomponents++;
|
||||
else {
|
||||
dprintk("cannot parse %d components in path\n", n);
|
||||
goto out_eio;
|
||||
}
|
||||
}
|
||||
out:
|
||||
return status;
|
||||
@@ -3557,27 +3539,23 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st
|
||||
n = be32_to_cpup(p);
|
||||
if (n <= 0)
|
||||
goto out_eio;
|
||||
res->nlocations = 0;
|
||||
while (res->nlocations < n) {
|
||||
for (res->nlocations = 0; res->nlocations < n; res->nlocations++) {
|
||||
u32 m;
|
||||
struct nfs4_fs_location *loc = &res->locations[res->nlocations];
|
||||
struct nfs4_fs_location *loc;
|
||||
|
||||
if (res->nlocations == NFS4_FS_LOCATIONS_MAXENTRIES)
|
||||
break;
|
||||
loc = &res->locations[res->nlocations];
|
||||
p = xdr_inline_decode(xdr, 4);
|
||||
if (unlikely(!p))
|
||||
goto out_overflow;
|
||||
m = be32_to_cpup(p);
|
||||
|
||||
loc->nservers = 0;
|
||||
dprintk("%s: servers:\n", __func__);
|
||||
while (loc->nservers < m) {
|
||||
struct nfs4_string *server = &loc->servers[loc->nservers];
|
||||
status = decode_opaque_inline(xdr, &server->len, &server->data);
|
||||
if (unlikely(status != 0))
|
||||
goto out_eio;
|
||||
dprintk("%s ", server->data);
|
||||
if (loc->nservers < NFS4_FS_LOCATION_MAXSERVERS)
|
||||
loc->nservers++;
|
||||
else {
|
||||
for (loc->nservers = 0; loc->nservers < m; loc->nservers++) {
|
||||
struct nfs4_string *server;
|
||||
|
||||
if (loc->nservers == NFS4_FS_LOCATION_MAXSERVERS) {
|
||||
unsigned int i;
|
||||
dprintk("%s: using first %u of %u servers "
|
||||
"returned for location %u\n",
|
||||
@@ -3591,13 +3569,17 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st
|
||||
if (unlikely(status != 0))
|
||||
goto out_eio;
|
||||
}
|
||||
break;
|
||||
}
|
||||
server = &loc->servers[loc->nservers];
|
||||
status = decode_opaque_inline(xdr, &server->len, &server->data);
|
||||
if (unlikely(status != 0))
|
||||
goto out_eio;
|
||||
dprintk("%s ", server->data);
|
||||
}
|
||||
status = decode_pathname(xdr, &loc->rootpath);
|
||||
if (unlikely(status != 0))
|
||||
goto out_eio;
|
||||
if (res->nlocations < NFS4_FS_LOCATIONS_MAXENTRIES)
|
||||
res->nlocations++;
|
||||
}
|
||||
if (res->nlocations != 0)
|
||||
status = NFS_ATTR_FATTR_V4_LOCATIONS;
|
||||
@@ -5209,27 +5191,30 @@ static int decode_delegreturn(struct xdr_stream *xdr)
|
||||
return decode_op_hdr(xdr, OP_DELEGRETURN);
|
||||
}
|
||||
|
||||
static int decode_secinfo_gss(struct xdr_stream *xdr, struct nfs4_secinfo_flavor *flavor)
|
||||
static int decode_secinfo_gss(struct xdr_stream *xdr,
|
||||
struct nfs4_secinfo4 *flavor)
|
||||
{
|
||||
u32 oid_len;
|
||||
__be32 *p;
|
||||
|
||||
p = xdr_inline_decode(xdr, 4);
|
||||
if (unlikely(!p))
|
||||
goto out_overflow;
|
||||
flavor->gss.sec_oid4.len = be32_to_cpup(p);
|
||||
if (flavor->gss.sec_oid4.len > GSS_OID_MAX_LEN)
|
||||
oid_len = be32_to_cpup(p);
|
||||
if (oid_len > GSS_OID_MAX_LEN)
|
||||
goto out_err;
|
||||
|
||||
p = xdr_inline_decode(xdr, flavor->gss.sec_oid4.len);
|
||||
p = xdr_inline_decode(xdr, oid_len);
|
||||
if (unlikely(!p))
|
||||
goto out_overflow;
|
||||
memcpy(flavor->gss.sec_oid4.data, p, flavor->gss.sec_oid4.len);
|
||||
memcpy(flavor->flavor_info.oid.data, p, oid_len);
|
||||
flavor->flavor_info.oid.len = oid_len;
|
||||
|
||||
p = xdr_inline_decode(xdr, 8);
|
||||
if (unlikely(!p))
|
||||
goto out_overflow;
|
||||
flavor->gss.qop4 = be32_to_cpup(p++);
|
||||
flavor->gss.service = be32_to_cpup(p);
|
||||
flavor->flavor_info.qop = be32_to_cpup(p++);
|
||||
flavor->flavor_info.service = be32_to_cpup(p);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -5242,10 +5227,10 @@ out_err:
|
||||
|
||||
static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
|
||||
{
|
||||
struct nfs4_secinfo_flavor *sec_flavor;
|
||||
struct nfs4_secinfo4 *sec_flavor;
|
||||
unsigned int i, num_flavors;
|
||||
int status;
|
||||
__be32 *p;
|
||||
int i, num_flavors;
|
||||
|
||||
p = xdr_inline_decode(xdr, 4);
|
||||
if (unlikely(!p))
|
||||
@@ -6648,8 +6633,7 @@ static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req,
|
||||
* Decode SETCLIENTID_CONFIRM response
|
||||
*/
|
||||
static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req,
|
||||
struct xdr_stream *xdr,
|
||||
struct nfs_fsinfo *fsinfo)
|
||||
struct xdr_stream *xdr)
|
||||
{
|
||||
struct compound_hdr hdr;
|
||||
int status;
|
||||
@@ -6657,10 +6641,6 @@ static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req,
|
||||
status = decode_compound_hdr(xdr, &hdr);
|
||||
if (!status)
|
||||
status = decode_setclientid_confirm(xdr);
|
||||
if (!status)
|
||||
status = decode_putrootfh(xdr);
|
||||
if (!status)
|
||||
status = decode_fsinfo(xdr, fsinfo);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,55 @@ nfs_page_free(struct nfs_page *p)
|
||||
kmem_cache_free(nfs_page_cachep, p);
|
||||
}
|
||||
|
||||
static void
|
||||
nfs_iocounter_inc(struct nfs_io_counter *c)
|
||||
{
|
||||
atomic_inc(&c->io_count);
|
||||
}
|
||||
|
||||
static void
|
||||
nfs_iocounter_dec(struct nfs_io_counter *c)
|
||||
{
|
||||
if (atomic_dec_and_test(&c->io_count)) {
|
||||
clear_bit(NFS_IO_INPROGRESS, &c->flags);
|
||||
smp_mb__after_clear_bit();
|
||||
wake_up_bit(&c->flags, NFS_IO_INPROGRESS);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
__nfs_iocounter_wait(struct nfs_io_counter *c)
|
||||
{
|
||||
wait_queue_head_t *wq = bit_waitqueue(&c->flags, NFS_IO_INPROGRESS);
|
||||
DEFINE_WAIT_BIT(q, &c->flags, NFS_IO_INPROGRESS);
|
||||
int ret = 0;
|
||||
|
||||
do {
|
||||
prepare_to_wait(wq, &q.wait, TASK_KILLABLE);
|
||||
set_bit(NFS_IO_INPROGRESS, &c->flags);
|
||||
if (atomic_read(&c->io_count) == 0)
|
||||
break;
|
||||
ret = nfs_wait_bit_killable(&c->flags);
|
||||
} while (atomic_read(&c->io_count) != 0);
|
||||
finish_wait(wq, &q.wait);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs_iocounter_wait - wait for i/o to complete
|
||||
* @c: nfs_io_counter to use
|
||||
*
|
||||
* returns -ERESTARTSYS if interrupted by a fatal signal.
|
||||
* Otherwise returns 0 once the io_count hits 0.
|
||||
*/
|
||||
int
|
||||
nfs_iocounter_wait(struct nfs_io_counter *c)
|
||||
{
|
||||
if (atomic_read(&c->io_count) == 0)
|
||||
return 0;
|
||||
return __nfs_iocounter_wait(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs_create_request - Create an NFS read/write request.
|
||||
* @ctx: open context to use
|
||||
@@ -104,6 +153,8 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
|
||||
struct nfs_page *req;
|
||||
struct nfs_lock_context *l_ctx;
|
||||
|
||||
if (test_bit(NFS_CONTEXT_BAD, &ctx->flags))
|
||||
return ERR_PTR(-EBADF);
|
||||
/* try to allocate the request struct */
|
||||
req = nfs_page_alloc();
|
||||
if (req == NULL)
|
||||
@@ -116,6 +167,7 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
|
||||
return ERR_CAST(l_ctx);
|
||||
}
|
||||
req->wb_lock_context = l_ctx;
|
||||
nfs_iocounter_inc(&l_ctx->io_count);
|
||||
|
||||
/* Initialize the request struct. Initially, we assume a
|
||||
* long write-back delay. This will be adjusted in
|
||||
@@ -175,6 +227,7 @@ static void nfs_clear_request(struct nfs_page *req)
|
||||
req->wb_page = NULL;
|
||||
}
|
||||
if (l_ctx != NULL) {
|
||||
nfs_iocounter_dec(&l_ctx->io_count);
|
||||
nfs_put_lock_context(l_ctx);
|
||||
req->wb_lock_context = NULL;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user