]> git.hungrycats.org Git - linux/commitdiff
Prepare for the introduction of NFSv4 state code.
authorTrond Myklebust <trond.myklebust@fys.uio.no>
Tue, 8 Apr 2003 02:23:03 +0000 (04:23 +0200)
committerTrond Myklebust <trond.myklebust@fys.uio.no>
Tue, 8 Apr 2003 02:23:03 +0000 (04:23 +0200)
Split out the open() method for regular files from that of
directories.

fs/nfs/dir.c
fs/nfs/file.c
fs/nfs/inode.c
fs/nfs/nfs4proc.c
include/linux/nfs_xdr.h

index cc35ed0b91e178a7275f12730fd07dcda04c3106..c9e533fca55e9279f188fa2419a7661af766e64f 100644 (file)
@@ -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;
index 40746348c9d81f2262480878a19272862a6c75a8..66ea5fdaa9d00898e32ee6de5e492af257269a1f 100644 (file)
@@ -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,
@@ -67,6 +68,30 @@ struct inode_operations nfs_file_inode_operations = {
 # define IS_SWAPFILE(inode)    (0)
 #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.
  *
index 67ed9d1bc1b847b95eaf5f1d7b7fe2bf4ad9c6d3..1c7b45be7358065b6ec2e76ca9214fd7eba723f6 100644 (file)
@@ -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)
index 317a8bb269d97a7190cb5b8cebde658540f5ac75..ccbca9dace46274ee50d1244cbb1696d2ea52d1c 100644 (file)
@@ -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,
 };
 
 /*
index 2b96e1e5aa97bd734bddd7306678f3fed4075b5c..980705c7307e285d1cd9ef6764b65d882fe72a95 100644 (file)
@@ -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 *);
 };
 
 /*