提交 2010e1b7 编写于 作者: J J. Bruce Fields 提交者: Zheng Zengkai

nfsd: ensure new clients break delegations

stable inclusion
from stable-5.10.38
commit 90e8fa8bdfb38fa4c8425dbb92985441cb7467c0
bugzilla: 51875
CVE: NA

--------------------------------

[ Upstream commit 217fd6f6 ]

If nfsd already has an open file that it plans to use for IO from
another, it may not need to do another vfs open, but it still may need
to break any delegations in case the existing opens are for another
client.

Symptoms are that we may incorrectly fail to break a delegation on a
write open from a different client, when the delegation-holding client
already has a write open.

Fixes: 28df3d15 ("nfsd: clients don't need to break their own delegations")
Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 77deccaa
......@@ -4874,6 +4874,11 @@ static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp,
if (nf)
nfsd_file_put(nf);
status = nfserrno(nfsd_open_break_lease(cur_fh->fh_dentry->d_inode,
access));
if (status)
goto out_put_access;
status = nfsd4_truncate(rqstp, cur_fh, open);
if (status)
goto out_put_access;
......@@ -6856,11 +6861,20 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file_lock *lock)
{
struct nfsd_file *nf;
__be32 err = nfsd_file_acquire(rqstp, fhp, NFSD_MAY_READ, &nf);
if (!err) {
err = nfserrno(vfs_test_lock(nf->nf_file, lock));
nfsd_file_put(nf);
}
__be32 err;
err = nfsd_file_acquire(rqstp, fhp, NFSD_MAY_READ, &nf);
if (err)
return err;
fh_lock(fhp); /* to block new leases till after test_lock: */
err = nfserrno(nfsd_open_break_lease(fhp->fh_dentry->d_inode,
NFSD_MAY_READ));
if (err)
goto out;
err = nfserrno(vfs_test_lock(nf->nf_file, lock));
out:
fh_unlock(fhp);
nfsd_file_put(nf);
return err;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册