NFSv4: OPEN must handle the NFS4ERR_IO return code correctly
decode_op_hdr() cannot distinguish between an XDR decoding error and the perfectly valid errorcode NFS4ERR_IO. This is normally not a problem, but for the particular case of OPEN, we need to be able to increment the NFSv4 open sequence id when the server returns a valid response. Reported-by: J Bruce Fields <bfields@fieldses.org> Link: http://lkml.kernel.org/r/20131204210356.GA19452@fieldses.org Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Cc: stable@vger.kernel.org
This commit is contained in:
parent
374b105797
commit
c7848f69ec
|
@ -3097,7 +3097,8 @@ out_overflow:
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
|
static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected,
|
||||||
|
int *nfs_retval)
|
||||||
{
|
{
|
||||||
__be32 *p;
|
__be32 *p;
|
||||||
uint32_t opnum;
|
uint32_t opnum;
|
||||||
|
@ -3107,19 +3108,32 @@ static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
|
||||||
if (unlikely(!p))
|
if (unlikely(!p))
|
||||||
goto out_overflow;
|
goto out_overflow;
|
||||||
opnum = be32_to_cpup(p++);
|
opnum = be32_to_cpup(p++);
|
||||||
if (opnum != expected) {
|
if (unlikely(opnum != expected))
|
||||||
|
goto out_bad_operation;
|
||||||
|
nfserr = be32_to_cpup(p);
|
||||||
|
if (nfserr == NFS_OK)
|
||||||
|
*nfs_retval = 0;
|
||||||
|
else
|
||||||
|
*nfs_retval = nfs4_stat_to_errno(nfserr);
|
||||||
|
return true;
|
||||||
|
out_bad_operation:
|
||||||
dprintk("nfs: Server returned operation"
|
dprintk("nfs: Server returned operation"
|
||||||
" %d but we issued a request for %d\n",
|
" %d but we issued a request for %d\n",
|
||||||
opnum, expected);
|
opnum, expected);
|
||||||
return -EIO;
|
*nfs_retval = -EREMOTEIO;
|
||||||
}
|
return false;
|
||||||
nfserr = be32_to_cpup(p);
|
|
||||||
if (nfserr != NFS_OK)
|
|
||||||
return nfs4_stat_to_errno(nfserr);
|
|
||||||
return 0;
|
|
||||||
out_overflow:
|
out_overflow:
|
||||||
print_overflow_msg(__func__, xdr);
|
print_overflow_msg(__func__, xdr);
|
||||||
return -EIO;
|
*nfs_retval = -EIO;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
|
||||||
|
{
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
__decode_op_hdr(xdr, expected, &retval);
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dummy routine */
|
/* Dummy routine */
|
||||||
|
@ -5001,10 +5015,11 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
|
||||||
uint32_t savewords, bmlen, i;
|
uint32_t savewords, bmlen, i;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = decode_op_hdr(xdr, OP_OPEN);
|
if (!__decode_op_hdr(xdr, OP_OPEN, &status))
|
||||||
if (status != -EIO)
|
return status;
|
||||||
nfs_increment_open_seqid(status, res->seqid);
|
nfs_increment_open_seqid(status, res->seqid);
|
||||||
if (!status)
|
if (status)
|
||||||
|
return status;
|
||||||
status = decode_stateid(xdr, &res->stateid);
|
status = decode_stateid(xdr, &res->stateid);
|
||||||
if (unlikely(status))
|
if (unlikely(status))
|
||||||
return status;
|
return status;
|
||||||
|
|
Loading…
Reference in New Issue