[PATCH 18/23] NFS: struct nfs_open_dir_context: convert rpc_cred pointer to cred.

2018-12-02 Thread NeilBrown
Use the common 'struct cred' to pass credentials for readdir.

Signed-off-by: NeilBrown 
---
 fs/nfs/dir.c|   15 +--
 fs/nfs/nfs3proc.c   |   11 +--
 fs/nfs/nfs4proc.c   |   13 ++---
 fs/nfs/proc.c   |   11 +--
 include/linux/nfs_fs.h  |2 +-
 include/linux/nfs_xdr.h |2 +-
 6 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 4dc61b6f74e8..6bf4471850c8 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -67,7 +67,7 @@ const struct address_space_operations nfs_dir_aops = {
.freepage = nfs_readdir_clear_array,
 };
 
-static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode 
*dir, struct rpc_cred *cred)
+static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode 
*dir, const struct cred *cred)
 {
struct nfs_inode *nfsi = NFS_I(dir);
struct nfs_open_dir_context *ctx;
@@ -77,7 +77,7 @@ static struct nfs_open_dir_context 
*alloc_nfs_open_dir_context(struct inode *dir
ctx->attr_gencount = nfsi->attr_gencount;
ctx->dir_cookie = 0;
ctx->dup_cookie = 0;
-   ctx->cred = get_rpccred(cred);
+   ctx->cred = get_cred(cred);
spin_lock(>i_lock);
list_add(>list, >open_files);
spin_unlock(>i_lock);
@@ -91,7 +91,7 @@ static void put_nfs_open_dir_context(struct inode *dir, 
struct nfs_open_dir_cont
spin_lock(>i_lock);
list_del(>list);
spin_unlock(>i_lock);
-   put_rpccred(ctx->cred);
+   put_cred(ctx->cred);
kfree(ctx);
 }
 
@@ -103,23 +103,18 @@ nfs_opendir(struct inode *inode, struct file *filp)
 {
int res = 0;
struct nfs_open_dir_context *ctx;
-   struct rpc_cred *cred;
 
dfprintk(FILE, "NFS: open dir(%pD2)\n", filp);
 
nfs_inc_stats(inode, NFSIOS_VFSOPEN);
 
-   cred = rpc_lookup_cred();
-   if (IS_ERR(cred))
-   return PTR_ERR(cred);
-   ctx = alloc_nfs_open_dir_context(inode, cred);
+   ctx = alloc_nfs_open_dir_context(inode, current_cred());
if (IS_ERR(ctx)) {
res = PTR_ERR(ctx);
goto out;
}
filp->private_data = ctx;
 out:
-   put_rpccred(cred);
return res;
 }
 
@@ -334,7 +329,7 @@ int nfs_readdir_xdr_filler(struct page **pages, 
nfs_readdir_descriptor_t *desc,
struct nfs_entry *entry, struct file *file, struct 
inode *inode)
 {
struct nfs_open_dir_context *ctx = file->private_data;
-   struct rpc_cred *cred = ctx->cred;
+   const struct cred *cred = ctx->cred;
unsigned long   timestamp, gencount;
int error;
 
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index f7174f3a9575..a2e9e09c3772 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -614,7 +614,7 @@ nfs3_proc_rmdir(struct inode *dir, const struct qstr *name)
  * readdirplus.
  */
 static int
-nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
+nfs3_proc_readdir(struct dentry *dentry, const struct cred *cred,
  u64 cookie, struct page **pages, unsigned int count, bool 
plus)
 {
struct inode*dir = d_inode(dentry);
@@ -631,11 +631,15 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred 
*cred,
.verf   = verf,
.plus   = plus
};
+   struct auth_cred acred = {
+   .cred   = cred,
+   };
struct rpc_message  msg = {
.rpc_proc   = _procedures[NFS3PROC_READDIR],
.rpc_argp   = ,
.rpc_resp   = ,
-   .rpc_cred   = cred
+   .rpc_cred   = rpc_lookup_generic_cred(,
+ 0, GFP_NOFS),
};
int status = -ENOMEM;
 
@@ -645,6 +649,8 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred 
*cred,
dprintk("NFS call  readdir%s %d\n",
plus? "plus" : "", (unsigned int) cookie);
 
+   if (!msg.rpc_cred)
+   return -ENOMEM;
res.dir_attr = nfs_alloc_fattr();
if (res.dir_attr == NULL)
goto out;
@@ -656,6 +662,7 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred 
*cred,
 
nfs_free_fattr(res.dir_attr);
 out:
+   put_rpccred(msg.rpc_cred);
dprintk("NFS reply readdir%s: %d\n",
plus? "plus" : "", status);
return status;
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index bf97331c02d3..80cedb007c3c 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -4699,7 +4699,7 @@ static int nfs4_proc_mkdir(struct inode *dir, struct 
dentry *dentry,
return err;
 }
 
-static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
+static int _nfs4_proc_readdir(struct dentry *dentry, const struct 

[PATCH 18/23] NFS: struct nfs_open_dir_context: convert rpc_cred pointer to cred.

2018-12-02 Thread NeilBrown
Use the common 'struct cred' to pass credentials for readdir.

Signed-off-by: NeilBrown 
---
 fs/nfs/dir.c|   15 +--
 fs/nfs/nfs3proc.c   |   11 +--
 fs/nfs/nfs4proc.c   |   13 ++---
 fs/nfs/proc.c   |   11 +--
 include/linux/nfs_fs.h  |2 +-
 include/linux/nfs_xdr.h |2 +-
 6 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 4dc61b6f74e8..6bf4471850c8 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -67,7 +67,7 @@ const struct address_space_operations nfs_dir_aops = {
.freepage = nfs_readdir_clear_array,
 };
 
-static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode 
*dir, struct rpc_cred *cred)
+static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode 
*dir, const struct cred *cred)
 {
struct nfs_inode *nfsi = NFS_I(dir);
struct nfs_open_dir_context *ctx;
@@ -77,7 +77,7 @@ static struct nfs_open_dir_context 
*alloc_nfs_open_dir_context(struct inode *dir
ctx->attr_gencount = nfsi->attr_gencount;
ctx->dir_cookie = 0;
ctx->dup_cookie = 0;
-   ctx->cred = get_rpccred(cred);
+   ctx->cred = get_cred(cred);
spin_lock(>i_lock);
list_add(>list, >open_files);
spin_unlock(>i_lock);
@@ -91,7 +91,7 @@ static void put_nfs_open_dir_context(struct inode *dir, 
struct nfs_open_dir_cont
spin_lock(>i_lock);
list_del(>list);
spin_unlock(>i_lock);
-   put_rpccred(ctx->cred);
+   put_cred(ctx->cred);
kfree(ctx);
 }
 
@@ -103,23 +103,18 @@ nfs_opendir(struct inode *inode, struct file *filp)
 {
int res = 0;
struct nfs_open_dir_context *ctx;
-   struct rpc_cred *cred;
 
dfprintk(FILE, "NFS: open dir(%pD2)\n", filp);
 
nfs_inc_stats(inode, NFSIOS_VFSOPEN);
 
-   cred = rpc_lookup_cred();
-   if (IS_ERR(cred))
-   return PTR_ERR(cred);
-   ctx = alloc_nfs_open_dir_context(inode, cred);
+   ctx = alloc_nfs_open_dir_context(inode, current_cred());
if (IS_ERR(ctx)) {
res = PTR_ERR(ctx);
goto out;
}
filp->private_data = ctx;
 out:
-   put_rpccred(cred);
return res;
 }
 
@@ -334,7 +329,7 @@ int nfs_readdir_xdr_filler(struct page **pages, 
nfs_readdir_descriptor_t *desc,
struct nfs_entry *entry, struct file *file, struct 
inode *inode)
 {
struct nfs_open_dir_context *ctx = file->private_data;
-   struct rpc_cred *cred = ctx->cred;
+   const struct cred *cred = ctx->cred;
unsigned long   timestamp, gencount;
int error;
 
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index f7174f3a9575..a2e9e09c3772 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -614,7 +614,7 @@ nfs3_proc_rmdir(struct inode *dir, const struct qstr *name)
  * readdirplus.
  */
 static int
-nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
+nfs3_proc_readdir(struct dentry *dentry, const struct cred *cred,
  u64 cookie, struct page **pages, unsigned int count, bool 
plus)
 {
struct inode*dir = d_inode(dentry);
@@ -631,11 +631,15 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred 
*cred,
.verf   = verf,
.plus   = plus
};
+   struct auth_cred acred = {
+   .cred   = cred,
+   };
struct rpc_message  msg = {
.rpc_proc   = _procedures[NFS3PROC_READDIR],
.rpc_argp   = ,
.rpc_resp   = ,
-   .rpc_cred   = cred
+   .rpc_cred   = rpc_lookup_generic_cred(,
+ 0, GFP_NOFS),
};
int status = -ENOMEM;
 
@@ -645,6 +649,8 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred 
*cred,
dprintk("NFS call  readdir%s %d\n",
plus? "plus" : "", (unsigned int) cookie);
 
+   if (!msg.rpc_cred)
+   return -ENOMEM;
res.dir_attr = nfs_alloc_fattr();
if (res.dir_attr == NULL)
goto out;
@@ -656,6 +662,7 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred 
*cred,
 
nfs_free_fattr(res.dir_attr);
 out:
+   put_rpccred(msg.rpc_cred);
dprintk("NFS reply readdir%s: %d\n",
plus? "plus" : "", status);
return status;
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index bf97331c02d3..80cedb007c3c 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -4699,7 +4699,7 @@ static int nfs4_proc_mkdir(struct inode *dir, struct 
dentry *dentry,
return err;
 }
 
-static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
+static int _nfs4_proc_readdir(struct dentry *dentry, const struct 

[PATCH 18/23] NFS: struct nfs_open_dir_context: convert rpc_cred pointer to cred.

2018-11-06 Thread NeilBrown
Use the common 'struct cred' to pass credentials for readdir.

Signed-off-by: NeilBrown 
---
 fs/nfs/dir.c|   15 +--
 fs/nfs/nfs3proc.c   |   11 +--
 fs/nfs/nfs4proc.c   |   13 ++---
 fs/nfs/proc.c   |   11 +--
 include/linux/nfs_fs.h  |2 +-
 include/linux/nfs_xdr.h |2 +-
 6 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 4dc61b6f74e8..6bf4471850c8 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -67,7 +67,7 @@ const struct address_space_operations nfs_dir_aops = {
.freepage = nfs_readdir_clear_array,
 };
 
-static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode 
*dir, struct rpc_cred *cred)
+static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode 
*dir, const struct cred *cred)
 {
struct nfs_inode *nfsi = NFS_I(dir);
struct nfs_open_dir_context *ctx;
@@ -77,7 +77,7 @@ static struct nfs_open_dir_context 
*alloc_nfs_open_dir_context(struct inode *dir
ctx->attr_gencount = nfsi->attr_gencount;
ctx->dir_cookie = 0;
ctx->dup_cookie = 0;
-   ctx->cred = get_rpccred(cred);
+   ctx->cred = get_cred(cred);
spin_lock(>i_lock);
list_add(>list, >open_files);
spin_unlock(>i_lock);
@@ -91,7 +91,7 @@ static void put_nfs_open_dir_context(struct inode *dir, 
struct nfs_open_dir_cont
spin_lock(>i_lock);
list_del(>list);
spin_unlock(>i_lock);
-   put_rpccred(ctx->cred);
+   put_cred(ctx->cred);
kfree(ctx);
 }
 
@@ -103,23 +103,18 @@ nfs_opendir(struct inode *inode, struct file *filp)
 {
int res = 0;
struct nfs_open_dir_context *ctx;
-   struct rpc_cred *cred;
 
dfprintk(FILE, "NFS: open dir(%pD2)\n", filp);
 
nfs_inc_stats(inode, NFSIOS_VFSOPEN);
 
-   cred = rpc_lookup_cred();
-   if (IS_ERR(cred))
-   return PTR_ERR(cred);
-   ctx = alloc_nfs_open_dir_context(inode, cred);
+   ctx = alloc_nfs_open_dir_context(inode, current_cred());
if (IS_ERR(ctx)) {
res = PTR_ERR(ctx);
goto out;
}
filp->private_data = ctx;
 out:
-   put_rpccred(cred);
return res;
 }
 
@@ -334,7 +329,7 @@ int nfs_readdir_xdr_filler(struct page **pages, 
nfs_readdir_descriptor_t *desc,
struct nfs_entry *entry, struct file *file, struct 
inode *inode)
 {
struct nfs_open_dir_context *ctx = file->private_data;
-   struct rpc_cred *cred = ctx->cred;
+   const struct cred *cred = ctx->cred;
unsigned long   timestamp, gencount;
int error;
 
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index f7174f3a9575..a2e9e09c3772 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -614,7 +614,7 @@ nfs3_proc_rmdir(struct inode *dir, const struct qstr *name)
  * readdirplus.
  */
 static int
-nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
+nfs3_proc_readdir(struct dentry *dentry, const struct cred *cred,
  u64 cookie, struct page **pages, unsigned int count, bool 
plus)
 {
struct inode*dir = d_inode(dentry);
@@ -631,11 +631,15 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred 
*cred,
.verf   = verf,
.plus   = plus
};
+   struct auth_cred acred = {
+   .cred   = cred,
+   };
struct rpc_message  msg = {
.rpc_proc   = _procedures[NFS3PROC_READDIR],
.rpc_argp   = ,
.rpc_resp   = ,
-   .rpc_cred   = cred
+   .rpc_cred   = rpc_lookup_generic_cred(,
+ 0, GFP_NOFS),
};
int status = -ENOMEM;
 
@@ -645,6 +649,8 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred 
*cred,
dprintk("NFS call  readdir%s %d\n",
plus? "plus" : "", (unsigned int) cookie);
 
+   if (!msg.rpc_cred)
+   return -ENOMEM;
res.dir_attr = nfs_alloc_fattr();
if (res.dir_attr == NULL)
goto out;
@@ -656,6 +662,7 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred 
*cred,
 
nfs_free_fattr(res.dir_attr);
 out:
+   put_rpccred(msg.rpc_cred);
dprintk("NFS reply readdir%s: %d\n",
plus? "plus" : "", status);
return status;
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index bf97331c02d3..80cedb007c3c 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -4699,7 +4699,7 @@ static int nfs4_proc_mkdir(struct inode *dir, struct 
dentry *dentry,
return err;
 }
 
-static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
+static int _nfs4_proc_readdir(struct dentry *dentry, const struct 

[PATCH 18/23] NFS: struct nfs_open_dir_context: convert rpc_cred pointer to cred.

2018-11-06 Thread NeilBrown
Use the common 'struct cred' to pass credentials for readdir.

Signed-off-by: NeilBrown 
---
 fs/nfs/dir.c|   15 +--
 fs/nfs/nfs3proc.c   |   11 +--
 fs/nfs/nfs4proc.c   |   13 ++---
 fs/nfs/proc.c   |   11 +--
 include/linux/nfs_fs.h  |2 +-
 include/linux/nfs_xdr.h |2 +-
 6 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 4dc61b6f74e8..6bf4471850c8 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -67,7 +67,7 @@ const struct address_space_operations nfs_dir_aops = {
.freepage = nfs_readdir_clear_array,
 };
 
-static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode 
*dir, struct rpc_cred *cred)
+static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode 
*dir, const struct cred *cred)
 {
struct nfs_inode *nfsi = NFS_I(dir);
struct nfs_open_dir_context *ctx;
@@ -77,7 +77,7 @@ static struct nfs_open_dir_context 
*alloc_nfs_open_dir_context(struct inode *dir
ctx->attr_gencount = nfsi->attr_gencount;
ctx->dir_cookie = 0;
ctx->dup_cookie = 0;
-   ctx->cred = get_rpccred(cred);
+   ctx->cred = get_cred(cred);
spin_lock(>i_lock);
list_add(>list, >open_files);
spin_unlock(>i_lock);
@@ -91,7 +91,7 @@ static void put_nfs_open_dir_context(struct inode *dir, 
struct nfs_open_dir_cont
spin_lock(>i_lock);
list_del(>list);
spin_unlock(>i_lock);
-   put_rpccred(ctx->cred);
+   put_cred(ctx->cred);
kfree(ctx);
 }
 
@@ -103,23 +103,18 @@ nfs_opendir(struct inode *inode, struct file *filp)
 {
int res = 0;
struct nfs_open_dir_context *ctx;
-   struct rpc_cred *cred;
 
dfprintk(FILE, "NFS: open dir(%pD2)\n", filp);
 
nfs_inc_stats(inode, NFSIOS_VFSOPEN);
 
-   cred = rpc_lookup_cred();
-   if (IS_ERR(cred))
-   return PTR_ERR(cred);
-   ctx = alloc_nfs_open_dir_context(inode, cred);
+   ctx = alloc_nfs_open_dir_context(inode, current_cred());
if (IS_ERR(ctx)) {
res = PTR_ERR(ctx);
goto out;
}
filp->private_data = ctx;
 out:
-   put_rpccred(cred);
return res;
 }
 
@@ -334,7 +329,7 @@ int nfs_readdir_xdr_filler(struct page **pages, 
nfs_readdir_descriptor_t *desc,
struct nfs_entry *entry, struct file *file, struct 
inode *inode)
 {
struct nfs_open_dir_context *ctx = file->private_data;
-   struct rpc_cred *cred = ctx->cred;
+   const struct cred *cred = ctx->cred;
unsigned long   timestamp, gencount;
int error;
 
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index f7174f3a9575..a2e9e09c3772 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -614,7 +614,7 @@ nfs3_proc_rmdir(struct inode *dir, const struct qstr *name)
  * readdirplus.
  */
 static int
-nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
+nfs3_proc_readdir(struct dentry *dentry, const struct cred *cred,
  u64 cookie, struct page **pages, unsigned int count, bool 
plus)
 {
struct inode*dir = d_inode(dentry);
@@ -631,11 +631,15 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred 
*cred,
.verf   = verf,
.plus   = plus
};
+   struct auth_cred acred = {
+   .cred   = cred,
+   };
struct rpc_message  msg = {
.rpc_proc   = _procedures[NFS3PROC_READDIR],
.rpc_argp   = ,
.rpc_resp   = ,
-   .rpc_cred   = cred
+   .rpc_cred   = rpc_lookup_generic_cred(,
+ 0, GFP_NOFS),
};
int status = -ENOMEM;
 
@@ -645,6 +649,8 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred 
*cred,
dprintk("NFS call  readdir%s %d\n",
plus? "plus" : "", (unsigned int) cookie);
 
+   if (!msg.rpc_cred)
+   return -ENOMEM;
res.dir_attr = nfs_alloc_fattr();
if (res.dir_attr == NULL)
goto out;
@@ -656,6 +662,7 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred 
*cred,
 
nfs_free_fattr(res.dir_attr);
 out:
+   put_rpccred(msg.rpc_cred);
dprintk("NFS reply readdir%s: %d\n",
plus? "plus" : "", status);
return status;
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index bf97331c02d3..80cedb007c3c 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -4699,7 +4699,7 @@ static int nfs4_proc_mkdir(struct inode *dir, struct 
dentry *dentry,
return err;
 }
 
-static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
+static int _nfs4_proc_readdir(struct dentry *dentry, const struct