Commit 7e193fd7 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] NFSv4 server - Read "share" state

From: "William A.(Andy) Adamson" <andros@citi.umich.edu>

this patch adds share state processing to nfsd4_read().
parent d6846e36
......@@ -346,14 +346,49 @@ nfsd4_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_loo
static inline int
nfsd4_read(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_read *read)
{
struct nfs4_stateid *stp;
int status;
/* no need to check permission - this will be done in nfsd_read() */
if (read->rd_offset >= OFFSET_MAX)
return nfserr_inval;
status = nfs_ok;
/* For stateid -1, we don't check share reservations. */
if (ONE_STATEID(&read->rd_stateid)) {
dprintk("NFSD: nfsd4_read: -1 stateid...\n");
goto out;
}
/*
* For stateid 0, the client doesn't have to have the file open, but
* we still check for share reservation conflicts.
*/
if (ZERO_STATEID(&read->rd_stateid)) {
dprintk("NFSD: nfsd4_read: zero stateid...\n");
if ((status = nfs4_share_conflict(current_fh, NFS4_SHARE_DENY_READ))) {
dprintk("NFSD: nfsd4_read: conflicting share reservation!\n");
goto out;
}
status = nfs_ok;
goto out;
}
/* check stateid */
if ((status = nfs4_preprocess_stateid_op(current_fh, &read->rd_stateid,
CHECK_FH, &stp))) {
dprintk("NFSD: nfsd4_read: couldn't process stateid!\n");
goto out;
}
status = nfserr_openmode;
if (!(stp->st_share_access & NFS4_SHARE_ACCESS_READ)) {
dprintk("NFSD: nfsd4_read: file not opened for read!\n");
goto out;
}
status = nfs_ok;
out:
read->rd_rqstp = rqstp;
read->rd_fhp = current_fh;
return nfs_ok;
return status;
}
static inline int
......
......@@ -100,7 +100,18 @@
NFSERR_RECLAIM_CONFLICT = 10035,/* v4 */
NFSERR_BAD_XDR = 10036, /* v4 */
NFSERR_LOCKS_HELD = 10037, /* v4 */
NFSERR_REPLAY_ME = 10038 /* v4 */
NFSERR_OPENMODE = 10038, /* v4 */
NFSERR_BADOWNER = 10039, /* v4 */
NFSERR_BADCHAR = 10040, /* v4 */
NFSERR_BADNAME = 10041, /* v4 */
NFSERR_BAD_RANGE = 10042, /* v4 */
NFSERR_LOCK_NOTSUPP = 10043, /* v4 */
NFSERR_OP_ILLEGAL = 10044, /* v4 */
NFSERR_DEADLOCK = 10045, /* v4 */
NFSERR_FILE_OPEN = 10046, /* v4 */
NFSERR_ADMIN_REVOKED = 10047, /* v4 */
NFSERR_CB_PATH_DOWN = 10048, /* v4 */
NFSERR_REPLAY_ME = 10049 /* v4 */
};
/* NFSv2 file types - beware, these are not the same in NFSv3 */
......
......@@ -35,6 +35,7 @@
#define NFS4_SHARE_ACCESS_READ 0x0001
#define NFS4_SHARE_ACCESS_WRITE 0x0002
#define NFS4_SHARE_ACCESS_BOTH 0x0003
#define NFS4_SHARE_DENY_READ 0x0001
#define NFS4_SET_TO_SERVER_TIME 0
#define NFS4_SET_TO_CLIENT_TIME 1
......
......@@ -189,6 +189,7 @@ void nfsd_lockd_shutdown(void);
#define nfserr_not_same __constant_htonl(NFSERR_NOT_SAME)
#define nfserr_readdir_nospc __constant_htonl(NFSERR_READDIR_NOSPC)
#define nfserr_bad_xdr __constant_htonl(NFSERR_BAD_XDR)
#define nfserr_openmode __constant_htonl(NFSERR_OPENMODE)
/* error codes for internal use */
/* if a request fails due to kmalloc failure, it gets dropped.
......
......@@ -59,6 +59,12 @@ typedef struct {
#define si_stateownerid si_opaque.so_stateownerid
#define si_fileid si_opaque.so_fileid
extern stateid_t zerostateid;
extern stateid_t onestateid;
#define ZERO_STATEID(stateid) (!memcmp((stateid), &zerostateid, sizeof(stateid_t)))
#define ONE_STATEID(stateid) (!memcmp((stateid), &onestateid, sizeof(stateid_t)))
/*
* struct nfs4_client - one per client. Clientids live here.
* o Each nfs4_client is hashed by clientid.
......@@ -83,13 +89,10 @@ struct nfs4_client {
nfs4_verifier cl_confirm; /* generated by server */
};
extern time_t nfs4_laundromat(void);
int nfsd4_renew(clientid_t *clid);
static inline void
update_stateid(stateid_t *stateid)
{
stateid->si_generation++;
stateid->si_generation++;
}
/*
......@@ -158,4 +161,10 @@ struct nfs4_stateid {
((err) != nfserr_stale_stateid) && \
((err) != nfserr_bad_stateid))
extern time_t nfs4_laundromat(void);
extern int nfsd4_renew(clientid_t *clid);
extern int nfs4_preprocess_stateid_op(struct svc_fh *current_fh,
stateid_t *stateid, int flags, struct nfs4_stateid **stpp);
extern int nfs4_share_conflict(struct svc_fh *current_fh,
unsigned int deny_type);
#endif /* NFSD4_STATE_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment