NFS: Add support for SEEK_HOLE and SEEK_DATA
Subsystems (2)
PATCH v2 1/1 NFS: Add support for SEEK_HOLE and SEEK_DATA
This patch should be applied after the matching NFSD patch series (NFSD: Implement SEEK) and only includes the SEEK patch from my earlier WRITE_PLUS / SEEK submission.
Questions? Comments? Thoughts?
Anna
Anna Schumaker (1):
NFS: Implement SEEK
fs/nfs/inode.c | 2 + fs/nfs/nfs4_fs.h | 4 ++ fs/nfs/nfs4file.c | 61 +++++++++++++++++++++++++++ fs/nfs/nfs4proc.c | 31 ++++++++++++++ fs/nfs/nfs4xdr.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/nfs4.h | 3 ++ include/linux/nfs_xdr.h | 22 ++++++++++ 7 files changed, 232 insertions(+)
Signature · 1 line
1.8.4.2
PATCH v2 1/1 NFS: Implement SEEK
The SEEK operation is used when an application makes an lseek call with either the SEEK_HOLE or SEEK_DATA flags set. I fall back on nfs_file_llseek() when other flags are set or in the NFS < 4.2 case.
Signed-off-by Anna Schumaker <[email protected]>
---
Changed in v2:
- Remove unnecessary return from nfs4_xdr_enc_seek()
fs/nfs/inode.c | 2 + fs/nfs/nfs4_fs.h | 4 ++ fs/nfs/nfs4file.c | 61 +++++++++++++++++++++++++++ fs/nfs/nfs4proc.c | 31 ++++++++++++++ fs/nfs/nfs4xdr.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/nfs4.h | 3 ++ include/linux/nfs_xdr.h | 22 ++++++++++ 7 files changed, 232 insertions(+)
fs/nfs/inode.c +2 -0
@@ -680,6 +680,7 @@ struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx)kfree (new);return res; } +EXPORT_SYMBOL_GPL (nfs_get_lock_context);void nfs_put_lock_context (struct nfs_lock_context *l_ctx) {
@@ -692,6 +693,7 @@ void nfs_put_lock_context(struct nfs_lock_context *l_ctx)spin_unlock (&inode->i_lock);kfree (l_ctx); } +EXPORT_SYMBOL_GPL (nfs_put_lock_context);/** * nfs_close_context - Common close_context() routine NFSv2/v3
fs/nfs/nfs4_fs.h +4 -0
@@ -365,6 +365,10 @@ nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp, }#endif /* CONFIG_NFS_V4_1 */ +#ifdef CONFIG_NFS_V4_2 +loff_t nfs42_proc_llseek (struct inode *,nfs4_stateid *,loff_t ,int ); +#endif /* CONFIG_NFS_V4_2 */ +extern const struct nfs4_minor_version_ops *nfs_v4_minor_ops[];extern const u32 nfs4_fattr_bitmap[3 ];
fs/nfs/nfs4file.c +61 -0
69 lines not on this page · raw message
fs/nfs/nfs4proc.c +31 -0
@@ -8163,6 +8163,37 @@ static bool nfs41_match_stateid(const nfs4_stateid *s1,#endif /* CONFIG_NFS_V4_1 */ +#ifdef CONFIG_NFS_V4_2 +loff_t nfs42_proc_llseek (struct inode *inode,nfs4_stateid *stateid, +loff_t offset,int whence) +{ +struct nfs42_seek_args args = { + .sa_fh =NFS_FH (inode), + .sa_stateid = stateid, + .sa_offset = offset, + }; +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 (whence ==SEEK_HOLE ) + args.sa_what =NFS4_CONTENT_HOLE ; +else + args.sa_what =NFS4_CONTENT_DATA ; + + status =nfs4_call_sync (server->client, server, &msg, + &args.seq_args, &res.seq_res,0 ); +if (status) +return status; +return res.sr_offset; +} +#endif /* CONFIG_NFS_V4_2 */ +static bool nfs4_match_stateid (const nfs4_stateid *s1,const nfs4_stateid *s2) {
fs/nfs/nfs4xdr.c +109 -0
151 lines not on this page · raw message
include/linux/nfs4.h +3 -0
@@ -493,6 +493,9 @@ enum {NFSPROC4_CLNT_GETDEVICELIST ,NFSPROC4_CLNT_BIND_CONN_TO_SESSION ,NFSPROC4_CLNT_DESTROY_CLIENTID , + +/* nfs42 */ + NFSPROC4_CLNT_SEEK, };/* nfs41 types */
include/linux/nfs_xdr.h +22 -0
@@ -1247,6 +1247,28 @@ struct pnfs_ds_commit_info {#endif /* CONFIG_NFS_V4_1 */ +#ifdef CONFIG_NFS_V4_2 +struct nfs42_seek_args { +struct nfs4_sequence_args seq_args; + +struct nfs_fh *sa_fh; +nfs4_stateid *sa_stateid; +u64 sa_offset; +u32 sa_what; +}; + +struct nfs42_seek_res { +struct nfs4_sequence_res seq_res; +unsigned int status; + +u32 sr_eof; +u32 sr_whence; +u64 sr_offset; +u64 sr_length; +u32 sr_allocated; +}; +#endif +struct nfs_page ;#define NFS_PAGEVEC_SIZE (8U)
Signature · 1 line
1.8.4.2