mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-15 22:31:47 -04:00
Merge tag 'nfsd-7.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
Pull nfsd fixes from Chuck Lever: "Fixes for this release: - Correctness fix for the new sunrpc cache netlink protocol Marked for stable: - Correctness fixes for delegated attributes - Prevent an infinite loop when revoking layouts" * tag 'nfsd-7.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: NFSD: Fix infinite loop in layout state revocation sunrpc: start cache request seqno at 1 to fix netlink GET_REQS nfsd: update mtime/ctime on COPY in presence of delegated attributes nfsd: update mtime/ctime on CLONE in presense of delegated attributes nfsd: fix file change detection in CB_GETATTR nfsd: fix GET_DIR_DELEGATION when VFS leases are disabled
This commit is contained in:
@@ -1413,6 +1413,9 @@ nfsd4_clone(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||
dst, clone->cl_dst_pos, clone->cl_count,
|
||||
EX_ISSYNC(cstate->current_fh.fh_export));
|
||||
|
||||
if (!status && (READ_ONCE(dst->nf_file->f_mode) & FMODE_NOCMTIME) != 0)
|
||||
nfsd_update_cmtime_attr(dst->nf_file, 0);
|
||||
|
||||
nfsd_file_put(dst);
|
||||
nfsd_file_put(src);
|
||||
out:
|
||||
@@ -2118,8 +2121,10 @@ static int nfsd4_do_async_copy(void *data)
|
||||
|
||||
set_bit(NFSD4_COPY_F_COMPLETED, ©->cp_flags);
|
||||
trace_nfsd_copy_async_done(copy);
|
||||
nfsd4_send_cb_offload(copy);
|
||||
atomic_dec(©->cp_nn->pending_async_copies);
|
||||
if (copy->cp_res.wr_bytes_written > 0 && copy->attr_update)
|
||||
nfsd_update_cmtime_attr(copy->nf_dst->nf_file, 0);
|
||||
nfsd4_send_cb_offload(copy);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2179,6 +2184,9 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||
memcpy(&result->cb_stateid, ©->cp_stateid.cs_stid,
|
||||
sizeof(result->cb_stateid));
|
||||
dup_copy_fields(copy, async_copy);
|
||||
if ((READ_ONCE(copy->nf_dst->nf_file->f_mode) &
|
||||
FMODE_NOCMTIME) != 0)
|
||||
async_copy->attr_update = true;
|
||||
memcpy(async_copy->cp_cb_offload.co_referring_sessionid.data,
|
||||
cstate->session->se_sessionid.data,
|
||||
NFS4_MAX_SESSIONID_LEN);
|
||||
@@ -2197,6 +2205,10 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||
} else {
|
||||
status = nfsd4_do_copy(copy, copy->nf_src->nf_file,
|
||||
copy->nf_dst->nf_file, true);
|
||||
if ((READ_ONCE(copy->nf_dst->nf_file->f_mode) &
|
||||
FMODE_NOCMTIME) != 0 &&
|
||||
copy->cp_res.wr_bytes_written > 0)
|
||||
nfsd_update_cmtime_attr(copy->nf_dst->nf_file, 0);
|
||||
}
|
||||
out:
|
||||
trace_nfsd_copy_done(copy, status);
|
||||
@@ -2535,10 +2547,6 @@ nfsd4_get_dir_delegation(struct svc_rqst *rqstp,
|
||||
dd = nfsd_get_dir_deleg(cstate, gdd, nf);
|
||||
nfsd_file_put(nf);
|
||||
if (IS_ERR(dd)) {
|
||||
int err = PTR_ERR(dd);
|
||||
|
||||
if (err != -EAGAIN)
|
||||
return nfserrno(err);
|
||||
gdd->gddrnf_status = GDD4_UNAVAIL;
|
||||
return nfs_ok;
|
||||
}
|
||||
|
||||
@@ -1221,10 +1221,6 @@ static void put_deleg_file(struct nfs4_file *fp)
|
||||
|
||||
static void nfsd4_finalize_deleg_timestamps(struct nfs4_delegation *dp, struct file *f)
|
||||
{
|
||||
struct iattr ia = { .ia_valid = ATTR_ATIME | ATTR_CTIME | ATTR_MTIME | ATTR_DELEG };
|
||||
struct inode *inode = file_inode(f);
|
||||
int ret;
|
||||
|
||||
/* don't do anything if FMODE_NOCMTIME isn't set */
|
||||
if ((READ_ONCE(f->f_mode) & FMODE_NOCMTIME) == 0)
|
||||
return;
|
||||
@@ -1242,17 +1238,7 @@ static void nfsd4_finalize_deleg_timestamps(struct nfs4_delegation *dp, struct f
|
||||
return;
|
||||
|
||||
/* Stamp everything to "now" */
|
||||
inode_lock(inode);
|
||||
ret = notify_change(&nop_mnt_idmap, f->f_path.dentry, &ia, NULL);
|
||||
inode_unlock(inode);
|
||||
if (ret) {
|
||||
struct inode *inode = file_inode(f);
|
||||
|
||||
pr_notice_ratelimited("nfsd: Unable to update timestamps on inode %02x:%02x:%llu: %d\n",
|
||||
MAJOR(inode->i_sb->s_dev),
|
||||
MINOR(inode->i_sb->s_dev),
|
||||
inode->i_ino, ret);
|
||||
}
|
||||
nfsd_update_cmtime_attr(f, ATTR_ATIME);
|
||||
}
|
||||
|
||||
static void nfs4_unlock_deleg_lease(struct nfs4_delegation *dp)
|
||||
@@ -1865,6 +1851,13 @@ void nfsd4_revoke_states(struct nfsd_net *nn, struct super_block *sb)
|
||||
break;
|
||||
case SC_TYPE_LAYOUT:
|
||||
ls = layoutstateid(stid);
|
||||
spin_lock(&clp->cl_lock);
|
||||
if (stid->sc_status == 0) {
|
||||
stid->sc_status |=
|
||||
SC_STATUS_ADMIN_REVOKED;
|
||||
atomic_inc(&clp->cl_admin_revoked);
|
||||
}
|
||||
spin_unlock(&clp->cl_lock);
|
||||
nfsd4_close_layout(ls);
|
||||
break;
|
||||
}
|
||||
@@ -6378,7 +6371,6 @@ nfs4_open_delegation(struct svc_rqst *rqstp, struct nfsd4_open *open,
|
||||
}
|
||||
open->op_delegate_type = deleg_ts ? OPEN_DELEGATE_WRITE_ATTRS_DELEG :
|
||||
OPEN_DELEGATE_WRITE;
|
||||
dp->dl_cb_fattr.ncf_cur_fsize = stat.size;
|
||||
dp->dl_cb_fattr.ncf_initial_cinfo = nfsd4_change_attribute(&stat);
|
||||
dp->dl_atime = stat.atime;
|
||||
dp->dl_ctime = stat.ctime;
|
||||
@@ -9429,11 +9421,15 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct dentry *dentry,
|
||||
if (status != nfserr_jukebox ||
|
||||
!nfsd_wait_for_delegreturn(rqstp, inode))
|
||||
goto out_status;
|
||||
status = nfs_ok;
|
||||
goto out_status;
|
||||
}
|
||||
if (!ncf->ncf_file_modified) {
|
||||
if (ncf->ncf_initial_cinfo != ncf->ncf_cb_change)
|
||||
ncf->ncf_file_modified = true;
|
||||
else if (i_size_read(inode) != ncf->ncf_cb_fsize)
|
||||
ncf->ncf_file_modified = true;
|
||||
}
|
||||
if (!ncf->ncf_file_modified &&
|
||||
(ncf->ncf_initial_cinfo != ncf->ncf_cb_change ||
|
||||
ncf->ncf_cur_fsize != ncf->ncf_cb_fsize))
|
||||
ncf->ncf_file_modified = true;
|
||||
if (ncf->ncf_file_modified) {
|
||||
int err;
|
||||
|
||||
@@ -9560,3 +9556,31 @@ nfsd_get_dir_deleg(struct nfsd4_compound_state *cstate,
|
||||
put_nfs4_file(fp);
|
||||
return ERR_PTR(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* nfsd_update_cmtime_attr - update file's delegated ctime/mtime,
|
||||
* and optionally other attributes (ie ATTR_ATIME).
|
||||
* @f: pointer to an opened file
|
||||
* @flags: any additional flags that should be updated
|
||||
*
|
||||
* Given upon opening a file delegated attributes were issues, update
|
||||
* @f attributes to current times.
|
||||
*/
|
||||
void nfsd_update_cmtime_attr(struct file *f, unsigned int flags)
|
||||
{
|
||||
int ret;
|
||||
struct inode *inode = file_inode(f);
|
||||
struct iattr attr = {
|
||||
.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_DELEG | flags,
|
||||
};
|
||||
|
||||
inode_lock(inode);
|
||||
ret = notify_change(&nop_mnt_idmap, f->f_path.dentry, &attr, NULL);
|
||||
inode_unlock(inode);
|
||||
if (ret)
|
||||
pr_notice_ratelimited("nfsd: Unable to update timestamps on "
|
||||
"inode %02x:%02x:%llu: %d\n",
|
||||
MAJOR(inode->i_sb->s_dev),
|
||||
MINOR(inode->i_sb->s_dev),
|
||||
inode->i_ino, ret);
|
||||
}
|
||||
|
||||
@@ -843,6 +843,7 @@ extern void nfsd4_shutdown_copy(struct nfs4_client *clp);
|
||||
void nfsd4_put_client(struct nfs4_client *clp);
|
||||
void nfsd4_async_copy_reaper(struct nfsd_net *nn);
|
||||
bool nfsd4_has_active_async_copies(struct nfs4_client *clp);
|
||||
void nfsd_update_cmtime_attr(struct file *f, unsigned int flags);
|
||||
extern struct nfs4_client_reclaim *nfs4_client_to_reclaim(struct xdr_netobj name,
|
||||
struct xdr_netobj princhash, struct nfsd_net *nn);
|
||||
extern bool nfs4_has_reclaimed_state(struct xdr_netobj name, struct nfsd_net *nn);
|
||||
|
||||
@@ -752,6 +752,7 @@ struct nfsd4_copy {
|
||||
|
||||
struct nfsd_file *nf_src;
|
||||
struct nfsd_file *nf_dst;
|
||||
bool attr_update;
|
||||
|
||||
copy_stateid_t cp_stateid;
|
||||
|
||||
|
||||
@@ -403,7 +403,7 @@ void sunrpc_init_cache_detail(struct cache_detail *cd)
|
||||
INIT_LIST_HEAD(&cd->readers);
|
||||
spin_lock_init(&cd->queue_lock);
|
||||
init_waitqueue_head(&cd->queue_wait);
|
||||
cd->next_seqno = 0;
|
||||
cd->next_seqno = 1;
|
||||
spin_lock(&cache_list_lock);
|
||||
cd->nextcheck = 0;
|
||||
cd->entries = 0;
|
||||
|
||||
Reference in New Issue
Block a user