Commit dc0b027d authored by Trond Myklebust's avatar Trond Myklebust

NFSv4: Convert the open and close ops to use fmode

Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 7a50c60e
...@@ -592,7 +592,7 @@ static void nfs_file_set_open_context(struct file *filp, struct nfs_open_context ...@@ -592,7 +592,7 @@ static void nfs_file_set_open_context(struct file *filp, struct nfs_open_context
/* /*
* Given an inode, search for an open context with the desired characteristics * Given an inode, search for an open context with the desired characteristics
*/ */
struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode) struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, fmode_t mode)
{ {
struct nfs_inode *nfsi = NFS_I(inode); struct nfs_inode *nfsi = NFS_I(inode);
struct nfs_open_context *pos, *ctx = NULL; struct nfs_open_context *pos, *ctx = NULL;
......
...@@ -161,7 +161,7 @@ struct nfs4_state { ...@@ -161,7 +161,7 @@ struct nfs4_state {
unsigned int n_rdonly; /* Number of read-only references */ unsigned int n_rdonly; /* Number of read-only references */
unsigned int n_wronly; /* Number of write-only references */ unsigned int n_wronly; /* Number of write-only references */
unsigned int n_rdwr; /* Number of read/write references */ unsigned int n_rdwr; /* Number of read/write references */
int state; /* State on the server (R,W, or RW) */ fmode_t state; /* State on the server (R,W, or RW) */
atomic_t count; atomic_t count;
}; };
...@@ -223,9 +223,9 @@ extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struc ...@@ -223,9 +223,9 @@ extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struc
extern void nfs4_put_state_owner(struct nfs4_state_owner *); extern void nfs4_put_state_owner(struct nfs4_state_owner *);
extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *); extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *);
extern void nfs4_put_open_state(struct nfs4_state *); extern void nfs4_put_open_state(struct nfs4_state *);
extern void nfs4_close_state(struct path *, struct nfs4_state *, mode_t); extern void nfs4_close_state(struct path *, struct nfs4_state *, fmode_t);
extern void nfs4_close_sync(struct path *, struct nfs4_state *, mode_t); extern void nfs4_close_sync(struct path *, struct nfs4_state *, fmode_t);
extern void nfs4_state_set_mode_locked(struct nfs4_state *, mode_t); extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t);
extern void nfs4_schedule_state_recovery(struct nfs_client *); extern void nfs4_schedule_state_recovery(struct nfs_client *);
extern void nfs4_schedule_state_manager(struct nfs_client *); extern void nfs4_schedule_state_manager(struct nfs_client *);
extern int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state); extern int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state);
......
This diff is collapsed.
...@@ -363,18 +363,18 @@ nfs4_alloc_open_state(void) ...@@ -363,18 +363,18 @@ nfs4_alloc_open_state(void)
} }
void void
nfs4_state_set_mode_locked(struct nfs4_state *state, mode_t mode) nfs4_state_set_mode_locked(struct nfs4_state *state, fmode_t fmode)
{ {
if (state->state == mode) if (state->state == fmode)
return; return;
/* NB! List reordering - see the reclaim code for why. */ /* NB! List reordering - see the reclaim code for why. */
if ((mode & FMODE_WRITE) != (state->state & FMODE_WRITE)) { if ((fmode & FMODE_WRITE) != (state->state & FMODE_WRITE)) {
if (mode & FMODE_WRITE) if (fmode & FMODE_WRITE)
list_move(&state->open_states, &state->owner->so_states); list_move(&state->open_states, &state->owner->so_states);
else else
list_move_tail(&state->open_states, &state->owner->so_states); list_move_tail(&state->open_states, &state->owner->so_states);
} }
state->state = mode; state->state = fmode;
} }
static struct nfs4_state * static struct nfs4_state *
...@@ -454,16 +454,16 @@ void nfs4_put_open_state(struct nfs4_state *state) ...@@ -454,16 +454,16 @@ void nfs4_put_open_state(struct nfs4_state *state)
/* /*
* Close the current file. * Close the current file.
*/ */
static void __nfs4_close(struct path *path, struct nfs4_state *state, mode_t mode, int wait) static void __nfs4_close(struct path *path, struct nfs4_state *state, fmode_t fmode, int wait)
{ {
struct nfs4_state_owner *owner = state->owner; struct nfs4_state_owner *owner = state->owner;
int call_close = 0; int call_close = 0;
int newstate; fmode_t newstate;
atomic_inc(&owner->so_count); atomic_inc(&owner->so_count);
/* Protect against nfs4_find_state() */ /* Protect against nfs4_find_state() */
spin_lock(&owner->so_lock); spin_lock(&owner->so_lock);
switch (mode & (FMODE_READ | FMODE_WRITE)) { switch (fmode & (FMODE_READ | FMODE_WRITE)) {
case FMODE_READ: case FMODE_READ:
state->n_rdonly--; state->n_rdonly--;
break; break;
...@@ -498,14 +498,14 @@ static void __nfs4_close(struct path *path, struct nfs4_state *state, mode_t mod ...@@ -498,14 +498,14 @@ static void __nfs4_close(struct path *path, struct nfs4_state *state, mode_t mod
nfs4_do_close(path, state, wait); nfs4_do_close(path, state, wait);
} }
void nfs4_close_state(struct path *path, struct nfs4_state *state, mode_t mode) void nfs4_close_state(struct path *path, struct nfs4_state *state, fmode_t fmode)
{ {
__nfs4_close(path, state, mode, 0); __nfs4_close(path, state, fmode, 0);
} }
void nfs4_close_sync(struct path *path, struct nfs4_state *state, mode_t mode) void nfs4_close_sync(struct path *path, struct nfs4_state *state, fmode_t fmode)
{ {
__nfs4_close(path, state, mode, 1); __nfs4_close(path, state, fmode, 1);
} }
/* /*
......
...@@ -953,12 +953,12 @@ static int encode_lookup(struct xdr_stream *xdr, const struct qstr *name) ...@@ -953,12 +953,12 @@ static int encode_lookup(struct xdr_stream *xdr, const struct qstr *name)
return 0; return 0;
} }
static void encode_share_access(struct xdr_stream *xdr, int open_flags) static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode)
{ {
__be32 *p; __be32 *p;
RESERVE_SPACE(8); RESERVE_SPACE(8);
switch (open_flags & (FMODE_READ|FMODE_WRITE)) { switch (fmode & (FMODE_READ|FMODE_WRITE)) {
case FMODE_READ: case FMODE_READ:
WRITE32(NFS4_SHARE_ACCESS_READ); WRITE32(NFS4_SHARE_ACCESS_READ);
break; break;
...@@ -969,7 +969,7 @@ static void encode_share_access(struct xdr_stream *xdr, int open_flags) ...@@ -969,7 +969,7 @@ static void encode_share_access(struct xdr_stream *xdr, int open_flags)
WRITE32(NFS4_SHARE_ACCESS_BOTH); WRITE32(NFS4_SHARE_ACCESS_BOTH);
break; break;
default: default:
BUG(); WRITE32(0);
} }
WRITE32(0); /* for linux, share_deny = 0 always */ WRITE32(0); /* for linux, share_deny = 0 always */
} }
...@@ -984,7 +984,7 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena ...@@ -984,7 +984,7 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena
RESERVE_SPACE(8); RESERVE_SPACE(8);
WRITE32(OP_OPEN); WRITE32(OP_OPEN);
WRITE32(arg->seqid->sequence->counter); WRITE32(arg->seqid->sequence->counter);
encode_share_access(xdr, arg->open_flags); encode_share_access(xdr, arg->fmode);
RESERVE_SPACE(28); RESERVE_SPACE(28);
WRITE64(arg->clientid); WRITE64(arg->clientid);
WRITE32(16); WRITE32(16);
...@@ -1112,7 +1112,7 @@ static int encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closea ...@@ -1112,7 +1112,7 @@ static int encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closea
WRITE32(OP_OPEN_DOWNGRADE); WRITE32(OP_OPEN_DOWNGRADE);
WRITEMEM(arg->stateid->data, NFS4_STATEID_SIZE); WRITEMEM(arg->stateid->data, NFS4_STATEID_SIZE);
WRITE32(arg->seqid->sequence->counter); WRITE32(arg->seqid->sequence->counter);
encode_share_access(xdr, arg->open_flags); encode_share_access(xdr, arg->fmode);
return 0; return 0;
} }
......
...@@ -83,7 +83,7 @@ struct nfs_open_context { ...@@ -83,7 +83,7 @@ struct nfs_open_context {
struct rpc_cred *cred; struct rpc_cred *cred;
struct nfs4_state *state; struct nfs4_state *state;
fl_owner_t lockowner; fl_owner_t lockowner;
int mode; fmode_t mode;
unsigned long flags; unsigned long flags;
#define NFS_CONTEXT_ERROR_WRITE (0) #define NFS_CONTEXT_ERROR_WRITE (0)
...@@ -342,7 +342,7 @@ extern int nfs_setattr(struct dentry *, struct iattr *); ...@@ -342,7 +342,7 @@ extern int nfs_setattr(struct dentry *, struct iattr *);
extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr); extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr);
extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx); extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
extern void put_nfs_open_context(struct nfs_open_context *ctx); extern void put_nfs_open_context(struct nfs_open_context *ctx);
extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode); extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, fmode_t mode);
extern u64 nfs_compat_user_ino64(u64 fileid); extern u64 nfs_compat_user_ino64(u64 fileid);
extern void nfs_fattr_init(struct nfs_fattr *fattr); extern void nfs_fattr_init(struct nfs_fattr *fattr);
......
...@@ -120,6 +120,7 @@ struct nfs_openargs { ...@@ -120,6 +120,7 @@ struct nfs_openargs {
const struct nfs_fh * fh; const struct nfs_fh * fh;
struct nfs_seqid * seqid; struct nfs_seqid * seqid;
int open_flags; int open_flags;
fmode_t fmode;
__u64 clientid; __u64 clientid;
__u64 id; __u64 id;
union { union {
...@@ -171,7 +172,7 @@ struct nfs_closeargs { ...@@ -171,7 +172,7 @@ struct nfs_closeargs {
struct nfs_fh * fh; struct nfs_fh * fh;
nfs4_stateid * stateid; nfs4_stateid * stateid;
struct nfs_seqid * seqid; struct nfs_seqid * seqid;
int open_flags; fmode_t fmode;
const u32 * bitmask; const u32 * bitmask;
}; };
......
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