Commit 40471856 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'nfs-for-2.6.39' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6

* 'nfs-for-2.6.39' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6: (28 commits)
  Cleanup XDR parsing for LAYOUTGET, GETDEVICEINFO
  NFSv4.1 convert layoutcommit sync to boolean
  NFSv4.1 pnfs_layoutcommit_inode fixes
  NFS: Determine initial mount security
  NFS: use secinfo when crossing mountpoints
  NFS: Add secinfo procedure
  NFS: lookup supports alternate client
  NFS: convert call_sync() to a function
  NFSv4.1 remove temp code that prevented ds commits
  NFSv4.1: layoutcommit
  NFSv4.1: filelayout driver specific code for COMMIT
  NFSv4.1: remove GETATTR from ds commits
  NFSv4.1: add generic layer hooks for pnfs COMMIT
  NFSv4.1: alloc and free commit_buckets
  NFSv4.1: shift filelayout_free_lseg
  NFSv4.1: pull out code from nfs_commit_release
  NFSv4.1: pull error handling out of nfs_commit_list
  NFSv4.1: add callback to nfs4_commit_done
  NFSv4.1: rearrange nfs_commit_rpcsetup
  NFSv4.1: don't send COMMIT to ds for data sync writes
  ...
parents ae005cbe 0acd2201
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
/* #define NFS_DEBUG_VERBOSE 1 */ /* #define NFS_DEBUG_VERBOSE 1 */
static int nfs_opendir(struct inode *, struct file *); static int nfs_opendir(struct inode *, struct file *);
static int nfs_closedir(struct inode *, struct file *);
static int nfs_readdir(struct file *, void *, filldir_t); static int nfs_readdir(struct file *, void *, filldir_t);
static struct dentry *nfs_lookup(struct inode *, struct dentry *, struct nameidata *); static struct dentry *nfs_lookup(struct inode *, struct dentry *, struct nameidata *);
static int nfs_create(struct inode *, struct dentry *, int, struct nameidata *); static int nfs_create(struct inode *, struct dentry *, int, struct nameidata *);
...@@ -64,7 +65,7 @@ const struct file_operations nfs_dir_operations = { ...@@ -64,7 +65,7 @@ const struct file_operations nfs_dir_operations = {
.read = generic_read_dir, .read = generic_read_dir,
.readdir = nfs_readdir, .readdir = nfs_readdir,
.open = nfs_opendir, .open = nfs_opendir,
.release = nfs_release, .release = nfs_closedir,
.fsync = nfs_fsync_dir, .fsync = nfs_fsync_dir,
}; };
...@@ -133,13 +134,35 @@ const struct inode_operations nfs4_dir_inode_operations = { ...@@ -133,13 +134,35 @@ const struct inode_operations nfs4_dir_inode_operations = {
#endif /* CONFIG_NFS_V4 */ #endif /* CONFIG_NFS_V4 */
static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct rpc_cred *cred)
{
struct nfs_open_dir_context *ctx;
ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
if (ctx != NULL) {
ctx->duped = 0;
ctx->dir_cookie = 0;
ctx->dup_cookie = 0;
ctx->cred = get_rpccred(cred);
} else
ctx = ERR_PTR(-ENOMEM);
return ctx;
}
static void put_nfs_open_dir_context(struct nfs_open_dir_context *ctx)
{
put_rpccred(ctx->cred);
kfree(ctx);
}
/* /*
* Open file * Open file
*/ */
static int static int
nfs_opendir(struct inode *inode, struct file *filp) nfs_opendir(struct inode *inode, struct file *filp)
{ {
int res; int res = 0;
struct nfs_open_dir_context *ctx;
struct rpc_cred *cred;
dfprintk(FILE, "NFS: open dir(%s/%s)\n", dfprintk(FILE, "NFS: open dir(%s/%s)\n",
filp->f_path.dentry->d_parent->d_name.name, filp->f_path.dentry->d_parent->d_name.name,
...@@ -147,8 +170,15 @@ nfs_opendir(struct inode *inode, struct file *filp) ...@@ -147,8 +170,15 @@ nfs_opendir(struct inode *inode, struct file *filp)
nfs_inc_stats(inode, NFSIOS_VFSOPEN); nfs_inc_stats(inode, NFSIOS_VFSOPEN);
/* Call generic open code in order to cache credentials */ cred = rpc_lookup_cred();
res = nfs_open(inode, filp); if (IS_ERR(cred))
return PTR_ERR(cred);
ctx = alloc_nfs_open_dir_context(cred);
if (IS_ERR(ctx)) {
res = PTR_ERR(ctx);
goto out;
}
filp->private_data = ctx;
if (filp->f_path.dentry == filp->f_path.mnt->mnt_root) { if (filp->f_path.dentry == filp->f_path.mnt->mnt_root) {
/* This is a mountpoint, so d_revalidate will never /* This is a mountpoint, so d_revalidate will never
* have been called, so we need to refresh the * have been called, so we need to refresh the
...@@ -156,9 +186,18 @@ nfs_opendir(struct inode *inode, struct file *filp) ...@@ -156,9 +186,18 @@ nfs_opendir(struct inode *inode, struct file *filp)
*/ */
__nfs_revalidate_inode(NFS_SERVER(inode), inode); __nfs_revalidate_inode(NFS_SERVER(inode), inode);
} }
out:
put_rpccred(cred);
return res; return res;
} }
static int
nfs_closedir(struct inode *inode, struct file *filp)
{
put_nfs_open_dir_context(filp->private_data);
return 0;
}
struct nfs_cache_array_entry { struct nfs_cache_array_entry {
u64 cookie; u64 cookie;
u64 ino; u64 ino;
...@@ -284,19 +323,20 @@ int nfs_readdir_search_for_pos(struct nfs_cache_array *array, nfs_readdir_descri ...@@ -284,19 +323,20 @@ int nfs_readdir_search_for_pos(struct nfs_cache_array *array, nfs_readdir_descri
{ {
loff_t diff = desc->file->f_pos - desc->current_index; loff_t diff = desc->file->f_pos - desc->current_index;
unsigned int index; unsigned int index;
struct nfs_open_dir_context *ctx = desc->file->private_data;
if (diff < 0) if (diff < 0)
goto out_eof; goto out_eof;
if (diff >= array->size) { if (diff >= array->size) {
if (array->eof_index >= 0) if (array->eof_index >= 0)
goto out_eof; goto out_eof;
desc->current_index += array->size;
return -EAGAIN; return -EAGAIN;
} }
index = (unsigned int)diff; index = (unsigned int)diff;
*desc->dir_cookie = array->array[index].cookie; *desc->dir_cookie = array->array[index].cookie;
desc->cache_entry_index = index; desc->cache_entry_index = index;
ctx->duped = 0;
return 0; return 0;
out_eof: out_eof:
desc->eof = 1; desc->eof = 1;
...@@ -307,10 +347,18 @@ static ...@@ -307,10 +347,18 @@ static
int nfs_readdir_search_for_cookie(struct nfs_cache_array *array, nfs_readdir_descriptor_t *desc) int nfs_readdir_search_for_cookie(struct nfs_cache_array *array, nfs_readdir_descriptor_t *desc)
{ {
int i; int i;
loff_t new_pos;
int status = -EAGAIN; int status = -EAGAIN;
struct nfs_open_dir_context *ctx = desc->file->private_data;
for (i = 0; i < array->size; i++) { for (i = 0; i < array->size; i++) {
if (array->array[i].cookie == *desc->dir_cookie) { if (array->array[i].cookie == *desc->dir_cookie) {
new_pos = desc->current_index + i;
if (new_pos < desc->file->f_pos) {
ctx->dup_cookie = *desc->dir_cookie;
ctx->duped = 1;
}
desc->file->f_pos = new_pos;
desc->cache_entry_index = i; desc->cache_entry_index = i;
return 0; return 0;
} }
...@@ -342,6 +390,7 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc) ...@@ -342,6 +390,7 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc)
if (status == -EAGAIN) { if (status == -EAGAIN) {
desc->last_cookie = array->last_cookie; desc->last_cookie = array->last_cookie;
desc->current_index += array->size;
desc->page_index++; desc->page_index++;
} }
nfs_readdir_release_array(desc->page); nfs_readdir_release_array(desc->page);
...@@ -354,7 +403,8 @@ static ...@@ -354,7 +403,8 @@ static
int nfs_readdir_xdr_filler(struct page **pages, nfs_readdir_descriptor_t *desc, 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_entry *entry, struct file *file, struct inode *inode)
{ {
struct rpc_cred *cred = nfs_file_cred(file); struct nfs_open_dir_context *ctx = file->private_data;
struct rpc_cred *cred = ctx->cred;
unsigned long timestamp, gencount; unsigned long timestamp, gencount;
int error; int error;
...@@ -693,6 +743,20 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent, ...@@ -693,6 +743,20 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
int i = 0; int i = 0;
int res = 0; int res = 0;
struct nfs_cache_array *array = NULL; struct nfs_cache_array *array = NULL;
struct nfs_open_dir_context *ctx = file->private_data;
if (ctx->duped != 0 && ctx->dup_cookie == *desc->dir_cookie) {
if (printk_ratelimit()) {
pr_notice("NFS: directory %s/%s contains a readdir loop. "
"Please contact your server vendor. "
"Offending cookie: %llu\n",
file->f_dentry->d_parent->d_name.name,
file->f_dentry->d_name.name,
*desc->dir_cookie);
}
res = -ELOOP;
goto out;
}
array = nfs_readdir_get_array(desc->page); array = nfs_readdir_get_array(desc->page);
if (IS_ERR(array)) { if (IS_ERR(array)) {
...@@ -785,6 +849,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -785,6 +849,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
nfs_readdir_descriptor_t my_desc, nfs_readdir_descriptor_t my_desc,
*desc = &my_desc; *desc = &my_desc;
struct nfs_open_dir_context *dir_ctx = filp->private_data;
int res; int res;
dfprintk(FILE, "NFS: readdir(%s/%s) starting at cookie %llu\n", dfprintk(FILE, "NFS: readdir(%s/%s) starting at cookie %llu\n",
...@@ -801,7 +866,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -801,7 +866,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
memset(desc, 0, sizeof(*desc)); memset(desc, 0, sizeof(*desc));
desc->file = filp; desc->file = filp;
desc->dir_cookie = &nfs_file_open_context(filp)->dir_cookie; desc->dir_cookie = &dir_ctx->dir_cookie;
desc->decode = NFS_PROTO(inode)->decode_dirent; desc->decode = NFS_PROTO(inode)->decode_dirent;
desc->plus = NFS_USE_READDIRPLUS(inode); desc->plus = NFS_USE_READDIRPLUS(inode);
...@@ -853,6 +918,7 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin) ...@@ -853,6 +918,7 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin)
{ {
struct dentry *dentry = filp->f_path.dentry; struct dentry *dentry = filp->f_path.dentry;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct nfs_open_dir_context *dir_ctx = filp->private_data;
dfprintk(FILE, "NFS: llseek dir(%s/%s, %lld, %d)\n", dfprintk(FILE, "NFS: llseek dir(%s/%s, %lld, %d)\n",
dentry->d_parent->d_name.name, dentry->d_parent->d_name.name,
...@@ -872,7 +938,8 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin) ...@@ -872,7 +938,8 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin)
} }
if (offset != filp->f_pos) { if (offset != filp->f_pos) {
filp->f_pos = offset; filp->f_pos = offset;
nfs_file_open_context(filp)->dir_cookie = 0; dir_ctx->dir_cookie = 0;
dir_ctx->duped = 0;
} }
out: out:
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
...@@ -1068,7 +1135,7 @@ static int nfs_lookup_revalidate(struct dentry *dentry, struct nameidata *nd) ...@@ -1068,7 +1135,7 @@ static int nfs_lookup_revalidate(struct dentry *dentry, struct nameidata *nd)
if (fhandle == NULL || fattr == NULL) if (fhandle == NULL || fattr == NULL)
goto out_error; goto out_error;
error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr); error = NFS_PROTO(dir)->lookup(NFS_SERVER(dir)->client, dir, &dentry->d_name, fhandle, fattr);
if (error) if (error)
goto out_bad; goto out_bad;
if (nfs_compare_fh(NFS_FH(inode), fhandle)) if (nfs_compare_fh(NFS_FH(inode), fhandle))
...@@ -1224,7 +1291,7 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru ...@@ -1224,7 +1291,7 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
parent = dentry->d_parent; parent = dentry->d_parent;
/* Protect against concurrent sillydeletes */ /* Protect against concurrent sillydeletes */
nfs_block_sillyrename(parent); nfs_block_sillyrename(parent);
error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr); error = NFS_PROTO(dir)->lookup(NFS_SERVER(dir)->client, dir, &dentry->d_name, fhandle, fattr);
if (error == -ENOENT) if (error == -ENOENT)
goto no_entry; goto no_entry;
if (error < 0) { if (error < 0) {
...@@ -1562,7 +1629,7 @@ int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle, ...@@ -1562,7 +1629,7 @@ int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
if (dentry->d_inode) if (dentry->d_inode)
goto out; goto out;
if (fhandle->size == 0) { if (fhandle->size == 0) {
error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr); error = NFS_PROTO(dir)->lookup(NFS_SERVER(dir)->client, dir, &dentry->d_name, fhandle, fattr);
if (error) if (error)
goto out_error; goto out_error;
} }
......
...@@ -326,6 +326,9 @@ nfs_file_fsync(struct file *file, int datasync) ...@@ -326,6 +326,9 @@ nfs_file_fsync(struct file *file, int datasync)
ret = xchg(&ctx->error, 0); ret = xchg(&ctx->error, 0);
if (!ret && status < 0) if (!ret && status < 0)
ret = status; ret = status;
if (!ret && !datasync)
/* application has asked for meta-data sync */
ret = pnfs_layoutcommit_inode(inode, true);
return ret; return ret;
} }
......
...@@ -222,6 +222,10 @@ struct dentry *nfs4_get_root(struct super_block *sb, struct nfs_fh *mntfh, ...@@ -222,6 +222,10 @@ struct dentry *nfs4_get_root(struct super_block *sb, struct nfs_fh *mntfh,
goto out; goto out;
} }
if (fattr->valid & NFS_ATTR_FATTR_FSID &&
!nfs_fsid_equal(&server->fsid, &fattr->fsid))
memcpy(&server->fsid, &fattr->fsid, sizeof(server->fsid));
inode = nfs_fhget(sb, mntfh, fattr); inode = nfs_fhget(sb, mntfh, fattr);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
dprintk("nfs_get_root: get root inode failed\n"); dprintk("nfs_get_root: get root inode failed\n");
......
...@@ -254,7 +254,9 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) ...@@ -254,7 +254,9 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
struct inode *inode = ERR_PTR(-ENOENT); struct inode *inode = ERR_PTR(-ENOENT);
unsigned long hash; unsigned long hash;
if ((fattr->valid & NFS_ATTR_FATTR_FILEID) == 0) nfs_attr_check_mountpoint(sb, fattr);
if ((fattr->valid & NFS_ATTR_FATTR_FILEID) == 0 && (fattr->valid & NFS_ATTR_FATTR_MOUNTPOINT) == 0)
goto out_no_inode; goto out_no_inode;
if ((fattr->valid & NFS_ATTR_FATTR_TYPE) == 0) if ((fattr->valid & NFS_ATTR_FATTR_TYPE) == 0)
goto out_no_inode; goto out_no_inode;
...@@ -298,8 +300,8 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) ...@@ -298,8 +300,8 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS)) if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS))
set_bit(NFS_INO_ADVISE_RDPLUS, &NFS_I(inode)->flags); set_bit(NFS_INO_ADVISE_RDPLUS, &NFS_I(inode)->flags);
/* Deal with crossing mountpoints */ /* Deal with crossing mountpoints */
if ((fattr->valid & NFS_ATTR_FATTR_FSID) if (fattr->valid & NFS_ATTR_FATTR_MOUNTPOINT ||
&& !nfs_fsid_equal(&NFS_SB(sb)->fsid, &fattr->fsid)) { fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) {
if (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) if (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL)
inode->i_op = &nfs_referral_inode_operations; inode->i_op = &nfs_referral_inode_operations;
else else
...@@ -639,7 +641,6 @@ struct nfs_open_context *alloc_nfs_open_context(struct path *path, struct rpc_cr ...@@ -639,7 +641,6 @@ struct nfs_open_context *alloc_nfs_open_context(struct path *path, struct rpc_cr
ctx->mode = f_mode; ctx->mode = f_mode;
ctx->flags = 0; ctx->flags = 0;
ctx->error = 0; ctx->error = 0;
ctx->dir_cookie = 0;
nfs_init_lock_context(&ctx->lock_context); nfs_init_lock_context(&ctx->lock_context);
ctx->lock_context.open_context = ctx; ctx->lock_context.open_context = ctx;
INIT_LIST_HEAD(&ctx->list); INIT_LIST_HEAD(&ctx->list);
...@@ -1471,6 +1472,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi) ...@@ -1471,6 +1472,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi)
nfsi->delegation_state = 0; nfsi->delegation_state = 0;
init_rwsem(&nfsi->rwsem); init_rwsem(&nfsi->rwsem);
nfsi->layout = NULL; nfsi->layout = NULL;
atomic_set(&nfsi->commits_outstanding, 0);
#endif #endif
} }
......
...@@ -39,6 +39,12 @@ static inline int nfs4_has_persistent_session(const struct nfs_client *clp) ...@@ -39,6 +39,12 @@ static inline int nfs4_has_persistent_session(const struct nfs_client *clp)
return 0; return 0;
} }
static inline void nfs_attr_check_mountpoint(struct super_block *parent, struct nfs_fattr *fattr)
{
if (!nfs_fsid_equal(&NFS_SB(parent)->fsid, &fattr->fsid))
fattr->valid |= NFS_ATTR_FATTR_MOUNTPOINT;
}
struct nfs_clone_mount { struct nfs_clone_mount {
const struct super_block *sb; const struct super_block *sb;
const struct dentry *dentry; const struct dentry *dentry;
...@@ -214,6 +220,7 @@ extern const u32 nfs41_maxwrite_overhead; ...@@ -214,6 +220,7 @@ extern const u32 nfs41_maxwrite_overhead;
/* nfs4proc.c */ /* nfs4proc.c */
#ifdef CONFIG_NFS_V4 #ifdef CONFIG_NFS_V4
extern struct rpc_procinfo nfs4_procedures[]; extern struct rpc_procinfo nfs4_procedures[];
void nfs_fixup_secinfo_attributes(struct nfs_fattr *, struct nfs_fh *);
#endif #endif
extern int nfs4_init_ds_session(struct nfs_client *clp); extern int nfs4_init_ds_session(struct nfs_client *clp);
...@@ -276,11 +283,25 @@ extern int nfs_initiate_read(struct nfs_read_data *data, struct rpc_clnt *clnt, ...@@ -276,11 +283,25 @@ extern int nfs_initiate_read(struct nfs_read_data *data, struct rpc_clnt *clnt,
extern void nfs_read_prepare(struct rpc_task *task, void *calldata); extern void nfs_read_prepare(struct rpc_task *task, void *calldata);
/* write.c */ /* write.c */
extern void nfs_commit_free(struct nfs_write_data *p);
extern int nfs_initiate_write(struct nfs_write_data *data, extern int nfs_initiate_write(struct nfs_write_data *data,
struct rpc_clnt *clnt, struct rpc_clnt *clnt,
const struct rpc_call_ops *call_ops, const struct rpc_call_ops *call_ops,
int how); int how);
extern void nfs_write_prepare(struct rpc_task *task, void *calldata); extern void nfs_write_prepare(struct rpc_task *task, void *calldata);
extern int nfs_initiate_commit(struct nfs_write_data *data,
struct rpc_clnt *clnt,
const struct rpc_call_ops *call_ops,
int how);
extern void nfs_init_commit(struct nfs_write_data *data,
struct list_head *head,
struct pnfs_layout_segment *lseg);
void nfs_retry_commit(struct list_head *page_list,
struct pnfs_layout_segment *lseg);
void nfs_commit_clear_lock(struct nfs_inode *nfsi);
void nfs_commitdata_release(void *data);
void nfs_commit_release_pages(struct nfs_write_data *data);
#ifdef CONFIG_MIGRATION #ifdef CONFIG_MIGRATION
extern int nfs_migrate_page(struct address_space *, extern int nfs_migrate_page(struct address_space *,
struct page *, struct page *); struct page *, struct page *);
...@@ -296,12 +317,14 @@ extern int nfs4_init_client(struct nfs_client *clp, ...@@ -296,12 +317,14 @@ extern int nfs4_init_client(struct nfs_client *clp,
rpc_authflavor_t authflavour, rpc_authflavor_t authflavour,
int noresvport); int noresvport);
extern void nfs4_reset_write(struct rpc_task *task, struct nfs_write_data *data); extern void nfs4_reset_write(struct rpc_task *task, struct nfs_write_data *data);
extern int _nfs4_call_sync(struct nfs_server *server, extern int _nfs4_call_sync(struct rpc_clnt *clnt,
struct nfs_server *server,
struct rpc_message *msg, struct rpc_message *msg,
struct nfs4_sequence_args *args, struct nfs4_sequence_args *args,
struct nfs4_sequence_res *res, struct nfs4_sequence_res *res,
int cache_reply); int cache_reply);
extern int _nfs4_call_sync_session(struct nfs_server *server, extern int _nfs4_call_sync_session(struct rpc_clnt *clnt,
struct nfs_server *server,
struct rpc_message *msg, struct rpc_message *msg,
struct nfs4_sequence_args *args, struct nfs4_sequence_args *args,
struct nfs4_sequence_res *res, struct nfs4_sequence_res *res,
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/clnt.h>
#include <linux/vfs.h> #include <linux/vfs.h>
#include <linux/sunrpc/gss_api.h>
#include "internal.h" #include "internal.h"
#define NFSDBG_FACILITY NFSDBG_VFS #define NFSDBG_FACILITY NFSDBG_VFS
...@@ -27,7 +28,8 @@ int nfs_mountpoint_expiry_timeout = 500 * HZ; ...@@ -27,7 +28,8 @@ int nfs_mountpoint_expiry_timeout = 500 * HZ;
static struct vfsmount *nfs_do_submount(struct dentry *dentry, static struct vfsmount *nfs_do_submount(struct dentry *dentry,
struct nfs_fh *fh, struct nfs_fh *fh,
struct nfs_fattr *fattr); struct nfs_fattr *fattr,
rpc_authflavor_t authflavor);
/* /*
* nfs_path - reconstruct the path given an arbitrary dentry * nfs_path - reconstruct the path given an arbitrary dentry
...@@ -116,6 +118,100 @@ char *nfs_path(char **p, struct dentry *dentry, char *buffer, ssize_t buflen) ...@@ -116,6 +118,100 @@ char *nfs_path(char **p, struct dentry *dentry, char *buffer, ssize_t buflen)
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
} }
#ifdef CONFIG_NFS_V4
static rpc_authflavor_t nfs_find_best_sec(struct nfs4_secinfo_flavors *flavors, struct inode *inode)
{
struct gss_api_mech *mech;
struct xdr_netobj oid;
int i;
rpc_authflavor_t pseudoflavor = RPC_AUTH_UNIX;
for (i = 0; i < flavors->num_flavors; i++) {
struct nfs4_secinfo_flavor *flavor;
flavor = &flavors->flavors[i];
if (flavor->flavor == RPC_AUTH_NULL || flavor->flavor == RPC_AUTH_UNIX) {
pseudoflavor = flavor->flavor;
break;
} else if (flavor->flavor == RPC_AUTH_GSS) {
oid.len = flavor->gss.sec_oid4.len;
oid.data = flavor->gss.sec_oid4.data;
mech = gss_mech_get_by_OID(&oid);
if (!mech)
continue;
pseudoflavor = gss_svc_to_pseudoflavor(mech, flavor->gss.service);
gss_mech_put(mech);
break;
}
}
return pseudoflavor;
}
static rpc_authflavor_t nfs_negotiate_security(const struct dentry *parent, const struct dentry *dentry)
{
int status = 0;
struct page *page;
struct nfs4_secinfo_flavors *flavors;
int (*secinfo)(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
rpc_authflavor_t flavor = RPC_AUTH_UNIX;
secinfo = NFS_PROTO(parent->d_inode)->secinfo;
if (secinfo != NULL) {
page = alloc_page(GFP_KERNEL);
if (!page) {
status = -ENOMEM;
goto out;
}
flavors = page_address(page);
status = secinfo(parent->d_inode, &dentry->d_name, flavors);
flavor = nfs_find_best_sec(flavors, dentry->d_inode);
put_page(page);
}
return flavor;
out:
status = -ENOMEM;
return status;
}
static rpc_authflavor_t nfs_lookup_with_sec(struct nfs_server *server, struct dentry *parent,
struct dentry *dentry, struct path *path,
struct nfs_fh *fh, struct nfs_fattr *fattr)
{
rpc_authflavor_t flavor;
struct rpc_clnt *clone;
struct rpc_auth *auth;
int err;
flavor = nfs_negotiate_security(parent, path->dentry);
if (flavor < 0)
goto out;
clone = rpc_clone_client(server->client);
auth = rpcauth_create(flavor, clone);
if (!auth) {
flavor = -EIO;
goto out;
}
err = server->nfs_client->rpc_ops->lookup(clone, parent->d_inode,
&path->dentry->d_name,
fh, fattr);
if (err < 0)
flavor = err;
out:
return flavor;
}
#else /* CONFIG_NFS_V4 */
static inline rpc_authflavor_t nfs_lookup_with_sec(struct nfs_server *server,
struct dentry *parent, struct dentry *dentry,
struct path *path, struct nfs_fh *fh,
struct nfs_fattr *fattr)
{
return -EPERM;
}
#endif /* CONFIG_NFS_V4 */
/* /*
* nfs_d_automount - Handle crossing a mountpoint on the server * nfs_d_automount - Handle crossing a mountpoint on the server
* @path - The mountpoint * @path - The mountpoint
...@@ -136,6 +232,7 @@ struct vfsmount *nfs_d_automount(struct path *path) ...@@ -136,6 +232,7 @@ struct vfsmount *nfs_d_automount(struct path *path)
struct nfs_fh *fh = NULL; struct nfs_fh *fh = NULL;
struct nfs_fattr *fattr = NULL; struct nfs_fattr *fattr = NULL;
int err; int err;
rpc_authflavor_t flavor = 1;
dprintk("--> nfs_d_automount()\n"); dprintk("--> nfs_d_automount()\n");
...@@ -153,9 +250,16 @@ struct vfsmount *nfs_d_automount(struct path *path) ...@@ -153,9 +250,16 @@ struct vfsmount *nfs_d_automount(struct path *path)
/* Look it up again to get its attributes */ /* Look it up again to get its attributes */
parent = dget_parent(path->dentry); parent = dget_parent(path->dentry);
err = server->nfs_client->rpc_ops->lookup(parent->d_inode, err = server->nfs_client->rpc_ops->lookup(server->client, parent->d_inode,
&path->dentry->d_name, &path->dentry->d_name,
fh, fattr); fh, fattr);
if (err == -EPERM) {
flavor = nfs_lookup_with_sec(server, parent, path->dentry, path, fh, fattr);
if (flavor < 0)
err = flavor;
else
err = 0;
}
dput(parent); dput(parent);
if (err != 0) { if (err != 0) {
mnt = ERR_PTR(err); mnt = ERR_PTR(err);
...@@ -165,7 +269,7 @@ struct vfsmount *nfs_d_automount(struct path *path) ...@@ -165,7 +269,7 @@ struct vfsmount *nfs_d_automount(struct path *path)
if (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) if (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL)
mnt = nfs_do_refmount(path->dentry); mnt = nfs_do_refmount(path->dentry);
else else
mnt = nfs_do_submount(path->dentry, fh, fattr); mnt = nfs_do_submount(path->dentry, fh, fattr, flavor);
if (IS_ERR(mnt)) if (IS_ERR(mnt))
goto out; goto out;
...@@ -232,17 +336,20 @@ static struct vfsmount *nfs_do_clone_mount(struct nfs_server *server, ...@@ -232,17 +336,20 @@ static struct vfsmount *nfs_do_clone_mount(struct nfs_server *server,
* @dentry - parent directory * @dentry - parent directory
* @fh - filehandle for new root dentry * @fh - filehandle for new root dentry
* @fattr - attributes for new root inode * @fattr - attributes for new root inode
* @authflavor - security flavor to use when performing the mount
* *
*/ */
static struct vfsmount *nfs_do_submount(struct dentry *dentry, static struct vfsmount *nfs_do_submount(struct dentry *dentry,
struct nfs_fh *fh, struct nfs_fh *fh,
struct nfs_fattr *fattr) struct nfs_fattr *fattr,
rpc_authflavor_t authflavor)
{ {
struct nfs_clone_mount mountdata = { struct nfs_clone_mount mountdata = {
.sb = dentry->d_sb, .sb = dentry->d_sb,
.dentry = dentry, .dentry = dentry,
.fh = fh, .fh = fh,
.fattr = fattr, .fattr = fattr,
.authflavor = authflavor,
}; };
struct vfsmount *mnt = ERR_PTR(-ENOMEM); struct vfsmount *mnt = ERR_PTR(-ENOMEM);
char *page = (char *) __get_free_page(GFP_USER); char *page = (char *) __get_free_page(GFP_USER);
......
...@@ -141,7 +141,7 @@ nfs3_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, ...@@ -141,7 +141,7 @@ nfs3_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
} }
static int static int
nfs3_proc_lookup(struct inode *dir, struct qstr *name, nfs3_proc_lookup(struct rpc_clnt *clnt, struct inode *dir, struct qstr *name,
struct nfs_fh *fhandle, struct nfs_fattr *fattr) struct nfs_fh *fhandle, struct nfs_fattr *fattr)
{ {
struct nfs3_diropargs arg = { struct nfs3_diropargs arg = {
......
...@@ -57,7 +57,8 @@ enum nfs4_session_state { ...@@ -57,7 +57,8 @@ enum nfs4_session_state {
struct nfs4_minor_version_ops { struct nfs4_minor_version_ops {
u32 minor_version; u32 minor_version;
int (*call_sync)(struct nfs_server *server, int (*call_sync)(struct rpc_clnt *clnt,
struct nfs_server *server,
struct rpc_message *msg, struct rpc_message *msg,
struct nfs4_sequence_args *args, struct nfs4_sequence_args *args,
struct nfs4_sequence_res *res, struct nfs4_sequence_res *res,
...@@ -262,6 +263,8 @@ extern int nfs4_proc_destroy_session(struct nfs4_session *); ...@@ -262,6 +263,8 @@ extern int nfs4_proc_destroy_session(struct nfs4_session *);
extern int nfs4_init_session(struct nfs_server *server); extern int nfs4_init_session(struct nfs_server *server);
extern int nfs4_proc_get_lease_time(struct nfs_client *clp, extern int nfs4_proc_get_lease_time(struct nfs_client *clp,
struct nfs_fsinfo *fsinfo); struct nfs_fsinfo *fsinfo);
extern int nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data,
bool sync);
static inline bool static inline bool
is_ds_only_client(struct nfs_client *clp) is_ds_only_client(struct nfs_client *clp)
......
This diff is collapsed.
...@@ -79,6 +79,8 @@ struct nfs4_filelayout_segment { ...@@ -79,6 +79,8 @@ struct nfs4_filelayout_segment {
struct nfs4_file_layout_dsaddr *dsaddr; /* Point to GETDEVINFO data */ struct nfs4_file_layout_dsaddr *dsaddr; /* Point to GETDEVINFO data */
unsigned int num_fh; unsigned int num_fh;
struct nfs_fh **fh_array; struct nfs_fh **fh_array;
struct list_head *commit_buckets; /* Sort commits to ds */
int number_of_buckets;
}; };
static inline struct nfs4_filelayout_segment * static inline struct nfs4_filelayout_segment *
......
...@@ -261,7 +261,7 @@ nfs4_pnfs_ds_add(struct inode *inode, u32 ip_addr, u32 port) ...@@ -261,7 +261,7 @@ nfs4_pnfs_ds_add(struct inode *inode, u32 ip_addr, u32 port)
* Currently only support ipv4, and one multi-path address. * Currently only support ipv4, and one multi-path address.
*/ */
static struct nfs4_pnfs_ds * static struct nfs4_pnfs_ds *
decode_and_add_ds(__be32 **pp, struct inode *inode) decode_and_add_ds(struct xdr_stream *streamp, struct inode *inode)
{ {
struct nfs4_pnfs_ds *ds = NULL; struct nfs4_pnfs_ds *ds = NULL;
char *buf; char *buf;
...@@ -269,25 +269,34 @@ decode_and_add_ds(__be32 **pp, struct inode *inode) ...@@ -269,25 +269,34 @@ decode_and_add_ds(__be32 **pp, struct inode *inode)
u32 ip_addr, port; u32 ip_addr, port;
int nlen, rlen, i; int nlen, rlen, i;
int tmp[2]; int tmp[2];
__be32 *r_netid, *r_addr, *p = *pp; __be32 *p;
/* r_netid */ /* r_netid */
p = xdr_inline_decode(streamp, 4);
if (unlikely(!p))
goto out_err;
nlen = be32_to_cpup(p++); nlen = be32_to_cpup(p++);
r_netid = p;
p += XDR_QUADLEN(nlen);
/* r_addr */ p = xdr_inline_decode(streamp, nlen);
rlen = be32_to_cpup(p++); if (unlikely(!p))
r_addr = p; goto out_err;
p += XDR_QUADLEN(rlen);
*pp = p;
/* Check that netid is "tcp" */ /* Check that netid is "tcp" */
if (nlen != 3 || memcmp((char *)r_netid, "tcp", 3)) { if (nlen != 3 || memcmp((char *)p, "tcp", 3)) {
dprintk("%s: ERROR: non ipv4 TCP r_netid\n", __func__); dprintk("%s: ERROR: non ipv4 TCP r_netid\n", __func__);
goto out_err; goto out_err;
} }
/* r_addr */
p = xdr_inline_decode(streamp, 4);
if (unlikely(!p))
goto out_err;
rlen = be32_to_cpup(p);
p = xdr_inline_decode(streamp, rlen);
if (unlikely(!p))
goto out_err;
/* ipv6 length plus port is legal */ /* ipv6 length plus port is legal */
if (rlen > INET6_ADDRSTRLEN + 8) { if (rlen > INET6_ADDRSTRLEN + 8) {
dprintk("%s: Invalid address, length %d\n", __func__, dprintk("%s: Invalid address, length %d\n", __func__,
...@@ -300,7 +309,7 @@ decode_and_add_ds(__be32 **pp, struct inode *inode) ...@@ -300,7 +309,7 @@ decode_and_add_ds(__be32 **pp, struct inode *inode)
goto out_err; goto out_err;
} }
buf[rlen] = '\0'; buf[rlen] = '\0';
memcpy(buf, r_addr, rlen); memcpy(buf, p, rlen);
/* replace the port dots with dashes for the in4_pton() delimiter*/ /* replace the port dots with dashes for the in4_pton() delimiter*/
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
...@@ -336,90 +345,154 @@ decode_and_add_ds(__be32 **pp, struct inode *inode) ...@@ -336,90 +345,154 @@ decode_and_add_ds(__be32 **pp, struct inode *inode)
static struct nfs4_file_layout_dsaddr* static struct nfs4_file_layout_dsaddr*
decode_device(struct inode *ino, struct pnfs_device *pdev) decode_device(struct inode *ino, struct pnfs_device *pdev)
{ {
int i, dummy; int i;
u32 cnt, num; u32 cnt, num;
u8 *indexp; u8 *indexp;
__be32 *p = (__be32 *)pdev->area, *indicesp; __be32 *p;
struct nfs4_file_layout_dsaddr *dsaddr; u8 *stripe_indices;
u8 max_stripe_index;
struct nfs4_file_layout_dsaddr *dsaddr = NULL;
struct xdr_stream stream;
struct xdr_buf buf = {
.pages = pdev->pages,
.page_len = pdev->pglen,
.buflen = pdev->pglen,
.len = pdev->pglen,
};
struct page *scratch;
/* set up xdr stream */
scratch = alloc_page(GFP_KERNEL);
if (!scratch)
goto out_err;
xdr_init_decode(&stream, &buf, NULL);
xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE);
/* Get the stripe count (number of stripe index) */ /* Get the stripe count (number of stripe index) */
cnt = be32_to_cpup(p++); p = xdr_inline_decode(&stream, 4);
if (unlikely(!p))
goto out_err_free_scratch;
cnt = be32_to_cpup(p);
dprintk("%s stripe count %d\n", __func__, cnt); dprintk("%s stripe count %d\n", __func__, cnt);
if (cnt > NFS4_PNFS_MAX_STRIPE_CNT) { if (cnt > NFS4_PNFS_MAX_STRIPE_CNT) {
printk(KERN_WARNING "%s: stripe count %d greater than " printk(KERN_WARNING "%s: stripe count %d greater than "
"supported maximum %d\n", __func__, "supported maximum %d\n", __func__,
cnt, NFS4_PNFS_MAX_STRIPE_CNT); cnt, NFS4_PNFS_MAX_STRIPE_CNT);
goto out_err; goto out_err_free_scratch;
}
/* read stripe indices */
stripe_indices = kcalloc(cnt, sizeof(u8), GFP_KERNEL);
if (!stripe_indices)
goto out_err_free_scratch;
p = xdr_inline_decode(&stream, cnt << 2);
if (unlikely(!p))
goto out_err_free_stripe_indices;
indexp = &stripe_indices[0];
max_stripe_index = 0;
for (i = 0; i < cnt; i++) {
*indexp = be32_to_cpup(p++);
max_stripe_index = max(max_stripe_index, *indexp);
indexp++;
} }
/* Check the multipath list count */ /* Check the multipath list count */
indicesp = p; p = xdr_inline_decode(&stream, 4);
p += XDR_QUADLEN(cnt << 2); if (unlikely(!p))
num = be32_to_cpup(p++); goto out_err_free_stripe_indices;
num = be32_to_cpup(p);
dprintk("%s ds_num %u\n", __func__, num); dprintk("%s ds_num %u\n", __func__, num);
if (num > NFS4_PNFS_MAX_MULTI_CNT) { if (num > NFS4_PNFS_MAX_MULTI_CNT) {
printk(KERN_WARNING "%s: multipath count %d greater than " printk(KERN_WARNING "%s: multipath count %d greater than "
"supported maximum %d\n", __func__, "supported maximum %d\n", __func__,
num, NFS4_PNFS_MAX_MULTI_CNT); num, NFS4_PNFS_MAX_MULTI_CNT);
goto out_err; goto out_err_free_stripe_indices;
} }
/* validate stripe indices are all < num */
if (max_stripe_index >= num) {
printk(KERN_WARNING "%s: stripe index %u >= num ds %u\n",
__func__, max_stripe_index, num);
goto out_err_free_stripe_indices;
}
dsaddr = kzalloc(sizeof(*dsaddr) + dsaddr = kzalloc(sizeof(*dsaddr) +
(sizeof(struct nfs4_pnfs_ds *) * (num - 1)), (sizeof(struct nfs4_pnfs_ds *) * (num - 1)),
GFP_KERNEL); GFP_KERNEL);
if (!dsaddr) if (!dsaddr)
goto out_err; goto out_err_free_stripe_indices;
dsaddr->stripe_indices = kzalloc(sizeof(u8) * cnt, GFP_KERNEL);
if (!dsaddr->stripe_indices)
goto out_err_free;
dsaddr->stripe_count = cnt; dsaddr->stripe_count = cnt;
dsaddr->stripe_indices = stripe_indices;
stripe_indices = NULL;
dsaddr->ds_num = num; dsaddr->ds_num = num;
memcpy(&dsaddr->deviceid, &pdev->dev_id, sizeof(pdev->dev_id)); memcpy(&dsaddr->deviceid, &pdev->dev_id, sizeof(pdev->dev_id));
/* Go back an read stripe indices */
p = indicesp;
indexp = &dsaddr->stripe_indices[0];
for (i = 0; i < dsaddr->stripe_count; i++) {
*indexp = be32_to_cpup(p++);
if (*indexp >= num)
goto out_err_free;
indexp++;
}
/* Skip already read multipath list count */
p++;
for (i = 0; i < dsaddr->ds_num; i++) { for (i = 0; i < dsaddr->ds_num; i++) {
int j; int j;
u32 mp_count;
p = xdr_inline_decode(&stream, 4);
if (unlikely(!p))
goto out_err_free_deviceid;
dummy = be32_to_cpup(p++); /* multipath count */ mp_count = be32_to_cpup(p); /* multipath count */
if (dummy > 1) { if (mp_count > 1) {
printk(KERN_WARNING printk(KERN_WARNING
"%s: Multipath count %d not supported, " "%s: Multipath count %d not supported, "
"skipping all greater than 1\n", __func__, "skipping all greater than 1\n", __func__,
dummy); mp_count);
} }
for (j = 0; j < dummy; j++) { for (j = 0; j < mp_count; j++) {
if (j == 0) { if (j == 0) {
dsaddr->ds_list[i] = decode_and_add_ds(&p, ino); dsaddr->ds_list[i] = decode_and_add_ds(&stream,
ino);
if (dsaddr->ds_list[i] == NULL) if (dsaddr->ds_list[i] == NULL)
goto out_err_free; goto out_err_free_deviceid;
} else { } else {
u32 len; u32 len;
/* skip extra multipath */ /* skip extra multipath */
len = be32_to_cpup(p++);
p += XDR_QUADLEN(len); /* read len, skip */
len = be32_to_cpup(p++); p = xdr_inline_decode(&stream, 4);
p += XDR_QUADLEN(len); if (unlikely(!p))
continue; goto out_err_free_deviceid;
len = be32_to_cpup(p);
p = xdr_inline_decode(&stream, len);
if (unlikely(!p))
goto out_err_free_deviceid;
/* read len, skip */
p = xdr_inline_decode(&stream, 4);
if (unlikely(!p))
goto out_err_free_deviceid;
len = be32_to_cpup(p);
p = xdr_inline_decode(&stream, len);
if (unlikely(!p))
goto out_err_free_deviceid;
} }
} }
} }
__free_page(scratch);
return dsaddr; return dsaddr;
out_err_free: out_err_free_deviceid:
nfs4_fl_free_deviceid(dsaddr); nfs4_fl_free_deviceid(dsaddr);
/* stripe_indicies was part of dsaddr */
goto out_err_free_scratch;
out_err_free_stripe_indices:
kfree(stripe_indices);
out_err_free_scratch:
__free_page(scratch);
out_err: out_err:
dprintk("%s ERROR: returning NULL\n", __func__); dprintk("%s ERROR: returning NULL\n", __func__);
return NULL; return NULL;
...@@ -498,11 +571,6 @@ get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id) ...@@ -498,11 +571,6 @@ get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id)
goto out_free; goto out_free;
} }
/* set pdev->area */
pdev->area = vmap(pages, max_pages, VM_MAP, PAGE_KERNEL);
if (!pdev->area)
goto out_free;
memcpy(&pdev->dev_id, dev_id, sizeof(*dev_id)); memcpy(&pdev->dev_id, dev_id, sizeof(*dev_id));
pdev->layout_type = LAYOUT_NFSV4_1_FILES; pdev->layout_type = LAYOUT_NFSV4_1_FILES;
pdev->pages = pages; pdev->pages = pages;
...@@ -521,8 +589,6 @@ get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id) ...@@ -521,8 +589,6 @@ get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id)
*/ */
dsaddr = decode_and_add_device(inode, pdev); dsaddr = decode_and_add_device(inode, pdev);
out_free: out_free:
if (pdev->area != NULL)
vunmap(pdev->area);
for (i = 0; i < max_pages; i++) for (i = 0; i < max_pages; i++)
__free_page(pages[i]); __free_page(pages[i]);
kfree(pages); kfree(pages);
......
This diff is collapsed.
This diff is collapsed.
...@@ -223,6 +223,7 @@ void nfs_pageio_init(struct nfs_pageio_descriptor *desc, ...@@ -223,6 +223,7 @@ void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
desc->pg_count = 0; desc->pg_count = 0;
desc->pg_bsize = bsize; desc->pg_bsize = bsize;
desc->pg_base = 0; desc->pg_base = 0;
desc->pg_moreio = 0;
desc->pg_inode = inode; desc->pg_inode = inode;
desc->pg_doio = doio; desc->pg_doio = doio;
desc->pg_ioflags = io_flags; desc->pg_ioflags = io_flags;
...@@ -335,9 +336,11 @@ int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc, ...@@ -335,9 +336,11 @@ int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
struct nfs_page *req) struct nfs_page *req)
{ {
while (!nfs_pageio_do_add_request(desc, req)) { while (!nfs_pageio_do_add_request(desc, req)) {
desc->pg_moreio = 1;
nfs_pageio_doio(desc); nfs_pageio_doio(desc);
if (desc->pg_error < 0) if (desc->pg_error < 0)
return 0; return 0;
desc->pg_moreio = 0;
} }
return 1; return 1;
} }
...@@ -395,6 +398,7 @@ int nfs_scan_list(struct nfs_inode *nfsi, ...@@ -395,6 +398,7 @@ int nfs_scan_list(struct nfs_inode *nfsi,
pgoff_t idx_end; pgoff_t idx_end;
int found, i; int found, i;
int res; int res;
struct list_head *list;
res = 0; res = 0;
if (npages == 0) if (npages == 0)
...@@ -415,10 +419,10 @@ int nfs_scan_list(struct nfs_inode *nfsi, ...@@ -415,10 +419,10 @@ int nfs_scan_list(struct nfs_inode *nfsi,
idx_start = req->wb_index + 1; idx_start = req->wb_index + 1;
if (nfs_set_page_tag_locked(req)) { if (nfs_set_page_tag_locked(req)) {
kref_get(&req->wb_kref); kref_get(&req->wb_kref);
nfs_list_remove_request(req);
radix_tree_tag_clear(&nfsi->nfs_page_tree, radix_tree_tag_clear(&nfsi->nfs_page_tree,
req->wb_index, tag); req->wb_index, tag);
nfs_list_add_request(req, dst); list = pnfs_choose_commit_list(req, dst);
nfs_list_add_request(req, list);
res++; res++;
if (res == INT_MAX) if (res == INT_MAX)
goto out; goto out;
......
...@@ -259,6 +259,7 @@ put_lseg(struct pnfs_layout_segment *lseg) ...@@ -259,6 +259,7 @@ put_lseg(struct pnfs_layout_segment *lseg)
pnfs_free_lseg_list(&free_me); pnfs_free_lseg_list(&free_me);
} }
} }
EXPORT_SYMBOL_GPL(put_lseg);
static bool static bool
should_free_lseg(u32 lseg_iomode, u32 recall_iomode) should_free_lseg(u32 lseg_iomode, u32 recall_iomode)
...@@ -471,6 +472,9 @@ send_layoutget(struct pnfs_layout_hdr *lo, ...@@ -471,6 +472,9 @@ send_layoutget(struct pnfs_layout_hdr *lo,
struct nfs_server *server = NFS_SERVER(ino); struct nfs_server *server = NFS_SERVER(ino);
struct nfs4_layoutget *lgp; struct nfs4_layoutget *lgp;
struct pnfs_layout_segment *lseg = NULL; struct pnfs_layout_segment *lseg = NULL;
struct page **pages = NULL;
int i;
u32 max_resp_sz, max_pages;
dprintk("--> %s\n", __func__); dprintk("--> %s\n", __func__);
...@@ -478,6 +482,21 @@ send_layoutget(struct pnfs_layout_hdr *lo, ...@@ -478,6 +482,21 @@ send_layoutget(struct pnfs_layout_hdr *lo,
lgp = kzalloc(sizeof(*lgp), GFP_KERNEL); lgp = kzalloc(sizeof(*lgp), GFP_KERNEL);
if (lgp == NULL) if (lgp == NULL)
return NULL; return NULL;
/* allocate pages for xdr post processing */
max_resp_sz = server->nfs_client->cl_session->fc_attrs.max_resp_sz;
max_pages = max_resp_sz >> PAGE_SHIFT;
pages = kzalloc(max_pages * sizeof(struct page *), GFP_KERNEL);
if (!pages)
goto out_err_free;
for (i = 0; i < max_pages; i++) {
pages[i] = alloc_page(GFP_KERNEL);
if (!pages[i])
goto out_err_free;
}
lgp->args.minlength = NFS4_MAX_UINT64; lgp->args.minlength = NFS4_MAX_UINT64;
lgp->args.maxcount = PNFS_LAYOUT_MAXSIZE; lgp->args.maxcount = PNFS_LAYOUT_MAXSIZE;
lgp->args.range.iomode = iomode; lgp->args.range.iomode = iomode;
...@@ -486,6 +505,8 @@ send_layoutget(struct pnfs_layout_hdr *lo, ...@@ -486,6 +505,8 @@ send_layoutget(struct pnfs_layout_hdr *lo,
lgp->args.type = server->pnfs_curr_ld->id; lgp->args.type = server->pnfs_curr_ld->id;
lgp->args.inode = ino; lgp->args.inode = ino;
lgp->args.ctx = get_nfs_open_context(ctx); lgp->args.ctx = get_nfs_open_context(ctx);
lgp->args.layout.pages = pages;
lgp->args.layout.pglen = max_pages * PAGE_SIZE;
lgp->lsegpp = &lseg; lgp->lsegpp = &lseg;
/* Synchronously retrieve layout information from server and /* Synchronously retrieve layout information from server and
...@@ -496,7 +517,26 @@ send_layoutget(struct pnfs_layout_hdr *lo, ...@@ -496,7 +517,26 @@ send_layoutget(struct pnfs_layout_hdr *lo,
/* remember that LAYOUTGET failed and suspend trying */ /* remember that LAYOUTGET failed and suspend trying */
set_bit(lo_fail_bit(iomode), &lo->plh_flags); set_bit(lo_fail_bit(iomode), &lo->plh_flags);
} }
/* free xdr pages */
for (i = 0; i < max_pages; i++)
__free_page(pages[i]);
kfree(pages);
return lseg; return lseg;
out_err_free:
/* free any allocated xdr pages, lgp as it's not used */
if (pages) {
for (i = 0; i < max_pages; i++) {
if (!pages[i])
break;
__free_page(pages[i]);
}
kfree(pages);
}
kfree(lgp);
return NULL;
} }
bool pnfs_roc(struct inode *ino) bool pnfs_roc(struct inode *ino)
...@@ -945,3 +985,105 @@ pnfs_try_to_read_data(struct nfs_read_data *rdata, ...@@ -945,3 +985,105 @@ pnfs_try_to_read_data(struct nfs_read_data *rdata,
dprintk("%s End (trypnfs:%d)\n", __func__, trypnfs); dprintk("%s End (trypnfs:%d)\n", __func__, trypnfs);
return trypnfs; return trypnfs;
} }
/*
* Currently there is only one (whole file) write lseg.
*/
static struct pnfs_layout_segment *pnfs_list_write_lseg(struct inode *inode)
{
struct pnfs_layout_segment *lseg, *rv = NULL;
list_for_each_entry(lseg, &NFS_I(inode)->layout->plh_segs, pls_list)
if (lseg->pls_range.iomode == IOMODE_RW)
rv = lseg;
return rv;
}
void
pnfs_set_layoutcommit(struct nfs_write_data *wdata)
{
struct nfs_inode *nfsi = NFS_I(wdata->inode);
loff_t end_pos = wdata->args.offset + wdata->res.count;
spin_lock(&nfsi->vfs_inode.i_lock);
if (!test_and_set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) {
/* references matched in nfs4_layoutcommit_release */
get_lseg(wdata->lseg);
wdata->lseg->pls_lc_cred =
get_rpccred(wdata->args.context->state->owner->so_cred);
mark_inode_dirty_sync(wdata->inode);
dprintk("%s: Set layoutcommit for inode %lu ",
__func__, wdata->inode->i_ino);
}
if (end_pos > wdata->lseg->pls_end_pos)
wdata->lseg->pls_end_pos = end_pos;
spin_unlock(&nfsi->vfs_inode.i_lock);
}
EXPORT_SYMBOL_GPL(pnfs_set_layoutcommit);
/*
* For the LAYOUT4_NFSV4_1_FILES layout type, NFS_DATA_SYNC WRITEs and
* NFS_UNSTABLE WRITEs with a COMMIT to data servers must store enough
* data to disk to allow the server to recover the data if it crashes.
* LAYOUTCOMMIT is only needed when the NFL4_UFLG_COMMIT_THRU_MDS flag
* is off, and a COMMIT is sent to a data server, or
* if WRITEs to a data server return NFS_DATA_SYNC.
*/
int
pnfs_layoutcommit_inode(struct inode *inode, bool sync)
{
struct nfs4_layoutcommit_data *data;
struct nfs_inode *nfsi = NFS_I(inode);
struct pnfs_layout_segment *lseg;
struct rpc_cred *cred;
loff_t end_pos;
int status = 0;
dprintk("--> %s inode %lu\n", __func__, inode->i_ino);
if (!test_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags))
return 0;
/* Note kzalloc ensures data->res.seq_res.sr_slot == NULL */
data = kzalloc(sizeof(*data), GFP_NOFS);
if (!data) {
mark_inode_dirty_sync(inode);
status = -ENOMEM;
goto out;
}
spin_lock(&inode->i_lock);
if (!test_and_clear_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) {
spin_unlock(&inode->i_lock);
kfree(data);
goto out;
}
/*
* Currently only one (whole file) write lseg which is referenced
* in pnfs_set_layoutcommit and will be found.
*/
lseg = pnfs_list_write_lseg(inode);
end_pos = lseg->pls_end_pos;
cred = lseg->pls_lc_cred;
lseg->pls_end_pos = 0;
lseg->pls_lc_cred = NULL;
memcpy(&data->args.stateid.data, nfsi->layout->plh_stateid.data,
sizeof(nfsi->layout->plh_stateid.data));
spin_unlock(&inode->i_lock);
data->args.inode = inode;
data->lseg = lseg;
data->cred = cred;
nfs_fattr_init(&data->fattr);
data->args.bitmask = NFS_SERVER(inode)->cache_consistency_bitmask;
data->res.fattr = &data->fattr;
data->args.lastbytewritten = end_pos - 1;
data->res.server = NFS_SERVER(inode);
status = nfs4_proc_layoutcommit(data, sync);
out:
dprintk("<-- %s status %d\n", __func__, status);
return status;
}
...@@ -43,6 +43,8 @@ struct pnfs_layout_segment { ...@@ -43,6 +43,8 @@ struct pnfs_layout_segment {
atomic_t pls_refcount; atomic_t pls_refcount;
unsigned long pls_flags; unsigned long pls_flags;
struct pnfs_layout_hdr *pls_layout; struct pnfs_layout_hdr *pls_layout;
struct rpc_cred *pls_lc_cred; /* LAYOUTCOMMIT credential */
loff_t pls_end_pos; /* LAYOUTCOMMIT write end */
}; };
enum pnfs_try_status { enum pnfs_try_status {
...@@ -74,6 +76,13 @@ struct pnfs_layoutdriver_type { ...@@ -74,6 +76,13 @@ struct pnfs_layoutdriver_type {
/* test for nfs page cache coalescing */ /* test for nfs page cache coalescing */
int (*pg_test)(struct nfs_pageio_descriptor *, struct nfs_page *, struct nfs_page *); int (*pg_test)(struct nfs_pageio_descriptor *, struct nfs_page *, struct nfs_page *);
/* Returns true if layoutdriver wants to divert this request to
* driver's commit routine.
*/
bool (*mark_pnfs_commit)(struct pnfs_layout_segment *lseg);
struct list_head * (*choose_commit_list) (struct nfs_page *req);
int (*commit_pagelist)(struct inode *inode, struct list_head *mds_pages, int how);
/* /*
* Return PNFS_ATTEMPTED to indicate the layout code has attempted * Return PNFS_ATTEMPTED to indicate the layout code has attempted
* I/O, else return PNFS_NOT_ATTEMPTED to fall back to normal NFS * I/O, else return PNFS_NOT_ATTEMPTED to fall back to normal NFS
...@@ -100,7 +109,6 @@ struct pnfs_device { ...@@ -100,7 +109,6 @@ struct pnfs_device {
unsigned int layout_type; unsigned int layout_type;
unsigned int mincount; unsigned int mincount;
struct page **pages; struct page **pages;
void *area;
unsigned int pgbase; unsigned int pgbase;
unsigned int pglen; unsigned int pglen;
}; };
...@@ -145,7 +153,8 @@ bool pnfs_roc(struct inode *ino); ...@@ -145,7 +153,8 @@ bool pnfs_roc(struct inode *ino);
void pnfs_roc_release(struct inode *ino); void pnfs_roc_release(struct inode *ino);
void pnfs_roc_set_barrier(struct inode *ino, u32 barrier); void pnfs_roc_set_barrier(struct inode *ino, u32 barrier);
bool pnfs_roc_drain(struct inode *ino, u32 *barrier); bool pnfs_roc_drain(struct inode *ino, u32 *barrier);
void pnfs_set_layoutcommit(struct nfs_write_data *wdata);
int pnfs_layoutcommit_inode(struct inode *inode, bool sync);
static inline int lo_fail_bit(u32 iomode) static inline int lo_fail_bit(u32 iomode)
{ {
...@@ -169,6 +178,51 @@ static inline int pnfs_enabled_sb(struct nfs_server *nfss) ...@@ -169,6 +178,51 @@ static inline int pnfs_enabled_sb(struct nfs_server *nfss)
return nfss->pnfs_curr_ld != NULL; return nfss->pnfs_curr_ld != NULL;
} }
static inline void
pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg)
{
if (lseg) {
struct pnfs_layoutdriver_type *ld;
ld = NFS_SERVER(req->wb_page->mapping->host)->pnfs_curr_ld;
if (ld->mark_pnfs_commit && ld->mark_pnfs_commit(lseg)) {
set_bit(PG_PNFS_COMMIT, &req->wb_flags);
req->wb_commit_lseg = get_lseg(lseg);
}
}
}
static inline int
pnfs_commit_list(struct inode *inode, struct list_head *mds_pages, int how)
{
if (!test_and_clear_bit(NFS_INO_PNFS_COMMIT, &NFS_I(inode)->flags))
return PNFS_NOT_ATTEMPTED;
return NFS_SERVER(inode)->pnfs_curr_ld->commit_pagelist(inode, mds_pages, how);
}
static inline struct list_head *
pnfs_choose_commit_list(struct nfs_page *req, struct list_head *mds)
{
struct list_head *rv;
if (test_and_clear_bit(PG_PNFS_COMMIT, &req->wb_flags)) {
struct inode *inode = req->wb_commit_lseg->pls_layout->plh_inode;
set_bit(NFS_INO_PNFS_COMMIT, &NFS_I(inode)->flags);
rv = NFS_SERVER(inode)->pnfs_curr_ld->choose_commit_list(req);
/* matched by ref taken when PG_PNFS_COMMIT is set */
put_lseg(req->wb_commit_lseg);
} else
rv = mds;
return rv;
}
static inline void pnfs_clear_request_commit(struct nfs_page *req)
{
if (test_and_clear_bit(PG_PNFS_COMMIT, &req->wb_flags))
put_lseg(req->wb_commit_lseg);
}
#else /* CONFIG_NFS_V4_1 */ #else /* CONFIG_NFS_V4_1 */
static inline void pnfs_destroy_all_layouts(struct nfs_client *clp) static inline void pnfs_destroy_all_layouts(struct nfs_client *clp)
...@@ -252,6 +306,31 @@ pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *ino) ...@@ -252,6 +306,31 @@ pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *ino)
pgio->pg_test = NULL; pgio->pg_test = NULL;
} }
static inline void
pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg)
{
}
static inline int
pnfs_commit_list(struct inode *inode, struct list_head *mds_pages, int how)
{
return PNFS_NOT_ATTEMPTED;
}
static inline struct list_head *
pnfs_choose_commit_list(struct nfs_page *req, struct list_head *mds)
{
return mds;
}
static inline void pnfs_clear_request_commit(struct nfs_page *req)
{
}
static inline int pnfs_layoutcommit_inode(struct inode *inode, bool sync)
{
return 0;
}
#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4_1 */
#endif /* FS_NFS_PNFS_H */ #endif /* FS_NFS_PNFS_H */
...@@ -177,7 +177,7 @@ nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, ...@@ -177,7 +177,7 @@ nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
} }
static int static int
nfs_proc_lookup(struct inode *dir, struct qstr *name, nfs_proc_lookup(struct rpc_clnt *clnt, struct inode *dir, struct qstr *name,
struct nfs_fh *fhandle, struct nfs_fattr *fattr) struct nfs_fh *fhandle, struct nfs_fattr *fattr)
{ {
struct nfs_diropargs arg = { struct nfs_diropargs arg = {
......
This diff is collapsed.
...@@ -117,7 +117,6 @@ int nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode, ...@@ -117,7 +117,6 @@ int nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,
* invoked in contexts where a memory allocation failure is * invoked in contexts where a memory allocation failure is
* fatal. Fortunately this fake ACL is small enough to * fatal. Fortunately this fake ACL is small enough to
* construct on the stack. */ * construct on the stack. */
memset(acl2, 0, sizeof(acl2));
posix_acl_init(acl2, 4); posix_acl_init(acl2, 4);
/* Insert entries in canonical order: other orders seem /* Insert entries in canonical order: other orders seem
......
...@@ -550,6 +550,7 @@ enum { ...@@ -550,6 +550,7 @@ enum {
NFSPROC4_CLNT_SETACL, NFSPROC4_CLNT_SETACL,
NFSPROC4_CLNT_FS_LOCATIONS, NFSPROC4_CLNT_FS_LOCATIONS,
NFSPROC4_CLNT_RELEASE_LOCKOWNER, NFSPROC4_CLNT_RELEASE_LOCKOWNER,
NFSPROC4_CLNT_SECINFO,
/* nfs41 */ /* nfs41 */
NFSPROC4_CLNT_EXCHANGE_ID, NFSPROC4_CLNT_EXCHANGE_ID,
...@@ -560,6 +561,7 @@ enum { ...@@ -560,6 +561,7 @@ enum {
NFSPROC4_CLNT_RECLAIM_COMPLETE, NFSPROC4_CLNT_RECLAIM_COMPLETE,
NFSPROC4_CLNT_LAYOUTGET, NFSPROC4_CLNT_LAYOUTGET,
NFSPROC4_CLNT_GETDEVICEINFO, NFSPROC4_CLNT_GETDEVICEINFO,
NFSPROC4_CLNT_LAYOUTCOMMIT,
}; };
/* nfs41 types */ /* nfs41 types */
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#define FLUSH_STABLE 4 /* commit to stable storage */ #define FLUSH_STABLE 4 /* commit to stable storage */
#define FLUSH_LOWPRI 8 /* low priority background flush */ #define FLUSH_LOWPRI 8 /* low priority background flush */
#define FLUSH_HIGHPRI 16 /* high priority memory reclaim flush */ #define FLUSH_HIGHPRI 16 /* high priority memory reclaim flush */
#define FLUSH_COND_STABLE 32 /* conditional stable write - only stable
* if everything fits in one RPC */
#ifdef __KERNEL__ #ifdef __KERNEL__
...@@ -93,8 +95,13 @@ struct nfs_open_context { ...@@ -93,8 +95,13 @@ struct nfs_open_context {
int error; int error;
struct list_head list; struct list_head list;
};
struct nfs_open_dir_context {
struct rpc_cred *cred;
__u64 dir_cookie; __u64 dir_cookie;
__u64 dup_cookie;
int duped;
}; };
/* /*
...@@ -191,6 +198,7 @@ struct nfs_inode { ...@@ -191,6 +198,7 @@ struct nfs_inode {
/* pNFS layout information */ /* pNFS layout information */
struct pnfs_layout_hdr *layout; struct pnfs_layout_hdr *layout;
atomic_t commits_outstanding;
#endif /* CONFIG_NFS_V4*/ #endif /* CONFIG_NFS_V4*/
#ifdef CONFIG_NFS_FSCACHE #ifdef CONFIG_NFS_FSCACHE
struct fscache_cookie *fscache; struct fscache_cookie *fscache;
...@@ -219,6 +227,8 @@ struct nfs_inode { ...@@ -219,6 +227,8 @@ struct nfs_inode {
#define NFS_INO_FSCACHE (5) /* inode can be cached by FS-Cache */ #define NFS_INO_FSCACHE (5) /* inode can be cached by FS-Cache */
#define NFS_INO_FSCACHE_LOCK (6) /* FS-Cache cookie management lock */ #define NFS_INO_FSCACHE_LOCK (6) /* FS-Cache cookie management lock */
#define NFS_INO_COMMIT (7) /* inode is committing unstable writes */ #define NFS_INO_COMMIT (7) /* inode is committing unstable writes */
#define NFS_INO_PNFS_COMMIT (8) /* use pnfs code for commit */
#define NFS_INO_LAYOUTCOMMIT (9) /* layoutcommit required */
static inline struct nfs_inode *NFS_I(const struct inode *inode) static inline struct nfs_inode *NFS_I(const struct inode *inode)
{ {
......
...@@ -33,11 +33,15 @@ enum { ...@@ -33,11 +33,15 @@ enum {
PG_CLEAN, PG_CLEAN,
PG_NEED_COMMIT, PG_NEED_COMMIT,
PG_NEED_RESCHED, PG_NEED_RESCHED,
PG_PNFS_COMMIT,
}; };
struct nfs_inode; struct nfs_inode;
struct nfs_page { struct nfs_page {
struct list_head wb_list; /* Defines state of page: */ union {
struct list_head wb_list; /* Defines state of page: */
struct pnfs_layout_segment *wb_commit_lseg; /* Used when PG_PNFS_COMMIT set */
};
struct page *wb_page; /* page to read in/write out */ struct page *wb_page; /* page to read in/write out */
struct nfs_open_context *wb_context; /* File state context info */ struct nfs_open_context *wb_context; /* File state context info */
struct nfs_lock_context *wb_lock_context; /* lock context info */ struct nfs_lock_context *wb_lock_context; /* lock context info */
...@@ -57,6 +61,7 @@ struct nfs_pageio_descriptor { ...@@ -57,6 +61,7 @@ struct nfs_pageio_descriptor {
size_t pg_count; size_t pg_count;
size_t pg_bsize; size_t pg_bsize;
unsigned int pg_base; unsigned int pg_base;
char pg_moreio;
struct inode *pg_inode; struct inode *pg_inode;
int (*pg_doio)(struct nfs_pageio_descriptor *); int (*pg_doio)(struct nfs_pageio_descriptor *);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <linux/nfsacl.h> #include <linux/nfsacl.h>
#include <linux/nfs3.h> #include <linux/nfs3.h>
#include <linux/sunrpc/gss_api.h>
/* /*
* To change the maximum rsize and wsize supported by the NFS client, adjust * To change the maximum rsize and wsize supported by the NFS client, adjust
...@@ -14,6 +15,9 @@ ...@@ -14,6 +15,9 @@
#define NFS_DEF_FILE_IO_SIZE (4096U) #define NFS_DEF_FILE_IO_SIZE (4096U)
#define NFS_MIN_FILE_IO_SIZE (1024U) #define NFS_MIN_FILE_IO_SIZE (1024U)
/* Forward declaration for NFS v3 */
struct nfs4_secinfo_flavors;
struct nfs_fsid { struct nfs_fsid {
uint64_t major; uint64_t major;
uint64_t minor; uint64_t minor;
...@@ -78,6 +82,7 @@ struct nfs_fattr { ...@@ -78,6 +82,7 @@ struct nfs_fattr {
#define NFS_ATTR_FATTR_CHANGE (1U << 17) #define NFS_ATTR_FATTR_CHANGE (1U << 17)
#define NFS_ATTR_FATTR_PRECHANGE (1U << 18) #define NFS_ATTR_FATTR_PRECHANGE (1U << 18)
#define NFS_ATTR_FATTR_V4_REFERRAL (1U << 19) /* NFSv4 referral */ #define NFS_ATTR_FATTR_V4_REFERRAL (1U << 19) /* NFSv4 referral */
#define NFS_ATTR_FATTR_MOUNTPOINT (1U << 20) /* Treat as mountpoint */
#define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \ #define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \
| NFS_ATTR_FATTR_MODE \ | NFS_ATTR_FATTR_MODE \
...@@ -190,8 +195,9 @@ struct nfs4_get_lease_time_res { ...@@ -190,8 +195,9 @@ struct nfs4_get_lease_time_res {
#define PNFS_LAYOUT_MAXSIZE 4096 #define PNFS_LAYOUT_MAXSIZE 4096
struct nfs4_layoutdriver_data { struct nfs4_layoutdriver_data {
struct page **pages;
__u32 pglen;
__u32 len; __u32 len;
void *buf;
}; };
struct pnfs_layout_range { struct pnfs_layout_range {
...@@ -209,6 +215,7 @@ struct nfs4_layoutget_args { ...@@ -209,6 +215,7 @@ struct nfs4_layoutget_args {
struct nfs_open_context *ctx; struct nfs_open_context *ctx;
struct nfs4_sequence_args seq_args; struct nfs4_sequence_args seq_args;
nfs4_stateid stateid; nfs4_stateid stateid;
struct nfs4_layoutdriver_data layout;
}; };
struct nfs4_layoutget_res { struct nfs4_layoutget_res {
...@@ -216,8 +223,8 @@ struct nfs4_layoutget_res { ...@@ -216,8 +223,8 @@ struct nfs4_layoutget_res {
struct pnfs_layout_range range; struct pnfs_layout_range range;
__u32 type; __u32 type;
nfs4_stateid stateid; nfs4_stateid stateid;
struct nfs4_layoutdriver_data layout;
struct nfs4_sequence_res seq_res; struct nfs4_sequence_res seq_res;
struct nfs4_layoutdriver_data *layoutp;
}; };
struct nfs4_layoutget { struct nfs4_layoutget {
...@@ -236,6 +243,29 @@ struct nfs4_getdeviceinfo_res { ...@@ -236,6 +243,29 @@ struct nfs4_getdeviceinfo_res {
struct nfs4_sequence_res seq_res; struct nfs4_sequence_res seq_res;
}; };
struct nfs4_layoutcommit_args {
nfs4_stateid stateid;
__u64 lastbytewritten;
struct inode *inode;
const u32 *bitmask;
struct nfs4_sequence_args seq_args;
};
struct nfs4_layoutcommit_res {
struct nfs_fattr *fattr;
const struct nfs_server *server;
struct nfs4_sequence_res seq_res;
};
struct nfs4_layoutcommit_data {
struct rpc_task task;
struct nfs_fattr fattr;
struct pnfs_layout_segment *lseg;
struct rpc_cred *cred;
struct nfs4_layoutcommit_args args;
struct nfs4_layoutcommit_res res;
};
/* /*
* Arguments to the open call. * Arguments to the open call.
*/ */
...@@ -936,6 +966,38 @@ struct nfs4_fs_locations_res { ...@@ -936,6 +966,38 @@ struct nfs4_fs_locations_res {
struct nfs4_sequence_res seq_res; struct nfs4_sequence_res seq_res;
}; };
struct nfs4_secinfo_oid {
unsigned int len;
char data[GSS_OID_MAX_LEN];
};
struct nfs4_secinfo_gss {
struct nfs4_secinfo_oid sec_oid4;
unsigned int qop4;
unsigned int service;
};
struct nfs4_secinfo_flavor {
unsigned int flavor;
struct nfs4_secinfo_gss gss;
};
struct nfs4_secinfo_flavors {
unsigned int num_flavors;
struct nfs4_secinfo_flavor flavors[0];
};
struct nfs4_secinfo_arg {
const struct nfs_fh *dir_fh;
const struct qstr *name;
struct nfs4_sequence_args seq_args;
};
struct nfs4_secinfo_res {
struct nfs4_secinfo_flavors *flavors;
struct nfs4_sequence_res seq_res;
};
#endif /* CONFIG_NFS_V4 */ #endif /* CONFIG_NFS_V4 */
struct nfstime4 { struct nfstime4 {
...@@ -1040,6 +1102,7 @@ struct nfs_write_data { ...@@ -1040,6 +1102,7 @@ struct nfs_write_data {
struct nfs_writeres res; /* result struct */ struct nfs_writeres res; /* result struct */
struct pnfs_layout_segment *lseg; struct pnfs_layout_segment *lseg;
struct nfs_client *ds_clp; /* pNFS data server */ struct nfs_client *ds_clp; /* pNFS data server */
int ds_commit_index;
const struct rpc_call_ops *mds_ops; const struct rpc_call_ops *mds_ops;
int (*write_done_cb) (struct rpc_task *task, struct nfs_write_data *data); int (*write_done_cb) (struct rpc_task *task, struct nfs_write_data *data);
#ifdef CONFIG_NFS_V4 #ifdef CONFIG_NFS_V4
...@@ -1071,7 +1134,7 @@ struct nfs_rpc_ops { ...@@ -1071,7 +1134,7 @@ struct nfs_rpc_ops {
struct nfs_fattr *); struct nfs_fattr *);
int (*setattr) (struct dentry *, struct nfs_fattr *, int (*setattr) (struct dentry *, struct nfs_fattr *,
struct iattr *); struct iattr *);
int (*lookup) (struct inode *, struct qstr *, int (*lookup) (struct rpc_clnt *clnt, struct inode *, struct qstr *,
struct nfs_fh *, struct nfs_fattr *); struct nfs_fh *, struct nfs_fattr *);
int (*access) (struct inode *, struct nfs_access_entry *); int (*access) (struct inode *, struct nfs_access_entry *);
int (*readlink)(struct inode *, struct page *, unsigned int, int (*readlink)(struct inode *, struct page *, unsigned int,
...@@ -1118,6 +1181,7 @@ struct nfs_rpc_ops { ...@@ -1118,6 +1181,7 @@ struct nfs_rpc_ops {
struct iattr *iattr); struct iattr *iattr);
int (*init_client) (struct nfs_client *, const struct rpc_timeout *, int (*init_client) (struct nfs_client *, const struct rpc_timeout *,
const char *, rpc_authflavor_t, int); const char *, rpc_authflavor_t, int);
int (*secinfo)(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
}; };
/* /*
......
...@@ -126,6 +126,9 @@ struct gss_api_mech *gss_mech_get_by_name(const char *); ...@@ -126,6 +126,9 @@ struct gss_api_mech *gss_mech_get_by_name(const char *);
/* Similar, but get by pseudoflavor. */ /* Similar, but get by pseudoflavor. */
struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32); struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32);
/* Fill in an array with a list of supported pseudoflavors */
int gss_mech_list_pseudoflavors(u32 *);
/* Just increments the mechanism's reference count and returns its input: */ /* Just increments the mechanism's reference count and returns its input: */
struct gss_api_mech * gss_mech_get(struct gss_api_mech *); struct gss_api_mech * gss_mech_get(struct gss_api_mech *);
......
...@@ -160,6 +160,28 @@ gss_mech_get_by_name(const char *name) ...@@ -160,6 +160,28 @@ gss_mech_get_by_name(const char *name)
EXPORT_SYMBOL_GPL(gss_mech_get_by_name); EXPORT_SYMBOL_GPL(gss_mech_get_by_name);
struct gss_api_mech *
gss_mech_get_by_OID(struct xdr_netobj *obj)
{
struct gss_api_mech *pos, *gm = NULL;
spin_lock(&registered_mechs_lock);
list_for_each_entry(pos, &registered_mechs, gm_list) {
if (obj->len == pos->gm_oid.len) {
if (0 == memcmp(obj->data, pos->gm_oid.data, obj->len)) {
if (try_module_get(pos->gm_owner))
gm = pos;
break;
}
}
}
spin_unlock(&registered_mechs_lock);
return gm;
}
EXPORT_SYMBOL_GPL(gss_mech_get_by_OID);
static inline int static inline int
mech_supports_pseudoflavor(struct gss_api_mech *gm, u32 pseudoflavor) mech_supports_pseudoflavor(struct gss_api_mech *gm, u32 pseudoflavor)
{ {
...@@ -193,6 +215,22 @@ gss_mech_get_by_pseudoflavor(u32 pseudoflavor) ...@@ -193,6 +215,22 @@ gss_mech_get_by_pseudoflavor(u32 pseudoflavor)
EXPORT_SYMBOL_GPL(gss_mech_get_by_pseudoflavor); EXPORT_SYMBOL_GPL(gss_mech_get_by_pseudoflavor);
int gss_mech_list_pseudoflavors(rpc_authflavor_t *array_ptr)
{
struct gss_api_mech *pos = NULL;
int i = 0;
spin_lock(&registered_mechs_lock);
list_for_each_entry(pos, &registered_mechs, gm_list) {
array_ptr[i] = pos->gm_pfs->pseudoflavor;
i++;
}
spin_unlock(&registered_mechs_lock);
return i;
}
EXPORT_SYMBOL_GPL(gss_mech_list_pseudoflavors);
u32 u32
gss_svc_to_pseudoflavor(struct gss_api_mech *gm, u32 service) gss_svc_to_pseudoflavor(struct gss_api_mech *gm, u32 service)
{ {
......
...@@ -710,6 +710,8 @@ static void xs_reset_transport(struct sock_xprt *transport) ...@@ -710,6 +710,8 @@ static void xs_reset_transport(struct sock_xprt *transport)
if (sk == NULL) if (sk == NULL)
return; return;
transport->srcport = 0;
write_lock_bh(&sk->sk_callback_lock); write_lock_bh(&sk->sk_callback_lock);
transport->inet = NULL; transport->inet = NULL;
transport->sock = NULL; transport->sock = NULL;
......
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