Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2d2f24ad authored by Trond Myklebust's avatar Trond Myklebust
Browse files

NFSv4: Simplify the struct nfs4_stateid



Replace the union with the common struct stateid4 as defined in both
RFC3530 and RFC5661. This makes it easier to access the sequence id,
which will again make implementing support for parallel OPEN calls
easier.

Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent f597c537
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -138,10 +138,10 @@ static __be32 decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
{
	__be32 *p;

	p = read_buf(xdr, 16);
	p = read_buf(xdr, NFS4_STATEID_SIZE);
	if (unlikely(p == NULL))
		return htonl(NFS4ERR_RESOURCE);
	memcpy(stateid->data, p, 16);
	memcpy(stateid, p, NFS4_STATEID_SIZE);
	return 0;
}

+2 −2
Original line number Diff line number Diff line
@@ -351,12 +351,12 @@ extern struct svc_version nfs4_callback_version4;

static inline void nfs4_stateid_copy(nfs4_stateid *dst, const nfs4_stateid *src)
{
	memcpy(dst->data, src->data, sizeof(dst->data));
	memcpy(dst, src, sizeof(*dst));
}

static inline bool nfs4_stateid_match(const nfs4_stateid *dst, const nfs4_stateid *src)
{
	return memcmp(dst->data, src->data, sizeof(dst->data)) == 0;
	return memcmp(dst, src, sizeof(*dst)) == 0;
}

#else
+3 −4
Original line number Diff line number Diff line
@@ -6271,13 +6271,12 @@ static int nfs41_free_stateid(struct nfs_server *server, nfs4_stateid *stateid)
static bool nfs41_match_stateid(const nfs4_stateid *s1,
		const nfs4_stateid *s2)
{
	if (memcmp(s1->stateid.other, s2->stateid.other,
		   sizeof(s1->stateid.other)) != 0)
	if (memcmp(s1->other, s2->other, sizeof(s1->other)) != 0)
		return false;

	if (s1->stateid.seqid == s2->stateid.seqid)
	if (s1->seqid == s2->seqid)
		return true;
	if (s1->stateid.seqid == 0 || s2->stateid.seqid == 0)
	if (s1->seqid == 0 || s2->seqid == 0)
		return true;

	return false;
+2 −2
Original line number Diff line number Diff line
@@ -1240,8 +1240,8 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs
				 * Open state on this file cannot be recovered
				 * All we can do is revert to using the zero stateid.
				 */
				memset(state->stateid.data, 0,
					sizeof(state->stateid.data));
				memset(&state->stateid, 0,
					sizeof(state->stateid));
				/* Mark the file as being 'closed' */
				state->state = 0;
				break;
+3 −3
Original line number Diff line number Diff line
@@ -930,7 +930,7 @@ static void encode_nops(struct compound_hdr *hdr)

static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid)
{
	encode_opaque_fixed(xdr, stateid->data, NFS4_STATEID_SIZE);
	encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE);
}

static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf)
@@ -1548,7 +1548,7 @@ static void encode_open_stateid(struct xdr_stream *xdr, const struct nfs_open_co
	if (ctx->state != NULL) {
		nfs4_select_rw_stateid(&stateid, ctx->state, l_ctx->lockowner, l_ctx->pid);
		if (zero_seqid)
			stateid.stateid.seqid = 0;
			stateid.seqid = 0;
		encode_nfs4_stateid(xdr, &stateid);
	} else
		encode_nfs4_stateid(xdr, &zero_stateid);
@@ -4237,7 +4237,7 @@ static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len)

static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
{
	return decode_opaque_fixed(xdr, stateid->data, NFS4_STATEID_SIZE);
	return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE);
}

static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
Loading