Commit 08dffcc7 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'nfsd-5.6' of git://linux-nfs.org/~bfields/linux

Pull nfsd updates from Bruce Fields:
 "Highlights:

   - Server-to-server copy code from Olga.

     To use it, client and both servers must have support, the target
     server must be able to access the source server over NFSv4.2, and
     the target server must have the inter_copy_offload_enable module
     parameter set.

   - Improvements and bugfixes for the new filehandle cache, especially
     in the container case, from Trond

   - Also from Trond, better reporting of write errors.

   - Y2038 work from Arnd"

* tag 'nfsd-5.6' of git://linux-nfs.org/~bfields/linux: (55 commits)
  sunrpc: expiry_time should be seconds not timeval
  nfsd: make nfsd_filecache_wq variable static
  nfsd4: fix double free in nfsd4_do_async_copy()
  nfsd: convert file cache to use over/underflow safe refcount
  nfsd: Define the file access mode enum for tracing
  nfsd: Fix a perf warning
  nfsd: Ensure sampling of the write verifier is atomic with the write
  nfsd: Ensure sampling of the commit verifier is atomic with the commit
  sunrpc: clean up cache entry add/remove from hashtable
  sunrpc: Fix potential leaks in sunrpc_cache_unhash()
  nfsd: Ensure exclusion between CLONE and WRITE errors
  nfsd: Pass the nfsd_file as arguments to nfsd4_clone_file_range()
  nfsd: Update the boot verifier on stable writes too.
  nfsd: Fix stable writes
  nfsd: Allow nfsd_vfs_write() to take the nfsd_file as an argument
  nfsd: Fix a soft lockup race in nfsd_file_mark_find_or_create()
  nfsd: Reduce the number of calls to nfsd_file_gc()
  nfsd: Schedule the laundrette regularly irrespective of file errors
  nfsd: Remove unused constant NFSD_FILE_LRU_RESCAN
  nfsd: Containerise filecache laundrette
  ...
parents f43574d0 3d96208c
...@@ -134,6 +134,16 @@ config NFSD_FLEXFILELAYOUT ...@@ -134,6 +134,16 @@ config NFSD_FLEXFILELAYOUT
If unsure, say N. If unsure, say N.
config NFSD_V4_2_INTER_SSC
bool "NFSv4.2 inter server to server COPY"
depends on NFSD_V4 && NFS_V4_1 && NFS_V4_2
help
This option enables support for NFSv4.2 inter server to
server copy where the destination server calls the NFSv4.2
client to read the data to copy from the source server.
If unsure, say N.
config NFSD_V4_SECURITY_LABEL config NFSD_V4_SECURITY_LABEL
bool "Provide Security Label support for NFSv4 server" bool "Provide Security Label support for NFSv4 server"
depends on NFSD_V4 && SECURITY depends on NFSD_V4 && SECURITY
......
This diff is collapsed.
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
*/ */
struct nfsd_file_mark { struct nfsd_file_mark {
struct fsnotify_mark nfm_mark; struct fsnotify_mark nfm_mark;
atomic_t nfm_ref; refcount_t nfm_ref;
}; };
/* /*
...@@ -43,14 +43,17 @@ struct nfsd_file { ...@@ -43,14 +43,17 @@ struct nfsd_file {
unsigned long nf_flags; unsigned long nf_flags;
struct inode *nf_inode; struct inode *nf_inode;
unsigned int nf_hashval; unsigned int nf_hashval;
atomic_t nf_ref; refcount_t nf_ref;
unsigned char nf_may; unsigned char nf_may;
struct nfsd_file_mark *nf_mark; struct nfsd_file_mark *nf_mark;
struct rw_semaphore nf_rwsem;
}; };
int nfsd_file_cache_init(void); int nfsd_file_cache_init(void);
void nfsd_file_cache_purge(struct net *); void nfsd_file_cache_purge(struct net *);
void nfsd_file_cache_shutdown(void); void nfsd_file_cache_shutdown(void);
int nfsd_file_cache_start_net(struct net *net);
void nfsd_file_cache_shutdown_net(struct net *net);
void nfsd_file_put(struct nfsd_file *nf); void nfsd_file_put(struct nfsd_file *nf);
struct nfsd_file *nfsd_file_get(struct nfsd_file *nf); struct nfsd_file *nfsd_file_get(struct nfsd_file *nf);
void nfsd_file_close_inode_sync(struct inode *inode); void nfsd_file_close_inode_sync(struct inode *inode);
......
...@@ -40,7 +40,7 @@ struct nfsd_net { ...@@ -40,7 +40,7 @@ struct nfsd_net {
struct lock_manager nfsd4_manager; struct lock_manager nfsd4_manager;
bool grace_ended; bool grace_ended;
time_t boot_time; time64_t boot_time;
/* internal mount of the "nfsd" pseudofilesystem: */ /* internal mount of the "nfsd" pseudofilesystem: */
struct vfsmount *nfsd_mnt; struct vfsmount *nfsd_mnt;
...@@ -92,8 +92,8 @@ struct nfsd_net { ...@@ -92,8 +92,8 @@ struct nfsd_net {
bool in_grace; bool in_grace;
const struct nfsd4_client_tracking_ops *client_tracking_ops; const struct nfsd4_client_tracking_ops *client_tracking_ops;
time_t nfsd4_lease; time64_t nfsd4_lease;
time_t nfsd4_grace; time64_t nfsd4_grace;
bool somebody_reclaimed; bool somebody_reclaimed;
bool track_reclaim_completes; bool track_reclaim_completes;
......
...@@ -203,7 +203,7 @@ nfsd3_proc_write(struct svc_rqst *rqstp) ...@@ -203,7 +203,7 @@ nfsd3_proc_write(struct svc_rqst *rqstp)
RETURN_STATUS(nfserr_io); RETURN_STATUS(nfserr_io);
nfserr = nfsd_write(rqstp, &resp->fh, argp->offset, nfserr = nfsd_write(rqstp, &resp->fh, argp->offset,
rqstp->rq_vec, nvecs, &cnt, rqstp->rq_vec, nvecs, &cnt,
resp->committed); resp->committed, resp->verf);
resp->count = cnt; resp->count = cnt;
RETURN_STATUS(nfserr); RETURN_STATUS(nfserr);
} }
...@@ -683,7 +683,8 @@ nfsd3_proc_commit(struct svc_rqst *rqstp) ...@@ -683,7 +683,8 @@ nfsd3_proc_commit(struct svc_rqst *rqstp)
RETURN_STATUS(nfserr_inval); RETURN_STATUS(nfserr_inval);
fh_copy(&resp->fh, &argp->fh); fh_copy(&resp->fh, &argp->fh);
nfserr = nfsd_commit(rqstp, &resp->fh, argp->offset, argp->count); nfserr = nfsd_commit(rqstp, &resp->fh, argp->offset, argp->count,
resp->verf);
RETURN_STATUS(nfserr); RETURN_STATUS(nfserr);
} }
......
...@@ -32,14 +32,14 @@ static u32 nfs3_ftypes[] = { ...@@ -32,14 +32,14 @@ static u32 nfs3_ftypes[] = {
* XDR functions for basic NFS types * XDR functions for basic NFS types
*/ */
static __be32 * static __be32 *
encode_time3(__be32 *p, struct timespec *time) encode_time3(__be32 *p, struct timespec64 *time)
{ {
*p++ = htonl((u32) time->tv_sec); *p++ = htonl(time->tv_nsec); *p++ = htonl((u32) time->tv_sec); *p++ = htonl(time->tv_nsec);
return p; return p;
} }
static __be32 * static __be32 *
decode_time3(__be32 *p, struct timespec *time) decode_time3(__be32 *p, struct timespec64 *time)
{ {
time->tv_sec = ntohl(*p++); time->tv_sec = ntohl(*p++);
time->tv_nsec = ntohl(*p++); time->tv_nsec = ntohl(*p++);
...@@ -167,7 +167,6 @@ encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, ...@@ -167,7 +167,6 @@ encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
struct kstat *stat) struct kstat *stat)
{ {
struct user_namespace *userns = nfsd_user_namespace(rqstp); struct user_namespace *userns = nfsd_user_namespace(rqstp);
struct timespec ts;
*p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]); *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
*p++ = htonl((u32) (stat->mode & S_IALLUGO)); *p++ = htonl((u32) (stat->mode & S_IALLUGO));
*p++ = htonl((u32) stat->nlink); *p++ = htonl((u32) stat->nlink);
...@@ -183,12 +182,9 @@ encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, ...@@ -183,12 +182,9 @@ encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
*p++ = htonl((u32) MINOR(stat->rdev)); *p++ = htonl((u32) MINOR(stat->rdev));
p = encode_fsid(p, fhp); p = encode_fsid(p, fhp);
p = xdr_encode_hyper(p, stat->ino); p = xdr_encode_hyper(p, stat->ino);
ts = timespec64_to_timespec(stat->atime); p = encode_time3(p, &stat->atime);
p = encode_time3(p, &ts); p = encode_time3(p, &stat->mtime);
ts = timespec64_to_timespec(stat->mtime); p = encode_time3(p, &stat->ctime);
p = encode_time3(p, &ts);
ts = timespec64_to_timespec(stat->ctime);
p = encode_time3(p, &ts);
return p; return p;
} }
...@@ -277,8 +273,8 @@ void fill_pre_wcc(struct svc_fh *fhp) ...@@ -277,8 +273,8 @@ void fill_pre_wcc(struct svc_fh *fhp)
stat.size = inode->i_size; stat.size = inode->i_size;
} }
fhp->fh_pre_mtime = timespec64_to_timespec(stat.mtime); fhp->fh_pre_mtime = stat.mtime;
fhp->fh_pre_ctime = timespec64_to_timespec(stat.ctime); fhp->fh_pre_ctime = stat.ctime;
fhp->fh_pre_size = stat.size; fhp->fh_pre_size = stat.size;
fhp->fh_pre_change = nfsd4_change_attribute(&stat, inode); fhp->fh_pre_change = nfsd4_change_attribute(&stat, inode);
fhp->fh_pre_saved = true; fhp->fh_pre_saved = true;
...@@ -330,7 +326,7 @@ nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, __be32 *p) ...@@ -330,7 +326,7 @@ nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, __be32 *p)
p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp)); p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp));
if ((args->check_guard = ntohl(*p++)) != 0) { if ((args->check_guard = ntohl(*p++)) != 0) {
struct timespec time; struct timespec64 time;
p = decode_time3(p, &time); p = decode_time3(p, &time);
args->guardtime = time.tv_sec; args->guardtime = time.tv_sec;
} }
...@@ -751,17 +747,13 @@ int ...@@ -751,17 +747,13 @@ int
nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p) nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p)
{ {
struct nfsd3_writeres *resp = rqstp->rq_resp; struct nfsd3_writeres *resp = rqstp->rq_resp;
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
__be32 verf[2];
p = encode_wcc_data(rqstp, p, &resp->fh); p = encode_wcc_data(rqstp, p, &resp->fh);
if (resp->status == 0) { if (resp->status == 0) {
*p++ = htonl(resp->count); *p++ = htonl(resp->count);
*p++ = htonl(resp->committed); *p++ = htonl(resp->committed);
/* unique identifier, y2038 overflow can be ignored */ *p++ = resp->verf[0];
nfsd_copy_boot_verifier(verf, nn); *p++ = resp->verf[1];
*p++ = verf[0];
*p++ = verf[1];
} }
return xdr_ressize_check(rqstp, p); return xdr_ressize_check(rqstp, p);
} }
...@@ -1125,16 +1117,12 @@ int ...@@ -1125,16 +1117,12 @@ int
nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p) nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p)
{ {
struct nfsd3_commitres *resp = rqstp->rq_resp; struct nfsd3_commitres *resp = rqstp->rq_resp;
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
__be32 verf[2];
p = encode_wcc_data(rqstp, p, &resp->fh); p = encode_wcc_data(rqstp, p, &resp->fh);
/* Write verifier */ /* Write verifier */
if (resp->status == 0) { if (resp->status == 0) {
/* unique identifier, y2038 overflow can be ignored */ *p++ = resp->verf[0];
nfsd_copy_boot_verifier(verf, nn); *p++ = resp->verf[1];
*p++ = verf[0];
*p++ = verf[1];
} }
return xdr_ressize_check(rqstp, p); return xdr_ressize_check(rqstp, p);
} }
......
...@@ -823,7 +823,16 @@ static const struct rpc_program cb_program = { ...@@ -823,7 +823,16 @@ static const struct rpc_program cb_program = {
static int max_cb_time(struct net *net) static int max_cb_time(struct net *net)
{ {
struct nfsd_net *nn = net_generic(net, nfsd_net_id); struct nfsd_net *nn = net_generic(net, nfsd_net_id);
return max(nn->nfsd4_lease/10, (time_t)1) * HZ;
/*
* nfsd4_lease is set to at most one hour in __nfsd4_write_time,
* so we can use 32-bit math on it. Warn if that assumption
* ever stops being true.
*/
if (WARN_ON_ONCE(nn->nfsd4_lease > 3600))
return 360 * HZ;
return max(((u32)nn->nfsd4_lease)/10, 1u) * HZ;
} }
static struct workqueue_struct *callback_wq; static struct workqueue_struct *callback_wq;
......
...@@ -675,7 +675,7 @@ nfsd4_cb_layout_done(struct nfsd4_callback *cb, struct rpc_task *task) ...@@ -675,7 +675,7 @@ nfsd4_cb_layout_done(struct nfsd4_callback *cb, struct rpc_task *task)
/* Client gets 2 lease periods to return it */ /* Client gets 2 lease periods to return it */
cutoff = ktime_add_ns(task->tk_start, cutoff = ktime_add_ns(task->tk_start,
nn->nfsd4_lease * NSEC_PER_SEC * 2); (u64)nn->nfsd4_lease * NSEC_PER_SEC * 2);
if (ktime_before(now, cutoff)) { if (ktime_before(now, cutoff)) {
rpc_delay(task, HZ/100); /* 10 mili-seconds */ rpc_delay(task, HZ/100); /* 10 mili-seconds */
......
This diff is collapsed.
...@@ -1445,7 +1445,7 @@ nfsd4_cld_grace_done_v0(struct nfsd_net *nn) ...@@ -1445,7 +1445,7 @@ nfsd4_cld_grace_done_v0(struct nfsd_net *nn)
} }
cup->cu_u.cu_msg.cm_cmd = Cld_GraceDone; cup->cu_u.cu_msg.cm_cmd = Cld_GraceDone;
cup->cu_u.cu_msg.cm_u.cm_gracetime = (int64_t)nn->boot_time; cup->cu_u.cu_msg.cm_u.cm_gracetime = nn->boot_time;
ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg); ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg);
if (!ret) if (!ret)
ret = cup->cu_u.cu_msg.cm_status; ret = cup->cu_u.cu_msg.cm_status;
...@@ -1782,7 +1782,7 @@ nfsd4_cltrack_client_has_session(struct nfs4_client *clp) ...@@ -1782,7 +1782,7 @@ nfsd4_cltrack_client_has_session(struct nfs4_client *clp)
} }
static char * static char *
nfsd4_cltrack_grace_start(time_t grace_start) nfsd4_cltrack_grace_start(time64_t grace_start)
{ {
int copied; int copied;
size_t len; size_t len;
...@@ -1795,7 +1795,7 @@ nfsd4_cltrack_grace_start(time_t grace_start) ...@@ -1795,7 +1795,7 @@ nfsd4_cltrack_grace_start(time_t grace_start)
if (!result) if (!result)
return result; return result;
copied = snprintf(result, len, GRACE_START_ENV_PREFIX "%ld", copied = snprintf(result, len, GRACE_START_ENV_PREFIX "%lld",
grace_start); grace_start);
if (copied >= len) { if (copied >= len) {
/* just return nothing if output was truncated */ /* just return nothing if output was truncated */
...@@ -2004,7 +2004,7 @@ nfsd4_umh_cltrack_grace_done(struct nfsd_net *nn) ...@@ -2004,7 +2004,7 @@ nfsd4_umh_cltrack_grace_done(struct nfsd_net *nn)
char *legacy; char *legacy;
char timestr[22]; /* FIXME: better way to determine max size? */ char timestr[22]; /* FIXME: better way to determine max size? */
sprintf(timestr, "%ld", nn->boot_time); sprintf(timestr, "%lld", nn->boot_time);
legacy = nfsd4_cltrack_legacy_topdir(); legacy = nfsd4_cltrack_legacy_topdir();
nfsd4_umh_cltrack_upcall("gracedone", timestr, legacy, NULL); nfsd4_umh_cltrack_upcall("gracedone", timestr, legacy, NULL);
kfree(legacy); kfree(legacy);
......
This diff is collapsed.
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <linux/utsname.h> #include <linux/utsname.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/sunrpc/svcauth_gss.h> #include <linux/sunrpc/svcauth_gss.h>
#include <linux/sunrpc/addr.h>
#include "idmap.h" #include "idmap.h"
#include "acl.h" #include "acl.h"
...@@ -1744,10 +1745,47 @@ nfsd4_decode_clone(struct nfsd4_compoundargs *argp, struct nfsd4_clone *clone) ...@@ -1744,10 +1745,47 @@ nfsd4_decode_clone(struct nfsd4_compoundargs *argp, struct nfsd4_clone *clone)
DECODE_TAIL; DECODE_TAIL;
} }
static __be32 nfsd4_decode_nl4_server(struct nfsd4_compoundargs *argp,
struct nl4_server *ns)
{
DECODE_HEAD;
struct nfs42_netaddr *naddr;
READ_BUF(4);
ns->nl4_type = be32_to_cpup(p++);
/* currently support for 1 inter-server source server */
switch (ns->nl4_type) {
case NL4_NETADDR:
naddr = &ns->u.nl4_addr;
READ_BUF(4);
naddr->netid_len = be32_to_cpup(p++);
if (naddr->netid_len > RPCBIND_MAXNETIDLEN)
goto xdr_error;
READ_BUF(naddr->netid_len + 4); /* 4 for uaddr len */
COPYMEM(naddr->netid, naddr->netid_len);
naddr->addr_len = be32_to_cpup(p++);
if (naddr->addr_len > RPCBIND_MAXUADDRLEN)
goto xdr_error;
READ_BUF(naddr->addr_len);
COPYMEM(naddr->addr, naddr->addr_len);
break;
default:
goto xdr_error;
}
DECODE_TAIL;
}
static __be32 static __be32
nfsd4_decode_copy(struct nfsd4_compoundargs *argp, struct nfsd4_copy *copy) nfsd4_decode_copy(struct nfsd4_compoundargs *argp, struct nfsd4_copy *copy)
{ {
DECODE_HEAD; DECODE_HEAD;
struct nl4_server *ns_dummy;
int i, count;
status = nfsd4_decode_stateid(argp, &copy->cp_src_stateid); status = nfsd4_decode_stateid(argp, &copy->cp_src_stateid);
if (status) if (status)
...@@ -1762,7 +1800,32 @@ nfsd4_decode_copy(struct nfsd4_compoundargs *argp, struct nfsd4_copy *copy) ...@@ -1762,7 +1800,32 @@ nfsd4_decode_copy(struct nfsd4_compoundargs *argp, struct nfsd4_copy *copy)
p = xdr_decode_hyper(p, &copy->cp_count); p = xdr_decode_hyper(p, &copy->cp_count);
p++; /* ca_consecutive: we always do consecutive copies */ p++; /* ca_consecutive: we always do consecutive copies */
copy->cp_synchronous = be32_to_cpup(p++); copy->cp_synchronous = be32_to_cpup(p++);
/* tmp = be32_to_cpup(p); Source server list not supported */
count = be32_to_cpup(p++);
copy->cp_intra = false;
if (count == 0) { /* intra-server copy */
copy->cp_intra = true;
goto intra;
}
/* decode all the supplied server addresses but use first */
status = nfsd4_decode_nl4_server(argp, &copy->cp_src);
if (status)
return status;
ns_dummy = kmalloc(sizeof(struct nl4_server), GFP_KERNEL);
if (ns_dummy == NULL)
return nfserrno(-ENOMEM);
for (i = 0; i < count - 1; i++) {
status = nfsd4_decode_nl4_server(argp, ns_dummy);
if (status) {
kfree(ns_dummy);
return status;
}
}
kfree(ns_dummy);
intra:
DECODE_TAIL; DECODE_TAIL;
} }
...@@ -1774,6 +1837,18 @@ nfsd4_decode_offload_status(struct nfsd4_compoundargs *argp, ...@@ -1774,6 +1837,18 @@ nfsd4_decode_offload_status(struct nfsd4_compoundargs *argp,
return nfsd4_decode_stateid(argp, &os->stateid); return nfsd4_decode_stateid(argp, &os->stateid);
} }
static __be32
nfsd4_decode_copy_notify(struct nfsd4_compoundargs *argp,
struct nfsd4_copy_notify *cn)
{
int status;
status = nfsd4_decode_stateid(argp, &cn->cpn_src_stateid);
if (status)
return status;
return nfsd4_decode_nl4_server(argp, &cn->cpn_dst);
}
static __be32 static __be32
nfsd4_decode_seek(struct nfsd4_compoundargs *argp, struct nfsd4_seek *seek) nfsd4_decode_seek(struct nfsd4_compoundargs *argp, struct nfsd4_seek *seek)
{ {
...@@ -1875,7 +1950,7 @@ static const nfsd4_dec nfsd4_dec_ops[] = { ...@@ -1875,7 +1950,7 @@ static const nfsd4_dec nfsd4_dec_ops[] = {
/* new operations for NFSv4.2 */ /* new operations for NFSv4.2 */
[OP_ALLOCATE] = (nfsd4_dec)nfsd4_decode_fallocate, [OP_ALLOCATE] = (nfsd4_dec)nfsd4_decode_fallocate,
[OP_COPY] = (nfsd4_dec)nfsd4_decode_copy, [OP_COPY] = (nfsd4_dec)nfsd4_decode_copy,
[OP_COPY_NOTIFY] = (nfsd4_dec)nfsd4_decode_notsupp, [OP_COPY_NOTIFY] = (nfsd4_dec)nfsd4_decode_copy_notify,
[OP_DEALLOCATE] = (nfsd4_dec)nfsd4_decode_fallocate, [OP_DEALLOCATE] = (nfsd4_dec)nfsd4_decode_fallocate,
[OP_IO_ADVISE] = (nfsd4_dec)nfsd4_decode_notsupp, [OP_IO_ADVISE] = (nfsd4_dec)nfsd4_decode_notsupp,
[OP_LAYOUTERROR] = (nfsd4_dec)nfsd4_decode_notsupp, [OP_LAYOUTERROR] = (nfsd4_dec)nfsd4_decode_notsupp,
...@@ -2024,11 +2099,11 @@ static __be32 *encode_change(__be32 *p, struct kstat *stat, struct inode *inode, ...@@ -2024,11 +2099,11 @@ static __be32 *encode_change(__be32 *p, struct kstat *stat, struct inode *inode,
*/ */
static __be32 *encode_time_delta(__be32 *p, struct inode *inode) static __be32 *encode_time_delta(__be32 *p, struct inode *inode)
{ {
struct timespec ts; struct timespec64 ts;
u32 ns; u32 ns;
ns = max_t(u32, NSEC_PER_SEC/HZ, inode->i_sb->s_time_gran); ns = max_t(u32, NSEC_PER_SEC/HZ, inode->i_sb->s_time_gran);
ts = ns_to_timespec(ns); ts = ns_to_timespec64(ns);
p = xdr_encode_hyper(p, ts.tv_sec); p = xdr_encode_hyper(p, ts.tv_sec);
*p++ = cpu_to_be32(ts.tv_nsec); *p++ = cpu_to_be32(ts.tv_nsec);
...@@ -4243,6 +4318,46 @@ nfsd42_encode_write_res(struct nfsd4_compoundres *resp, ...@@ -4243,6 +4318,46 @@ nfsd42_encode_write_res(struct nfsd4_compoundres *resp,
return nfs_ok; return nfs_ok;
} }
static __be32
nfsd42_encode_nl4_server(struct nfsd4_compoundres *resp, struct nl4_server *ns)
{
struct xdr_stream *xdr = &resp->xdr;
struct nfs42_netaddr *addr;
__be32 *p;
p = xdr_reserve_space(xdr, 4);
*p++ = cpu_to_be32(ns->nl4_type);
switch (ns->nl4_type) {
case NL4_NETADDR:
addr = &ns->u.nl4_addr;
/* netid_len, netid, uaddr_len, uaddr (port included
* in RPCBIND_MAXUADDRLEN)
*/
p = xdr_reserve_space(xdr,
4 /* netid len */ +
(XDR_QUADLEN(addr->netid_len) * 4) +
4 /* uaddr len */ +
(XDR_QUADLEN(addr->addr_len) * 4));
if (!p)
return nfserr_resource;
*p++ = cpu_to_be32(addr->netid_len);
p = xdr_encode_opaque_fixed(p, addr->netid,
addr->netid_len);
*p++ = cpu_to_be32(addr->addr_len);
p = xdr_encode_opaque_fixed(p, addr->addr,
addr->addr_len);
break;
default:
WARN_ON_ONCE(ns->nl4_type != NL4_NETADDR);
return nfserr_inval;
}
return 0;
}
static __be32 static __be32
nfsd4_encode_copy(struct nfsd4_compoundres *resp, __be32 nfserr, nfsd4_encode_copy(struct nfsd4_compoundres *resp, __be32 nfserr,
struct nfsd4_copy *copy) struct nfsd4_copy *copy)
...@@ -4276,6 +4391,40 @@ nfsd4_encode_offload_status(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4276,6 +4391,40 @@ nfsd4_encode_offload_status(struct nfsd4_compoundres *resp, __be32 nfserr,
return nfserr; return nfserr;
} }
static __be32
nfsd4_encode_copy_notify(struct nfsd4_compoundres *resp, __be32 nfserr,
struct nfsd4_copy_notify *cn)
{
struct xdr_stream *xdr = &resp->xdr;
__be32 *p;
if (nfserr)
return nfserr;
/* 8 sec, 4 nsec */
p = xdr_reserve_space(xdr, 12);
if (!p)
return nfserr_resource;
/* cnr_lease_time */
p = xdr_encode_hyper(p, cn->cpn_sec);
*p++ = cpu_to_be32(cn->cpn_nsec);
/* cnr_stateid */
nfserr = nfsd4_encode_stateid(xdr, &cn->cpn_cnr_stateid);
if (nfserr)
return nfserr;
/* cnr_src.nl_nsvr */
p = xdr_reserve_space(xdr, 4);
if (!p)
return nfserr_resource;
*p++ = cpu_to_be32(1);
return nfsd42_encode_nl4_server(resp, &cn->cpn_src);
}
static __be32 static __be32
nfsd4_encode_seek(struct nfsd4_compoundres *resp, __be32 nfserr, nfsd4_encode_seek(struct nfsd4_compoundres *resp, __be32 nfserr,
struct nfsd4_seek *seek) struct nfsd4_seek *seek)
...@@ -4373,7 +4522,7 @@ static const nfsd4_enc nfsd4_enc_ops[] = { ...@@ -4373,7 +4522,7 @@ static const nfsd4_enc nfsd4_enc_ops[] = {
/* NFSv4.2 operations */ /* NFSv4.2 operations */
[OP_ALLOCATE] = (nfsd4_enc)nfsd4_encode_noop, [OP_ALLOCATE] = (nfsd4_enc)nfsd4_encode_noop,
[OP_COPY] = (nfsd4_enc)nfsd4_encode_copy, [OP_COPY] = (nfsd4_enc)nfsd4_encode_copy,
[OP_COPY_NOTIFY] = (nfsd4_enc)nfsd4_encode_noop, [OP_COPY_NOTIFY] = (nfsd4_enc)nfsd4_encode_copy_notify,
[OP_DEALLOCATE] = (nfsd4_enc)nfsd4_encode_noop, [OP_DEALLOCATE] = (nfsd4_enc)nfsd4_encode_noop,
[OP_IO_ADVISE] = (nfsd4_enc)nfsd4_encode_noop, [OP_IO_ADVISE] = (nfsd4_enc)nfsd4_encode_noop,
[OP_LAYOUTERROR] = (nfsd4_enc)nfsd4_encode_noop, [OP_LAYOUTERROR] = (nfsd4_enc)nfsd4_encode_noop,
...@@ -4500,8 +4649,6 @@ nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op) ...@@ -4500,8 +4649,6 @@ nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op)
__be32 *p; __be32 *p;
struct nfs4_replay *rp = op->replay; struct nfs4_replay *rp = op->replay;
BUG_ON(!rp);
p = xdr_reserve_space(xdr, 8 + rp->rp_buflen); p = xdr_reserve_space(xdr, 8 + rp->rp_buflen);
if (!p) { if (!p) {
WARN_ON_ONCE(1); WARN_ON_ONCE(1);
......
...@@ -956,7 +956,7 @@ static ssize_t write_maxconn(struct file *file, char *buf, size_t size) ...@@ -956,7 +956,7 @@ static ssize_t write_maxconn(struct file *file, char *buf, size_t size)
#ifdef CONFIG_NFSD_V4 #ifdef CONFIG_NFSD_V4
static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size, static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size,
time_t *time, struct nfsd_net *nn) time64_t *time, struct nfsd_net *nn)
{ {
char *mesg = buf; char *mesg = buf;
int rv, i; int rv, i;
...@@ -984,11 +984,11 @@ static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size, ...@@ -984,11 +984,11 @@ static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size,
*time = i; *time = i;
} }
return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%ld\n", *time); return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%lld\n", *time);
} }
static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size, static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size,
time_t *time, struct nfsd_net *nn) time64_t *time, struct nfsd_net *nn)
{ {
ssize_t rv; ssize_t rv;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/sunrpc/svc.h> #include <linux/sunrpc/svc.h>
#include <linux/sunrpc/svc_xprt.h> #include <linux/sunrpc/svc_xprt.h>
#include <linux/sunrpc/msg_prot.h> #include <linux/sunrpc/msg_prot.h>
#include <linux/sunrpc/addr.h>
#include <uapi/linux/nfsd/debug.h> #include <uapi/linux/nfsd/debug.h>
...@@ -142,7 +143,6 @@ int nfs4_state_start(void); ...@@ -142,7 +143,6 @@ int nfs4_state_start(void);
int nfs4_state_start_net(struct net *net); int nfs4_state_start_net(struct net *net);
void nfs4_state_shutdown(void); void nfs4_state_shutdown(void);
void nfs4_state_shutdown_net(struct net *net); void nfs4_state_shutdown_net(struct net *net);
void nfs4_reset_lease(time_t leasetime);
int nfs4_reset_recoverydir(char *recdir); int nfs4_reset_recoverydir(char *recdir);
char * nfs4_recoverydir(void); char * nfs4_recoverydir(void);
bool nfsd4_spo_must_allow(struct svc_rqst *rqstp); bool nfsd4_spo_must_allow(struct svc_rqst *rqstp);
...@@ -153,7 +153,6 @@ static inline int nfs4_state_start(void) { return 0; } ...@@ -153,7 +153,6 @@ static inline int nfs4_state_start(void) { return 0; }
static inline int nfs4_state_start_net(struct net *net) { return 0; } static inline int nfs4_state_start_net(struct net *net) { return 0; }
static inline void nfs4_state_shutdown(void) { } static inline void nfs4_state_shutdown(void) { }
static inline void nfs4_state_shutdown_net(struct net *net) { } static inline void nfs4_state_shutdown_net(struct net *net) { }
static inline void nfs4_reset_lease(time_t leasetime) { }
static inline int nfs4_reset_recoverydir(char *recdir) { return 0; } static inline int nfs4_reset_recoverydir(char *recdir) { return 0; }
static inline char * nfs4_recoverydir(void) {return NULL; } static inline char * nfs4_recoverydir(void) {return NULL; }
static inline bool nfsd4_spo_must_allow(struct svc_rqst *rqstp) static inline bool nfsd4_spo_must_allow(struct svc_rqst *rqstp)
...@@ -387,6 +386,37 @@ void nfsd_lockd_shutdown(void); ...@@ -387,6 +386,37 @@ void nfsd_lockd_shutdown(void);
extern const u32 nfsd_suppattrs[3][3]; extern const u32 nfsd_suppattrs[3][3];
static inline __be32 nfsd4_set_netaddr(struct sockaddr *addr,
struct nfs42_netaddr *netaddr)
{
struct sockaddr_in *sin = (struct sockaddr_in *)addr;
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr;
unsigned int port;
size_t ret_addr, ret_port;
switch (addr->sa_family) {
case AF_INET:
port = ntohs(sin->sin_port);
sprintf(netaddr->netid, "tcp");
netaddr->netid_len = 3;
break;
case AF_INET6:
port = ntohs(sin6->sin6_port);
sprintf(netaddr->netid, "tcp6");
netaddr->netid_len = 4;
break;
default:
return nfserr_inval;
}
ret_addr = rpc_ntop(addr, netaddr->addr, sizeof(netaddr->addr));
ret_port = snprintf(netaddr->addr + ret_addr,
RPCBIND_MAXUADDRLEN + 1 - ret_addr,
".%u.%u", port >> 8, port & 0xff);
WARN_ON(ret_port >= RPCBIND_MAXUADDRLEN + 1 - ret_addr);
netaddr->addr_len = ret_addr + ret_port;
return 0;
}
static inline bool bmval_is_subset(const u32 *bm1, const u32 *bm2) static inline bool bmval_is_subset(const u32 *bm1, const u32 *bm2)
{ {
return !((bm1[0] & ~bm2[0]) || return !((bm1[0] & ~bm2[0]) ||
......
...@@ -35,15 +35,15 @@ typedef struct svc_fh { ...@@ -35,15 +35,15 @@ typedef struct svc_fh {
bool fh_locked; /* inode locked by us */ bool fh_locked; /* inode locked by us */
bool fh_want_write; /* remount protection taken */ bool fh_want_write; /* remount protection taken */
int fh_flags; /* FH flags */
#ifdef CONFIG_NFSD_V3 #ifdef CONFIG_NFSD_V3
bool fh_post_saved; /* post-op attrs saved */ bool fh_post_saved; /* post-op attrs saved */
bool fh_pre_saved; /* pre-op attrs saved */ bool fh_pre_saved; /* pre-op attrs saved */
/* Pre-op attributes saved during fh_lock */ /* Pre-op attributes saved during fh_lock */
__u64 fh_pre_size; /* size before operation */ __u64 fh_pre_size; /* size before operation */
struct timespec fh_pre_mtime; /* mtime before oper */ struct timespec64 fh_pre_mtime; /* mtime before oper */
struct timespec fh_pre_ctime; /* ctime before oper */ struct timespec64 fh_pre_ctime; /* ctime before oper */
/* /*
* pre-op nfsv4 change attr: note must check IS_I_VERSION(inode) * pre-op nfsv4 change attr: note must check IS_I_VERSION(inode)
* to find out if it is valid. * to find out if it is valid.
...@@ -56,6 +56,9 @@ typedef struct svc_fh { ...@@ -56,6 +56,9 @@ typedef struct svc_fh {
#endif /* CONFIG_NFSD_V3 */ #endif /* CONFIG_NFSD_V3 */
} svc_fh; } svc_fh;
#define NFSD4_FH_FOREIGN (1<<0)
#define SET_FH_FLAG(c, f) ((c)->fh_flags |= (f))
#define HAS_FH_FLAG(c, f) ((c)->fh_flags & (f))
enum nfsd_fsid { enum nfsd_fsid {
FSID_DEV = 0, FSID_DEV = 0,
......
...@@ -94,7 +94,7 @@ nfsd_proc_setattr(struct svc_rqst *rqstp) ...@@ -94,7 +94,7 @@ nfsd_proc_setattr(struct svc_rqst *rqstp)
* Solaris, at least, doesn't seem to care what the time * Solaris, at least, doesn't seem to care what the time
* request is. We require it be within 30 minutes of now. * request is. We require it be within 30 minutes of now.
*/ */
time_t delta = iap->ia_atime.tv_sec - get_seconds(); time64_t delta = iap->ia_atime.tv_sec - ktime_get_real_seconds();
nfserr = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP); nfserr = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP);
if (nfserr) if (nfserr)
...@@ -113,7 +113,7 @@ nfsd_proc_setattr(struct svc_rqst *rqstp) ...@@ -113,7 +113,7 @@ nfsd_proc_setattr(struct svc_rqst *rqstp)
} }
} }
nfserr = nfsd_setattr(rqstp, fhp, iap, 0, (time_t)0); nfserr = nfsd_setattr(rqstp, fhp, iap, 0, (time64_t)0);
done: done:
return nfsd_return_attrs(nfserr, resp); return nfsd_return_attrs(nfserr, resp);
} }
...@@ -226,7 +226,7 @@ nfsd_proc_write(struct svc_rqst *rqstp) ...@@ -226,7 +226,7 @@ nfsd_proc_write(struct svc_rqst *rqstp)
return nfserr_io; return nfserr_io;
nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh),
argp->offset, rqstp->rq_vec, nvecs, argp->offset, rqstp->rq_vec, nvecs,
&cnt, NFS_DATA_SYNC); &cnt, NFS_DATA_SYNC, NULL);
return nfsd_return_attrs(nfserr, resp); return nfsd_return_attrs(nfserr, resp);
} }
...@@ -380,7 +380,7 @@ nfsd_proc_create(struct svc_rqst *rqstp) ...@@ -380,7 +380,7 @@ nfsd_proc_create(struct svc_rqst *rqstp)
*/ */
attr->ia_valid &= ATTR_SIZE; attr->ia_valid &= ATTR_SIZE;
if (attr->ia_valid) if (attr->ia_valid)
nfserr = nfsd_setattr(rqstp, newfhp, attr, 0, (time_t)0); nfserr = nfsd_setattr(rqstp, newfhp, attr, 0, (time64_t)0);
} }
out_unlock: out_unlock:
......
...@@ -31,6 +31,12 @@ ...@@ -31,6 +31,12 @@
#define NFSDDBG_FACILITY NFSDDBG_SVC #define NFSDDBG_FACILITY NFSDDBG_SVC
bool inter_copy_offload_enable;
EXPORT_SYMBOL_GPL(inter_copy_offload_enable);
module_param(inter_copy_offload_enable, bool, 0644);
MODULE_PARM_DESC(inter_copy_offload_enable,
"Enable inter server to server copy offload. Default: false");
extern struct svc_program nfsd_program; extern struct svc_program nfsd_program;
static int nfsd(void *vrqstp); static int nfsd(void *vrqstp);
#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
...@@ -391,20 +397,25 @@ static int nfsd_startup_net(int nrservs, struct net *net, const struct cred *cre ...@@ -391,20 +397,25 @@ static int nfsd_startup_net(int nrservs, struct net *net, const struct cred *cre
ret = lockd_up(net, cred); ret = lockd_up(net, cred);
if (ret) if (ret)
goto out_socks; goto out_socks;
nn->lockd_up = 1; nn->lockd_up = true;
} }
ret = nfs4_state_start_net(net); ret = nfsd_file_cache_start_net(net);
if (ret) if (ret)
goto out_lockd; goto out_lockd;
ret = nfs4_state_start_net(net);
if (ret)
goto out_filecache;
nn->nfsd_net_up = true; nn->nfsd_net_up = true;
return 0; return 0;
out_filecache:
nfsd_file_cache_shutdown_net(net);
out_lockd: out_lockd:
if (nn->lockd_up) { if (nn->lockd_up) {
lockd_down(net); lockd_down(net);
nn->lockd_up = 0; nn->lockd_up = false;
} }
out_socks: out_socks:
nfsd_shutdown_generic(); nfsd_shutdown_generic();
...@@ -415,11 +426,11 @@ static void nfsd_shutdown_net(struct net *net) ...@@ -415,11 +426,11 @@ static void nfsd_shutdown_net(struct net *net)
{ {
struct nfsd_net *nn = net_generic(net, nfsd_net_id); struct nfsd_net *nn = net_generic(net, nfsd_net_id);
nfsd_file_cache_purge(net); nfsd_file_cache_shutdown_net(net);
nfs4_state_shutdown_net(net); nfs4_state_shutdown_net(net);
if (nn->lockd_up) { if (nn->lockd_up) {
lockd_down(net); lockd_down(net);
nn->lockd_up = 0; nn->lockd_up = false;
} }
nn->nfsd_net_up = false; nn->nfsd_net_up = false;
nfsd_shutdown_generic(); nfsd_shutdown_generic();
......
...@@ -56,6 +56,14 @@ typedef struct { ...@@ -56,6 +56,14 @@ typedef struct {
stateid_opaque_t si_opaque; stateid_opaque_t si_opaque;
} stateid_t; } stateid_t;
typedef struct {
stateid_t stid;
#define NFS4_COPY_STID 1
#define NFS4_COPYNOTIFY_STID 2
unsigned char sc_type;
refcount_t sc_count;
} copy_stateid_t;
#define STATEID_FMT "(%08x/%08x/%08x/%08x)" #define STATEID_FMT "(%08x/%08x/%08x/%08x)"
#define STATEID_VAL(s) \ #define STATEID_VAL(s) \
(s)->si_opaque.so_clid.cl_boot, \ (s)->si_opaque.so_clid.cl_boot, \
...@@ -96,6 +104,7 @@ struct nfs4_stid { ...@@ -96,6 +104,7 @@ struct nfs4_stid {
#define NFS4_REVOKED_DELEG_STID 16 #define NFS4_REVOKED_DELEG_STID 16
#define NFS4_CLOSED_DELEG_STID 32 #define NFS4_CLOSED_DELEG_STID 32
#define NFS4_LAYOUT_STID 64 #define NFS4_LAYOUT_STID 64
struct list_head sc_cp_list;
unsigned char sc_type; unsigned char sc_type;
stateid_t sc_stateid; stateid_t sc_stateid;
spinlock_t sc_lock; spinlock_t sc_lock;
...@@ -104,6 +113,17 @@ struct nfs4_stid { ...@@ -104,6 +113,17 @@ struct nfs4_stid {
void (*sc_free)(struct nfs4_stid *); void (*sc_free)(struct nfs4_stid *);
}; };
/* Keep a list of stateids issued by the COPY_NOTIFY, associate it with the
* parent OPEN/LOCK/DELEG stateid.
*/
struct nfs4_cpntf_state {
copy_stateid_t cp_stateid;
struct list_head cp_list; /* per parent nfs4_stid */
stateid_t cp_p_stateid; /* copy of parent's stateid */
clientid_t cp_p_clid; /* copy of parent's clid */
time64_t cpntf_time; /* last time stateid used */
};
/* /*
* Represents a delegation stateid. The nfs4_client holds references to these * Represents a delegation stateid. The nfs4_client holds references to these
* and they are put when it is being destroyed or when the delegation is * and they are put when it is being destroyed or when the delegation is
...@@ -132,7 +152,7 @@ struct nfs4_delegation { ...@@ -132,7 +152,7 @@ struct nfs4_delegation {
struct list_head dl_recall_lru; /* delegation recalled */ struct list_head dl_recall_lru; /* delegation recalled */
struct nfs4_clnt_odstate *dl_clnt_odstate; struct nfs4_clnt_odstate *dl_clnt_odstate;
u32 dl_type; u32 dl_type;
time_t dl_time; time64_t dl_time;
/* For recall: */ /* For recall: */
int dl_retries; int dl_retries;
struct nfsd4_callback dl_recall; struct nfsd4_callback dl_recall;
...@@ -310,7 +330,7 @@ struct nfs4_client { ...@@ -310,7 +330,7 @@ struct nfs4_client {
#endif #endif
struct xdr_netobj cl_name; /* id generated by client */ struct xdr_netobj cl_name; /* id generated by client */
nfs4_verifier cl_verifier; /* generated by client */ nfs4_verifier cl_verifier; /* generated by client */
time_t cl_time; /* time of last lease renewal */ time64_t cl_time; /* time of last lease renewal */
struct sockaddr_storage cl_addr; /* client ipaddress */ struct sockaddr_storage cl_addr; /* client ipaddress */
bool cl_mach_cred; /* SP4_MACH_CRED in force */ bool cl_mach_cred; /* SP4_MACH_CRED in force */
struct svc_cred cl_cred; /* setclientid principal */ struct svc_cred cl_cred; /* setclientid principal */
...@@ -320,7 +340,7 @@ struct nfs4_client { ...@@ -320,7 +340,7 @@ struct nfs4_client {
/* NFSv4.1 client implementation id: */ /* NFSv4.1 client implementation id: */
struct xdr_netobj cl_nii_domain; struct xdr_netobj cl_nii_domain;
struct xdr_netobj cl_nii_name; struct xdr_netobj cl_nii_name;
struct timespec cl_nii_time; struct timespec64 cl_nii_time;
/* for v4.0 and v4.1 callbacks: */ /* for v4.0 and v4.1 callbacks: */
struct nfs4_cb_conn cl_cb_conn; struct nfs4_cb_conn cl_cb_conn;
...@@ -449,7 +469,7 @@ struct nfs4_openowner { ...@@ -449,7 +469,7 @@ struct nfs4_openowner {
*/ */
struct list_head oo_close_lru; struct list_head oo_close_lru;
struct nfs4_ol_stateid *oo_last_closed_stid; struct nfs4_ol_stateid *oo_last_closed_stid;
time_t oo_time; /* time of placement on so_close_lru */ time64_t oo_time; /* time of placement on so_close_lru */
#define NFS4_OO_CONFIRMED 1 #define NFS4_OO_CONFIRMED 1
unsigned char oo_flags; unsigned char oo_flags;
}; };
...@@ -606,7 +626,7 @@ static inline bool nfsd4_stateid_generation_after(stateid_t *a, stateid_t *b) ...@@ -606,7 +626,7 @@ static inline bool nfsd4_stateid_generation_after(stateid_t *a, stateid_t *b)
struct nfsd4_blocked_lock { struct nfsd4_blocked_lock {
struct list_head nbl_list; struct list_head nbl_list;
struct list_head nbl_lru; struct list_head nbl_lru;
unsigned long nbl_time; time64_t nbl_time;
struct file_lock nbl_lock; struct file_lock nbl_lock;
struct knfsd_fh nbl_fh; struct knfsd_fh nbl_fh;
struct nfsd4_callback nbl_cb; struct nfsd4_callback nbl_cb;
...@@ -618,14 +638,17 @@ struct nfsd4_copy; ...@@ -618,14 +638,17 @@ struct nfsd4_copy;
extern __be32 nfs4_preprocess_stateid_op(struct svc_rqst *rqstp, extern __be32 nfs4_preprocess_stateid_op(struct svc_rqst *rqstp,
struct nfsd4_compound_state *cstate, struct svc_fh *fhp, struct nfsd4_compound_state *cstate, struct svc_fh *fhp,
stateid_t *stateid, int flags, struct nfsd_file **filp); stateid_t *stateid, int flags, struct nfsd_file **filp,
struct nfs4_stid **cstid);
__be32 nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate, __be32 nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate,
stateid_t *stateid, unsigned char typemask, stateid_t *stateid, unsigned char typemask,
struct nfs4_stid **s, struct nfsd_net *nn); struct nfs4_stid **s, struct nfsd_net *nn);
struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl, struct kmem_cache *slab, struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl, struct kmem_cache *slab,
void (*sc_free)(struct nfs4_stid *)); void (*sc_free)(struct nfs4_stid *));
int nfs4_init_cp_state(struct nfsd_net *nn, struct nfsd4_copy *copy); int nfs4_init_copy_state(struct nfsd_net *nn, struct nfsd4_copy *copy);
void nfs4_free_cp_state(struct nfsd4_copy *copy); void nfs4_free_copy_state(struct nfsd4_copy *copy);
struct nfs4_cpntf_state *nfs4_alloc_init_cpntf_state(struct nfsd_net *nn,
struct nfs4_stid *p_stid);
void nfs4_unhash_stid(struct nfs4_stid *s); void nfs4_unhash_stid(struct nfs4_stid *s);
void nfs4_put_stid(struct nfs4_stid *s); void nfs4_put_stid(struct nfs4_stid *s);
void nfs4_inc_and_copy_stateid(stateid_t *dst, struct nfs4_stid *stid); void nfs4_inc_and_copy_stateid(stateid_t *dst, struct nfs4_stid *stid);
...@@ -655,6 +678,11 @@ void put_nfs4_file(struct nfs4_file *fi); ...@@ -655,6 +678,11 @@ void put_nfs4_file(struct nfs4_file *fi);
extern void nfs4_put_copy(struct nfsd4_copy *copy); extern void nfs4_put_copy(struct nfsd4_copy *copy);
extern struct nfsd4_copy * extern struct nfsd4_copy *
find_async_copy(struct nfs4_client *clp, stateid_t *staetid); find_async_copy(struct nfs4_client *clp, stateid_t *staetid);
extern void nfs4_put_cpntf_state(struct nfsd_net *nn,
struct nfs4_cpntf_state *cps);
extern __be32 manage_cpntf_state(struct nfsd_net *nn, stateid_t *st,
struct nfs4_client *clp,
struct nfs4_cpntf_state **cps);
static inline void get_nfs4_file(struct nfs4_file *fi) static inline void get_nfs4_file(struct nfs4_file *fi)
{ {
refcount_inc(&fi->fi_ref); refcount_inc(&fi->fi_ref);
......
...@@ -166,6 +166,12 @@ DEFINE_STATEID_EVENT(layout_recall_done); ...@@ -166,6 +166,12 @@ DEFINE_STATEID_EVENT(layout_recall_done);
DEFINE_STATEID_EVENT(layout_recall_fail); DEFINE_STATEID_EVENT(layout_recall_fail);
DEFINE_STATEID_EVENT(layout_recall_release); DEFINE_STATEID_EVENT(layout_recall_release);
TRACE_DEFINE_ENUM(NFSD_FILE_HASHED);
TRACE_DEFINE_ENUM(NFSD_FILE_PENDING);
TRACE_DEFINE_ENUM(NFSD_FILE_BREAK_READ);
TRACE_DEFINE_ENUM(NFSD_FILE_BREAK_WRITE);
TRACE_DEFINE_ENUM(NFSD_FILE_REFERENCED);
#define show_nf_flags(val) \ #define show_nf_flags(val) \
__print_flags(val, "|", \ __print_flags(val, "|", \
{ 1 << NFSD_FILE_HASHED, "HASHED" }, \ { 1 << NFSD_FILE_HASHED, "HASHED" }, \
...@@ -195,7 +201,7 @@ DECLARE_EVENT_CLASS(nfsd_file_class, ...@@ -195,7 +201,7 @@ DECLARE_EVENT_CLASS(nfsd_file_class,
TP_fast_assign( TP_fast_assign(
__entry->nf_hashval = nf->nf_hashval; __entry->nf_hashval = nf->nf_hashval;
__entry->nf_inode = nf->nf_inode; __entry->nf_inode = nf->nf_inode;
__entry->nf_ref = atomic_read(&nf->nf_ref); __entry->nf_ref = refcount_read(&nf->nf_ref);
__entry->nf_flags = nf->nf_flags; __entry->nf_flags = nf->nf_flags;
__entry->nf_may = nf->nf_may; __entry->nf_may = nf->nf_may;
__entry->nf_file = nf->nf_file; __entry->nf_file = nf->nf_file;
...@@ -228,7 +234,7 @@ TRACE_EVENT(nfsd_file_acquire, ...@@ -228,7 +234,7 @@ TRACE_EVENT(nfsd_file_acquire,
TP_ARGS(rqstp, hash, inode, may_flags, nf, status), TP_ARGS(rqstp, hash, inode, may_flags, nf, status),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(__be32, xid) __field(u32, xid)
__field(unsigned int, hash) __field(unsigned int, hash)
__field(void *, inode) __field(void *, inode)
__field(unsigned int, may_flags) __field(unsigned int, may_flags)
...@@ -236,27 +242,27 @@ TRACE_EVENT(nfsd_file_acquire, ...@@ -236,27 +242,27 @@ TRACE_EVENT(nfsd_file_acquire,
__field(unsigned long, nf_flags) __field(unsigned long, nf_flags)
__field(unsigned char, nf_may) __field(unsigned char, nf_may)
__field(struct file *, nf_file) __field(struct file *, nf_file)
__field(__be32, status) __field(u32, status)
), ),
TP_fast_assign( TP_fast_assign(
__entry->xid = rqstp->rq_xid; __entry->xid = be32_to_cpu(rqstp->rq_xid);
__entry->hash = hash; __entry->hash = hash;
__entry->inode = inode; __entry->inode = inode;
__entry->may_flags = may_flags; __entry->may_flags = may_flags;
__entry->nf_ref = nf ? atomic_read(&nf->nf_ref) : 0; __entry->nf_ref = nf ? refcount_read(&nf->nf_ref) : 0;
__entry->nf_flags = nf ? nf->nf_flags : 0; __entry->nf_flags = nf ? nf->nf_flags : 0;
__entry->nf_may = nf ? nf->nf_may : 0; __entry->nf_may = nf ? nf->nf_may : 0;
__entry->nf_file = nf ? nf->nf_file : NULL; __entry->nf_file = nf ? nf->nf_file : NULL;
__entry->status = status; __entry->status = be32_to_cpu(status);
), ),
TP_printk("xid=0x%x hash=0x%x inode=0x%p may_flags=%s ref=%d nf_flags=%s nf_may=%s nf_file=0x%p status=%u", TP_printk("xid=0x%x hash=0x%x inode=0x%p may_flags=%s ref=%d nf_flags=%s nf_may=%s nf_file=0x%p status=%u",
be32_to_cpu(__entry->xid), __entry->hash, __entry->inode, __entry->xid, __entry->hash, __entry->inode,
show_nf_may(__entry->may_flags), __entry->nf_ref, show_nf_may(__entry->may_flags), __entry->nf_ref,
show_nf_flags(__entry->nf_flags), show_nf_flags(__entry->nf_flags),
show_nf_may(__entry->nf_may), __entry->nf_file, show_nf_may(__entry->nf_may), __entry->nf_file,
be32_to_cpu(__entry->status)) __entry->status)
); );
DECLARE_EVENT_CLASS(nfsd_file_search_class, DECLARE_EVENT_CLASS(nfsd_file_search_class,
......
...@@ -280,19 +280,25 @@ nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name, ...@@ -280,19 +280,25 @@ nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name,
* Commit metadata changes to stable storage. * Commit metadata changes to stable storage.
*/ */
static int static int
commit_metadata(struct svc_fh *fhp) commit_inode_metadata(struct inode *inode)
{ {
struct inode *inode = d_inode(fhp->fh_dentry);
const struct export_operations *export_ops = inode->i_sb->s_export_op; const struct export_operations *export_ops = inode->i_sb->s_export_op;
if (!EX_ISSYNC(fhp->fh_export))
return 0;
if (export_ops->commit_metadata) if (export_ops->commit_metadata)
return export_ops->commit_metadata(inode); return export_ops->commit_metadata(inode);
return sync_inode_metadata(inode, 1); return sync_inode_metadata(inode, 1);
} }
static int
commit_metadata(struct svc_fh *fhp)
{
struct inode *inode = d_inode(fhp->fh_dentry);
if (!EX_ISSYNC(fhp->fh_export))
return 0;
return commit_inode_metadata(inode);
}
/* /*
* Go over the attributes and take care of the small differences between * Go over the attributes and take care of the small differences between
* NFS semantics and what Linux expects. * NFS semantics and what Linux expects.
...@@ -358,7 +364,7 @@ nfsd_get_write_access(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -358,7 +364,7 @@ nfsd_get_write_access(struct svc_rqst *rqstp, struct svc_fh *fhp,
*/ */
__be32 __be32
nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
int check_guard, time_t guardtime) int check_guard, time64_t guardtime)
{ {
struct dentry *dentry; struct dentry *dentry;
struct inode *inode; struct inode *inode;
...@@ -524,23 +530,39 @@ __be32 nfsd4_set_nfs4_label(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -524,23 +530,39 @@ __be32 nfsd4_set_nfs4_label(struct svc_rqst *rqstp, struct svc_fh *fhp,
} }
#endif #endif
__be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst, __be32 nfsd4_clone_file_range(struct nfsd_file *nf_src, u64 src_pos,
u64 dst_pos, u64 count, bool sync) struct nfsd_file *nf_dst, u64 dst_pos, u64 count, bool sync)
{ {
struct file *src = nf_src->nf_file;
struct file *dst = nf_dst->nf_file;
loff_t cloned; loff_t cloned;
__be32 ret = 0;
down_write(&nf_dst->nf_rwsem);
cloned = vfs_clone_file_range(src, src_pos, dst, dst_pos, count, 0); cloned = vfs_clone_file_range(src, src_pos, dst, dst_pos, count, 0);
if (cloned < 0) if (cloned < 0) {
return nfserrno(cloned); ret = nfserrno(cloned);
if (count && cloned != count) goto out_err;
return nfserrno(-EINVAL); }
if (count && cloned != count) {
ret = nfserrno(-EINVAL);
goto out_err;
}
if (sync) { if (sync) {
loff_t dst_end = count ? dst_pos + count - 1 : LLONG_MAX; loff_t dst_end = count ? dst_pos + count - 1 : LLONG_MAX;
int status = vfs_fsync_range(dst, dst_pos, dst_end, 0); int status = vfs_fsync_range(dst, dst_pos, dst_end, 0);
if (status < 0)
return nfserrno(status); if (!status)
status = commit_inode_metadata(file_inode(src));
if (status < 0) {
nfsd_reset_boot_verifier(net_generic(nf_dst->nf_net,
nfsd_net_id));
ret = nfserrno(status);
} }
return 0; }
out_err:
up_write(&nf_dst->nf_rwsem);
return ret;
} }
ssize_t nfsd_copy_file_range(struct file *src, u64 src_pos, struct file *dst, ssize_t nfsd_copy_file_range(struct file *src, u64 src_pos, struct file *dst,
...@@ -938,10 +960,12 @@ static int wait_for_concurrent_writes(struct file *file) ...@@ -938,10 +960,12 @@ static int wait_for_concurrent_writes(struct file *file)
} }
__be32 __be32
nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfsd_file *nf,
loff_t offset, struct kvec *vec, int vlen, loff_t offset, struct kvec *vec, int vlen,
unsigned long *cnt, int stable) unsigned long *cnt, int stable,
__be32 *verf)
{ {
struct file *file = nf->nf_file;
struct svc_export *exp; struct svc_export *exp;
struct iov_iter iter; struct iov_iter iter;
__be32 nfserr; __be32 nfserr;
...@@ -972,9 +996,28 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, ...@@ -972,9 +996,28 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
flags |= RWF_SYNC; flags |= RWF_SYNC;
iov_iter_kvec(&iter, WRITE, vec, vlen, *cnt); iov_iter_kvec(&iter, WRITE, vec, vlen, *cnt);
if (flags & RWF_SYNC) {
down_write(&nf->nf_rwsem);
host_err = vfs_iter_write(file, &iter, &pos, flags); host_err = vfs_iter_write(file, &iter, &pos, flags);
if (host_err < 0) if (host_err < 0)
nfsd_reset_boot_verifier(net_generic(SVC_NET(rqstp),
nfsd_net_id));
up_write(&nf->nf_rwsem);
} else {
down_read(&nf->nf_rwsem);
if (verf)
nfsd_copy_boot_verifier(verf,
net_generic(SVC_NET(rqstp),
nfsd_net_id));
host_err = vfs_iter_write(file, &iter, &pos, flags);
up_read(&nf->nf_rwsem);
}
if (host_err < 0) {
nfsd_reset_boot_verifier(net_generic(SVC_NET(rqstp),
nfsd_net_id));
goto out_nfserr; goto out_nfserr;
}
*cnt = host_err;
nfsdstats.io_write += *cnt; nfsdstats.io_write += *cnt;
fsnotify_modify(file); fsnotify_modify(file);
...@@ -1036,7 +1079,8 @@ __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1036,7 +1079,8 @@ __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
*/ */
__be32 __be32
nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset, nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset,
struct kvec *vec, int vlen, unsigned long *cnt, int stable) struct kvec *vec, int vlen, unsigned long *cnt, int stable,
__be32 *verf)
{ {
struct nfsd_file *nf; struct nfsd_file *nf;
__be32 err; __be32 err;
...@@ -1047,8 +1091,8 @@ nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset, ...@@ -1047,8 +1091,8 @@ nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset,
if (err) if (err)
goto out; goto out;
err = nfsd_vfs_write(rqstp, fhp, nf->nf_file, offset, vec, err = nfsd_vfs_write(rqstp, fhp, nf, offset, vec,
vlen, cnt, stable); vlen, cnt, stable, verf);
nfsd_file_put(nf); nfsd_file_put(nf);
out: out:
trace_nfsd_write_done(rqstp, fhp, offset, *cnt); trace_nfsd_write_done(rqstp, fhp, offset, *cnt);
...@@ -1067,7 +1111,7 @@ nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset, ...@@ -1067,7 +1111,7 @@ nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset,
*/ */
__be32 __be32
nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp,
loff_t offset, unsigned long count) loff_t offset, unsigned long count, __be32 *verf)
{ {
struct nfsd_file *nf; struct nfsd_file *nf;
loff_t end = LLONG_MAX; loff_t end = LLONG_MAX;
...@@ -1086,10 +1130,14 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1086,10 +1130,14 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp,
if (err) if (err)
goto out; goto out;
if (EX_ISSYNC(fhp->fh_export)) { if (EX_ISSYNC(fhp->fh_export)) {
int err2 = vfs_fsync_range(nf->nf_file, offset, end, 0); int err2;
down_write(&nf->nf_rwsem);
err2 = vfs_fsync_range(nf->nf_file, offset, end, 0);
switch (err2) { switch (err2) {
case 0: case 0:
nfsd_copy_boot_verifier(verf, net_generic(nf->nf_net,
nfsd_net_id));
break; break;
case -EINVAL: case -EINVAL:
err = nfserr_notsupp; err = nfserr_notsupp;
...@@ -1099,7 +1147,10 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1099,7 +1147,10 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp,
nfsd_reset_boot_verifier(net_generic(nf->nf_net, nfsd_reset_boot_verifier(net_generic(nf->nf_net,
nfsd_net_id)); nfsd_net_id));
} }
} up_write(&nf->nf_rwsem);
} else
nfsd_copy_boot_verifier(verf, net_generic(nf->nf_net,
nfsd_net_id));
nfsd_file_put(nf); nfsd_file_put(nf);
out: out:
...@@ -1123,7 +1174,7 @@ nfsd_create_setattr(struct svc_rqst *rqstp, struct svc_fh *resfhp, ...@@ -1123,7 +1174,7 @@ nfsd_create_setattr(struct svc_rqst *rqstp, struct svc_fh *resfhp,
if (!uid_eq(current_fsuid(), GLOBAL_ROOT_UID)) if (!uid_eq(current_fsuid(), GLOBAL_ROOT_UID))
iap->ia_valid &= ~(ATTR_UID|ATTR_GID); iap->ia_valid &= ~(ATTR_UID|ATTR_GID);
if (iap->ia_valid) if (iap->ia_valid)
return nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0); return nfsd_setattr(rqstp, resfhp, iap, 0, (time64_t)0);
/* Callers expect file metadata to be committed here */ /* Callers expect file metadata to be committed here */
return nfserrno(commit_metadata(resfhp)); return nfserrno(commit_metadata(resfhp));
} }
...@@ -1386,7 +1437,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1386,7 +1437,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
&& d_inode(dchild)->i_atime.tv_sec == v_atime && d_inode(dchild)->i_atime.tv_sec == v_atime
&& d_inode(dchild)->i_size == 0 ) { && d_inode(dchild)->i_size == 0 ) {
if (created) if (created)
*created = 1; *created = true;
break; break;
} }
/* fall through */ /* fall through */
...@@ -1395,7 +1446,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1395,7 +1446,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
&& d_inode(dchild)->i_atime.tv_sec == v_atime && d_inode(dchild)->i_atime.tv_sec == v_atime
&& d_inode(dchild)->i_size == 0 ) { && d_inode(dchild)->i_size == 0 ) {
if (created) if (created)
*created = 1; *created = true;
goto set_attr; goto set_attr;
} }
/* fall through */ /* fall through */
...@@ -1412,7 +1463,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1412,7 +1463,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
goto out_nfserr; goto out_nfserr;
} }
if (created) if (created)
*created = 1; *created = true;
nfsd_check_ignore_resizing(iap); nfsd_check_ignore_resizing(iap);
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#define NFSD_MAY_CREATE (NFSD_MAY_EXEC|NFSD_MAY_WRITE) #define NFSD_MAY_CREATE (NFSD_MAY_EXEC|NFSD_MAY_WRITE)
#define NFSD_MAY_REMOVE (NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC) #define NFSD_MAY_REMOVE (NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC)
struct nfsd_file;
/* /*
* Callback function for readdir * Callback function for readdir
*/ */
...@@ -48,15 +50,16 @@ __be32 nfsd_lookup_dentry(struct svc_rqst *, struct svc_fh *, ...@@ -48,15 +50,16 @@ __be32 nfsd_lookup_dentry(struct svc_rqst *, struct svc_fh *,
const char *, unsigned int, const char *, unsigned int,
struct svc_export **, struct dentry **); struct svc_export **, struct dentry **);
__be32 nfsd_setattr(struct svc_rqst *, struct svc_fh *, __be32 nfsd_setattr(struct svc_rqst *, struct svc_fh *,
struct iattr *, int, time_t); struct iattr *, int, time64_t);
int nfsd_mountpoint(struct dentry *, struct svc_export *); int nfsd_mountpoint(struct dentry *, struct svc_export *);
#ifdef CONFIG_NFSD_V4 #ifdef CONFIG_NFSD_V4
__be32 nfsd4_set_nfs4_label(struct svc_rqst *, struct svc_fh *, __be32 nfsd4_set_nfs4_label(struct svc_rqst *, struct svc_fh *,
struct xdr_netobj *); struct xdr_netobj *);
__be32 nfsd4_vfs_fallocate(struct svc_rqst *, struct svc_fh *, __be32 nfsd4_vfs_fallocate(struct svc_rqst *, struct svc_fh *,
struct file *, loff_t, loff_t, int); struct file *, loff_t, loff_t, int);
__be32 nfsd4_clone_file_range(struct file *, u64, struct file *, __be32 nfsd4_clone_file_range(struct nfsd_file *nf_src, u64 src_pos,
u64, u64, bool); struct nfsd_file *nf_dst, u64 dst_pos,
u64 count, bool sync);
#endif /* CONFIG_NFSD_V4 */ #endif /* CONFIG_NFSD_V4 */
__be32 nfsd_create_locked(struct svc_rqst *, struct svc_fh *, __be32 nfsd_create_locked(struct svc_rqst *, struct svc_fh *,
char *name, int len, struct iattr *attrs, char *name, int len, struct iattr *attrs,
...@@ -71,7 +74,7 @@ __be32 do_nfsd_create(struct svc_rqst *, struct svc_fh *, ...@@ -71,7 +74,7 @@ __be32 do_nfsd_create(struct svc_rqst *, struct svc_fh *,
struct svc_fh *res, int createmode, struct svc_fh *res, int createmode,
u32 *verifier, bool *truncp, bool *created); u32 *verifier, bool *truncp, bool *created);
__be32 nfsd_commit(struct svc_rqst *, struct svc_fh *, __be32 nfsd_commit(struct svc_rqst *, struct svc_fh *,
loff_t, unsigned long); loff_t, unsigned long, __be32 *verf);
#endif /* CONFIG_NFSD_V3 */ #endif /* CONFIG_NFSD_V3 */
int nfsd_open_break_lease(struct inode *, int); int nfsd_open_break_lease(struct inode *, int);
__be32 nfsd_open(struct svc_rqst *, struct svc_fh *, umode_t, __be32 nfsd_open(struct svc_rqst *, struct svc_fh *, umode_t,
...@@ -91,11 +94,12 @@ __be32 nfsd_read(struct svc_rqst *, struct svc_fh *, ...@@ -91,11 +94,12 @@ __be32 nfsd_read(struct svc_rqst *, struct svc_fh *,
loff_t, struct kvec *, int, unsigned long *, loff_t, struct kvec *, int, unsigned long *,
u32 *eof); u32 *eof);
__be32 nfsd_write(struct svc_rqst *, struct svc_fh *, loff_t, __be32 nfsd_write(struct svc_rqst *, struct svc_fh *, loff_t,
struct kvec *, int, unsigned long *, int); struct kvec *, int, unsigned long *,
int stable, __be32 *verf);
__be32 nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, __be32 nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp,
struct file *file, loff_t offset, struct nfsd_file *nf, loff_t offset,
struct kvec *vec, int vlen, unsigned long *cnt, struct kvec *vec, int vlen, unsigned long *cnt,
int stable); int stable, __be32 *verf);
__be32 nfsd_readlink(struct svc_rqst *, struct svc_fh *, __be32 nfsd_readlink(struct svc_rqst *, struct svc_fh *,
char *, int *); char *, int *);
__be32 nfsd_symlink(struct svc_rqst *, struct svc_fh *, __be32 nfsd_symlink(struct svc_rqst *, struct svc_fh *,
......
...@@ -14,7 +14,7 @@ struct nfsd3_sattrargs { ...@@ -14,7 +14,7 @@ struct nfsd3_sattrargs {
struct svc_fh fh; struct svc_fh fh;
struct iattr attrs; struct iattr attrs;
int check_guard; int check_guard;
time_t guardtime; time64_t guardtime;
}; };
struct nfsd3_diropargs { struct nfsd3_diropargs {
...@@ -159,6 +159,7 @@ struct nfsd3_writeres { ...@@ -159,6 +159,7 @@ struct nfsd3_writeres {
struct svc_fh fh; struct svc_fh fh;
unsigned long count; unsigned long count;
int committed; int committed;
__be32 verf[2];
}; };
struct nfsd3_renameres { struct nfsd3_renameres {
...@@ -223,6 +224,7 @@ struct nfsd3_pathconfres { ...@@ -223,6 +224,7 @@ struct nfsd3_pathconfres {
struct nfsd3_commitres { struct nfsd3_commitres {
__be32 status; __be32 status;
struct svc_fh fh; struct svc_fh fh;
__be32 verf[2];
}; };
struct nfsd3_getaclres { struct nfsd3_getaclres {
......
...@@ -46,9 +46,9 @@ ...@@ -46,9 +46,9 @@
#define CURRENT_STATE_ID_FLAG (1<<0) #define CURRENT_STATE_ID_FLAG (1<<0)
#define SAVED_STATE_ID_FLAG (1<<1) #define SAVED_STATE_ID_FLAG (1<<1)
#define SET_STATE_ID(c, f) ((c)->sid_flags |= (f)) #define SET_CSTATE_FLAG(c, f) ((c)->sid_flags |= (f))
#define HAS_STATE_ID(c, f) ((c)->sid_flags & (f)) #define HAS_CSTATE_FLAG(c, f) ((c)->sid_flags & (f))
#define CLEAR_STATE_ID(c, f) ((c)->sid_flags &= ~(f)) #define CLEAR_CSTATE_FLAG(c, f) ((c)->sid_flags &= ~(f))
struct nfsd4_compound_state { struct nfsd4_compound_state {
struct svc_fh current_fh; struct svc_fh current_fh;
...@@ -221,6 +221,7 @@ struct nfsd4_lookup { ...@@ -221,6 +221,7 @@ struct nfsd4_lookup {
struct nfsd4_putfh { struct nfsd4_putfh {
u32 pf_fhlen; /* request */ u32 pf_fhlen; /* request */
char *pf_fhval; /* request */ char *pf_fhval; /* request */
bool no_verify; /* represents foreigh fh */
}; };
struct nfsd4_open { struct nfsd4_open {
...@@ -523,6 +524,8 @@ struct nfsd4_copy { ...@@ -523,6 +524,8 @@ struct nfsd4_copy {
u64 cp_src_pos; u64 cp_src_pos;
u64 cp_dst_pos; u64 cp_dst_pos;
u64 cp_count; u64 cp_count;
struct nl4_server cp_src;
bool cp_intra;
/* both */ /* both */
bool cp_synchronous; bool cp_synchronous;
...@@ -540,13 +543,18 @@ struct nfsd4_copy { ...@@ -540,13 +543,18 @@ struct nfsd4_copy {
struct nfsd_file *nf_src; struct nfsd_file *nf_src;
struct nfsd_file *nf_dst; struct nfsd_file *nf_dst;
stateid_t cp_stateid; copy_stateid_t cp_stateid;
struct list_head copies; struct list_head copies;
struct task_struct *copy_task; struct task_struct *copy_task;
refcount_t refcount; refcount_t refcount;
bool stopped; bool stopped;
struct vfsmount *ss_mnt;
struct nfs_fh c_fh;
nfs4_stateid stateid;
}; };
extern bool inter_copy_offload_enable;
struct nfsd4_seek { struct nfsd4_seek {
/* request */ /* request */
...@@ -568,6 +576,18 @@ struct nfsd4_offload_status { ...@@ -568,6 +576,18 @@ struct nfsd4_offload_status {
u32 status; u32 status;
}; };
struct nfsd4_copy_notify {
/* request */
stateid_t cpn_src_stateid;
struct nl4_server cpn_dst;
/* response */
stateid_t cpn_cnr_stateid;
u64 cpn_sec;
u32 cpn_nsec;
struct nl4_server cpn_src;
};
struct nfsd4_op { struct nfsd4_op {
int opnum; int opnum;
const struct nfsd4_operation * opdesc; const struct nfsd4_operation * opdesc;
...@@ -627,6 +647,7 @@ struct nfsd4_op { ...@@ -627,6 +647,7 @@ struct nfsd4_op {
struct nfsd4_clone clone; struct nfsd4_clone clone;
struct nfsd4_copy copy; struct nfsd4_copy copy;
struct nfsd4_offload_status offload_status; struct nfsd4_offload_status offload_status;
struct nfsd4_copy_notify copy_notify;
struct nfsd4_seek seek; struct nfsd4_seek seek;
} u; } u;
struct nfs4_replay * replay; struct nfs4_replay * replay;
......
...@@ -1248,6 +1248,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd, ...@@ -1248,6 +1248,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
dprintk("RPC: No creds found!\n"); dprintk("RPC: No creds found!\n");
goto out; goto out;
} else { } else {
struct timespec64 boot;
/* steal creds */ /* steal creds */
rsci.cred = ud->creds; rsci.cred = ud->creds;
...@@ -1268,6 +1269,9 @@ static int gss_proxy_save_rsc(struct cache_detail *cd, ...@@ -1268,6 +1269,9 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
&expiry, GFP_KERNEL); &expiry, GFP_KERNEL);
if (status) if (status)
goto out; goto out;
getboottime64(&boot);
expiry -= boot.tv_sec;
} }
rsci.h.expiry_time = expiry; rsci.h.expiry_time = expiry;
......
...@@ -77,6 +77,22 @@ static struct cache_head *sunrpc_cache_find_rcu(struct cache_detail *detail, ...@@ -77,6 +77,22 @@ static struct cache_head *sunrpc_cache_find_rcu(struct cache_detail *detail,
return NULL; return NULL;
} }
static void sunrpc_begin_cache_remove_entry(struct cache_head *ch,
struct cache_detail *cd)
{
/* Must be called under cd->hash_lock */
hlist_del_init_rcu(&ch->cache_list);
set_bit(CACHE_CLEANED, &ch->flags);
cd->entries --;
}
static void sunrpc_end_cache_remove_entry(struct cache_head *ch,
struct cache_detail *cd)
{
cache_fresh_unlocked(ch, cd);
cache_put(ch, cd);
}
static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail, static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail,
struct cache_head *key, struct cache_head *key,
int hash) int hash)
...@@ -100,8 +116,7 @@ static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail, ...@@ -100,8 +116,7 @@ static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail,
hlist_for_each_entry_rcu(tmp, head, cache_list) { hlist_for_each_entry_rcu(tmp, head, cache_list) {
if (detail->match(tmp, key)) { if (detail->match(tmp, key)) {
if (cache_is_expired(detail, tmp)) { if (cache_is_expired(detail, tmp)) {
hlist_del_init_rcu(&tmp->cache_list); sunrpc_begin_cache_remove_entry(tmp, detail);
detail->entries --;
freeme = tmp; freeme = tmp;
break; break;
} }
...@@ -117,10 +132,8 @@ static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail, ...@@ -117,10 +132,8 @@ static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail,
cache_get(new); cache_get(new);
spin_unlock(&detail->hash_lock); spin_unlock(&detail->hash_lock);
if (freeme) { if (freeme)
cache_fresh_unlocked(freeme, detail); sunrpc_end_cache_remove_entry(freeme, detail);
cache_put(freeme, detail);
}
return new; return new;
} }
...@@ -454,8 +467,7 @@ static int cache_clean(void) ...@@ -454,8 +467,7 @@ static int cache_clean(void)
if (!cache_is_expired(current_detail, ch)) if (!cache_is_expired(current_detail, ch))
continue; continue;
hlist_del_init_rcu(&ch->cache_list); sunrpc_begin_cache_remove_entry(ch, current_detail);
current_detail->entries--;
rv = 1; rv = 1;
break; break;
} }
...@@ -465,11 +477,8 @@ static int cache_clean(void) ...@@ -465,11 +477,8 @@ static int cache_clean(void)
if (!ch) if (!ch)
current_index ++; current_index ++;
spin_unlock(&cache_list_lock); spin_unlock(&cache_list_lock);
if (ch) { if (ch)
set_bit(CACHE_CLEANED, &ch->flags); sunrpc_end_cache_remove_entry(ch, d);
cache_fresh_unlocked(ch, d);
cache_put(ch, d);
}
} else } else
spin_unlock(&cache_list_lock); spin_unlock(&cache_list_lock);
...@@ -525,13 +534,9 @@ void cache_purge(struct cache_detail *detail) ...@@ -525,13 +534,9 @@ void cache_purge(struct cache_detail *detail)
for (i = 0; i < detail->hash_size; i++) { for (i = 0; i < detail->hash_size; i++) {
head = &detail->hash_table[i]; head = &detail->hash_table[i];
hlist_for_each_entry_safe(ch, tmp, head, cache_list) { hlist_for_each_entry_safe(ch, tmp, head, cache_list) {
hlist_del_init_rcu(&ch->cache_list); sunrpc_begin_cache_remove_entry(ch, detail);
detail->entries--;
set_bit(CACHE_CLEANED, &ch->flags);
spin_unlock(&detail->hash_lock); spin_unlock(&detail->hash_lock);
cache_fresh_unlocked(ch, detail); sunrpc_end_cache_remove_entry(ch, detail);
cache_put(ch, detail);
spin_lock(&detail->hash_lock); spin_lock(&detail->hash_lock);
} }
} }
...@@ -1885,10 +1890,9 @@ void sunrpc_cache_unhash(struct cache_detail *cd, struct cache_head *h) ...@@ -1885,10 +1890,9 @@ void sunrpc_cache_unhash(struct cache_detail *cd, struct cache_head *h)
{ {
spin_lock(&cd->hash_lock); spin_lock(&cd->hash_lock);
if (!hlist_unhashed(&h->cache_list)){ if (!hlist_unhashed(&h->cache_list)){
hlist_del_init_rcu(&h->cache_list); sunrpc_begin_cache_remove_entry(h, cd);
cd->entries--;
spin_unlock(&cd->hash_lock); spin_unlock(&cd->hash_lock);
cache_put(h, cd); sunrpc_end_cache_remove_entry(h, cd);
} else } else
spin_unlock(&cd->hash_lock); spin_unlock(&cd->hash_lock);
} }
......
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