All of lore.kernel.org
 help / color / mirror / Atom feed
* compound header status
@ 2008-02-21  5:18 Halevy, Benny
       [not found] ` <E472128B1EB43941B4E7FB268020C89B054968F1-XOSzO3tqRPoWvTAaqqP10hT1OSi83eBDAL8bYrjMMd8@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Halevy, Benny @ 2008-02-21  5:18 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: nfsv4, pnfs, linux-nfs

Trond, we had a discussion today in Austin about the COMPOUND result header
status.  Looking at fs/nfs/nfs4xdr.c we saw that some decoding routines
return an error based on hdr.status after all the compound operations
decoding completed successfully.

For example:
static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo)
{
	struct xdr_stream xdr;
	struct compound_hdr hdr;
	int status;

	xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
	status = decode_compound_hdr(&xdr, &hdr);
	if (!status)
		status = decode_setclientid_confirm(&xdr);
	if (!status)
		status = decode_putrootfh(&xdr);
	if (!status)
		status = decode_fsinfo(&xdr, fsinfo);
	if (!status)
		status = -nfs4_stat_to_errno(hdr.status);
		                             ^^^^^^^^^^
	return status;
}

It seems like this is unneeded since hdr.status must be NFS_OK if all operations
in the compound succeeded (and assuming we decode the results from all ops we sent).
The first error will be found by decode_op_hdr called by any of the decoding
routines for the individual ops.
If hdr.status contains an error in this case, the server must be broken, isn't it?

Also, nfs4_stat_to_errno is not handling the success case very efficiently as
it looks for it in its mapping table like any other error code.

One more thing, all use sites for nfs4_stat_to_errno negate its return value
so it might make sense to return a negative error from nfs4_stat_to_errno rather
than negating its return value everywhere.

Benny


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: compound header status
       [not found] ` <E472128B1EB43941B4E7FB268020C89B054968F1-XOSzO3tqRPoWvTAaqqP10hT1OSi83eBDAL8bYrjMMd8@public.gmane.org>
@ 2008-02-21 21:15   ` Trond Myklebust
       [not found]     ` <1203628540.8258.28.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2008-02-21 21:15 UTC (permalink / raw)
  To: Halevy, Benny; +Cc: nfsv4, pnfs, linux-nfs


On Thu, 2008-02-21 at 00:18 -0500, Halevy, Benny wrote:
> Trond, we had a discussion today in Austin about the COMPOUND result header
> status.  Looking at fs/nfs/nfs4xdr.c we saw that some decoding routines
> return an error based on hdr.status after all the compound operations
> decoding completed successfully.
> 
> For example:
> static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo)
> {
> 	struct xdr_stream xdr;
> 	struct compound_hdr hdr;
> 	int status;
> 
> 	xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
> 	status = decode_compound_hdr(&xdr, &hdr);
> 	if (!status)
> 		status = decode_setclientid_confirm(&xdr);
> 	if (!status)
> 		status = decode_putrootfh(&xdr);
> 	if (!status)
> 		status = decode_fsinfo(&xdr, fsinfo);
> 	if (!status)
> 		status = -nfs4_stat_to_errno(hdr.status);
> 		                             ^^^^^^^^^^
> 	return status;
> }
> 
> It seems like this is unneeded since hdr.status must be NFS_OK if all operations
> in the compound succeeded (and assuming we decode the results from all ops we sent).
> The first error will be found by decode_op_hdr called by any of the decoding
> routines for the individual ops.
> If hdr.status contains an error in this case, the server must be broken, isn't it?

Agreed. I can only see 3 cases where we do this, but it would be nice to
fix them.

> One more thing, all use sites for nfs4_stat_to_errno negate its return value
> so it might make sense to return a negative error from nfs4_stat_to_errno rather
> than negating its return value everywhere.

If we do, then we should fix up nfs_stat_to_errno() too. It will just
get confusing if we establish differing standards between NFSv2/v3 and
NFSv4.

Trond

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pnfs] compound header status
       [not found]     ` <1203628540.8258.28.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
@ 2008-02-21 22:37       ` Benny Halevy
  0 siblings, 0 replies; 3+ messages in thread
From: Benny Halevy @ 2008-02-21 22:37 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: linux-nfs, pnfs, nfsv4

On Feb. 21, 2008, 15:15 -0600, Trond Myklebust <Trond.Myklebust@netapp.com> wrote:
> On Thu, 2008-02-21 at 00:18 -0500, Halevy, Benny wrote:
>> Trond, we had a discussion today in Austin about the COMPOUND result header
>> status.  Looking at fs/nfs/nfs4xdr.c we saw that some decoding routines
>> return an error based on hdr.status after all the compound operations
>> decoding completed successfully.
>>
>> For example:
>> static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo)
>> {
>> 	struct xdr_stream xdr;
>> 	struct compound_hdr hdr;
>> 	int status;
>>
>> 	xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
>> 	status = decode_compound_hdr(&xdr, &hdr);
>> 	if (!status)
>> 		status = decode_setclientid_confirm(&xdr);
>> 	if (!status)
>> 		status = decode_putrootfh(&xdr);
>> 	if (!status)
>> 		status = decode_fsinfo(&xdr, fsinfo);
>> 	if (!status)
>> 		status = -nfs4_stat_to_errno(hdr.status);
>> 		                             ^^^^^^^^^^
>> 	return status;
>> }
>>
>> It seems like this is unneeded since hdr.status must be NFS_OK if all operations
>> in the compound succeeded (and assuming we decode the results from all ops we sent).
>> The first error will be found by decode_op_hdr called by any of the decoding
>> routines for the individual ops.
>> If hdr.status contains an error in this case, the server must be broken, isn't it?
> 
> Agreed. I can only see 3 cases where we do this, but it would be nice to
> fix them.

Cool. The cases we do need to look at hdr.status are when we fail to
decode the op header, i.e. we ran out of bytes to code, or the opnum
doesn't match what we expect.  Then, if hdr.status != NFS_OK we should
translate and return this error rather than a generic -EIO;

> 
>> One more thing, all use sites for nfs4_stat_to_errno negate its return value
>> so it might make sense to return a negative error from nfs4_stat_to_errno rather
>> than negating its return value everywhere.
> 
> If we do, then we should fix up nfs_stat_to_errno() too. It will just
> get confusing if we establish differing standards between NFSv2/v3 and
> NFSv4.

Agreed.  This will be in a separate patch of course.

Benny

> 
> Trond
> _______________________________________________
> pNFS mailing list
> pNFS@linux-nfs.org
> http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-02-21 22:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-21  5:18 compound header status Halevy, Benny
     [not found] ` <E472128B1EB43941B4E7FB268020C89B054968F1-XOSzO3tqRPoWvTAaqqP10hT1OSi83eBDAL8bYrjMMd8@public.gmane.org>
2008-02-21 21:15   ` Trond Myklebust
     [not found]     ` <1203628540.8258.28.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-02-21 22:37       ` [pnfs] " Benny Halevy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.