2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Server-side types for NFSv4.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2002 The Regents of the University of Michigan.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Kendrick Smith <kmsmith@umich.edu>
|
|
|
|
* Andy Adamson <andros@umich.edu>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the University nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
|
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINUX_NFSD_XDR4_H
|
|
|
|
#define _LINUX_NFSD_XDR4_H
|
|
|
|
|
2009-12-04 02:30:56 +08:00
|
|
|
#include "state.h"
|
|
|
|
#include "nfsd.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define NFSD4_MAX_TAGLEN 128
|
|
|
|
#define XDR_LEN(n) (((n) + 3) & ~3)
|
|
|
|
|
2012-02-14 05:55:32 +08:00
|
|
|
#define CURRENT_STATE_ID_FLAG (1<<0)
|
|
|
|
#define SAVED_STATE_ID_FLAG (1<<1)
|
|
|
|
|
2018-09-14 01:58:24 +08:00
|
|
|
#define SET_CSTATE_FLAG(c, f) ((c)->sid_flags |= (f))
|
|
|
|
#define HAS_CSTATE_FLAG(c, f) ((c)->sid_flags & (f))
|
|
|
|
#define CLEAR_CSTATE_FLAG(c, f) ((c)->sid_flags &= ~(f))
|
2012-02-14 05:55:32 +08:00
|
|
|
|
2006-12-13 16:35:27 +08:00
|
|
|
struct nfsd4_compound_state {
|
2009-03-28 16:30:52 +08:00
|
|
|
struct svc_fh current_fh;
|
|
|
|
struct svc_fh save_fh;
|
|
|
|
struct nfs4_stateowner *replay_owner;
|
2014-06-30 23:48:44 +08:00
|
|
|
struct nfs4_client *clp;
|
2009-04-03 13:28:08 +08:00
|
|
|
/* For sessions DRC */
|
|
|
|
struct nfsd4_session *session;
|
|
|
|
struct nfsd4_slot *slot;
|
2014-03-22 05:57:57 +08:00
|
|
|
int data_offset;
|
2016-06-16 00:52:09 +08:00
|
|
|
bool spo_must_allowed;
|
2009-04-03 13:28:22 +08:00
|
|
|
size_t iovlen;
|
2009-04-03 13:28:53 +08:00
|
|
|
u32 minorversion;
|
2012-04-26 05:58:50 +08:00
|
|
|
__be32 status;
|
2012-02-14 05:55:32 +08:00
|
|
|
stateid_t current_stateid;
|
|
|
|
stateid_t save_stateid;
|
|
|
|
/* to indicate current and saved state id presents */
|
|
|
|
u32 sid_flags;
|
2006-12-13 16:35:27 +08:00
|
|
|
};
|
|
|
|
|
2009-04-03 13:28:45 +08:00
|
|
|
static inline bool nfsd4_has_session(struct nfsd4_compound_state *cs)
|
|
|
|
{
|
|
|
|
return cs->slot != NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct nfsd4_change_info {
|
|
|
|
u32 atomic;
|
2009-04-17 05:33:25 +08:00
|
|
|
bool change_supported;
|
2005-04-17 06:20:36 +08:00
|
|
|
u32 before_ctime_sec;
|
|
|
|
u32 before_ctime_nsec;
|
2009-04-17 05:33:25 +08:00
|
|
|
u64 before_change;
|
2005-04-17 06:20:36 +08:00
|
|
|
u32 after_ctime_sec;
|
|
|
|
u32 after_ctime_nsec;
|
2009-04-17 05:33:25 +08:00
|
|
|
u64 after_change;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_access {
|
|
|
|
u32 ac_req_access; /* request */
|
|
|
|
u32 ac_supported; /* response */
|
|
|
|
u32 ac_resp_access; /* response */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_close {
|
|
|
|
u32 cl_seqid; /* request */
|
|
|
|
stateid_t cl_stateid; /* request+response */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_commit {
|
|
|
|
u64 co_offset; /* request */
|
|
|
|
u32 co_count; /* request */
|
|
|
|
nfs4_verifier co_verf; /* response */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_create {
|
|
|
|
u32 cr_namelen; /* request */
|
|
|
|
char * cr_name; /* request */
|
|
|
|
u32 cr_type; /* request */
|
|
|
|
union { /* request */
|
|
|
|
struct {
|
2014-06-25 03:06:41 +08:00
|
|
|
u32 datalen;
|
|
|
|
char *data;
|
2018-03-27 22:54:21 +08:00
|
|
|
struct kvec first;
|
2005-04-17 06:20:36 +08:00
|
|
|
} link; /* NF4LNK */
|
|
|
|
struct {
|
|
|
|
u32 specdata1;
|
|
|
|
u32 specdata2;
|
|
|
|
} dev; /* NF4BLK, NF4CHR */
|
|
|
|
} u;
|
2009-04-03 13:29:11 +08:00
|
|
|
u32 cr_bmval[3]; /* request */
|
2005-04-17 06:20:36 +08:00
|
|
|
struct iattr cr_iattr; /* request */
|
2018-03-22 05:19:02 +08:00
|
|
|
int cr_umask; /* request */
|
2005-04-17 06:20:36 +08:00
|
|
|
struct nfsd4_change_info cr_cinfo; /* response */
|
|
|
|
struct nfs4_acl *cr_acl;
|
2013-05-03 01:19:10 +08:00
|
|
|
struct xdr_netobj cr_label;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
2014-06-25 03:06:41 +08:00
|
|
|
#define cr_datalen u.link.datalen
|
|
|
|
#define cr_data u.link.data
|
2018-03-27 22:54:21 +08:00
|
|
|
#define cr_first u.link.first
|
2005-04-17 06:20:36 +08:00
|
|
|
#define cr_specdata1 u.dev.specdata1
|
|
|
|
#define cr_specdata2 u.dev.specdata2
|
|
|
|
|
|
|
|
struct nfsd4_delegreturn {
|
|
|
|
stateid_t dr_stateid;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_getattr {
|
2009-04-03 13:29:11 +08:00
|
|
|
u32 ga_bmval[3]; /* request */
|
2005-04-17 06:20:36 +08:00
|
|
|
struct svc_fh *ga_fhp; /* response */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_link {
|
|
|
|
u32 li_namelen; /* request */
|
|
|
|
char * li_name; /* request */
|
|
|
|
struct nfsd4_change_info li_cinfo; /* response */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_lock_denied {
|
|
|
|
clientid_t ld_clientid;
|
2011-08-31 10:15:47 +08:00
|
|
|
struct xdr_netobj ld_owner;
|
2005-04-17 06:20:36 +08:00
|
|
|
u64 ld_start;
|
|
|
|
u64 ld_length;
|
|
|
|
u32 ld_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_lock {
|
|
|
|
/* request */
|
|
|
|
u32 lk_type;
|
|
|
|
u32 lk_reclaim; /* boolean */
|
|
|
|
u64 lk_offset;
|
|
|
|
u64 lk_length;
|
|
|
|
u32 lk_is_new;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u32 open_seqid;
|
|
|
|
stateid_t open_stateid;
|
|
|
|
u32 lock_seqid;
|
|
|
|
clientid_t clientid;
|
|
|
|
struct xdr_netobj owner;
|
|
|
|
} new;
|
|
|
|
struct {
|
|
|
|
stateid_t lock_stateid;
|
|
|
|
u32 lock_seqid;
|
|
|
|
} old;
|
|
|
|
} v;
|
|
|
|
|
|
|
|
/* response */
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
stateid_t stateid;
|
|
|
|
} ok;
|
|
|
|
struct nfsd4_lock_denied denied;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
#define lk_new_open_seqid v.new.open_seqid
|
|
|
|
#define lk_new_open_stateid v.new.open_stateid
|
|
|
|
#define lk_new_lock_seqid v.new.lock_seqid
|
|
|
|
#define lk_new_clientid v.new.clientid
|
|
|
|
#define lk_new_owner v.new.owner
|
|
|
|
#define lk_old_lock_stateid v.old.lock_stateid
|
|
|
|
#define lk_old_lock_seqid v.old.lock_seqid
|
|
|
|
|
|
|
|
#define lk_resp_stateid u.ok.stateid
|
|
|
|
#define lk_denied u.denied
|
|
|
|
|
|
|
|
|
|
|
|
struct nfsd4_lockt {
|
|
|
|
u32 lt_type;
|
|
|
|
clientid_t lt_clientid;
|
|
|
|
struct xdr_netobj lt_owner;
|
|
|
|
u64 lt_offset;
|
|
|
|
u64 lt_length;
|
|
|
|
struct nfsd4_lock_denied lt_denied;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct nfsd4_locku {
|
|
|
|
u32 lu_type;
|
|
|
|
u32 lu_seqid;
|
|
|
|
stateid_t lu_stateid;
|
|
|
|
u64 lu_offset;
|
|
|
|
u64 lu_length;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct nfsd4_lookup {
|
|
|
|
u32 lo_len; /* request */
|
|
|
|
char * lo_name; /* request */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_putfh {
|
|
|
|
u32 pf_fhlen; /* request */
|
|
|
|
char *pf_fhval; /* request */
|
2019-10-07 22:56:48 +08:00
|
|
|
bool no_verify; /* represents foreigh fh */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_open {
|
|
|
|
u32 op_claim_type; /* request */
|
|
|
|
struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */
|
|
|
|
u32 op_delegate_type; /* request - CLAIM_PREV only */
|
|
|
|
stateid_t op_delegate_stateid; /* request - response */
|
2012-02-17 02:57:17 +08:00
|
|
|
u32 op_why_no_deleg; /* response - DELEG_NONE_EXT only */
|
2005-04-17 06:20:36 +08:00
|
|
|
u32 op_create; /* request */
|
|
|
|
u32 op_createmode; /* request */
|
2018-03-22 05:19:02 +08:00
|
|
|
int op_umask; /* request */
|
2009-04-03 13:29:11 +08:00
|
|
|
u32 op_bmval[3]; /* request */
|
2013-12-05 10:41:40 +08:00
|
|
|
struct iattr op_iattr; /* UNCHECKED4, GUARDED4, EXCLUSIVE4_1 */
|
2012-03-03 06:13:50 +08:00
|
|
|
nfs4_verifier op_verf __attribute__((aligned(32)));
|
|
|
|
/* EXCLUSIVE4 */
|
2005-04-17 06:20:36 +08:00
|
|
|
clientid_t op_clientid; /* request */
|
|
|
|
struct xdr_netobj op_owner; /* request */
|
|
|
|
u32 op_seqid; /* request */
|
|
|
|
u32 op_share_access; /* request */
|
|
|
|
u32 op_share_deny; /* request */
|
2012-02-17 02:57:09 +08:00
|
|
|
u32 op_deleg_want; /* request */
|
2005-04-17 06:20:36 +08:00
|
|
|
stateid_t op_stateid; /* response */
|
2013-03-01 04:51:49 +08:00
|
|
|
__be32 op_xdr_error; /* see nfsd4_open_omfg() */
|
2005-06-24 13:03:23 +08:00
|
|
|
u32 op_recall; /* recall */
|
2005-04-17 06:20:36 +08:00
|
|
|
struct nfsd4_change_info op_cinfo; /* response */
|
|
|
|
u32 op_rflags; /* response */
|
2011-10-13 23:37:11 +08:00
|
|
|
bool op_truncate; /* used during processing */
|
|
|
|
bool op_created; /* used during processing */
|
2011-07-31 11:33:59 +08:00
|
|
|
struct nfs4_openowner *op_openowner; /* used during processing */
|
2011-10-14 04:00:16 +08:00
|
|
|
struct nfs4_file *op_file; /* used during processing */
|
2011-10-18 03:57:47 +08:00
|
|
|
struct nfs4_ol_stateid *op_stp; /* used during processing */
|
2015-04-27 20:50:14 +08:00
|
|
|
struct nfs4_clnt_odstate *op_odstate; /* used during processing */
|
2005-04-17 06:20:36 +08:00
|
|
|
struct nfs4_acl *op_acl;
|
2013-05-03 01:19:10 +08:00
|
|
|
struct xdr_netobj op_label;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_open_confirm {
|
|
|
|
stateid_t oc_req_stateid /* request */;
|
|
|
|
u32 oc_seqid /* request */;
|
|
|
|
stateid_t oc_resp_stateid /* response */;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_open_downgrade {
|
|
|
|
stateid_t od_stateid;
|
|
|
|
u32 od_seqid;
|
2012-02-17 02:57:09 +08:00
|
|
|
u32 od_share_access; /* request */
|
|
|
|
u32 od_deleg_want; /* request */
|
|
|
|
u32 od_share_deny; /* request */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct nfsd4_read {
|
2019-08-19 02:18:54 +08:00
|
|
|
stateid_t rd_stateid; /* request */
|
|
|
|
u64 rd_offset; /* request */
|
|
|
|
u32 rd_length; /* request */
|
|
|
|
int rd_vlen;
|
|
|
|
struct nfsd_file *rd_nf;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2019-08-19 02:18:54 +08:00
|
|
|
struct svc_rqst *rd_rqstp; /* response */
|
|
|
|
struct svc_fh *rd_fhp; /* response */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_readdir {
|
|
|
|
u64 rd_cookie; /* request */
|
|
|
|
nfs4_verifier rd_verf; /* request */
|
|
|
|
u32 rd_dircount; /* request */
|
|
|
|
u32 rd_maxcount; /* request */
|
2009-04-03 13:29:11 +08:00
|
|
|
u32 rd_bmval[3]; /* request */
|
2005-04-17 06:20:36 +08:00
|
|
|
struct svc_rqst *rd_rqstp; /* response */
|
|
|
|
struct svc_fh * rd_fhp; /* response */
|
|
|
|
|
|
|
|
struct readdir_cd common;
|
2014-01-21 05:37:11 +08:00
|
|
|
struct xdr_stream *xdr;
|
|
|
|
int cookie_offset;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_release_lockowner {
|
|
|
|
clientid_t rl_clientid;
|
|
|
|
struct xdr_netobj rl_owner;
|
|
|
|
};
|
|
|
|
struct nfsd4_readlink {
|
|
|
|
struct svc_rqst *rl_rqstp; /* request */
|
|
|
|
struct svc_fh * rl_fhp; /* request */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_remove {
|
|
|
|
u32 rm_namelen; /* request */
|
|
|
|
char * rm_name; /* request */
|
|
|
|
struct nfsd4_change_info rm_cinfo; /* response */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_rename {
|
|
|
|
u32 rn_snamelen; /* request */
|
|
|
|
char * rn_sname; /* request */
|
|
|
|
u32 rn_tnamelen; /* request */
|
|
|
|
char * rn_tname; /* request */
|
|
|
|
struct nfsd4_change_info rn_sinfo; /* response */
|
|
|
|
struct nfsd4_change_info rn_tinfo; /* response */
|
|
|
|
};
|
|
|
|
|
2007-07-17 19:04:51 +08:00
|
|
|
struct nfsd4_secinfo {
|
|
|
|
u32 si_namelen; /* request */
|
|
|
|
char *si_name; /* request */
|
|
|
|
struct svc_export *si_exp; /* response */
|
|
|
|
};
|
|
|
|
|
2010-12-16 22:51:13 +08:00
|
|
|
struct nfsd4_secinfo_no_name {
|
|
|
|
u32 sin_style; /* request */
|
|
|
|
struct svc_export *sin_exp; /* response */
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct nfsd4_setattr {
|
|
|
|
stateid_t sa_stateid; /* request */
|
2009-04-03 13:29:11 +08:00
|
|
|
u32 sa_bmval[3]; /* request */
|
2005-04-17 06:20:36 +08:00
|
|
|
struct iattr sa_iattr; /* request */
|
|
|
|
struct nfs4_acl *sa_acl;
|
2013-05-03 01:19:10 +08:00
|
|
|
struct xdr_netobj sa_label;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_setclientid {
|
|
|
|
nfs4_verifier se_verf; /* request */
|
2011-10-11 03:07:40 +08:00
|
|
|
struct xdr_netobj se_name;
|
2005-04-17 06:20:36 +08:00
|
|
|
u32 se_callback_prog; /* request */
|
|
|
|
u32 se_callback_netid_len; /* request */
|
|
|
|
char * se_callback_netid_val; /* request */
|
|
|
|
u32 se_callback_addr_len; /* request */
|
|
|
|
char * se_callback_addr_val; /* request */
|
|
|
|
u32 se_callback_ident; /* request */
|
|
|
|
clientid_t se_clientid; /* response */
|
|
|
|
nfs4_verifier se_confirm; /* response */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_setclientid_confirm {
|
|
|
|
clientid_t sc_clientid;
|
|
|
|
nfs4_verifier sc_confirm;
|
|
|
|
};
|
|
|
|
|
2011-07-13 22:50:48 +08:00
|
|
|
struct nfsd4_saved_compoundargs {
|
|
|
|
__be32 *p;
|
|
|
|
__be32 *end;
|
|
|
|
int pagelen;
|
|
|
|
struct page **pagelist;
|
|
|
|
};
|
|
|
|
|
2012-01-27 23:22:49 +08:00
|
|
|
struct nfsd4_test_stateid_id {
|
|
|
|
__be32 ts_id_status;
|
|
|
|
stateid_t ts_id_stateid;
|
|
|
|
struct list_head ts_id_list;
|
|
|
|
};
|
|
|
|
|
2011-07-13 22:50:48 +08:00
|
|
|
struct nfsd4_test_stateid {
|
2012-04-26 05:58:50 +08:00
|
|
|
u32 ts_num_ids;
|
2012-01-27 23:22:49 +08:00
|
|
|
struct list_head ts_stateid_list;
|
2011-07-13 22:50:48 +08:00
|
|
|
};
|
|
|
|
|
2011-07-13 23:04:21 +08:00
|
|
|
struct nfsd4_free_stateid {
|
|
|
|
stateid_t fr_stateid; /* request */
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* also used for NVERIFY */
|
|
|
|
struct nfsd4_verify {
|
2009-04-03 13:29:11 +08:00
|
|
|
u32 ve_bmval[3]; /* request */
|
2005-04-17 06:20:36 +08:00
|
|
|
u32 ve_attrlen; /* request */
|
|
|
|
char * ve_attrval; /* request */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_write {
|
|
|
|
stateid_t wr_stateid; /* request */
|
|
|
|
u64 wr_offset; /* request */
|
|
|
|
u32 wr_stable_how; /* request */
|
|
|
|
u32 wr_buflen; /* request */
|
2012-11-17 03:16:46 +08:00
|
|
|
struct kvec wr_head;
|
|
|
|
struct page ** wr_pagelist; /* request */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
u32 wr_bytes_written; /* response */
|
|
|
|
u32 wr_how_written; /* response */
|
|
|
|
nfs4_verifier wr_verifier; /* response */
|
|
|
|
};
|
|
|
|
|
2009-04-03 13:27:55 +08:00
|
|
|
struct nfsd4_exchange_id {
|
2009-04-03 13:28:01 +08:00
|
|
|
nfs4_verifier verifier;
|
|
|
|
struct xdr_netobj clname;
|
|
|
|
u32 flags;
|
|
|
|
clientid_t clientid;
|
|
|
|
u32 seqid;
|
|
|
|
int spa_how;
|
2016-06-16 00:52:09 +08:00
|
|
|
u32 spo_must_enforce[3];
|
|
|
|
u32 spo_must_allow[3];
|
2019-06-06 00:42:05 +08:00
|
|
|
struct xdr_netobj nii_domain;
|
|
|
|
struct xdr_netobj nii_name;
|
|
|
|
struct timespec64 nii_time;
|
2009-04-03 13:27:55 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_sequence {
|
2009-04-03 13:28:08 +08:00
|
|
|
struct nfs4_sessionid sessionid; /* request/response */
|
|
|
|
u32 seqid; /* request/response */
|
|
|
|
u32 slotid; /* request/response */
|
|
|
|
u32 maxslots; /* request/response */
|
|
|
|
u32 cachethis; /* request */
|
|
|
|
#if 0
|
|
|
|
u32 target_maxslots; /* response */
|
|
|
|
#endif /* not yet */
|
2010-11-18 21:30:33 +08:00
|
|
|
u32 status_flags; /* response */
|
2009-04-03 13:27:55 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_destroy_session {
|
2009-04-03 13:28:38 +08:00
|
|
|
struct nfs4_sessionid sessionid;
|
2009-04-03 13:27:55 +08:00
|
|
|
};
|
|
|
|
|
2011-10-20 17:51:39 +08:00
|
|
|
struct nfsd4_destroy_clientid {
|
|
|
|
clientid_t clientid;
|
|
|
|
};
|
|
|
|
|
2010-04-20 03:11:28 +08:00
|
|
|
struct nfsd4_reclaim_complete {
|
|
|
|
u32 rca_one_fs;
|
|
|
|
};
|
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 19:11:59 +08:00
|
|
|
struct nfsd4_deviceid {
|
|
|
|
u64 fsid_idx;
|
|
|
|
u32 generation;
|
|
|
|
u32 pad;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_layout_seg {
|
|
|
|
u32 iomode;
|
|
|
|
u64 offset;
|
|
|
|
u64 length;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_getdeviceinfo {
|
|
|
|
struct nfsd4_deviceid gd_devid; /* request */
|
|
|
|
u32 gd_layout_type; /* request */
|
|
|
|
u32 gd_maxcount; /* request */
|
|
|
|
u32 gd_notify_types;/* request - response */
|
|
|
|
void *gd_device; /* response */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_layoutget {
|
|
|
|
u64 lg_minlength; /* request */
|
|
|
|
u32 lg_signal; /* request */
|
|
|
|
u32 lg_layout_type; /* request */
|
|
|
|
u32 lg_maxcount; /* request */
|
|
|
|
stateid_t lg_sid; /* request/response */
|
|
|
|
struct nfsd4_layout_seg lg_seg; /* request/response */
|
|
|
|
void *lg_content; /* response */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_layoutcommit {
|
|
|
|
stateid_t lc_sid; /* request */
|
|
|
|
struct nfsd4_layout_seg lc_seg; /* request */
|
|
|
|
u32 lc_reclaim; /* request */
|
|
|
|
u32 lc_newoffset; /* request */
|
|
|
|
u64 lc_last_wr; /* request */
|
2019-06-06 02:17:42 +08:00
|
|
|
struct timespec64 lc_mtime; /* request */
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 19:11:59 +08:00
|
|
|
u32 lc_layout_type; /* request */
|
|
|
|
u32 lc_up_len; /* layout length */
|
|
|
|
void *lc_up_layout; /* decoded by callback */
|
|
|
|
u32 lc_size_chg; /* boolean for response */
|
|
|
|
u64 lc_newsize; /* response */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_layoutreturn {
|
|
|
|
u32 lr_return_type; /* request */
|
|
|
|
u32 lr_layout_type; /* request */
|
|
|
|
struct nfsd4_layout_seg lr_seg; /* request */
|
|
|
|
u32 lr_reclaim; /* request */
|
|
|
|
u32 lrf_body_len; /* request */
|
|
|
|
void *lrf_body; /* request */
|
|
|
|
stateid_t lr_sid; /* request/response */
|
|
|
|
u32 lrs_present; /* response */
|
|
|
|
};
|
|
|
|
|
2014-11-08 03:44:26 +08:00
|
|
|
struct nfsd4_fallocate {
|
|
|
|
/* request */
|
|
|
|
stateid_t falloc_stateid;
|
|
|
|
loff_t falloc_offset;
|
|
|
|
u64 falloc_length;
|
|
|
|
};
|
|
|
|
|
2015-12-03 19:59:52 +08:00
|
|
|
struct nfsd4_clone {
|
|
|
|
/* request */
|
|
|
|
stateid_t cl_src_stateid;
|
|
|
|
stateid_t cl_dst_stateid;
|
|
|
|
u64 cl_src_pos;
|
|
|
|
u64 cl_dst_pos;
|
|
|
|
u64 cl_count;
|
|
|
|
};
|
|
|
|
|
2016-09-08 03:57:30 +08:00
|
|
|
struct nfsd42_write_res {
|
|
|
|
u64 wr_bytes_written;
|
|
|
|
u32 wr_stable_how;
|
|
|
|
nfs4_verifier wr_verifier;
|
2018-07-21 06:19:17 +08:00
|
|
|
stateid_t cb_stateid;
|
2016-09-08 03:57:30 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_copy {
|
|
|
|
/* request */
|
2019-09-14 02:00:57 +08:00
|
|
|
stateid_t cp_src_stateid;
|
|
|
|
stateid_t cp_dst_stateid;
|
|
|
|
u64 cp_src_pos;
|
|
|
|
u64 cp_dst_pos;
|
|
|
|
u64 cp_count;
|
|
|
|
struct nl4_server cp_src;
|
|
|
|
bool cp_intra;
|
2016-09-08 03:57:30 +08:00
|
|
|
|
|
|
|
/* both */
|
|
|
|
bool cp_synchronous;
|
|
|
|
|
|
|
|
/* response */
|
|
|
|
struct nfsd42_write_res cp_res;
|
2018-07-21 06:19:17 +08:00
|
|
|
|
|
|
|
/* for cb_offload */
|
|
|
|
struct nfsd4_callback cp_cb;
|
|
|
|
__be32 nfserr;
|
|
|
|
struct knfsd_fh fh;
|
2018-07-21 06:19:20 +08:00
|
|
|
|
|
|
|
struct nfs4_client *cp_clp;
|
|
|
|
|
2019-08-19 02:18:54 +08:00
|
|
|
struct nfsd_file *nf_src;
|
|
|
|
struct nfsd_file *nf_dst;
|
2018-07-21 06:19:20 +08:00
|
|
|
|
2019-10-05 04:34:26 +08:00
|
|
|
copy_stateid_t cp_stateid;
|
2018-07-21 06:19:20 +08:00
|
|
|
|
|
|
|
struct list_head copies;
|
|
|
|
struct task_struct *copy_task;
|
|
|
|
refcount_t refcount;
|
|
|
|
bool stopped;
|
2019-10-09 23:50:48 +08:00
|
|
|
|
|
|
|
struct vfsmount *ss_mnt;
|
|
|
|
struct nfs_fh c_fh;
|
|
|
|
nfs4_stateid stateid;
|
2016-09-08 03:57:30 +08:00
|
|
|
};
|
2019-10-09 23:50:48 +08:00
|
|
|
extern bool inter_copy_offload_enable;
|
2016-09-08 03:57:30 +08:00
|
|
|
|
2014-09-27 01:58:27 +08:00
|
|
|
struct nfsd4_seek {
|
|
|
|
/* request */
|
|
|
|
stateid_t seek_stateid;
|
|
|
|
loff_t seek_offset;
|
|
|
|
u32 seek_whence;
|
|
|
|
|
|
|
|
/* response */
|
|
|
|
u32 seek_eof;
|
|
|
|
loff_t seek_pos;
|
|
|
|
};
|
|
|
|
|
2018-07-21 06:19:18 +08:00
|
|
|
struct nfsd4_offload_status {
|
|
|
|
/* request */
|
|
|
|
stateid_t stateid;
|
|
|
|
|
|
|
|
/* response */
|
|
|
|
u64 count;
|
|
|
|
u32 status;
|
|
|
|
};
|
|
|
|
|
2019-08-08 23:14:59 +08:00
|
|
|
struct nfsd4_copy_notify {
|
|
|
|
/* request */
|
|
|
|
stateid_t cpn_src_stateid;
|
|
|
|
struct nl4_server cpn_dst;
|
|
|
|
|
|
|
|
/* response */
|
|
|
|
stateid_t cpn_cnr_stateid;
|
|
|
|
u64 cpn_sec;
|
|
|
|
u32 cpn_nsec;
|
|
|
|
struct nl4_server cpn_src;
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct nfsd4_op {
|
|
|
|
int opnum;
|
2017-07-07 05:51:29 +08:00
|
|
|
const struct nfsd4_operation * opdesc;
|
2006-10-20 14:28:59 +08:00
|
|
|
__be32 status;
|
2017-05-09 02:03:15 +08:00
|
|
|
union nfsd4_op_u {
|
2005-04-17 06:20:36 +08:00
|
|
|
struct nfsd4_access access;
|
|
|
|
struct nfsd4_close close;
|
|
|
|
struct nfsd4_commit commit;
|
|
|
|
struct nfsd4_create create;
|
|
|
|
struct nfsd4_delegreturn delegreturn;
|
|
|
|
struct nfsd4_getattr getattr;
|
|
|
|
struct svc_fh * getfh;
|
|
|
|
struct nfsd4_link link;
|
|
|
|
struct nfsd4_lock lock;
|
|
|
|
struct nfsd4_lockt lockt;
|
|
|
|
struct nfsd4_locku locku;
|
|
|
|
struct nfsd4_lookup lookup;
|
|
|
|
struct nfsd4_verify nverify;
|
|
|
|
struct nfsd4_open open;
|
|
|
|
struct nfsd4_open_confirm open_confirm;
|
|
|
|
struct nfsd4_open_downgrade open_downgrade;
|
|
|
|
struct nfsd4_putfh putfh;
|
|
|
|
struct nfsd4_read read;
|
|
|
|
struct nfsd4_readdir readdir;
|
|
|
|
struct nfsd4_readlink readlink;
|
|
|
|
struct nfsd4_remove remove;
|
|
|
|
struct nfsd4_rename rename;
|
|
|
|
clientid_t renew;
|
2007-07-17 19:04:51 +08:00
|
|
|
struct nfsd4_secinfo secinfo;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct nfsd4_setattr setattr;
|
|
|
|
struct nfsd4_setclientid setclientid;
|
|
|
|
struct nfsd4_setclientid_confirm setclientid_confirm;
|
|
|
|
struct nfsd4_verify verify;
|
|
|
|
struct nfsd4_write write;
|
|
|
|
struct nfsd4_release_lockowner release_lockowner;
|
2009-04-03 13:27:55 +08:00
|
|
|
|
|
|
|
/* NFSv4.1 */
|
|
|
|
struct nfsd4_exchange_id exchange_id;
|
2012-11-02 06:09:48 +08:00
|
|
|
struct nfsd4_backchannel_ctl backchannel_ctl;
|
2010-10-05 11:12:59 +08:00
|
|
|
struct nfsd4_bind_conn_to_session bind_conn_to_session;
|
2009-04-03 13:27:55 +08:00
|
|
|
struct nfsd4_create_session create_session;
|
|
|
|
struct nfsd4_destroy_session destroy_session;
|
2017-05-09 02:58:35 +08:00
|
|
|
struct nfsd4_destroy_clientid destroy_clientid;
|
2009-04-03 13:27:55 +08:00
|
|
|
struct nfsd4_sequence sequence;
|
2010-04-20 03:11:28 +08:00
|
|
|
struct nfsd4_reclaim_complete reclaim_complete;
|
2011-07-13 22:50:48 +08:00
|
|
|
struct nfsd4_test_stateid test_stateid;
|
2011-07-13 23:04:21 +08:00
|
|
|
struct nfsd4_free_stateid free_stateid;
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 19:11:59 +08:00
|
|
|
struct nfsd4_getdeviceinfo getdeviceinfo;
|
|
|
|
struct nfsd4_layoutget layoutget;
|
|
|
|
struct nfsd4_layoutcommit layoutcommit;
|
|
|
|
struct nfsd4_layoutreturn layoutreturn;
|
2017-05-09 02:58:35 +08:00
|
|
|
struct nfsd4_secinfo_no_name secinfo_no_name;
|
2014-09-27 01:58:27 +08:00
|
|
|
|
|
|
|
/* NFSv4.2 */
|
2014-11-08 03:44:26 +08:00
|
|
|
struct nfsd4_fallocate allocate;
|
2014-11-08 03:44:27 +08:00
|
|
|
struct nfsd4_fallocate deallocate;
|
2015-12-03 19:59:52 +08:00
|
|
|
struct nfsd4_clone clone;
|
2016-09-08 03:57:30 +08:00
|
|
|
struct nfsd4_copy copy;
|
2018-07-21 06:19:18 +08:00
|
|
|
struct nfsd4_offload_status offload_status;
|
2019-08-08 23:14:59 +08:00
|
|
|
struct nfsd4_copy_notify copy_notify;
|
2014-09-27 01:58:27 +08:00
|
|
|
struct nfsd4_seek seek;
|
2005-04-17 06:20:36 +08:00
|
|
|
} u;
|
|
|
|
struct nfs4_replay * replay;
|
|
|
|
};
|
|
|
|
|
2011-01-25 01:11:02 +08:00
|
|
|
bool nfsd4_cache_this_op(struct nfsd4_op *);
|
|
|
|
|
2014-06-25 05:43:45 +08:00
|
|
|
/*
|
|
|
|
* Memory needed just for the duration of processing one compound:
|
|
|
|
*/
|
|
|
|
struct svcxdr_tmpbuf {
|
|
|
|
struct svcxdr_tmpbuf *next;
|
|
|
|
char buf[];
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct nfsd4_compoundargs {
|
|
|
|
/* scratch variables for XDR decode */
|
2006-10-20 14:28:58 +08:00
|
|
|
__be32 * p;
|
|
|
|
__be32 * end;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct page ** pagelist;
|
|
|
|
int pagelen;
|
2017-08-18 23:12:27 +08:00
|
|
|
bool tail;
|
2006-10-20 14:28:58 +08:00
|
|
|
__be32 tmp[8];
|
|
|
|
__be32 * tmpp;
|
2014-06-25 05:43:45 +08:00
|
|
|
struct svcxdr_tmpbuf *to_free;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct svc_rqst *rqstp;
|
|
|
|
|
|
|
|
u32 taglen;
|
|
|
|
char * tag;
|
|
|
|
u32 minorversion;
|
|
|
|
u32 opcnt;
|
|
|
|
struct nfsd4_op *ops;
|
|
|
|
struct nfsd4_op iops[8];
|
2011-01-25 01:11:02 +08:00
|
|
|
int cachetype;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_compoundres {
|
|
|
|
/* scratch variables for XDR encode */
|
2014-01-16 04:17:58 +08:00
|
|
|
struct xdr_stream xdr;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct svc_rqst * rqstp;
|
|
|
|
|
|
|
|
u32 taglen;
|
|
|
|
char * tag;
|
|
|
|
u32 opcnt;
|
2009-03-28 16:30:52 +08:00
|
|
|
__be32 * tagp; /* tag, opcount encode location */
|
|
|
|
struct nfsd4_compound_state cstate;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2009-04-03 13:28:35 +08:00
|
|
|
static inline bool nfsd4_is_solo_sequence(struct nfsd4_compoundres *resp)
|
|
|
|
{
|
|
|
|
struct nfsd4_compoundargs *args = resp->rqstp->rq_argp;
|
2009-08-28 00:07:40 +08:00
|
|
|
return resp->opcnt == 1 && args->ops[0].opnum == OP_SEQUENCE;
|
2009-04-03 13:28:35 +08:00
|
|
|
}
|
|
|
|
|
nfsd4: fix cached replies to solo SEQUENCE compounds
Currently our handling of 4.1+ requests without "cachethis" set is
confusing and not quite correct.
Suppose a client sends a compound consisting of only a single SEQUENCE
op, and it matches the seqid in a session slot (so it's a retry), but
the previous request with that seqid did not have "cachethis" set.
The obvious thing to do might be to return NFS4ERR_RETRY_UNCACHED_REP,
but the protocol only allows that to be returned on the op following the
SEQUENCE, and there is no such op in this case.
The protocol permits us to cache replies even if the client didn't ask
us to. And it's easy to do so in the case of solo SEQUENCE compounds.
So, when we get a solo SEQUENCE, we can either return the previously
cached reply or NFSERR_SEQ_FALSE_RETRY if we notice it differs in some
way from the original call.
Currently, we're returning a corrupt reply in the case a solo SEQUENCE
matches a previous compound with more ops. This actually matters
because the Linux client recently started doing this as a way to recover
from lost replies to idempotent operations in the case the process doing
the original reply was killed: in that case it's difficult to keep the
original arguments around to do a real retry, and the client no longer
cares what the result is anyway, but it would like to make sure that the
slot's sequence id has been incremented, and the solo SEQUENCE assures
that: if the server never got the original reply, it will increment the
sequence id. If it did get the original reply, it won't increment, and
nothing else that about the reply really matters much. But we can at
least attempt to return valid xdr!
Tested-by: Olga Kornievskaia <aglo@umich.edu>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2017-10-19 04:17:18 +08:00
|
|
|
/*
|
|
|
|
* The session reply cache only needs to cache replies that the client
|
|
|
|
* actually asked us to. But it's almost free for us to cache compounds
|
|
|
|
* consisting of only a SEQUENCE op, so we may as well cache those too.
|
|
|
|
* Also, the protocol doesn't give us a convenient response in the case
|
|
|
|
* of a replay of a solo SEQUENCE op that wasn't cached
|
|
|
|
* (RETRY_UNCACHED_REP can only be returned in the second op of a
|
|
|
|
* compound).
|
|
|
|
*/
|
|
|
|
static inline bool nfsd4_cache_this(struct nfsd4_compoundres *resp)
|
2009-04-03 13:28:35 +08:00
|
|
|
{
|
nfsd4: fix cached replies to solo SEQUENCE compounds
Currently our handling of 4.1+ requests without "cachethis" set is
confusing and not quite correct.
Suppose a client sends a compound consisting of only a single SEQUENCE
op, and it matches the seqid in a session slot (so it's a retry), but
the previous request with that seqid did not have "cachethis" set.
The obvious thing to do might be to return NFS4ERR_RETRY_UNCACHED_REP,
but the protocol only allows that to be returned on the op following the
SEQUENCE, and there is no such op in this case.
The protocol permits us to cache replies even if the client didn't ask
us to. And it's easy to do so in the case of solo SEQUENCE compounds.
So, when we get a solo SEQUENCE, we can either return the previously
cached reply or NFSERR_SEQ_FALSE_RETRY if we notice it differs in some
way from the original call.
Currently, we're returning a corrupt reply in the case a solo SEQUENCE
matches a previous compound with more ops. This actually matters
because the Linux client recently started doing this as a way to recover
from lost replies to idempotent operations in the case the process doing
the original reply was killed: in that case it's difficult to keep the
original arguments around to do a real retry, and the client no longer
cares what the result is anyway, but it would like to make sure that the
slot's sequence id has been incremented, and the solo SEQUENCE assures
that: if the server never got the original reply, it will increment the
sequence id. If it did get the original reply, it won't increment, and
nothing else that about the reply really matters much. But we can at
least attempt to return valid xdr!
Tested-by: Olga Kornievskaia <aglo@umich.edu>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2017-10-19 04:17:18 +08:00
|
|
|
return (resp->cstate.slot->sl_flags & NFSD4_SLOT_CACHETHIS)
|
2012-02-14 05:39:00 +08:00
|
|
|
|| nfsd4_is_solo_sequence(resp);
|
2009-04-03 13:28:35 +08:00
|
|
|
}
|
|
|
|
|
2012-12-05 07:03:46 +08:00
|
|
|
static inline bool nfsd4_last_compound_op(struct svc_rqst *rqstp)
|
|
|
|
{
|
|
|
|
struct nfsd4_compoundres *resp = rqstp->rq_resp;
|
|
|
|
struct nfsd4_compoundargs *argp = rqstp->rq_argp;
|
|
|
|
|
|
|
|
return argp->opcnt == resp->opcnt;
|
|
|
|
}
|
|
|
|
|
2017-07-07 05:51:29 +08:00
|
|
|
const struct nfsd4_operation *OPDESC(struct nfsd4_op *op);
|
2014-03-12 03:39:13 +08:00
|
|
|
int nfsd4_max_reply(struct svc_rqst *rqstp, struct nfsd4_op *op);
|
2014-03-07 09:39:29 +08:00
|
|
|
void warn_on_nonidempotent_op(struct nfsd4_op *op);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs)
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
|
|
|
|
{
|
2010-12-02 08:14:30 +08:00
|
|
|
BUG_ON(!fhp->fh_pre_saved);
|
2015-09-17 20:28:39 +08:00
|
|
|
cinfo->atomic = (u32)fhp->fh_post_saved;
|
2015-03-18 06:25:59 +08:00
|
|
|
cinfo->change_supported = IS_I_VERSION(d_inode(fhp->fh_dentry));
|
2010-12-02 08:14:30 +08:00
|
|
|
|
|
|
|
cinfo->before_change = fhp->fh_pre_change;
|
|
|
|
cinfo->after_change = fhp->fh_post_change;
|
|
|
|
cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
|
|
|
|
cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
|
|
|
|
cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec;
|
|
|
|
cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2016-06-16 00:52:08 +08:00
|
|
|
|
|
|
|
bool nfsd4_mach_creds_match(struct nfs4_client *cl, struct svc_rqst *rqstp);
|
2017-05-09 01:42:02 +08:00
|
|
|
int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *);
|
2017-05-09 01:01:48 +08:00
|
|
|
int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *);
|
2017-05-09 01:42:02 +08:00
|
|
|
int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *);
|
2012-04-26 05:58:50 +08:00
|
|
|
__be32 nfsd4_check_resp_size(struct nfsd4_compoundres *, u32);
|
2005-04-17 06:20:36 +08:00
|
|
|
void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
|
2014-01-31 06:18:38 +08:00
|
|
|
void nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op);
|
2013-08-27 04:04:46 +08:00
|
|
|
__be32 nfsd4_encode_fattr_to_buf(__be32 **p, int words,
|
|
|
|
struct svc_fh *fhp, struct svc_export *exp,
|
|
|
|
struct dentry *dentry,
|
|
|
|
u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
|
2006-10-20 14:28:59 +08:00
|
|
|
extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
|
2017-05-09 02:58:35 +08:00
|
|
|
struct nfsd4_compound_state *, union nfsd4_op_u *u);
|
2006-10-20 14:28:59 +08:00
|
|
|
extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
|
2017-05-09 02:58:35 +08:00
|
|
|
struct nfsd4_compound_state *, union nfsd4_op_u *u);
|
2009-04-03 13:27:58 +08:00
|
|
|
extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp,
|
2017-05-09 02:58:35 +08:00
|
|
|
struct nfsd4_compound_state *, union nfsd4_op_u *u);
|
|
|
|
extern __be32 nfsd4_backchannel_ctl(struct svc_rqst *,
|
|
|
|
struct nfsd4_compound_state *, union nfsd4_op_u *u);
|
|
|
|
extern __be32 nfsd4_bind_conn_to_session(struct svc_rqst *,
|
|
|
|
struct nfsd4_compound_state *, union nfsd4_op_u *u);
|
2010-04-20 03:12:51 +08:00
|
|
|
extern __be32 nfsd4_create_session(struct svc_rqst *,
|
2017-05-09 02:58:35 +08:00
|
|
|
struct nfsd4_compound_state *, union nfsd4_op_u *u);
|
2009-04-03 13:27:58 +08:00
|
|
|
extern __be32 nfsd4_sequence(struct svc_rqst *,
|
2017-05-09 02:58:35 +08:00
|
|
|
struct nfsd4_compound_state *, union nfsd4_op_u *u);
|
2014-06-30 23:48:35 +08:00
|
|
|
extern void nfsd4_sequence_done(struct nfsd4_compoundres *resp);
|
2009-04-03 13:27:58 +08:00
|
|
|
extern __be32 nfsd4_destroy_session(struct svc_rqst *,
|
2017-05-09 02:58:35 +08:00
|
|
|
struct nfsd4_compound_state *, union nfsd4_op_u *u);
|
|
|
|
extern __be32 nfsd4_destroy_clientid(struct svc_rqst *, struct nfsd4_compound_state *,
|
|
|
|
union nfsd4_op_u *u);
|
|
|
|
__be32 nfsd4_reclaim_complete(struct svc_rqst *, struct nfsd4_compound_state *,
|
|
|
|
union nfsd4_op_u *u);
|
2009-04-03 13:28:45 +08:00
|
|
|
extern __be32 nfsd4_process_open1(struct nfsd4_compound_state *,
|
2012-11-14 23:22:07 +08:00
|
|
|
struct nfsd4_open *open, struct nfsd_net *nn);
|
2006-10-20 14:28:59 +08:00
|
|
|
extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
|
2005-04-17 06:20:36 +08:00
|
|
|
struct svc_fh *current_fh, struct nfsd4_open *open);
|
2014-07-30 09:34:27 +08:00
|
|
|
extern void nfsd4_cstate_clear_replay(struct nfsd4_compound_state *cstate);
|
|
|
|
extern void nfsd4_cleanup_open_state(struct nfsd4_compound_state *cstate,
|
2015-03-23 22:53:44 +08:00
|
|
|
struct nfsd4_open *open);
|
2006-10-20 14:28:59 +08:00
|
|
|
extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,
|
2017-05-09 02:58:35 +08:00
|
|
|
struct nfsd4_compound_state *, union nfsd4_op_u *u);
|
|
|
|
extern __be32 nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
|
|
|
|
union nfsd4_op_u *u);
|
2006-10-20 14:28:59 +08:00
|
|
|
extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp,
|
2017-05-09 02:58:35 +08:00
|
|
|
struct nfsd4_compound_state *, union nfsd4_op_u *u);
|
2006-12-13 16:35:27 +08:00
|
|
|
extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
|
2017-05-09 02:58:35 +08:00
|
|
|
union nfsd4_op_u *u);
|
|
|
|
extern __be32 nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
|
|
|
|
union nfsd4_op_u *u);
|
|
|
|
extern __be32 nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
|
|
|
|
union nfsd4_op_u *u);
|
2006-10-20 14:28:59 +08:00
|
|
|
extern __be32
|
2005-04-17 06:20:36 +08:00
|
|
|
nfsd4_release_lockowner(struct svc_rqst *rqstp,
|
2017-05-09 02:58:35 +08:00
|
|
|
struct nfsd4_compound_state *, union nfsd4_op_u *u);
|
2017-05-09 00:48:24 +08:00
|
|
|
extern void nfsd4_release_compoundargs(struct svc_rqst *rqstp);
|
2006-10-20 14:28:59 +08:00
|
|
|
extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp,
|
2017-05-09 02:58:35 +08:00
|
|
|
struct nfsd4_compound_state *, union nfsd4_op_u *u);
|
|
|
|
extern __be32 nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
|
|
|
|
union nfsd4_op_u *u);
|
2011-07-13 22:50:48 +08:00
|
|
|
extern __be32 nfsd4_test_stateid(struct svc_rqst *rqstp,
|
2017-05-09 02:58:35 +08:00
|
|
|
struct nfsd4_compound_state *, union nfsd4_op_u *);
|
2011-07-13 23:04:21 +08:00
|
|
|
extern __be32 nfsd4_free_stateid(struct svc_rqst *rqstp,
|
2017-05-09 02:58:35 +08:00
|
|
|
struct nfsd4_compound_state *, union nfsd4_op_u *);
|
2013-04-02 04:37:12 +08:00
|
|
|
extern void nfsd4_bump_seqid(struct nfsd4_compound_state *, __be32 nfserr);
|
2014-07-30 09:34:27 +08:00
|
|
|
|
2017-05-06 22:38:39 +08:00
|
|
|
enum nfsd4_op_flags {
|
|
|
|
ALLOWED_WITHOUT_FH = 1 << 0, /* No current filehandle required */
|
|
|
|
ALLOWED_ON_ABSENT_FS = 1 << 1, /* ops processed on absent fs */
|
|
|
|
ALLOWED_AS_FIRST_OP = 1 << 2, /* ops reqired first in compound */
|
|
|
|
/* For rfc 5661 section 2.6.3.1.1: */
|
|
|
|
OP_HANDLES_WRONGSEC = 1 << 3,
|
|
|
|
OP_IS_PUTFH_LIKE = 1 << 4,
|
|
|
|
/*
|
|
|
|
* These are the ops whose result size we estimate before
|
|
|
|
* encoding, to avoid performing an op then not being able to
|
|
|
|
* respond or cache a response. This includes writes and setattrs
|
|
|
|
* as well as the operations usually called "nonidempotent":
|
|
|
|
*/
|
|
|
|
OP_MODIFIES_SOMETHING = 1 << 5,
|
|
|
|
/*
|
|
|
|
* Cache compounds containing these ops in the xid-based drc:
|
|
|
|
* We use the DRC for compounds containing non-idempotent
|
|
|
|
* operations, *except* those that are 4.1-specific (since
|
|
|
|
* sessions provide their own EOS), and except for stateful
|
|
|
|
* operations other than setclientid and setclientid_confirm
|
|
|
|
* (since sequence numbers provide EOS for open, lock, etc in
|
|
|
|
* the v4.0 case).
|
|
|
|
*/
|
|
|
|
OP_CACHEME = 1 << 6,
|
|
|
|
/*
|
|
|
|
* These are ops which clear current state id.
|
|
|
|
*/
|
|
|
|
OP_CLEAR_STATEID = 1 << 7,
|
2017-05-06 22:49:21 +08:00
|
|
|
/* Most ops return only an error on failure; some may do more: */
|
|
|
|
OP_NONTRIVIAL_ERROR_ENCODE = 1 << 8,
|
2017-05-06 22:38:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nfsd4_operation {
|
|
|
|
__be32 (*op_func)(struct svc_rqst *, struct nfsd4_compound_state *,
|
|
|
|
union nfsd4_op_u *);
|
2017-05-06 05:09:37 +08:00
|
|
|
void (*op_release)(union nfsd4_op_u *);
|
2017-05-06 22:38:39 +08:00
|
|
|
u32 op_flags;
|
|
|
|
char *op_name;
|
|
|
|
/* Try to get response size before operation */
|
|
|
|
u32 (*op_rsize_bop)(struct svc_rqst *, struct nfsd4_op *);
|
|
|
|
void (*op_get_currentstateid)(struct nfsd4_compound_state *,
|
|
|
|
union nfsd4_op_u *);
|
|
|
|
void (*op_set_currentstateid)(struct nfsd4_compound_state *,
|
|
|
|
union nfsd4_op_u *);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|