forked from grate-driver/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'nfs-for-3.18-2' of git://git.linux-nfs.org/projects/trondm…
…y/linux-nfs Pull NFS client updates from Trond Myklebust: "Highlights include: Stable fixes: - fix an uninitialised pointer Oops in the writeback error path - fix a bogus warning (and early exit from the loop) in nfs_generic_pgio() Features: - Add NFSv4.2 SEEK feature and client support for lseek(SEEK_HOLE/SEEK_DATA) Other fixes: - pnfs: replace broken pnfs_put_lseg_async - Remove dead prototype for nfs4_insert_deviceid_node" * tag 'nfs-for-3.18-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: NFS: Fix a bogus warning in nfs_generic_pgio NFS: Fix an uninitialised pointer Oops in the writeback error path NFSv4.1/pnfs: replace broken pnfs_put_lseg_async NFSv4: Remove dead prototype for nfs4_insert_deviceid_node() NFS: Implement SEEK
- Loading branch information
Showing
16 changed files
with
278 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com> | ||
*/ | ||
|
||
#ifndef __LINUX_FS_NFS_NFS4_2_H | ||
#define __LINUX_FS_NFS_NFS4_2_H | ||
|
||
/* nfs4.2proc.c */ | ||
loff_t nfs42_proc_llseek(struct file *, loff_t, int); | ||
|
||
/* nfs4.2xdr.h */ | ||
extern struct rpc_procinfo nfs4_2_procedures[]; | ||
|
||
#endif /* __LINUX_FS_NFS_NFS4_2_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com> | ||
*/ | ||
#include <linux/fs.h> | ||
#include <linux/sunrpc/sched.h> | ||
#include <linux/nfs.h> | ||
#include <linux/nfs3.h> | ||
#include <linux/nfs4.h> | ||
#include <linux/nfs_xdr.h> | ||
#include <linux/nfs_fs.h> | ||
#include "nfs4_fs.h" | ||
#include "nfs42.h" | ||
|
||
static int nfs42_set_rw_stateid(nfs4_stateid *dst, struct file *file, | ||
fmode_t fmode) | ||
{ | ||
struct nfs_open_context *open; | ||
struct nfs_lock_context *lock; | ||
int ret; | ||
|
||
open = get_nfs_open_context(nfs_file_open_context(file)); | ||
lock = nfs_get_lock_context(open); | ||
if (IS_ERR(lock)) { | ||
put_nfs_open_context(open); | ||
return PTR_ERR(lock); | ||
} | ||
|
||
ret = nfs4_set_rw_stateid(dst, open, lock, fmode); | ||
|
||
nfs_put_lock_context(lock); | ||
put_nfs_open_context(open); | ||
return ret; | ||
} | ||
|
||
loff_t nfs42_proc_llseek(struct file *filep, loff_t offset, int whence) | ||
{ | ||
struct inode *inode = file_inode(filep); | ||
struct nfs42_seek_args args = { | ||
.sa_fh = NFS_FH(inode), | ||
.sa_offset = offset, | ||
.sa_what = (whence == SEEK_HOLE) ? | ||
NFS4_CONTENT_HOLE : NFS4_CONTENT_DATA, | ||
}; | ||
struct nfs42_seek_res res; | ||
struct rpc_message msg = { | ||
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SEEK], | ||
.rpc_argp = &args, | ||
.rpc_resp = &res, | ||
}; | ||
struct nfs_server *server = NFS_SERVER(inode); | ||
int status; | ||
|
||
if (!(server->caps & NFS_CAP_SEEK)) | ||
return -ENOTSUPP; | ||
|
||
status = nfs42_set_rw_stateid(&args.sa_stateid, filep, FMODE_READ); | ||
if (status) | ||
return status; | ||
|
||
nfs_wb_all(inode); | ||
status = nfs4_call_sync(server->client, server, &msg, | ||
&args.seq_args, &res.seq_res, 0); | ||
if (status == -ENOTSUPP) | ||
server->caps &= ~NFS_CAP_SEEK; | ||
if (status) | ||
return status; | ||
|
||
return vfs_setpos(filep, res.sr_offset, inode->i_sb->s_maxbytes); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com> | ||
*/ | ||
#ifndef __LINUX_FS_NFS_NFS4_2XDR_H | ||
#define __LINUX_FS_NFS_NFS4_2XDR_H | ||
|
||
#define encode_seek_maxsz (op_encode_hdr_maxsz + \ | ||
encode_stateid_maxsz + \ | ||
2 /* offset */ + \ | ||
1 /* whence */) | ||
#define decode_seek_maxsz (op_decode_hdr_maxsz + \ | ||
1 /* eof */ + \ | ||
1 /* whence */ + \ | ||
2 /* offset */ + \ | ||
2 /* length */) | ||
|
||
#define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \ | ||
encode_putfh_maxsz + \ | ||
encode_seek_maxsz) | ||
#define NFS4_dec_seek_sz (compound_decode_hdr_maxsz + \ | ||
decode_putfh_maxsz + \ | ||
decode_seek_maxsz) | ||
|
||
|
||
static void encode_seek(struct xdr_stream *xdr, | ||
struct nfs42_seek_args *args, | ||
struct compound_hdr *hdr) | ||
{ | ||
encode_op_hdr(xdr, OP_SEEK, decode_seek_maxsz, hdr); | ||
encode_nfs4_stateid(xdr, &args->sa_stateid); | ||
encode_uint64(xdr, args->sa_offset); | ||
encode_uint32(xdr, args->sa_what); | ||
} | ||
|
||
/* | ||
* Encode SEEK request | ||
*/ | ||
static void nfs4_xdr_enc_seek(struct rpc_rqst *req, | ||
struct xdr_stream *xdr, | ||
struct nfs42_seek_args *args) | ||
{ | ||
struct compound_hdr hdr = { | ||
.minorversion = nfs4_xdr_minorversion(&args->seq_args), | ||
}; | ||
|
||
encode_compound_hdr(xdr, req, &hdr); | ||
encode_sequence(xdr, &args->seq_args, &hdr); | ||
encode_putfh(xdr, args->sa_fh, &hdr); | ||
encode_seek(xdr, args, &hdr); | ||
encode_nops(&hdr); | ||
} | ||
|
||
static int decode_seek(struct xdr_stream *xdr, struct nfs42_seek_res *res) | ||
{ | ||
int status; | ||
__be32 *p; | ||
|
||
status = decode_op_hdr(xdr, OP_SEEK); | ||
if (status) | ||
return status; | ||
|
||
p = xdr_inline_decode(xdr, 4 + 8); | ||
if (unlikely(!p)) | ||
goto out_overflow; | ||
|
||
res->sr_eof = be32_to_cpup(p++); | ||
p = xdr_decode_hyper(p, &res->sr_offset); | ||
return 0; | ||
|
||
out_overflow: | ||
print_overflow_msg(__func__, xdr); | ||
return -EIO; | ||
} | ||
|
||
/* | ||
* Decode SEEK request | ||
*/ | ||
static int nfs4_xdr_dec_seek(struct rpc_rqst *rqstp, | ||
struct xdr_stream *xdr, | ||
struct nfs42_seek_res *res) | ||
{ | ||
struct compound_hdr hdr; | ||
int status; | ||
|
||
status = decode_compound_hdr(xdr, &hdr); | ||
if (status) | ||
goto out; | ||
status = decode_sequence(xdr, &res->seq_res, rqstp); | ||
if (status) | ||
goto out; | ||
status = decode_putfh(xdr); | ||
if (status) | ||
goto out; | ||
status = decode_seek(xdr, res); | ||
out: | ||
return status; | ||
} | ||
#endif /* __LINUX_FS_NFS_NFS4_2XDR_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.