@@ -4046,16 +4046,29 @@ int nfs4_set_rw_stateid(nfs4_stateid *stateid,
}
EXPORT_SYMBOL_GPL(nfs4_set_rw_stateid);
-static bool nfs4_stateid_is_current(nfs4_stateid *stateid,
+/**
+ * @stateid: stateid to test
+ * @ctx: open context with current stateid (unless lock context)
+ * @l_ctx: lock context with current stateid
+ * @fmode: open mode
+ *
+ * returns
+ * 0: @stateid does not match current stateid
+ * 1: @stateid matches current stateid
+ * negative: error
+ */
+static int nfs4_stateid_is_current(nfs4_stateid *stateid,
const struct nfs_open_context *ctx,
const struct nfs_lock_context *l_ctx,
fmode_t fmode)
{
nfs4_stateid current_stateid;
+ int ret;
- if (nfs4_set_rw_stateid(¤t_stateid, ctx, l_ctx, fmode))
- return false;
- return nfs4_stateid_match(stateid, ¤t_stateid);
+ ret = nfs4_set_rw_stateid(¤t_stateid, ctx, l_ctx, fmode);
+ if (ret == 0) /* current stateid set, see if it matches input stateid */
+ return nfs4_stateid_match(stateid, ¤t_stateid) ? 1 : 0;
+ return ret; /* error */
}
static bool nfs4_error_stateid_expired(int err)
@@ -1112,6 +1112,12 @@ static int nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state)
/*
* Byte-range lock aware utility to initialize the stateid of read/write
* requests.
+ *
+ * returns:
+ * 0: success, stateid selected and copied
+ * -EWOULDBLOCK: from nfs4_copy_open. stateid change in progress
+ * with stateid copied
+ * -EIO: lost lock, fail I/O
*/
int nfs4_select_rw_stateid(nfs4_stateid *dst, struct nfs4_state *state,
fmode_t fmode, const struct nfs_lockowner *lockowner)