diff options
| author | Trond Myklebust <trond.myklebust@fys.uio.no> | 2003-04-08 04:23:03 +0200 |
|---|---|---|
| committer | Trond Myklebust <trond.myklebust@fys.uio.no> | 2003-04-08 04:23:03 +0200 |
| commit | ec059472a57fdabbac0d4e0e89a3b9547f88d62b (patch) | |
| tree | 80eae59fc9d87835b75741e3aa79e8ce4c3040eb | |
| parent | c0aaa9614d1d974e8cef7aafc82b894f1a145a07 (diff) | |
Prepare for the introduction of NFSv4 state code.
Split out the open() method for regular files from that of
directories.
| -rw-r--r-- | fs/nfs/dir.c | 23 | ||||
| -rw-r--r-- | fs/nfs/file.c | 27 | ||||
| -rw-r--r-- | fs/nfs/inode.c | 12 | ||||
| -rw-r--r-- | fs/nfs/nfs4proc.c | 11 | ||||
| -rw-r--r-- | include/linux/nfs_xdr.h | 1 |
5 files changed, 61 insertions, 13 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index cc35ed0b91e1..c9e533fca55e 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -35,6 +35,7 @@ #define NFS_PARANOIA 1 /* #define NFS_DEBUG_VERBOSE 1 */ +static int nfs_opendir(struct inode *, struct file *); static int nfs_readdir(struct file *, void *, filldir_t); static struct dentry *nfs_lookup(struct inode *, struct dentry *); static int nfs_cached_lookup(struct inode *, struct dentry *, @@ -52,7 +53,7 @@ static int nfs_rename(struct inode *, struct dentry *, struct file_operations nfs_dir_operations = { .read = generic_read_dir, .readdir = nfs_readdir, - .open = nfs_open, + .open = nfs_opendir, .release = nfs_release, }; @@ -71,6 +72,26 @@ struct inode_operations nfs_dir_inode_operations = { .setattr = nfs_setattr, }; +/* + * Open file + */ +static int +nfs_opendir(struct inode *inode, struct file *filp) +{ + struct nfs_server *server = NFS_SERVER(inode); + int res = 0; + + lock_kernel(); + /* Do cto revalidation */ + if (server->flags & NFS_MOUNT_NOCTO) + res = __nfs_revalidate_inode(server, inode); + /* Call generic open code in order to cache credentials */ + if (!res) + res = nfs_open(inode, filp); + unlock_kernel(); + return res; +} + typedef u32 * (*decode_dirent_t)(u32 *, struct nfs_entry *, int); typedef struct { struct file *file; diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 40746348c9d8..66ea5fdaa9d0 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -34,6 +34,7 @@ #define NFSDBG_FACILITY NFSDBG_FILE +static int nfs_file_open(struct inode *, struct file *); static int nfs_file_mmap(struct file *, struct vm_area_struct *); static ssize_t nfs_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *); static ssize_t nfs_file_read(struct kiocb *, char *, size_t, loff_t); @@ -48,7 +49,7 @@ struct file_operations nfs_file_operations = { .aio_read = nfs_file_read, .aio_write = nfs_file_write, .mmap = nfs_file_mmap, - .open = nfs_open, + .open = nfs_file_open, .flush = nfs_file_flush, .release = nfs_release, .fsync = nfs_fsync, @@ -68,6 +69,30 @@ struct inode_operations nfs_file_inode_operations = { #endif /* + * Open file + */ +static int +nfs_file_open(struct inode *inode, struct file *filp) +{ + struct nfs_server *server = NFS_SERVER(inode); + int (*open)(struct inode *, struct file *); + int res = 0; + + lock_kernel(); + /* Do NFSv4 open() call */ + if ((open = server->rpc_ops->file_open) != NULL) + res = open(inode, filp); + /* Do cto revalidation */ + else if (server->flags & NFS_MOUNT_NOCTO) + res = __nfs_revalidate_inode(server, inode); + /* Call generic open code in order to cache credentials */ + if (!res) + res = nfs_open(inode, filp); + unlock_kernel(); + return res; +} + +/* * Flush all dirty pages, and check for write errors. * */ diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 67ed9d1bc1b8..1c7b45be7358 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -855,23 +855,13 @@ int nfs_open(struct inode *inode, struct file *filp) { struct rpc_auth *auth; struct rpc_cred *cred; - int err = 0; - lock_kernel(); - /* Ensure that we revalidate the data cache */ - if (NFS_SERVER(inode)->flags & NFS_MOUNT_NOCTO) { - err = __nfs_revalidate_inode(NFS_SERVER(inode),inode); - if (err) - goto out; - } auth = NFS_CLIENT(inode)->cl_auth; cred = rpcauth_lookupcred(auth, 0); filp->private_data = cred; if (filp->f_mode & FMODE_WRITE) nfs_set_mmcred(inode, cred); -out: - unlock_kernel(); - return err; + return 0; } int nfs_release(struct inode *inode, struct file *filp) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 317a8bb269d9..ccbca9dace46 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1560,6 +1560,16 @@ nfs4_proc_renew(struct nfs_server *server) return rpc_execute(task); } +/* +* To be changed into a real NFSv4 file_open soon. +*/ + +int +nfs4_proc_file_open(struct inode *inode, struct file *filp) +{ + return 0; +} + struct nfs_rpc_ops nfs_v4_clientops = { .version = 4, /* protocol version */ .getroot = nfs4_proc_get_root, @@ -1589,6 +1599,7 @@ struct nfs_rpc_ops nfs_v4_clientops = { .read_setup = nfs4_proc_read_setup, .write_setup = nfs4_proc_write_setup, .commit_setup = nfs4_proc_commit_setup, + .file_open = nfs4_proc_file_open, }; /* diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 2b96e1e5aa97..980705c7307e 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -597,6 +597,7 @@ struct nfs_rpc_ops { void (*read_setup) (struct nfs_read_data *, unsigned int count); void (*write_setup) (struct nfs_write_data *, unsigned int count, int how); void (*commit_setup) (struct nfs_write_data *, u64 start, u32 len, int how); + int (*file_open) (struct inode *, struct file *); }; /* |
