I've been trying to understand how LAYOUTRETURN is used in pNFS,
primarily because our SLE12-SP1 kernel (based on 3.12) appears
to have a very different opinion than some Netapp filers.
My reading of RFC-5661 suggests that the client needs to call
LAYOUTRETURN for every layout that it received from the server. A
single LAYOUTRETURN can cover a whole file or a whole filesystem, so it
doesn't need to be 1-for-1, but there is no implicit return.
However RFC-5663 contains the text
A LAYOUTRETURN operation represents an explicit release of resources
by the client, usually done for the purpose of avoiding unnecessary
CB_LAYOUTRECALL operations in the future.
This seems to imply that LAYOUTRETURN is only an optimisation. If you
don't want to avoid CB_LAYOUTRECALL, there is not much call for
LAYOUTRETURN. It seems to suggest (without explicitly saying) that the
CB_LAYOUTRECALL will effect the return of a layout without the client
explicitly sending LAYOUTRETURN in response. RFC-5661 says LAYOUTRETURN
does need to be sent in response.
The code in 3.12 doesn't send LAYOUTRETURN in response to
CB_LAYOUTRECALL, nor does it send LAYOUTRETURN when it closes a file
marked as "return layouts on close". The one place I have seen evidence
of it returning layouts is when a file is unlinked, though I think there
are others (chmod, IO error).
The current upstream code seems to call LAYOUTRETURN more correctly, but
it is hard to be sure because I couldn't find a commit which acknowledged
the specific problem and corrected it - just commits that claim to be
making improvements and avoiding races and things like that.
Questions:
- Am I correct that all layouts need to be explicitly returned by the
client, and so the text from RFC-5663 is misleading?
- If so, what is the earliest kernel that is believed to correctly
return layouts in response to CB_LAYOUTRECALL, or a 'roc' file being
closed?
I was advised that Netapp are considering a change (netapp issue
955835):
An enhancement will be added in future versions of Ontap to clear out
the corresponding layout states after a file has been closed in the
event the client does not return them.
This sounds like a mistake, unless "clear out" means "send
CB_LAYOUTRECALL for". Should we advice Netapp against this?
Thanks,
NeilBrown
Hi Neil,
sorry for the sparse reply, I'm travelling right now,
take a look at the NFS4ERR_NOMATCHING_LAYOUT error in NFSv4.2
and maybe try to do an internet search for forgetful clients - that's
the way how the Linux pNFS client operates using the above error
to signal it doesn't have any outstanding layouts when responding
to a layoutrecall.
On Fri, 2017-03-03 at 08:24 +1100, NeilBrown wrote:
> I've been trying to understand how LAYOUTRETURN is used in pNFS,
> primarily because our SLE12-SP1 kernel (based on 3.12) appears
> to have a very different opinion than some Netapp filers.
>
> My reading of RFC-5661 suggests that the client needs to call
> LAYOUTRETURN for every layout that it received from the server. A
> single LAYOUTRETURN can cover a whole file or a whole filesystem, so it
> doesn't need to be 1-for-1, but there is no implicit return.
>
> However RFC-5663 contains the text
>
> A LAYOUTRETURN operation represents an explicit release of resources
> by the client, usually done for the purpose of avoiding unnecessary
> CB_LAYOUTRECALL operations in the future.
>
> This seems to imply that LAYOUTRETURN is only an optimisation. If you
> don't want to avoid CB_LAYOUTRECALL, there is not much call for
> LAYOUTRETURN. It seems to suggest (without explicitly saying) that the
> CB_LAYOUTRECALL will effect the return of a layout without the client
> explicitly sending LAYOUTRETURN in response. RFC-5661 says LAYOUTRETURN
> does need to be sent in response.
>
> The code in 3.12 doesn't send LAYOUTRETURN in response to
> CB_LAYOUTRECALL, nor does it send LAYOUTRETURN when it closes a file
> marked as "return layouts on close". The one place I have seen evidence
> of it returning layouts is when a file is unlinked, though I think there
> are others (chmod, IO error).
>
> The current upstream code seems to call LAYOUTRETURN more correctly, but
> it is hard to be sure because I couldn't find a commit which acknowledged
> the specific problem and corrected it - just commits that claim to be
> making improvements and avoiding races and things like that.
>
> Questions:
> - Am I correct that all layouts need to be explicitly returned by the
> client, and so the text from RFC-5663 is misleading?
>
There is one special case...
When the server does a CB_LAYOUTRECALL, the client can reply with
NFS4ERR_NOMATCHING_LAYOUT if it's not actively using the layout at the
time. With that, the client isn't expected to do a LAYOUTRETURN.
Any other status on the CB_LAYOUTRECALL however does require a
LAYOUTRETURN.
> - If so, what is the earliest kernel that is believed to correctly
> return layouts in response to CB_LAYOUTRECALL, or a 'roc' file being
> closed?
>
> I was advised that Netapp are considering a change (netapp issue
> 955835):
> An enhancement will be added in future versions of Ontap to clear out
> the corresponding layout states after a file has been closed in the
> event the client does not return them.
>
> This sounds like a mistake, unless "clear out" means "send
> CB_LAYOUTRECALL for". Should we advice Netapp against this?
>
> Thanks,
> NeilBrown
>
On Fri, Mar 03 2017, Jeff Layton wrote:
>
> There is one special case...
>
> When the server does a CB_LAYOUTRECALL, the client can reply with
> NFS4ERR_NOMATCHING_LAYOUT if it's not actively using the layout at the
> time. With that, the client isn't expected to do a LAYOUTRETURN.
>
> Any other status on the CB_LAYOUTRECALL however does require a
> LAYOUTRETURN.
Thanks, both to you and Christoph, for this pointer.
Things are starting to make sense.
However RFC5661 says under
Operation 5: CB_LAYOUTRECALL - Recall Layout from Client
While the client responds to the CB_LAYOUTRECALL immediately, the
operation is not considered complete (i.e., considered pending) until
all affected layouts are returned to the server via the LAYOUTRETURN
operation.
which seems to strongly imply that a LAYOUTRETURN is expected. No
alternative is listed.
Further:
The NFS4ERR_NOMATCHING_LAYOUT error is only returned when the client
does not hold layouts for the file or if the client does not have
any overlapping layouts for the specification in the layout recall.
This is an *error* condition. The client really does still hold
the layouts if it hasn't sent "LAYOUTRETURN". The fact that the linux
client chooses to forget them and won't ever use them again isn't really
the same thing as "not hold[ing] layouts".
If I were a server author and I got NFS4ERR_NOMATCHING_LAYOUT for a
CB_LAYOUTRECALL where a I knew for certain that the client really did
have the layout, then I would probably feel justified in discarding all
state held by that confused client, and requiring to re-establish
everything (because I cannot trust anything any more).
So the Netapp filer is clearly doing the wrong thing, as we doesn't send
CB_LAYOUTRECALL. But I'm far from convinced that Linux is doing the
right thing by replying NFS4ERR_NOMATCHING_LAYOUT.
However, I'm not going to try to "fix" anything here. Hopefully we can
manage to stumble forward.
Thanks again,
NeilBrown
SGkgTmVpbCwNCg0KT24gTW9uLCAyMDE3LTAzLTA2IGF0IDE0OjU0ICsxMTAwLCBOZWlsQnJvd24g
d3JvdGU6DQo+IE9uIEZyaSwgTWFyIDAzIDIwMTcsIEplZmYgTGF5dG9uIHdyb3RlOg0KPiANCj4g
PiANCj4gPiBUaGVyZSBpcyBvbmUgc3BlY2lhbCBjYXNlLi4uDQo+ID4gDQo+ID4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0aGUNCkxpbnV4IGNsaWVudCBi
ZWhhdmlvdXIgaXMgcXVpdGUgY29ycmVjdCB3LnIudC4gdGhlIHNwZWMuDQpUaGVyZSBhcmUgYSBj
b3VwbGUgb2YgZXJyYXRhIHRvIGNvbnNpZGVyIHRvbywgYnV0IHRoZXkgbWFpbmx5IHRyeSB0bw0K
bmFpbCBkb3duIHRoZSBleHBlY3RlZCBiZWhhdmlvdXIgZm9yIGEgY291cGxlIG9mIGNvcm5lciBj
YXNlcy4NCg0KLS0gDQpUcm9uZCBNeWtsZWJ1c3QNCkxpbnV4IE5GUyBjbGllbnQgbWFpbnRhaW5l
ciwgUHJpbWFyeURhdGENCnRyb25kLm15a2xlYnVzdEBwcmltYXJ5ZGF0YS5jb20NCg==
On Tue, Mar 07 2017, Trond Myklebust wrote:
> Hi Neil,
>
> On Mon, 2017-03-06 at 14:54 +1100, NeilBrown wrote:
...
>>
>> So the Netapp filer is clearly doing the wrong thing, as we doesn't
>> send
>> CB_LAYOUTRECALL. But I'm far from convinced that Linux is doing the
>> right thing by replying NFS4ERR_NOMATCHING_LAYOUT.
>>
>> However, I'm not going to try to "fix" anything here. Hopefully we
>> can
>> manage to stumble forward.
>>
>
> Please see RFC5661, Section 12.5.5.1 https://tools.ietf.org/html/rfc566
> 1#section-12.5.5.1
>
> That section has a full documentation of what the server should
> interpret NFS4ERR_NOMATCHING_LAYOUT to mean, and should explain why the
> Linux client behaviour is quite correct w.r.t. the spec.
> There are a couple of errata to consider too, but they mainly try to
> nail down the expected behaviour for a couple of corner cases.
Thanks for that. The last too sentences to suggest that
NFS4ERR_NOMATCHING_LAYOUT isn't really an error, and the whole
discusses how the server and client can reasonably have different
understandings of the current set of layouts.
Thanks,
NeilBrown