In the case where SEQUENCE receives a NFS4ERR_BADSESSION or
NFS4ERR_DEADSESSION error, we just want to report the session as needing
recovery, and then we want to retry the operation.
Signed-off-by: Trond Myklebust <[email protected]>
---
fs/nfs/nfs4proc.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index f992281c9b29..4fd0e2b7b08e 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -816,6 +816,10 @@ static int nfs41_sequence_process(struct rpc_task *task,
case -NFS4ERR_SEQ_FALSE_RETRY:
++slot->seq_nr;
goto retry_nowait;
+ case -NFS4ERR_DEADSESSION:
+ case -NFS4ERR_BADSESSION:
+ nfs4_schedule_session_recovery(session, res->sr_status);
+ goto retry_nowait;
default:
/* Just update the slot sequence no. */
slot->seq_done = 1;
--
2.9.3
If the session has an error, then we want to start by recovering the
session, as any SEQUENCE we send is going to fail with a session
error.
Signed-off-by: Trond Myklebust <[email protected]>
---
fs/nfs/nfs4state.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 26b6b8b0cae3..95baf7d340f0 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -2193,7 +2193,7 @@ void nfs4_schedule_session_recovery(struct nfs4_session *session, int err)
case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
set_bit(NFS4CLNT_BIND_CONN_TO_SESSION, &clp->cl_state);
}
- nfs4_schedule_lease_recovery(clp);
+ nfs4_schedule_state_manager(clp);
}
EXPORT_SYMBOL_GPL(nfs4_schedule_session_recovery);
--
2.9.3
On Sun, Dec 4, 2016 at 7:40 PM, Trond Myklebust
<[email protected]> wrote:
> In the case where SEQUENCE receives a NFS4ERR_BADSESSION or
> NFS4ERR_DEADSESSION error, we just want to report the session as needing
> recovery, and then we want to retry the operation.
>
> Signed-off-by: Trond Myklebust <[email protected]>
> ---
> fs/nfs/nfs4proc.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index f992281c9b29..4fd0e2b7b08e 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -816,6 +816,10 @@ static int nfs41_sequence_process(struct rpc_task *task,
> case -NFS4ERR_SEQ_FALSE_RETRY:
> ++slot->seq_nr;
> goto retry_nowait;
> + case -NFS4ERR_DEADSESSION:
> + case -NFS4ERR_BADSESSION:
> + nfs4_schedule_session_recovery(session, res->sr_status);
> + goto retry_nowait;
> default:
> /* Just update the slot sequence no. */
> slot->seq_done = 1;
> --
> 2.9.3
Hi Trond,
Can you explain the implications of retrying the operation without
waiting for recovery to complete?
This patch introduces regression in intra COPY failing if the server
rebooted during that operation. What happens is that COPY is re-sent
with the same stateid from the old open instead of the open that was
done from the recovery (leading to BAD_STATEID error and failure).
I wonder if it's because COPY is written to just use nfs4_call_sync()
instead of defining rpc_callback_ops to handle rpc_prepare() where a
new stateid could be gotten? I have re-written the COPY to do that and
I no longer see that problem.
If my suspicion is correct, it would help for the future to know that
any operations that use stateid must have rpc callback ops
defined/used so that they avoid this problem. Perhaps as a comment in
the code or maybe some other way?
Thanks.
T24gV2VkLCAyMDE3LTAyLTE1IGF0IDE1OjE2IC0wNTAwLCBPbGdhIEtvcm5pZXZza2FpYSB3cm90
ZToNCj4gT24gU3VuLCBEZWMgNCwgMjAxNiBhdCA3OjQwIFBNLCBUcm9uZCBNeWtsZWJ1c3QNCj4g
PHRyb25kLm15a2xlYnVzdEBwcmltYXJ5ZGF0YS5jb20+IHdyb3RlOg0KPiA+IEluIHRoZSBjYXNl
IHdoZXJlIFNFUVVFTkNFIHJlY2VpdmVzIGEgTkZTNEVSUl9CQURTRVNTSU9OIG9yDQo+ID4gTkZT
NEVSUl9ERUFEU0VTU0lPTiBlcnJvciwgd2UganVzdCB3YW50IHRvIHJlcG9ydCB0aGUg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G8gcnBjX2NhbGxfc3luYygpDQog
Y29pbmNpZGVzIHdpdGggYSByZWJvb3QgcmVjb3ZlcnkgdGhhdCB3YXMgc3RhcnRlZCBieSBhbm90
aGVyIHByb2Nlc3MuDQoNCi0tIA0KVHJvbmQgTXlrbGVidXN0DQpMaW51eCBORlMgY2xpZW50IG1h
aW50YWluZXIsIFByaW1hcnlEYXRhDQp0cm9uZC5teWtsZWJ1c3RAcHJpbWFyeWRhdGEuY29tDQo=
On Wed, Feb 15, 2017 at 3:48 PM, Trond Myklebust
<[email protected]> wrote:
> On Wed, 2017-02-15 at 15:16 -0500, Olga Kornievskaia wrote:
>> On Sun, Dec 4, 2016 at 7:40 PM, Trond Myklebust
>> <[email protected]> wrote:
>> > In the case where SEQUENCE receives a NFS4ERR_BADSESSION or
>> > NFS4ERR_DEADSESSION error, we just want to report the session as
>> > needing
>> > recovery, and then we want to retry the operation.
>> >
>> > Signed-off-by: Trond Myklebust <[email protected]>
>> > ---
>> > fs/nfs/nfs4proc.c | 4 ++++
>> > 1 file changed, 4 insertions(+)
>> >
>> > diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
>> > index f992281c9b29..4fd0e2b7b08e 100644
>> > --- a/fs/nfs/nfs4proc.c
>> > +++ b/fs/nfs/nfs4proc.c
>> > @@ -816,6 +816,10 @@ static int nfs41_sequence_process(struct
>> > rpc_task *task,
>> > case -NFS4ERR_SEQ_FALSE_RETRY:
>> > ++slot->seq_nr;
>> > goto retry_nowait;
>> > + case -NFS4ERR_DEADSESSION:
>> > + case -NFS4ERR_BADSESSION:
>> > + nfs4_schedule_session_recovery(session, res-
>> > >sr_status);
>> > + goto retry_nowait;
>> > default:
>> > /* Just update the slot sequence no. */
>> > slot->seq_done = 1;
>> > --
>> > 2.9.3
>>
>> Hi Trond,
>>
>> Can you explain the implications of retrying the operation without
>> waiting for recovery to complete?
>>
>> This patch introduces regression in intra COPY failing if the server
>> rebooted during that operation. What happens is that COPY is re-sent
>> with the same stateid from the old open instead of the open that was
>> done from the recovery (leading to BAD_STATEID error and failure).
>>
>> I wonder if it's because COPY is written to just use nfs4_call_sync()
>> instead of defining rpc_callback_ops to handle rpc_prepare() where a
>> new stateid could be gotten? I have re-written the COPY to do that
>> and
>> I no longer see that problem.
>>
>> If my suspicion is correct, it would help for the future to know that
>> any operations that use stateid must have rpc callback ops
>> defined/used so that they avoid this problem. Perhaps as a comment in
>> the code or maybe some other way?
>>
>> Thanks.
>>
> Yes, the way that rpc_call_sync() has been written, it assumes that the
> call is unaffected by reboot recovery, or that the resulting state
> errors will be handled by the caller. The patch you reference does not
> change that expectation.
The "or" is confusing me. The current COPY code does call into
nfs4_handle_exception() and "should handle errors". Yet after this
patch, the code fails to in presence of a reboot. I don't see what
else can the current code should do in terms of handling errors to fix
that problem.
I'm almost ready to submit the patch that turns the existing code into
async rpc but if this is not the right approach then I'd like to know
where I should be looking into instead.
Thanks.
>
> The same race can happen, for instance, if your call to rpc_call_sync()
> coincides with a reboot recovery that was started by another process.
>
> --
> Trond Myklebust
> Linux NFS client maintainer, PrimaryData
> [email protected]
T24gV2VkLCAyMDE3LTAyLTE1IGF0IDE2OjU2IC0wNTAwLCBPbGdhIEtvcm5pZXZza2FpYSB3cm90
ZToNCj4gT24gV2VkLCBGZWIgMTUsIDIwMTcgYXQgMzo0OCBQTSwgVHJvbmQgTXlrbGVidXN0DQo+
IDx0cm9uZG15QHByaW1hcnlkYXRhLmNvbT4gd3JvdGU6DQo+ID4gT24gV2VkLCAyMDE3LTAyLTE1
IGF0IDE1OjE2IC0wNTAwLCBPbGdhIEtvcm5pZXZza2FpYSB3cm90ZToNCj4gPiA+IE9uIFN1biwg
RGVjIDQsIDIwMTYgYXQgNzo0MCBQTSwgVHJvbmQgTXlrbGVidXN0DQo+ID4gPiA8dHJvbmQubXlr
bGVidXN0QHByaW1hcnlkYXRhLmNvbT4gd3JvdGU6DQo+ID4gPiA+IEluIHRoZSBjYXNlIHdoZXJl
IFNFUVVFTkNFIH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MgcnBjIGJ1dCBpZiB0aGlzIGlzIG5vdCB0aGUgcmlnaHQg
YXBwcm9hY2ggdGhlbiBJJ2QgbGlrZSB0byBrbm93DQo+IHdoZXJlIEkgc2hvdWxkIGJlIGxvb2tp
bmcgaW50byBpbnN0ZWFkLg0KPiANCj4gVGhhbmtzLg0KPiANCj4gPiANCj4gPiBUaGUgc2FtZSBy
YWNlIGNhbiBoYXBwZW4sIGZvciBpbnN0YW5jZSwgaWYgeW91ciBjYWxsIHRvDQo+ID4gcnBjX2Nh
bGxfc3luYygpDQo+ID4gwqBjb2luY2lkZXMgd2l0aCBhIHJlYm9vdCByZWNvdmVyeSB0aGF0IHdh
cyBzdGFydGVkIGJ5IGFub3RoZXINCj4gPiBwcm9jZXNzLg0KPiA+IA0KDQoNCkkgZG9uJ3QgdW5k
ZXJzdGFuZC4gSWYgaXQgaXMgaGFuZGxpbmcgdGhlIHJlc3VsdGluZyBORlM0RVJSX0JBRF9TVEFU
RUlEDQplcnJvciBjb3JyZWN0bHksIHRoZW4gd2hhdCBpcyBmYWlsaW5nPyBBcyBJIHNhaWQgYWJv
dmUsIHlvdSBjYW4gZ2V0IHRoZQ0KTkZTNEVSUl9CQURfU1RBVEVJRCBmcm9twqBvdGhlciBpbnN0
YW5jZXMgb2YgdGhlIHNhbWUgcmFjZS4NCg0KLS0gDQpUcm9uZCBNeWtsZWJ1c3QNCkxpbnV4IE5G
UyBjbGllbnQgbWFpbnRhaW5lciwgUHJpbWFyeURhdGENCnRyb25kLm15a2xlYnVzdEBwcmltYXJ5
ZGF0YS5jb20NCg==
On Wed, Feb 15, 2017 at 5:23 PM, Trond Myklebust
<[email protected]> wrote:
> On Wed, 2017-02-15 at 16:56 -0500, Olga Kornievskaia wrote:
>> On Wed, Feb 15, 2017 at 3:48 PM, Trond Myklebust
>> <[email protected]> wrote:
>> > On Wed, 2017-02-15 at 15:16 -0500, Olga Kornievskaia wrote:
>> > > On Sun, Dec 4, 2016 at 7:40 PM, Trond Myklebust
>> > > <[email protected]> wrote:
>> > > > In the case where SEQUENCE receives a NFS4ERR_BADSESSION or
>> > > > NFS4ERR_DEADSESSION error, we just want to report the session
>> > > > as
>> > > > needing
>> > > > recovery, and then we want to retry the operation.
>> > > >
>> > > > Signed-off-by: Trond Myklebust <[email protected]
>> > > > >
>> > > > ---
>> > > > fs/nfs/nfs4proc.c | 4 ++++
>> > > > 1 file changed, 4 insertions(+)
>> > > >
>> > > > diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
>> > > > index f992281c9b29..4fd0e2b7b08e 100644
>> > > > --- a/fs/nfs/nfs4proc.c
>> > > > +++ b/fs/nfs/nfs4proc.c
>> > > > @@ -816,6 +816,10 @@ static int nfs41_sequence_process(struct
>> > > > rpc_task *task,
>> > > > case -NFS4ERR_SEQ_FALSE_RETRY:
>> > > > ++slot->seq_nr;
>> > > > goto retry_nowait;
>> > > > + case -NFS4ERR_DEADSESSION:
>> > > > + case -NFS4ERR_BADSESSION:
>> > > > + nfs4_schedule_session_recovery(session, res-
>> > > > > sr_status);
>> > > >
>> > > > + goto retry_nowait;
>> > > > default:
>> > > > /* Just update the slot sequence no. */
>> > > > slot->seq_done = 1;
>> > > > --
>> > > > 2.9.3
>> > >
>> > > Hi Trond,
>> > >
>> > > Can you explain the implications of retrying the operation
>> > > without
>> > > waiting for recovery to complete?
>> > >
>> > > This patch introduces regression in intra COPY failing if the
>> > > server
>> > > rebooted during that operation. What happens is that COPY is re-
>> > > sent
>> > > with the same stateid from the old open instead of the open that
>> > > was
>> > > done from the recovery (leading to BAD_STATEID error and
>> > > failure).
>> > >
>> > > I wonder if it's because COPY is written to just use
>> > > nfs4_call_sync()
>> > > instead of defining rpc_callback_ops to handle rpc_prepare()
>> > > where a
>> > > new stateid could be gotten? I have re-written the COPY to do
>> > > that
>> > > and
>> > > I no longer see that problem.
>> > >
>> > > If my suspicion is correct, it would help for the future to know
>> > > that
>> > > any operations that use stateid must have rpc callback ops
>> > > defined/used so that they avoid this problem. Perhaps as a
>> > > comment in
>> > > the code or maybe some other way?
>> > >
>> > > Thanks.
>> > >
>> >
>> > Yes, the way that rpc_call_sync() has been written, it assumes that
>> > the
>> > call is unaffected by reboot recovery, or that the resulting state
>> > errors will be handled by the caller. The patch you reference does
>> > not
>> > change that expectation.
>>
>> The "or" is confusing me. The current COPY code does call into
>> nfs4_handle_exception() and "should handle errors". Yet after this
>> patch, the code fails to in presence of a reboot. I don't see what
>> else can the current code should do in terms of handling errors to
>> fix
>> that problem.
>>
>> I'm almost ready to submit the patch that turns the existing code
>> into
>> async rpc but if this is not the right approach then I'd like to know
>> where I should be looking into instead.
>>
>> Thanks.
>>
>> >
>> > The same race can happen, for instance, if your call to
>> > rpc_call_sync()
>> > coincides with a reboot recovery that was started by another
>> > process.
>> >
>
>
> I don't understand. If it is handling the resulting NFS4ERR_BAD_STATEID
> error correctly, then what is failing? As I said above, you can get the
> NFS4ERR_BAD_STATEID from other instances of the same race.
COPY (just like READ or WRITE) can not handle BAD_STATEID error
because it holds a lock and that lock is marked lost. COPY should have
never been sent with the old stated after the new open stateid and
lock stateid was gotten. But with this patch the behavior changed and
thus I was trying to understand what has changed.
I think that previously BAD_SESSION error was not handled by the
SEQUENCE and was handled by each of the operations calling the general
nfs4_handle_exception() routine that actually waits on recovery to
complete before retrying the operation. Then the retry actually would
allow COPY to get the new stateid. However, with the new code SEQUENCE
handles the error and calls to retry the operation without the wait
which actually again gets the BAD_SESSION then recovery happens but
2nd SEQUENCE again retries the operation without going all the out to
the operation so no new stateid is gotten.
>
> --
> Trond Myklebust
> Linux NFS client maintainer, PrimaryData
> [email protected]
On Thu, Feb 16, 2017 at 9:16 AM, Olga Kornievskaia <[email protected]> wrote:
> On Wed, Feb 15, 2017 at 5:23 PM, Trond Myklebust
> <[email protected]> wrote:
>> On Wed, 2017-02-15 at 16:56 -0500, Olga Kornievskaia wrote:
>>> On Wed, Feb 15, 2017 at 3:48 PM, Trond Myklebust
>>> <[email protected]> wrote:
>>> > On Wed, 2017-02-15 at 15:16 -0500, Olga Kornievskaia wrote:
>>> > > On Sun, Dec 4, 2016 at 7:40 PM, Trond Myklebust
>>> > > <[email protected]> wrote:
>>> > > > In the case where SEQUENCE receives a NFS4ERR_BADSESSION or
>>> > > > NFS4ERR_DEADSESSION error, we just want to report the session
>>> > > > as
>>> > > > needing
>>> > > > recovery, and then we want to retry the operation.
>>> > > >
>>> > > > Signed-off-by: Trond Myklebust <[email protected]
>>> > > > >
>>> > > > ---
>>> > > > fs/nfs/nfs4proc.c | 4 ++++
>>> > > > 1 file changed, 4 insertions(+)
>>> > > >
>>> > > > diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
>>> > > > index f992281c9b29..4fd0e2b7b08e 100644
>>> > > > --- a/fs/nfs/nfs4proc.c
>>> > > > +++ b/fs/nfs/nfs4proc.c
>>> > > > @@ -816,6 +816,10 @@ static int nfs41_sequence_process(struct
>>> > > > rpc_task *task,
>>> > > > case -NFS4ERR_SEQ_FALSE_RETRY:
>>> > > > ++slot->seq_nr;
>>> > > > goto retry_nowait;
>>> > > > + case -NFS4ERR_DEADSESSION:
>>> > > > + case -NFS4ERR_BADSESSION:
>>> > > > + nfs4_schedule_session_recovery(session, res-
>>> > > > > sr_status);
>>> > > >
>>> > > > + goto retry_nowait;
>>> > > > default:
>>> > > > /* Just update the slot sequence no. */
>>> > > > slot->seq_done = 1;
>>> > > > --
>>> > > > 2.9.3
>>> > >
>>> > > Hi Trond,
>>> > >
>>> > > Can you explain the implications of retrying the operation
>>> > > without
>>> > > waiting for recovery to complete?
>>> > >
>>> > > This patch introduces regression in intra COPY failing if the
>>> > > server
>>> > > rebooted during that operation. What happens is that COPY is re-
>>> > > sent
>>> > > with the same stateid from the old open instead of the open that
>>> > > was
>>> > > done from the recovery (leading to BAD_STATEID error and
>>> > > failure).
>>> > >
>>> > > I wonder if it's because COPY is written to just use
>>> > > nfs4_call_sync()
>>> > > instead of defining rpc_callback_ops to handle rpc_prepare()
>>> > > where a
>>> > > new stateid could be gotten? I have re-written the COPY to do
>>> > > that
>>> > > and
>>> > > I no longer see that problem.
>>> > >
>>> > > If my suspicion is correct, it would help for the future to know
>>> > > that
>>> > > any operations that use stateid must have rpc callback ops
>>> > > defined/used so that they avoid this problem. Perhaps as a
>>> > > comment in
>>> > > the code or maybe some other way?
>>> > >
>>> > > Thanks.
>>> > >
>>> >
>>> > Yes, the way that rpc_call_sync() has been written, it assumes that
>>> > the
>>> > call is unaffected by reboot recovery, or that the resulting state
>>> > errors will be handled by the caller. The patch you reference does
>>> > not
>>> > change that expectation.
>>>
>>> The "or" is confusing me. The current COPY code does call into
>>> nfs4_handle_exception() and "should handle errors". Yet after this
>>> patch, the code fails to in presence of a reboot. I don't see what
>>> else can the current code should do in terms of handling errors to
>>> fix
>>> that problem.
>>>
>>> I'm almost ready to submit the patch that turns the existing code
>>> into
>>> async rpc but if this is not the right approach then I'd like to know
>>> where I should be looking into instead.
>>>
>>> Thanks.
>>>
>>> >
>>> > The same race can happen, for instance, if your call to
>>> > rpc_call_sync()
>>> > coincides with a reboot recovery that was started by another
>>> > process.
>>> >
>>
>>
>> I don't understand. If it is handling the resulting NFS4ERR_BAD_STATEID
>> error correctly, then what is failing? As I said above, you can get the
>> NFS4ERR_BAD_STATEID from other instances of the same race.
>
> COPY (just like READ or WRITE) can not handle BAD_STATEID error
> because it holds a lock and that lock is marked lost. COPY should have
> never been sent with the old stated after the new open stateid and
> lock stateid was gotten. But with this patch the behavior changed and
> thus I was trying to understand what has changed.
>
> I think that previously BAD_SESSION error was not handled by the
> SEQUENCE and was handled by each of the operations calling the general
> nfs4_handle_exception() routine that actually waits on recovery to
> complete before retrying the operation. Then the retry actually would
> allow COPY to get the new stateid. However, with the new code SEQUENCE
> handles the error and calls to retry the operation without the wait
> which actually again gets the BAD_SESSION then recovery happens but
> 2nd SEQUENCE again retries the operation without going all the out to
> the operation so no new stateid is gotten.
>
I also would like to point out that not only does this patch
introduces a regression with the COPY. It also introduces the
BAD_SESSION loop where the SEQUENCE that gets this error just keeps
getting resent over and over again. This happens to the heartbeat
SEQUENCE when server reboots.
On Thu, Feb 16, 2017 at 11:04 AM, Olga Kornievskaia <[email protected]> wrote:
> On Thu, Feb 16, 2017 at 9:16 AM, Olga Kornievskaia <[email protected]> wrote:
>> On Wed, Feb 15, 2017 at 5:23 PM, Trond Myklebust
>> <[email protected]> wrote:
>>> On Wed, 2017-02-15 at 16:56 -0500, Olga Kornievskaia wrote:
>>>> On Wed, Feb 15, 2017 at 3:48 PM, Trond Myklebust
>>>> <[email protected]> wrote:
>>>> > On Wed, 2017-02-15 at 15:16 -0500, Olga Kornievskaia wrote:
>>>> > > On Sun, Dec 4, 2016 at 7:40 PM, Trond Myklebust
>>>> > > <[email protected]> wrote:
>>>> > > > In the case where SEQUENCE receives a NFS4ERR_BADSESSION or
>>>> > > > NFS4ERR_DEADSESSION error, we just want to report the session
>>>> > > > as
>>>> > > > needing
>>>> > > > recovery, and then we want to retry the operation.
>>>> > > >
>>>> > > > Signed-off-by: Trond Myklebust <[email protected]
>>>> > > > >
>>>> > > > ---
>>>> > > > fs/nfs/nfs4proc.c | 4 ++++
>>>> > > > 1 file changed, 4 insertions(+)
>>>> > > >
>>>> > > > diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
>>>> > > > index f992281c9b29..4fd0e2b7b08e 100644
>>>> > > > --- a/fs/nfs/nfs4proc.c
>>>> > > > +++ b/fs/nfs/nfs4proc.c
>>>> > > > @@ -816,6 +816,10 @@ static int nfs41_sequence_process(struct
>>>> > > > rpc_task *task,
>>>> > > > case -NFS4ERR_SEQ_FALSE_RETRY:
>>>> > > > ++slot->seq_nr;
>>>> > > > goto retry_nowait;
>>>> > > > + case -NFS4ERR_DEADSESSION:
>>>> > > > + case -NFS4ERR_BADSESSION:
>>>> > > > + nfs4_schedule_session_recovery(session, res-
>>>> > > > > sr_status);
>>>> > > >
>>>> > > > + goto retry_nowait;
>>>> > > > default:
>>>> > > > /* Just update the slot sequence no. */
>>>> > > > slot->seq_done = 1;
>>>> > > > --
>>>> > > > 2.9.3
>>>> > >
>>>> > > Hi Trond,
>>>> > >
>>>> > > Can you explain the implications of retrying the operation
>>>> > > without
>>>> > > waiting for recovery to complete?
>>>> > >
>>>> > > This patch introduces regression in intra COPY failing if the
>>>> > > server
>>>> > > rebooted during that operation. What happens is that COPY is re-
>>>> > > sent
>>>> > > with the same stateid from the old open instead of the open that
>>>> > > was
>>>> > > done from the recovery (leading to BAD_STATEID error and
>>>> > > failure).
>>>> > >
>>>> > > I wonder if it's because COPY is written to just use
>>>> > > nfs4_call_sync()
>>>> > > instead of defining rpc_callback_ops to handle rpc_prepare()
>>>> > > where a
>>>> > > new stateid could be gotten? I have re-written the COPY to do
>>>> > > that
>>>> > > and
>>>> > > I no longer see that problem.
>>>> > >
>>>> > > If my suspicion is correct, it would help for the future to know
>>>> > > that
>>>> > > any operations that use stateid must have rpc callback ops
>>>> > > defined/used so that they avoid this problem. Perhaps as a
>>>> > > comment in
>>>> > > the code or maybe some other way?
>>>> > >
>>>> > > Thanks.
>>>> > >
>>>> >
>>>> > Yes, the way that rpc_call_sync() has been written, it assumes that
>>>> > the
>>>> > call is unaffected by reboot recovery, or that the resulting state
>>>> > errors will be handled by the caller. The patch you reference does
>>>> > not
>>>> > change that expectation.
>>>>
>>>> The "or" is confusing me. The current COPY code does call into
>>>> nfs4_handle_exception() and "should handle errors". Yet after this
>>>> patch, the code fails to in presence of a reboot. I don't see what
>>>> else can the current code should do in terms of handling errors to
>>>> fix
>>>> that problem.
>>>>
>>>> I'm almost ready to submit the patch that turns the existing code
>>>> into
>>>> async rpc but if this is not the right approach then I'd like to know
>>>> where I should be looking into instead.
>>>>
>>>> Thanks.
>>>>
>>>> >
>>>> > The same race can happen, for instance, if your call to
>>>> > rpc_call_sync()
>>>> > coincides with a reboot recovery that was started by another
>>>> > process.
>>>> >
>>>
>>>
>>> I don't understand. If it is handling the resulting NFS4ERR_BAD_STATEID
>>> error correctly, then what is failing? As I said above, you can get the
>>> NFS4ERR_BAD_STATEID from other instances of the same race.
>>
>> COPY (just like READ or WRITE) can not handle BAD_STATEID error
>> because it holds a lock and that lock is marked lost. COPY should have
>> never been sent with the old stated after the new open stateid and
>> lock stateid was gotten. But with this patch the behavior changed and
>> thus I was trying to understand what has changed.
>>
>> I think that previously BAD_SESSION error was not handled by the
>> SEQUENCE and was handled by each of the operations calling the general
>> nfs4_handle_exception() routine that actually waits on recovery to
>> complete before retrying the operation. Then the retry actually would
>> allow COPY to get the new stateid. However, with the new code SEQUENCE
>> handles the error and calls to retry the operation without the wait
>> which actually again gets the BAD_SESSION then recovery happens but
>> 2nd SEQUENCE again retries the operation without going all the out to
>> the operation so no new stateid is gotten.
>>
>
> I also would like to point out that not only does this patch
> introduces a regression with the COPY. It also introduces the
> BAD_SESSION loop where the SEQUENCE that gets this error just keeps
> getting resent over and over again. This happens to the heartbeat
> SEQUENCE when server reboots.
I have written a test case for the SETATTR since it also uses a
stateid and calls nfs4_sync_call() and it also after the reboot will
send the operation with the old stateid. Thankfully, SETATTR doesn't
really care about the 'validity' of the stateid and will retry the
operation. It will produce no errors but I can't say the client is
working properly.
So I'd save that the patch has introduced some significant change to
the philosophy that wasn't expected.
Do we really need this patch?? Does it solve an existing problem? All
the operations are able to handle BAD_SESSION errors in their
corresponding nfs4_handle_exception code that they do. Why change it.
DQo+IE9uIEZlYiAxNiwgMjAxNywgYXQgMTE6MTIsIE9sZ2EgS29ybmlldnNrYWlhIDxhZ2xvQHVt
aWNoLmVkdT4gd3JvdGU6DQo+IA0KPiBPbiBUaHUsIEZlYiAxNiwgMjAxNyBhdCAxMTowNCBBTSwg
T2xnYSBLb3JuaWV2c2thaWEgPGFnbG9AdW1pY2guZWR1PiB3cm90ZToNCj4+IE9uIFRodSwgRmVi
IDE2LCAyMDE3IGF0IDk6MTYgQU0sIE9sZ2EgS29ybmlldnNrYWlhIDxhZ2xvQHVtaWNoLmVkdT4g
d3JvdGU6DQo+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ciBlbm91Z2gsIEnigJlsbCBhc2sg
QW5uYSB0byByZXZlcnQgdGhlIHBhdGNoLiBIb3dldmVyIHJldmVydGluZyB0aGUgcGF0Y2ggd29u
4oCZdCBwcmV2ZW50IHRoZSBzZXJ2ZXIgZnJvbSByZXR1cm5pbmcgTkZTNEVSUl9CQURfU1RBVEVJ
RCBpbiBhbnkgY2FzZXMgd2hlcmUgdGhlIGNhbGxzIHRvIG5mczRfc2V0X3J3X3N0YXRlaWQoKSBo
YXBwZW4gYmVmb3JlIHN0YXRlIHJlY292ZXJ5LiBUaGlzIGlzIHdoeSB3ZSBoYXZlIHRoZSBsb29w
IGluIG5mczQyX3Byb2NfY29weSgpLg0KDQo+IA0KPiBTbyBJJ2Qgc2F2ZSB0aGF0IHRoZSBwYXRj
aCBoYXMgaW50cm9kdWNlZCBzb21lIHNpZ25pZmljYW50IGNoYW5nZSB0bw0KPiB0aGUgcGhpbG9z
b3BoeSB0aGF0IHdhc24ndCBleHBlY3RlZC4NCg0KTm8uIFRoZSBwaGlsb3NvcGh5IGlzIHRoZSBz
YW1lLiBCb3RoIHdpdGggb3Igd2l0aG91dCB0aGlzIHBhdGNoLCBhbiBSUEMgY2FsbCB0aGF0IGNh
cnJpZXMgYSBzdGF0ZWQgTVVTVCBiZSBwcmVwYXJlZCB0byBoYW5kbGUgTkZTNEVSUl9CQURfU1RB
VEVJRC4NCg0KX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fDQpUcm9uZCBNeWtsZWJ1
c3QNCkxpbnV4IE5GUyBjbGllbnQgbWFpbnRhaW5lciwgUHJpbWFyeURhdGENCnRyb25kLm15a2xl
YnVzdEBwcmltYXJ5ZGF0YS5jb20NCg0K
On Thu, Feb 16, 2017 at 4:45 PM, Trond Myklebust
<[email protected]> wrote:
>
>> On Feb 16, 2017, at 11:12, Olga Kornievskaia <[email protected]> wrote:
>>
>> On Thu, Feb 16, 2017 at 11:04 AM, Olga Kornievskaia <[email protected]> wro=
te:
>>> On Thu, Feb 16, 2017 at 9:16 AM, Olga Kornievskaia <[email protected]> wro=
te:
>>>> On Wed, Feb 15, 2017 at 5:23 PM, Trond Myklebust
>>>> <[email protected]> wrote:
>>>>> On Wed, 2017-02-15 at 16:56 -0500, Olga Kornievskaia wrote:
>>>>>> On Wed, Feb 15, 2017 at 3:48 PM, Trond Myklebust
>>>>>> <[email protected]> wrote:
>>>>>>> On Wed, 2017-02-15 at 15:16 -0500, Olga Kornievskaia wrote:
>>>>>>>> On Sun, Dec 4, 2016 at 7:40 PM, Trond Myklebust
>>>>>>>> <[email protected]> wrote:
>>>>>>>>> In the case where SEQUENCE receives a NFS4ERR_BADSESSION or
>>>>>>>>> NFS4ERR_DEADSESSION error, we just want to report the session
>>>>>>>>> as
>>>>>>>>> needing
>>>>>>>>> recovery, and then we want to retry the operation.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Trond Myklebust <[email protected]
>>>>>>>>>>
>>>>>>>>> ---
>>>>>>>>> fs/nfs/nfs4proc.c | 4 ++++
>>>>>>>>> 1 file changed, 4 insertions(+)
>>>>>>>>>
>>>>>>>>> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
>>>>>>>>> index f992281c9b29..4fd0e2b7b08e 100644
>>>>>>>>> --- a/fs/nfs/nfs4proc.c
>>>>>>>>> +++ b/fs/nfs/nfs4proc.c
>>>>>>>>> @@ -816,6 +816,10 @@ static int nfs41_sequence_process(struct
>>>>>>>>> rpc_task *task,
>>>>>>>>> case -NFS4ERR_SEQ_FALSE_RETRY:
>>>>>>>>> ++slot->seq_nr;
>>>>>>>>> goto retry_nowait;
>>>>>>>>> + case -NFS4ERR_DEADSESSION:
>>>>>>>>> + case -NFS4ERR_BADSESSION:
>>>>>>>>> + nfs4_schedule_session_recovery(session, res-
>>>>>>>>>> sr_status);
>>>>>>>>>
>>>>>>>>> + goto retry_nowait;
>>>>>>>>> default:
>>>>>>>>> /* Just update the slot sequence no. */
>>>>>>>>> slot->seq_done =3D 1;
>>>>>>>>> --
>>>>>>>>> 2.9.3
>>>>>>>>
>>>>>>>> Hi Trond,
>>>>>>>>
>>>>>>>> Can you explain the implications of retrying the operation
>>>>>>>> without
>>>>>>>> waiting for recovery to complete?
>>>>>>>>
>>>>>>>> This patch introduces regression in intra COPY failing if the
>>>>>>>> server
>>>>>>>> rebooted during that operation. What happens is that COPY is re-
>>>>>>>> sent
>>>>>>>> with the same stateid from the old open instead of the open that
>>>>>>>> was
>>>>>>>> done from the recovery (leading to BAD_STATEID error and
>>>>>>>> failure).
>>>>>>>>
>>>>>>>> I wonder if it's because COPY is written to just use
>>>>>>>> nfs4_call_sync()
>>>>>>>> instead of defining rpc_callback_ops to handle rpc_prepare()
>>>>>>>> where a
>>>>>>>> new stateid could be gotten? I have re-written the COPY to do
>>>>>>>> that
>>>>>>>> and
>>>>>>>> I no longer see that problem.
>>>>>>>>
>>>>>>>> If my suspicion is correct, it would help for the future to know
>>>>>>>> that
>>>>>>>> any operations that use stateid must have rpc callback ops
>>>>>>>> defined/used so that they avoid this problem. Perhaps as a
>>>>>>>> comment in
>>>>>>>> the code or maybe some other way?
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>
>>>>>>> Yes, the way that rpc_call_sync() has been written, it assumes that
>>>>>>> the
>>>>>>> call is unaffected by reboot recovery, or that the resulting state
>>>>>>> errors will be handled by the caller. The patch you reference does
>>>>>>> not
>>>>>>> change that expectation.
>>>>>>
>>>>>> The "or" is confusing me. The current COPY code does call into
>>>>>> nfs4_handle_exception() and "should handle errors". Yet after this
>>>>>> patch, the code fails to in presence of a reboot. I don't see what
>>>>>> else can the current code should do in terms of handling errors to
>>>>>> fix
>>>>>> that problem.
>>>>>>
>>>>>> I'm almost ready to submit the patch that turns the existing code
>>>>>> into
>>>>>> async rpc but if this is not the right approach then I'd like to kno=
w
>>>>>> where I should be looking into instead.
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>>>
>>>>>>> The same race can happen, for instance, if your call to
>>>>>>> rpc_call_sync()
>>>>>>> coincides with a reboot recovery that was started by another
>>>>>>> process.
>>>>>>>
>>>>>
>>>>>
>>>>> I don't understand. If it is handling the resulting NFS4ERR_BAD_STATE=
ID
>>>>> error correctly, then what is failing? As I said above, you can get t=
he
>>>>> NFS4ERR_BAD_STATEID from other instances of the same race.
>>>>
>>>> COPY (just like READ or WRITE) can not handle BAD_STATEID error
>>>> because it holds a lock and that lock is marked lost. COPY should have
>>>> never been sent with the old stated after the new open stateid and
>>>> lock stateid was gotten. But with this patch the behavior changed and
>>>> thus I was trying to understand what has changed.
>>>>
>>>> I think that previously BAD_SESSION error was not handled by the
>>>> SEQUENCE and was handled by each of the operations calling the general
>>>> nfs4_handle_exception() routine that actually waits on recovery to
>>>> complete before retrying the operation. Then the retry actually would
>>>> allow COPY to get the new stateid. However, with the new code SEQUENCE
>>>> handles the error and calls to retry the operation without the wait
>>>> which actually again gets the BAD_SESSION then recovery happens but
>>>> 2nd SEQUENCE again retries the operation without going all the out to
>>>> the operation so no new stateid is gotten.
>>>>
>>>
>>> I also would like to point out that not only does this patch
>>> introduces a regression with the COPY. It also introduces the
>>> BAD_SESSION loop where the SEQUENCE that gets this error just keeps
>>> getting resent over and over again. This happens to the heartbeat
>>> SEQUENCE when server reboots.
>>
>> I have written a test case for the SETATTR since it also uses a
>> stateid and calls nfs4_sync_call() and it also after the reboot will
>> send the operation with the old stateid. Thankfully, SETATTR doesn't
>> really care about the 'validity' of the stateid and will retry the
>> operation. It will produce no errors but I can't say the client is
>> working properly.
>
> That=E2=80=99s because SETATTR was designed correctly. Just like copy off=
load, it has to deal with the fact that it can race with a server reboot.
Let's agree to disagree that design is correct. Copy offload does
everything that current design asks it to do but there is still a
failure so let's figure out how to fix it.
> Olga, all your test is doing is showing that we hit the race more often. =
Fair enough, I=E2=80=99ll ask Anna to revert the patch. However reverting t=
he patch won=E2=80=99t prevent the server from returning NFS4ERR_BAD_STATEI=
D in any cases where the calls to nfs4_set_rw_stateid() happen before state=
recovery. This is why we have the loop in nfs42_proc_copy().
I thought that if retry of the operation waits for the recovery to
complete then nfs4_set_rw_stateid() will choose the correct stateid,
is that not correct?
If that's not correct, then we somehow need to separate the case when
BAD_STATEID should indeed mark the locks lost vs this case where the
code erroneously used the bad stateid (oops) and it should really
ignore this error. This really doesn't sound very plausible to
accomplish.
>> So I'd save that the patch has introduced some significant change to
>> the philosophy that wasn't expected.
>
> No. The philosophy is the same. Both with or without this patch, an RPC c=
all that carries a stated MUST be prepared to handle NFS4ERR_BAD_STATEID.
>
> _________________________________
> Trond Myklebust
> Linux NFS client maintainer, PrimaryData
> [email protected]
>
T24gVGh1LCAyMDE3LTAyLTE2IGF0IDE3OjE0IC0wNTAwLCBPbGdhIEtvcm5pZXZza2FpYSB3cm90
ZToNCj4gT24gVGh1LCBGZWIgMTYsIDIwMTcgYXQgNDo0NSBQTSwgVHJvbmQgTXlrbGVidXN0DQo+
IDx0cm9uZG15QHByaW1hcnlkYXRhLmNvbT4gd3JvdGU6DQo+ID4gDQo+ID4gT2xnYSwgYWxsIHlv
dXIgdGVzdCBpcyBkb2luZyBpcyBzaG93aW5nIHRoYXQgd2UgaGl0IHRoZSByYWNlIG1vcmUNCj4g
PiBvZnRlbi4gRmFpciBlbm91Z2gsIEnigJlsbCBhc2sgQW5uYSB0byByZXZlcnQgdGhlIHBhdGNo
LiBIb3dldmVyDQo+ID4gcmV2ZXJ0aW5nIHRoZSBwYXRjaCB3b27igJl0IHByZXZlbnQgdGhlIHNl
cnZlciBmcm9tIHJldHVybmluZw0KPiA+IE5GUzRFUlJfQkFEX1NUQVRFSUQgaW4gYW55IGNhc2Vz
IHdoZXJlIHRoZSBjYWxscyB0bw0KPiA+IG5mczRfc2V0X3J3X3N0YXRlaWQoKSBoYXBwZW4gYmVm
b3JlIHN0YXRlIHJlY292ZXJ5LiBUaGlzIGlzIHdoeSB3ZQ0KPiA+IGhhdmUgdGhlIGxvb3AgaW4g
bmZzNDJfcHJvY19jb3B5KCkuDQo+IA0KP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gX25mczQyX3Byb2NfY29weShzcmMsIHNyY19sb2NrLA0KKwkJCQlkc3QsIGRzdF9s
b2NrLA0KKwkJCQkmYXJncywgJnJlcyk7DQogCQlpbm9kZV91bmxvY2soZmlsZV9pbm9kZShkc3Qp
KTsNCiANCiAJCWlmIChlcnIgPT0gLUVOT1RTVVBQKSB7DQotLSANCjIuOS4zDQoNCi0tIA0KVHJv
bmQgTXlrbGVidXN0DQpMaW51eCBORlMgY2xpZW50IG1haW50YWluZXIsIFByaW1hcnlEYXRhDQp0
cm9uZC5teWtsZWJ1c3RAcHJpbWFyeWRhdGEuY29tDQo=
On Thu, Feb 16, 2017 at 6:28 PM, Trond Myklebust
<[email protected]> wrote:
> On Thu, 2017-02-16 at 17:14 -0500, Olga Kornievskaia wrote:
>> On Thu, Feb 16, 2017 at 4:45 PM, Trond Myklebust
>> <[email protected]> wrote:
>> >
>> > Olga, all your test is doing is showing that we hit the race more
>> > often. Fair enough, I=E2=80=99ll ask Anna to revert the patch. However
>> > reverting the patch won=E2=80=99t prevent the server from returning
>> > NFS4ERR_BAD_STATEID in any cases where the calls to
>> > nfs4_set_rw_stateid() happen before state recovery. This is why we
>> > have the loop in nfs42_proc_copy().
>>
>> I thought that if retry of the operation waits for the recovery to
>> complete then nfs4_set_rw_stateid() will choose the correct stateid,
>> is that not correct?
>>
>> If that's not correct, then we somehow need to separate the case when
>> BAD_STATEID should indeed mark the locks lost vs this case where the
>> code erroneously used the bad stateid (oops) and it should really
>> ignore this error. This really doesn't sound very plausible to
>> accomplish.
>
> Does this patch fix the problem?
>
> 8<-------------------------------------------------------------
> From bbae95e8f97cad6a91ca8caa50b61cae789632f9 Mon Sep 17 00:00:00 2001
> From: Trond Myklebust <[email protected]>
> Date: Thu, 16 Feb 2017 18:14:38 -0500
> Subject: [PATCH] NFSv4: Fix reboot recovery in copy offload
>
> Copy offload code needs to be hooked into the code for handling
> NFS4ERR_BAD_STATEID by ensuring that we set the "stateid" field
> in struct nfs4_exception.
>
> Reported-by: Olga Kornievskaia <[email protected]>
> Fixes: 2e72448b07dc3 ("NFS: Add COPY nfs operation")
> Signed-off-by: Trond Myklebust <[email protected]>
> ---
> fs/nfs/nfs42proc.c | 57 +++++++++++++++++++++++++++++++-----------------=
------
> 1 file changed, 33 insertions(+), 24 deletions(-)
>
> diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
> index d12ff9385f49..baf1fe2dc296 100644
> --- a/fs/nfs/nfs42proc.c
> +++ b/fs/nfs/nfs42proc.c
> @@ -128,20 +128,13 @@ int nfs42_proc_deallocate(struct file *filep, loff_=
t offset, loff_t len)
> return err;
> }
>
> -static ssize_t _nfs42_proc_copy(struct file *src, loff_t pos_src,
> +static ssize_t _nfs42_proc_copy(struct file *src,
> struct nfs_lock_context *src_lock,
> - struct file *dst, loff_t pos_dst,
> + struct file *dst,
> struct nfs_lock_context *dst_lock,
> - size_t count)
> + struct nfs42_copy_args *args,
> + struct nfs42_copy_res *res)
> {
> - struct nfs42_copy_args args =3D {
> - .src_fh =3D NFS_FH(file_inode(src)),
> - .src_pos =3D pos_src,
> - .dst_fh =3D NFS_FH(file_inode(dst)),
> - .dst_pos =3D pos_dst,
> - .count =3D count,
> - };
> - struct nfs42_copy_res res;
> struct rpc_message msg =3D {
> .rpc_proc =3D &nfs4_procedures[NFSPROC4_CLNT_COPY],
> .rpc_argp =3D &args,
> @@ -149,9 +142,12 @@ static ssize_t _nfs42_proc_copy(struct file *src, lo=
ff_t pos_src,
> };
> struct inode *dst_inode =3D file_inode(dst);
> struct nfs_server *server =3D NFS_SERVER(dst_inode);
> + loff_t pos_src =3D args->src_pos;
> + loff_t pos_dst =3D args->dst_pos;
> + size_t count =3D args->count;
> int status;
>
> - status =3D nfs4_set_rw_stateid(&args.src_stateid, src_lock->open_=
context,
> + status =3D nfs4_set_rw_stateid(&args->src_stateid, src_lock->open=
_context,
> src_lock, FMODE_READ);
> if (status)
> return status;
> @@ -161,7 +157,7 @@ static ssize_t _nfs42_proc_copy(struct file *src, lof=
f_t pos_src,
> if (status)
> return status;
>
> - status =3D nfs4_set_rw_stateid(&args.dst_stateid, dst_lock->open_=
context,
> + status =3D nfs4_set_rw_stateid(&args->dst_stateid, dst_lock->open=
_context,
> dst_lock, FMODE_WRITE);
> if (status)
> return status;
> @@ -171,22 +167,22 @@ static ssize_t _nfs42_proc_copy(struct file *src, l=
off_t pos_src,
> return status;
>
> status =3D nfs4_call_sync(server->client, server, &msg,
> - &args.seq_args, &res.seq_res, 0);
> + &args->seq_args, &res->seq_res, 0);
> if (status =3D=3D -ENOTSUPP)
> server->caps &=3D ~NFS_CAP_COPY;
> if (status)
> return status;
>
> - if (res.write_res.verifier.committed !=3D NFS_FILE_SYNC) {
> - status =3D nfs_commit_file(dst, &res.write_res.verifier.v=
erifier);
> + if (res->write_res.verifier.committed !=3D NFS_FILE_SYNC) {
> + status =3D nfs_commit_file(dst, &res->write_res.verifier.=
verifier);
> if (status)
> return status;
> }
>
> truncate_pagecache_range(dst_inode, pos_dst,
> - pos_dst + res.write_res.count);
> + pos_dst + res->write_res.count);
>
> - return res.write_res.count;
> + return res->write_res.count;
> }
>
> ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,
> @@ -196,8 +192,22 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos=
_src,
> struct nfs_server *server =3D NFS_SERVER(file_inode(dst));
> struct nfs_lock_context *src_lock;
> struct nfs_lock_context *dst_lock;
> - struct nfs4_exception src_exception =3D { };
> - struct nfs4_exception dst_exception =3D { };
> + struct nfs42_copy_args args =3D {
> + .src_fh =3D NFS_FH(file_inode(src)),
> + .src_pos =3D pos_src,
> + .dst_fh =3D NFS_FH(file_inode(dst)),
> + .dst_pos =3D pos_dst,
> + .count =3D count,
> + };
> + struct nfs42_copy_res res;
> + struct nfs4_exception src_exception =3D {
> + .inode =3D file_inode(src),
> + .stateid =3D &args.src_stateid,
> + };
> + struct nfs4_exception dst_exception =3D {
> + .inode =3D file_inode(dst),
> + .stateid =3D &args.dst_stateid,
> + };
> ssize_t err, err2;
>
> if (!nfs_server_capable(file_inode(dst), NFS_CAP_COPY))
> @@ -207,7 +217,6 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_=
src,
> if (IS_ERR(src_lock))
> return PTR_ERR(src_lock);
>
> - src_exception.inode =3D file_inode(src);
> src_exception.state =3D src_lock->open_context->state;
>
> dst_lock =3D nfs_get_lock_context(nfs_file_open_context(dst));
> @@ -216,13 +225,13 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t po=
s_src,
> goto out_put_src_lock;
> }
>
> - dst_exception.inode =3D file_inode(dst);
> dst_exception.state =3D dst_lock->open_context->state;
>
> do {
> inode_lock(file_inode(dst));
> - err =3D _nfs42_proc_copy(src, pos_src, src_lock,
> - dst, pos_dst, dst_lock, count);
> + err =3D _nfs42_proc_copy(src, src_lock,
> + dst, dst_lock,
> + &args, &res);
> inode_unlock(file_inode(dst));
>
> if (err =3D=3D -ENOTSUPP) {
> --
> 2.9.3
I wish it did but no it does not.
T24gRnJpLCAyMDE3LTAyLTE3IGF0IDA5OjQ2IC0wNTAwLCBPbGdhIEtvcm5pZXZza2FpYSB3cm90
ZToNCj4gT24gVGh1LCBGZWIgMTYsIDIwMTcgYXQgNjoyOCBQTSwgVHJvbmQgTXlrbGVidXN0DQo+
IDx0cm9uZG15QHByaW1hcnlkYXRhLmNvbT4gd3JvdGU6DQo+ID4gT24gVGh1LCAyMDE3LTAyLTE2
IGF0IDE3OjE0IC0wNTAwLCBPbGdhIEtvcm5pZXZza2FpYSB3cm90ZToNCj4gPiA+IE9uIFRodSwg
RmViIDE2LCAyMDE3IGF0IDQ6NDUgUE0sIFRyb25kIE15a2xlYnVzdA0KPiA+ID4gPHRyb25kbXlA
cHJpbWFyeWRhdGEuY29tPiB3cm90ZToNCj4gPiA+ID4gDQo+ID4gPiA+IE9sZ2EsIGFsbCB5b3Vy
IHRlc3QgaXMgZG9pbmcgaXMgc2hvd2luZyB0aGF0IHdlIGhp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gaW5zdGVhZCBv
ZiB1c2luZyB0aGUgZ2VuZXJpYyBjb2RlIGluDQpuZnM0X2hhbmRsZV9leGNlcHRpb24oKS4NCg0K
LS0gDQpUcm9uZCBNeWtsZWJ1c3QNCkxpbnV4IE5GUyBjbGllbnQgbWFpbnRhaW5lciwgUHJpbWFy
eURhdGENCnRyb25kLm15a2xlYnVzdEBwcmltYXJ5ZGF0YS5jb20NCg==
On Fri, Feb 17, 2017 at 9:58 AM, Trond Myklebust
<[email protected]> wrote:
> On Fri, 2017-02-17 at 09:46 -0500, Olga Kornievskaia wrote:
>> On Thu, Feb 16, 2017 at 6:28 PM, Trond Myklebust
>> <[email protected]> wrote:
>> > On Thu, 2017-02-16 at 17:14 -0500, Olga Kornievskaia wrote:
>> > > On Thu, Feb 16, 2017 at 4:45 PM, Trond Myklebust
>> > > <[email protected]> wrote:
>> > > >
>> > > > Olga, all your test is doing is showing that we hit the race
>> > > > more
>> > > > often. Fair enough, I=E2=80=99ll ask Anna to revert the patch. How=
ever
>> > > > reverting the patch won=E2=80=99t prevent the server from returnin=
g
>> > > > NFS4ERR_BAD_STATEID in any cases where the calls to
>> > > > nfs4_set_rw_stateid() happen before state recovery. This is why
>> > > > we
>> > > > have the loop in nfs42_proc_copy().
>> > >
>> > > I thought that if retry of the operation waits for the recovery
>> > > to
>> > > complete then nfs4_set_rw_stateid() will choose the correct
>> > > stateid,
>> > > is that not correct?
>> > >
>> > > If that's not correct, then we somehow need to separate the case
>> > > when
>> > > BAD_STATEID should indeed mark the locks lost vs this case where
>> > > the
>> > > code erroneously used the bad stateid (oops) and it should really
>> > > ignore this error. This really doesn't sound very plausible to
>> > > accomplish.
>> >
>> > Does this patch fix the problem?
>> >
>> > 8<-------------------------------------------------------------
>> > From bbae95e8f97cad6a91ca8caa50b61cae789632f9 Mon Sep 17 00:00:00
>> > 2001
>> > From: Trond Myklebust <[email protected]>
>> > Date: Thu, 16 Feb 2017 18:14:38 -0500
>> > Subject: [PATCH] NFSv4: Fix reboot recovery in copy offload
>> >
>> > Copy offload code needs to be hooked into the code for handling
>> > NFS4ERR_BAD_STATEID by ensuring that we set the "stateid" field
>> > in struct nfs4_exception.
>> >
>> > Reported-by: Olga Kornievskaia <[email protected]>
>> > Fixes: 2e72448b07dc3 ("NFS: Add COPY nfs operation")
>> > Signed-off-by: Trond Myklebust <[email protected]>
>> > ---
>> > fs/nfs/nfs42proc.c | 57 +++++++++++++++++++++++++++++++-----------
>> > ------------
>> > 1 file changed, 33 insertions(+), 24 deletions(-)
>> >
>> > diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
>> > index d12ff9385f49..baf1fe2dc296 100644
>> > --- a/fs/nfs/nfs42proc.c
>> > +++ b/fs/nfs/nfs42proc.c
>> > @@ -128,20 +128,13 @@ int nfs42_proc_deallocate(struct file *filep,
>> > loff_t offset, loff_t len)
>> > return err;
>> > }
>> >
>> > -static ssize_t _nfs42_proc_copy(struct file *src, loff_t pos_src,
>> > +static ssize_t _nfs42_proc_copy(struct file *src,
>> > struct nfs_lock_context *src_lock,
>> > - struct file *dst, loff_t pos_dst,
>> > + struct file *dst,
>> > struct nfs_lock_context *dst_lock,
>> > - size_t count)
>> > + struct nfs42_copy_args *args,
>> > + struct nfs42_copy_res *res)
>> > {
>> > - struct nfs42_copy_args args =3D {
>> > - .src_fh =3D NFS_FH(file_inode(src)),
>> > - .src_pos =3D pos_src,
>> > - .dst_fh =3D NFS_FH(file_inode(dst)),
>> > - .dst_pos =3D pos_dst,
>> > - .count =3D count,
>> > - };
>> > - struct nfs42_copy_res res;
>> > struct rpc_message msg =3D {
>> > .rpc_proc =3D &nfs4_procedures[NFSPROC4_CLNT_COPY],
>> > .rpc_argp =3D &args,
>> > @@ -149,9 +142,12 @@ static ssize_t _nfs42_proc_copy(struct file
>> > *src, loff_t pos_src,
>> > };
>> > struct inode *dst_inode =3D file_inode(dst);
>> > struct nfs_server *server =3D NFS_SERVER(dst_inode);
>> > + loff_t pos_src =3D args->src_pos;
>> > + loff_t pos_dst =3D args->dst_pos;
>> > + size_t count =3D args->count;
>> > int status;
>> >
>> > - status =3D nfs4_set_rw_stateid(&args.src_stateid, src_lock-
>> > >open_context,
>> > + status =3D nfs4_set_rw_stateid(&args->src_stateid, src_lock-
>> > >open_context,
>> > src_lock, FMODE_READ);
>> > if (status)
>> > return status;
>> > @@ -161,7 +157,7 @@ static ssize_t _nfs42_proc_copy(struct file
>> > *src, loff_t pos_src,
>> > if (status)
>> > return status;
>> >
>> > - status =3D nfs4_set_rw_stateid(&args.dst_stateid, dst_lock-
>> > >open_context,
>> > + status =3D nfs4_set_rw_stateid(&args->dst_stateid, dst_lock-
>> > >open_context,
>> > dst_lock, FMODE_WRITE);
>> > if (status)
>> > return status;
>> > @@ -171,22 +167,22 @@ static ssize_t _nfs42_proc_copy(struct file
>> > *src, loff_t pos_src,
>> > return status;
>> >
>> > status =3D nfs4_call_sync(server->client, server, &msg,
>> > - &args.seq_args, &res.seq_res, 0);
>> > + &args->seq_args, &res->seq_res, 0);
>> > if (status =3D=3D -ENOTSUPP)
>> > server->caps &=3D ~NFS_CAP_COPY;
>> > if (status)
>> > return status;
>> >
>> > - if (res.write_res.verifier.committed !=3D NFS_FILE_SYNC) {
>> > - status =3D nfs_commit_file(dst,
>> > &res.write_res.verifier.verifier);
>> > + if (res->write_res.verifier.committed !=3D NFS_FILE_SYNC) {
>> > + status =3D nfs_commit_file(dst, &res-
>> > >write_res.verifier.verifier);
>> > if (status)
>> > return status;
>> > }
>> >
>> > truncate_pagecache_range(dst_inode, pos_dst,
>> > - pos_dst + res.write_res.count);
>> > + pos_dst + res->write_res.count);
>> >
>> > - return res.write_res.count;
>> > + return res->write_res.count;
>> > }
>> >
>> > ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,
>> > @@ -196,8 +192,22 @@ ssize_t nfs42_proc_copy(struct file *src,
>> > loff_t pos_src,
>> > struct nfs_server *server =3D NFS_SERVER(file_inode(dst));
>> > struct nfs_lock_context *src_lock;
>> > struct nfs_lock_context *dst_lock;
>> > - struct nfs4_exception src_exception =3D { };
>> > - struct nfs4_exception dst_exception =3D { };
>> > + struct nfs42_copy_args args =3D {
>> > + .src_fh =3D NFS_FH(file_inode(src)),
>> > + .src_pos =3D pos_src,
>> > + .dst_fh =3D NFS_FH(file_inode(dst)),
>> > + .dst_pos =3D pos_dst,
>> > + .count =3D count,
>> > + };
>> > + struct nfs42_copy_res res;
>> > + struct nfs4_exception src_exception =3D {
>> > + .inode =3D file_inode(src),
>> > + .stateid =3D &args.src_stateid,
>> > + };
>> > + struct nfs4_exception dst_exception =3D {
>> > + .inode =3D file_inode(dst),
>> > + .stateid =3D &args.dst_stateid,
>> > + };
>> > ssize_t err, err2;
>> >
>> > if (!nfs_server_capable(file_inode(dst), NFS_CAP_COPY))
>> > @@ -207,7 +217,6 @@ ssize_t nfs42_proc_copy(struct file *src,
>> > loff_t pos_src,
>> > if (IS_ERR(src_lock))
>> > return PTR_ERR(src_lock);
>> >
>> > - src_exception.inode =3D file_inode(src);
>> > src_exception.state =3D src_lock->open_context->state;
>> >
>> > dst_lock =3D
>> > nfs_get_lock_context(nfs_file_open_context(dst));
>> > @@ -216,13 +225,13 @@ ssize_t nfs42_proc_copy(struct file *src,
>> > loff_t pos_src,
>> > goto out_put_src_lock;
>> > }
>> >
>> > - dst_exception.inode =3D file_inode(dst);
>> > dst_exception.state =3D dst_lock->open_context->state;
>> >
>> > do {
>> > inode_lock(file_inode(dst));
>> > - err =3D _nfs42_proc_copy(src, pos_src, src_lock,
>> > - dst, pos_dst, dst_lock,
>> > count);
>> > + err =3D _nfs42_proc_copy(src, src_lock,
>> > + dst, dst_lock,
>> > + &args, &res);
>> > inode_unlock(file_inode(dst));
>> >
>> > if (err =3D=3D -ENOTSUPP) {
>> > --
>> > 2.9.3
>>
>> I wish it did but no it does not.
>>
>
> So what is still happening? With this patch, the error handler should
> be able to distinguish between a stateid that is up to date and one
> that isn't.
>
> There might, however, still be a problem because we have 2 stateids,
> meaning that one could be stale (and generating NFS4ERR_BAD_STATEID)
> and the other one not. We might have to special case that, and do the
> comparisons inside nfs42_proc_copy instead of using the generic code in
> nfs4_handle_exception().
After COPY gets the BAD_STATEID (on the old stateids), I see 4
TEST_STATEIDs sent with 3 distinct stateids which are the new open
stateid for the src file, the locking stateid for the source file and
the new old stateid for the destination file. All of which are ok.
On Fri, Feb 17, 2017 at 10:07 AM, Olga Kornievskaia <[email protected]> wrote:
> On Fri, Feb 17, 2017 at 9:58 AM, Trond Myklebust
> <[email protected]> wrote:
>> On Fri, 2017-02-17 at 09:46 -0500, Olga Kornievskaia wrote:
>>> On Thu, Feb 16, 2017 at 6:28 PM, Trond Myklebust
>>> <[email protected]> wrote:
>>> > On Thu, 2017-02-16 at 17:14 -0500, Olga Kornievskaia wrote:
>>> > > On Thu, Feb 16, 2017 at 4:45 PM, Trond Myklebust
>>> > > <[email protected]> wrote:
>>> > > >
>>> > > > Olga, all your test is doing is showing that we hit the race
>>> > > > more
>>> > > > often. Fair enough, I=E2=80=99ll ask Anna to revert the patch. Ho=
wever
>>> > > > reverting the patch won=E2=80=99t prevent the server from returni=
ng
>>> > > > NFS4ERR_BAD_STATEID in any cases where the calls to
>>> > > > nfs4_set_rw_stateid() happen before state recovery. This is why
>>> > > > we
>>> > > > have the loop in nfs42_proc_copy().
>>> > >
>>> > > I thought that if retry of the operation waits for the recovery
>>> > > to
>>> > > complete then nfs4_set_rw_stateid() will choose the correct
>>> > > stateid,
>>> > > is that not correct?
>>> > >
>>> > > If that's not correct, then we somehow need to separate the case
>>> > > when
>>> > > BAD_STATEID should indeed mark the locks lost vs this case where
>>> > > the
>>> > > code erroneously used the bad stateid (oops) and it should really
>>> > > ignore this error. This really doesn't sound very plausible to
>>> > > accomplish.
>>> >
>>> > Does this patch fix the problem?
>>> >
>>> > 8<-------------------------------------------------------------
>>> > From bbae95e8f97cad6a91ca8caa50b61cae789632f9 Mon Sep 17 00:00:00
>>> > 2001
>>> > From: Trond Myklebust <[email protected]>
>>> > Date: Thu, 16 Feb 2017 18:14:38 -0500
>>> > Subject: [PATCH] NFSv4: Fix reboot recovery in copy offload
>>> >
>>> > Copy offload code needs to be hooked into the code for handling
>>> > NFS4ERR_BAD_STATEID by ensuring that we set the "stateid" field
>>> > in struct nfs4_exception.
>>> >
>>> > Reported-by: Olga Kornievskaia <[email protected]>
>>> > Fixes: 2e72448b07dc3 ("NFS: Add COPY nfs operation")
>>> > Signed-off-by: Trond Myklebust <[email protected]>
>>> > ---
>>> > fs/nfs/nfs42proc.c | 57 +++++++++++++++++++++++++++++++-----------
>>> > ------------
>>> > 1 file changed, 33 insertions(+), 24 deletions(-)
>>> >
>>> > diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
>>> > index d12ff9385f49..baf1fe2dc296 100644
>>> > --- a/fs/nfs/nfs42proc.c
>>> > +++ b/fs/nfs/nfs42proc.c
>>> > @@ -128,20 +128,13 @@ int nfs42_proc_deallocate(struct file *filep,
>>> > loff_t offset, loff_t len)
>>> > return err;
>>> > }
>>> >
>>> > -static ssize_t _nfs42_proc_copy(struct file *src, loff_t pos_src,
>>> > +static ssize_t _nfs42_proc_copy(struct file *src,
>>> > struct nfs_lock_context *src_lock,
>>> > - struct file *dst, loff_t pos_dst,
>>> > + struct file *dst,
>>> > struct nfs_lock_context *dst_lock,
>>> > - size_t count)
>>> > + struct nfs42_copy_args *args,
>>> > + struct nfs42_copy_res *res)
>>> > {
>>> > - struct nfs42_copy_args args =3D {
>>> > - .src_fh =3D NFS_FH(file_inode(src)),
>>> > - .src_pos =3D pos_src,
>>> > - .dst_fh =3D NFS_FH(file_inode(dst)),
>>> > - .dst_pos =3D pos_dst,
>>> > - .count =3D count,
>>> > - };
>>> > - struct nfs42_copy_res res;
>>> > struct rpc_message msg =3D {
>>> > .rpc_proc =3D &nfs4_procedures[NFSPROC4_CLNT_COPY],
>>> > .rpc_argp =3D &args,
>>> > @@ -149,9 +142,12 @@ static ssize_t _nfs42_proc_copy(struct file
>>> > *src, loff_t pos_src,
>>> > };
>>> > struct inode *dst_inode =3D file_inode(dst);
>>> > struct nfs_server *server =3D NFS_SERVER(dst_inode);
>>> > + loff_t pos_src =3D args->src_pos;
>>> > + loff_t pos_dst =3D args->dst_pos;
>>> > + size_t count =3D args->count;
>>> > int status;
>>> >
>>> > - status =3D nfs4_set_rw_stateid(&args.src_stateid, src_lock-
>>> > >open_context,
>>> > + status =3D nfs4_set_rw_stateid(&args->src_stateid, src_lock-
>>> > >open_context,
>>> > src_lock, FMODE_READ);
>>> > if (status)
>>> > return status;
>>> > @@ -161,7 +157,7 @@ static ssize_t _nfs42_proc_copy(struct file
>>> > *src, loff_t pos_src,
>>> > if (status)
>>> > return status;
>>> >
>>> > - status =3D nfs4_set_rw_stateid(&args.dst_stateid, dst_lock-
>>> > >open_context,
>>> > + status =3D nfs4_set_rw_stateid(&args->dst_stateid, dst_lock-
>>> > >open_context,
>>> > dst_lock, FMODE_WRITE);
>>> > if (status)
>>> > return status;
>>> > @@ -171,22 +167,22 @@ static ssize_t _nfs42_proc_copy(struct file
>>> > *src, loff_t pos_src,
>>> > return status;
>>> >
>>> > status =3D nfs4_call_sync(server->client, server, &msg,
>>> > - &args.seq_args, &res.seq_res, 0);
>>> > + &args->seq_args, &res->seq_res, 0);
>>> > if (status =3D=3D -ENOTSUPP)
>>> > server->caps &=3D ~NFS_CAP_COPY;
>>> > if (status)
>>> > return status;
>>> >
>>> > - if (res.write_res.verifier.committed !=3D NFS_FILE_SYNC) {
>>> > - status =3D nfs_commit_file(dst,
>>> > &res.write_res.verifier.verifier);
>>> > + if (res->write_res.verifier.committed !=3D NFS_FILE_SYNC) {
>>> > + status =3D nfs_commit_file(dst, &res-
>>> > >write_res.verifier.verifier);
>>> > if (status)
>>> > return status;
>>> > }
>>> >
>>> > truncate_pagecache_range(dst_inode, pos_dst,
>>> > - pos_dst + res.write_res.count);
>>> > + pos_dst + res->write_res.count);
>>> >
>>> > - return res.write_res.count;
>>> > + return res->write_res.count;
>>> > }
>>> >
>>> > ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,
>>> > @@ -196,8 +192,22 @@ ssize_t nfs42_proc_copy(struct file *src,
>>> > loff_t pos_src,
>>> > struct nfs_server *server =3D NFS_SERVER(file_inode(dst));
>>> > struct nfs_lock_context *src_lock;
>>> > struct nfs_lock_context *dst_lock;
>>> > - struct nfs4_exception src_exception =3D { };
>>> > - struct nfs4_exception dst_exception =3D { };
>>> > + struct nfs42_copy_args args =3D {
>>> > + .src_fh =3D NFS_FH(file_inode(src)),
>>> > + .src_pos =3D pos_src,
>>> > + .dst_fh =3D NFS_FH(file_inode(dst)),
>>> > + .dst_pos =3D pos_dst,
>>> > + .count =3D count,
>>> > + };
>>> > + struct nfs42_copy_res res;
>>> > + struct nfs4_exception src_exception =3D {
>>> > + .inode =3D file_inode(src),
>>> > + .stateid =3D &args.src_stateid,
>>> > + };
>>> > + struct nfs4_exception dst_exception =3D {
>>> > + .inode =3D file_inode(dst),
>>> > + .stateid =3D &args.dst_stateid,
>>> > + };
>>> > ssize_t err, err2;
>>> >
>>> > if (!nfs_server_capable(file_inode(dst), NFS_CAP_COPY))
>>> > @@ -207,7 +217,6 @@ ssize_t nfs42_proc_copy(struct file *src,
>>> > loff_t pos_src,
>>> > if (IS_ERR(src_lock))
>>> > return PTR_ERR(src_lock);
>>> >
>>> > - src_exception.inode =3D file_inode(src);
>>> > src_exception.state =3D src_lock->open_context->state;
>>> >
>>> > dst_lock =3D
>>> > nfs_get_lock_context(nfs_file_open_context(dst));
>>> > @@ -216,13 +225,13 @@ ssize_t nfs42_proc_copy(struct file *src,
>>> > loff_t pos_src,
>>> > goto out_put_src_lock;
>>> > }
>>> >
>>> > - dst_exception.inode =3D file_inode(dst);
>>> > dst_exception.state =3D dst_lock->open_context->state;
>>> >
>>> > do {
>>> > inode_lock(file_inode(dst));
>>> > - err =3D _nfs42_proc_copy(src, pos_src, src_lock,
>>> > - dst, pos_dst, dst_lock,
>>> > count);
>>> > + err =3D _nfs42_proc_copy(src, src_lock,
>>> > + dst, dst_lock,
>>> > + &args, &res);
>>> > inode_unlock(file_inode(dst));
>>> >
>>> > if (err =3D=3D -ENOTSUPP) {
>>> > --
>>> > 2.9.3
>>>
>>> I wish it did but no it does not.
>>>
>>
>> So what is still happening? With this patch, the error handler should
>> be able to distinguish between a stateid that is up to date and one
>> that isn't.
>>
>> There might, however, still be a problem because we have 2 stateids,
>> meaning that one could be stale (and generating NFS4ERR_BAD_STATEID)
>> and the other one not. We might have to special case that, and do the
>> comparisons inside nfs42_proc_copy instead of using the generic code in
>> nfs4_handle_exception().
>
> After COPY gets the BAD_STATEID (on the old stateids), I see 4
> TEST_STATEIDs sent with 3 distinct stateids which are the new open
> stateid for the src file, the locking stateid for the source file and
> the new old stateid for the destination file. All of which are ok.
Urgh. sorry please wait. Last time I booted into the wrong kernel. You
patch currently oops. I need to fix that first. There is HOPE now it
works.