All of lore.kernel.org
 help / color / mirror / Atom feed
* CB_LAYOUTRECALL "deadlock" with in-kernel flexfiles server and XFS
@ 2016-08-11 15:23 Jeff Layton
  2016-08-11 15:55 ` Trond Myklebust
  2018-01-27 15:39 ` Benjamin Coddington
  0 siblings, 2 replies; 10+ messages in thread
From: Jeff Layton @ 2016-08-11 15:23 UTC (permalink / raw)
  To: open list:NFS, SUNRPC, AND...; +Cc: Tom Haynes, Christoph Hellwig, Bruce Fields

I was playing around with the in-kernel flexfiles server today, and I
seem to be hitting a deadlock when using it on an XFS-exported
filesystem. Here's the stack trace of how the CB_LAYOUTRECALL occurs:

[  928.736139] CPU: 0 PID: 846 Comm: nfsd Tainted: G           OE   4.8.0-rc1+ #3
[  928.737040] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.9.1-1.fc24 04/01/2014
[  928.738009]  0000000000000286 000000006125f50e ffff91153845b878 ffffffff8f463853
[  928.738906]  ffff91152ec194d0 ffff91152d31d9c0 ffff91153845b8a8 ffffffffc045936f
[  928.739788]  ffff91152c051980 ffff91152d31d9c0 ffff91152c051540 ffff9115361b8a58
[  928.740697] Call Trace:
[  928.740998]  [<ffffffff8f463853>] dump_stack+0x86/0xc3
[  928.741570]  [<ffffffffc045936f>] nfsd4_recall_file_layout+0x17f/0x190 [nfsd]
[  928.742380]  [<ffffffffc045939d>] nfsd4_layout_lm_break+0x1d/0x30 [nfsd]
[  928.743115]  [<ffffffff8f3056d8>] __break_lease+0x118/0x6a0
[  928.743759]  [<ffffffffc02dea69>] xfs_break_layouts+0x79/0x120 [xfs]
[  928.744462]  [<ffffffffc029ea04>] xfs_file_aio_write_checks+0x94/0x1f0 [xfs]
[  928.745251]  [<ffffffffc029f36b>] xfs_file_buffered_aio_write+0x7b/0x330 [xfs]
[  928.746063]  [<ffffffffc029f70c>] xfs_file_write_iter+0xec/0x140 [xfs]
[  928.746803]  [<ffffffff8f2a0599>] do_iter_readv_writev+0xb9/0x140
[  928.747478]  [<ffffffff8f2a126b>] do_readv_writev+0x19b/0x240
[  928.748146]  [<ffffffffc029f620>] ? xfs_file_buffered_aio_write+0x330/0x330 [xfs]
[  928.748956]  [<ffffffff8f29e02b>] ? do_dentry_open+0x28b/0x310
[  928.749614]  [<ffffffffc029c800>] ? xfs_extent_busy_ag_cmp+0x20/0x20 [xfs]
[  928.750367]  [<ffffffff8f2a156f>] vfs_writev+0x3f/0x50
[  928.750934]  [<ffffffffc04276ca>] nfsd_vfs_write+0xca/0x3a0 [nfsd]
[  928.751608]  [<ffffffffc0429ec5>] nfsd_write+0x485/0x780 [nfsd]
[  928.752263]  [<ffffffffc043144c>] nfsd3_proc_write+0xbc/0x150 [nfsd]
[  928.752973]  [<ffffffffc0421388>] nfsd_dispatch+0xb8/0x1f0 [nfsd]
[  928.753642]  [<ffffffffc036d78f>] svc_process_common+0x42f/0x690 [sunrpc]
[  928.754395]  [<ffffffffc036e8e8>] svc_process+0x118/0x330 [sunrpc]
[  928.755080]  [<ffffffffc04208ac>] nfsd+0x19c/0x2b0 [nfsd]
[  928.755681]  [<ffffffffc0420715>] ? nfsd+0x5/0x2b0 [nfsd]
[  928.756274]  [<ffffffffc0420710>] ? nfsd_destroy+0x190/0x190 [nfsd]
[  928.756991]  [<ffffffff8f0d5891>] kthread+0x101/0x120
[  928.757563]  [<ffffffff8f10dcc5>] ? trace_hardirqs_on_caller+0xf5/0x1b0
[  928.758282]  [<ffffffff8f8f2fef>] ret_from_fork+0x1f/0x40
[  928.758875]  [<ffffffff8f0d5790>] ? kthread_create_on_node+0x250/0x250


So the client gets a flexfiles layout, and then tries to issue a v3
WRITE against the file. XFS then recalls the layout, but the client
can't return the layout until the v3 WRITE completes. Eventually this
should resolve itself after 2 lease periods, but that's quite a long
time.

I guess XFS requires recalling block and SCSI layouts when the server
wants to issue a write (or someone writes to it locally), but that
seems like it shouldn't be happening when the layout is a flexfiles
layout.

Any thoughts on what the right fix is here?

On a related note, knfsd will spam the heck out of the client with
CB_LAYOUTRECALLs during this time. I think we ought to consider fixing
the server not to treat an NFS_OK return from the client like
NFS4ERR_DELAY there, but that would mean a different mechanism for
timing out a CB_LAYOUTRECALL.

-- 
Jeff Layton <jlayton@redhat.com>

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

* Re: CB_LAYOUTRECALL "deadlock" with in-kernel flexfiles server and XFS
  2016-08-11 15:23 CB_LAYOUTRECALL "deadlock" with in-kernel flexfiles server and XFS Jeff Layton
@ 2016-08-11 15:55 ` Trond Myklebust
  2016-08-11 16:06   ` Jeff Layton
  2018-01-27 15:39 ` Benjamin Coddington
  1 sibling, 1 reply; 10+ messages in thread
From: Trond Myklebust @ 2016-08-11 15:55 UTC (permalink / raw)
  To: Jeff Layton
  Cc: List Linux NFS Mailing, Thomas Haynes, hch, Fields Bruce James

DQo+IE9uIEF1ZyAxMSwgMjAxNiwgYXQgMTE6MjMsIEplZmYgTGF5dG9uIDxqbGF5dG9uQHJlZGhh
dC5jb20+IHdyb3RlOg0KPiANCj4gSSB3YXMgcGxheWluZyBhcm91bmQgd2l0aCB0aGUgaW4ta2Vy
bmVsIGZsZXhmaWxlcyBzZXJ2ZXIgdG9kYXksIGFuZCBJDQo+IHNlZW0gdG8gYmUgaGl0dGluZyBh
IGRlYWRsb2NrIHdoZW4gdXNpbmcgaXQgb24gYW4gWEZTLWV4cG9ydGVkDQo+IGZpbGVzeXN0ZW0u
IEhlcmUncyB0aGUgc3RhY2sgdHJhY2Ugb2YgaG93IHRoZSBDQl9MQVlPVVRSRUNBTEwgb2NjdXJz
Og0KPiANCj4gWyAgOTI4LjczNjEzOV0gQ1BVOiAwIFBJRDogODQ2IENvbW06IG5mc2QgVGFpbnRl
ZDogRyAgICAgICAgICAgT0UgICA0LjguMC1yYzErICMzDQo+IFsgIDkyOC43MzcwNDBdIEhhcmR3
YXJlIG5hbWU6IFFFTVUgU3RhbmRhcmQgUEMgKGk0NDBGWCArIFBJSVgsIDE5OTYpLCBCSU9TIDEu
OS4xLTEuZmMyNCAwNC8wM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IGJhY2sgY2hhbm5lbCBhcyBpdCBkb2VzIGluIHRoZSBmb3J3YXJkIGNoYW5uZWw6
IEnigJltIGJ1c3kgYW5kIGNhbm5vdCBwcm9jZXNzIHlvdXIgcmVxdWVzdCwgcGxlYXNlIHJlc2Vu
ZCBpdCBsYXRlci4=


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

* Re: CB_LAYOUTRECALL "deadlock" with in-kernel flexfiles server and XFS
  2016-08-11 15:55 ` Trond Myklebust
@ 2016-08-11 16:06   ` Jeff Layton
  2016-08-11 16:20     ` Trond Myklebust
  0 siblings, 1 reply; 10+ messages in thread
From: Jeff Layton @ 2016-08-11 16:06 UTC (permalink / raw)
  To: Trond Myklebust
  Cc: List Linux NFS Mailing, Thomas Haynes, hch, Fields Bruce James

On Thu, 2016-08-11 at 15:55 +0000, Trond Myklebust wrote:
> > 
> > On Aug 11, 2016, at 11:23, Jeff Layton <jlayton@redhat.com> wrote:
> > 
> > I was playing around with the in-kernel flexfiles server today, and
> > I
> > seem to be hitting a deadlock when using it on an XFS-exported
> > filesystem. Here's the stack trace of how the CB_LAYOUTRECALL
> > occurs:
> > 
> > [  928.736139] CPU: 0 PID: 846 Comm: nfsd Tainted:
> > G           OE   4.8.0-rc1+ #3
> > [  928.737040] Hardware name: QEMU Standard PC (i440FX + PIIX,
> > 1996), BIOS 1.9.1-1.fc24 04/01/2014
> > [  928.738009]  0000000000000286 000000006125f50e ffff91153845b878
> > ffffffff8f463853
> > [  928.738906]  ffff91152ec194d0 ffff91152d31d9c0 ffff91153845b8a8
> > ffffffffc045936f
> > [  928.739788]  ffff91152c051980 ffff91152d31d9c0 ffff91152c051540
> > ffff9115361b8a58
> > [  928.740697] Call Trace:
> > [  928.740998]  [<ffffffff8f463853>] dump_stack+0x86/0xc3
> > [  928.741570]  [<ffffffffc045936f>]
> > nfsd4_recall_file_layout+0x17f/0x190 [nfsd]
> > [  928.742380]  [<ffffffffc045939d>]
> > nfsd4_layout_lm_break+0x1d/0x30 [nfsd]
> > [  928.743115]  [<ffffffff8f3056d8>] __break_lease+0x118/0x6a0
> > [  928.743759]  [<ffffffffc02dea69>] xfs_break_layouts+0x79/0x120
> > [xfs]
> > [  928.744462]  [<ffffffffc029ea04>]
> > xfs_file_aio_write_checks+0x94/0x1f0 [xfs]
> > [  928.745251]  [<ffffffffc029f36b>]
> > xfs_file_buffered_aio_write+0x7b/0x330 [xfs]
> > [  928.746063]  [<ffffffffc029f70c>] xfs_file_write_iter+0xec/0x140
> > [xfs]
> > [  928.746803]  [<ffffffff8f2a0599>]
> > do_iter_readv_writev+0xb9/0x140
> > [  928.747478]  [<ffffffff8f2a126b>] do_readv_writev+0x19b/0x240
> > [  928.748146]  [<ffffffffc029f620>] ?
> > xfs_file_buffered_aio_write+0x330/0x330 [xfs]
> > [  928.748956]  [<ffffffff8f29e02b>] ? do_dentry_open+0x28b/0x310
> > [  928.749614]  [<ffffffffc029c800>] ?
> > xfs_extent_busy_ag_cmp+0x20/0x20 [xfs]
> > [  928.750367]  [<ffffffff8f2a156f>] vfs_writev+0x3f/0x50
> > [  928.750934]  [<ffffffffc04276ca>] nfsd_vfs_write+0xca/0x3a0
> > [nfsd]
> > [  928.751608]  [<ffffffffc0429ec5>] nfsd_write+0x485/0x780 [nfsd]
> > [  928.752263]  [<ffffffffc043144c>] nfsd3_proc_write+0xbc/0x150
> > [nfsd]
> > [  928.752973]  [<ffffffffc0421388>] nfsd_dispatch+0xb8/0x1f0
> > [nfsd]
> > [  928.753642]  [<ffffffffc036d78f>] svc_process_common+0x42f/0x690
> > [sunrpc]
> > [  928.754395]  [<ffffffffc036e8e8>] svc_process+0x118/0x330
> > [sunrpc]
> > [  928.755080]  [<ffffffffc04208ac>] nfsd+0x19c/0x2b0 [nfsd]
> > [  928.755681]  [<ffffffffc0420715>] ? nfsd+0x5/0x2b0 [nfsd]
> > [  928.756274]  [<ffffffffc0420710>] ? nfsd_destroy+0x190/0x190
> > [nfsd]
> > [  928.756991]  [<ffffffff8f0d5891>] kthread+0x101/0x120
> > [  928.757563]  [<ffffffff8f10dcc5>] ?
> > trace_hardirqs_on_caller+0xf5/0x1b0
> > [  928.758282]  [<ffffffff8f8f2fef>] ret_from_fork+0x1f/0x40
> > [  928.758875]  [<ffffffff8f0d5790>] ?
> > kthread_create_on_node+0x250/0x250
> > 
> > 
> > So the client gets a flexfiles layout, and then tries to issue a v3
> > WRITE against the file. XFS then recalls the layout, but the client
> > can't return the layout until the v3 WRITE completes. Eventually
> > this
> > should resolve itself after 2 lease periods, but that's quite a
> > long
> > time.
> 
> What’s the sequence of operations here? If the client has outstanding
> I/O, I should now be returning NFS_OK, and then completing the recall
> with a LAYOUTRETURN as soon as the outstanding I/O (and layoutcommit,
> if one is due) is done.
> 
> The server is expected to return NFS4ERR_RECALLCONFLICT to any
> LAYOUTGET attempts that occur before the LAYOUTRETURN.
> 

Basically, I'm just doing this on the client:

    $ echo "foo" > /mnt/knfsdsrv/testfile


The client does:

OPEN
LAYOUTGET (for RW)
GETDEVICEINFO

...and then a v3 WRITE under the aegis of the layout it got.

The server then issues a CB_LAYOUTRECALL (because XFS wants to do that
whenever there is a local write, apparently). The client returns
NFS_OK, but it can't return the layout until the v3 WRITE completes.
The v3 write is hung though because it's waiting for the layout to be
returned.

> > 
> > 
> > I guess XFS requires recalling block and SCSI layouts when the
> > server
> > wants to issue a write (or someone writes to it locally), but that
> > seems like it shouldn't be happening when the layout is a flexfiles
> > layout.
> > 
> > Any thoughts on what the right fix is here?
> > 
> > On a related note, knfsd will spam the heck out of the client with
> > CB_LAYOUTRECALLs during this time. I think we ought to consider
> > fixing
> > the server not to treat an NFS_OK return from the client like
> > NFS4ERR_DELAY there, but that would mean a different mechanism for
> > timing out a CB_LAYOUTRECALL.
> 
> There is a big difference between NFS_OK and NFS4ERR_DELAY as far as
> the server is concerned:
> 
> - NFS_OK means that the client has now seen the stateid with the
> updated sequence id that was sent in CB_LAYOUTRECALL, and is
> processing it. No resend of the CB_LAYOUTRECALL is required.
> - OTOH, NFS4ERR_DELAY means the same thing in the back channel as it
> does in the forward channel: I’m busy and cannot process your
> request, please resend it later.

Right. The current code basically just treats them the same as a
mechanism to handle eventually timing out the layoutrecall. The extra
CB_LAYOUTRECALLs are entirely superfluous. It's probably not too hard
to fix, but we'd need to come up with some other mechanism for timing
out the layoutrecall.

-- 
Jeff Layton <jlayton@redhat.com>

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

* Re: CB_LAYOUTRECALL "deadlock" with in-kernel flexfiles server and XFS
  2016-08-11 16:06   ` Jeff Layton
@ 2016-08-11 16:20     ` Trond Myklebust
  2016-08-11 16:25       ` hch
  0 siblings, 1 reply; 10+ messages in thread
From: Trond Myklebust @ 2016-08-11 16:20 UTC (permalink / raw)
  To: Jeff Layton
  Cc: List Linux NFS Mailing, Thomas Haynes, hch, Fields Bruce James

DQo+IE9uIEF1ZyAxMSwgMjAxNiwgYXQgMTI6MDYsIEplZmYgTGF5dG9uIDxqbGF5dG9uQHJlZGhh
dC5jb20+IHdyb3RlOg0KPiANCj4gT24gVGh1LCAyMDE2LTA4LTExIGF0IDE1OjU1ICswMDAwLCBU
cm9uZCBNeWtsZWJ1c3Qgd3JvdGU6DQo+Pj4gDQo+Pj4gT24gQXVnIDExLCAyMDE2LCBhdCAxMToy
MywgSmVmZiBMYXl0b24gPGpsYXl0b25AcmVkaGF0LmNvbT4gd3JvdGU6DQo+Pj4gDQo+Pj4gSSB3
YXMgcGxheWluZyBhcm91bmQgd2l0aCB0aGUgaW4ta2VybmVsIGZsZXhmaWxlcyBzZXJ2ZXIgdG9k
YXksIGFuZA0KPj4+IEkNCj4+PiBzZWVtIHRvIGJlIGhpdHRpbmcgYSBkZWFkbG9jayB3aGVuIHVz
aW5nIGl0IG9uIGFuIFhGUy1leHBvcnRlZA0KPj4+IGZpbGVzeXN0ZW0uIEhlcmUncyB0aGUgc3Rh
Y2sgdHJhY2Ugb2YgaG93IHRoZSBDQl9MQVlPVVRSRUNBTEwNCj4+PiBvY2N1cnM6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d2UnZCBuZWVkIHRvIGNvbWUgdXAgd2l0aCBzb21lIG90aGVyIG1lY2hhbmlzbSBmb3Ig
dGltaW5nDQo+IG91dCB0aGUgbGF5b3V0cmVjYWxsLg0KPiANCj4gLS0gDQo+IEplZmYgTGF5dG9u
IDxqbGF5dG9uQHJlZGhhdC5jb20+DQoNCg==


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

* Re: CB_LAYOUTRECALL "deadlock" with in-kernel flexfiles server and XFS
  2016-08-11 16:20     ` Trond Myklebust
@ 2016-08-11 16:25       ` hch
  2016-08-11 16:33         ` Jeff Layton
  0 siblings, 1 reply; 10+ messages in thread
From: hch @ 2016-08-11 16:25 UTC (permalink / raw)
  To: Trond Myklebust
  Cc: Jeff Layton, List Linux NFS Mailing, Thomas Haynes, hch,
	Fields Bruce James

Yeah, for file-like layouts there should be a flag in
struct nfsd4_layout_ops to disable recalls.

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

* Re: CB_LAYOUTRECALL "deadlock" with in-kernel flexfiles server and XFS
  2016-08-11 16:25       ` hch
@ 2016-08-11 16:33         ` Jeff Layton
  2016-08-11 16:59           ` hch
  0 siblings, 1 reply; 10+ messages in thread
From: Jeff Layton @ 2016-08-11 16:33 UTC (permalink / raw)
  To: hch, Trond Myklebust
  Cc: List Linux NFS Mailing, Thomas Haynes, Fields Bruce James

On Thu, 2016-08-11 at 18:25 +0200, hch wrote:
> Yeah, for file-like layouts there should be a flag in
> struct nfsd4_layout_ops to disable recalls.

I don't think disabling recalls would be enough, would it? XFS still
wants to break_layout and won't proceed until the layout list is empty,
AFAICT. We need some way to indicate to the lower filesystem not to
call break_layout in this case.

-- 
Jeff Layton <jlayton@redhat.com>

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

* Re: CB_LAYOUTRECALL "deadlock" with in-kernel flexfiles server and XFS
  2016-08-11 16:33         ` Jeff Layton
@ 2016-08-11 16:59           ` hch
  2016-08-11 17:10             ` Jeff Layton
  0 siblings, 1 reply; 10+ messages in thread
From: hch @ 2016-08-11 16:59 UTC (permalink / raw)
  To: Jeff Layton
  Cc: hch, Trond Myklebust, List Linux NFS Mailing, Thomas Haynes,
	Fields Bruce James

On Thu, Aug 11, 2016 at 12:33:47PM -0400, Jeff Layton wrote:
> On Thu, 2016-08-11 at 18:25 +0200, hch wrote:
> > Yeah, for file-like layouts there should be a flag in
> > struct nfsd4_layout_ops to disable recalls.
> 
> I don't think disabling recalls would be enough, would it? XFS still
> wants to break_layout and won't proceed until the layout list is empty,
> AFAICT. We need some way to indicate to the lower filesystem not to
> call break_layout in this case.

XFS only cares about block-like layours where the client has direct
access to the file blocks.  I'd need to look how to propagate the
flag into break_layout, but in principle we don't need to do any
recalls on truncate every for file and flexfile layouts.

> 
> -- 
> Jeff Layton <jlayton@redhat.com>
---end quoted text---

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

* Re: CB_LAYOUTRECALL "deadlock" with in-kernel flexfiles server and XFS
  2016-08-11 16:59           ` hch
@ 2016-08-11 17:10             ` Jeff Layton
  0 siblings, 0 replies; 10+ messages in thread
From: Jeff Layton @ 2016-08-11 17:10 UTC (permalink / raw)
  To: hch
  Cc: Trond Myklebust, List Linux NFS Mailing, Thomas Haynes,
	Fields Bruce James

On Thu, 2016-08-11 at 18:59 +0200, hch wrote:
> On Thu, Aug 11, 2016 at 12:33:47PM -0400, Jeff Layton wrote:
> > 
> > On Thu, 2016-08-11 at 18:25 +0200, hch wrote:
> > > 
> > > Yeah, for file-like layouts there should be a flag in
> > > struct nfsd4_layout_ops to disable recalls.
> > 
> > I don't think disabling recalls would be enough, would it? XFS
> > still
> > wants to break_layout and won't proceed until the layout list is
> > empty,
> > AFAICT. We need some way to indicate to the lower filesystem not to
> > call break_layout in this case.
> 
> XFS only cares about block-like layours where the client has direct
> access to the file blocks.  I'd need to look how to propagate the
> flag into break_layout, but in principle we don't need to do any
> recalls on truncate every for file and flexfile layouts.
> 

Hmm...if we aren't ever going to recall files and flexfiles layouts,
then do we even need to set a FL_LAYOUT lease for them at all?

I think I'll try hacking something up that takes that approach and see
if that might be a reasonable fix.

-- 
Jeff Layton <jlayton@redhat.com>

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

* Re: CB_LAYOUTRECALL "deadlock" with in-kernel flexfiles server and XFS
  2016-08-11 15:23 CB_LAYOUTRECALL "deadlock" with in-kernel flexfiles server and XFS Jeff Layton
  2016-08-11 15:55 ` Trond Myklebust
@ 2018-01-27 15:39 ` Benjamin Coddington
  2018-01-27 21:41   ` Jeff Layton
  1 sibling, 1 reply; 10+ messages in thread
From: Benjamin Coddington @ 2018-01-27 15:39 UTC (permalink / raw)
  To: Jeff Layton
  Cc: open list:NFS, SUNRPC, AND...,
	Tom Haynes, Christoph Hellwig, Bruce Fields

On 11 Aug 2016, at 11:23, Jeff Layton wrote:

> I was playing around with the in-kernel flexfiles server today, and I
> seem to be hitting a deadlock when using it on an XFS-exported
> filesystem. Here's the stack trace of how the CB_LAYOUTRECALL occurs:
>
> [  928.736139] CPU: 0 PID: 846 Comm: nfsd Tainted: G           OE   
> 4.8.0-rc1+ #3
> [  928.737040] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), 
> BIOS 1.9.1-1.fc24 04/01/2014
> [  928.738009]  0000000000000286 000000006125f50e ffff91153845b878 
> ffffffff8f463853
> [  928.738906]  ffff91152ec194d0 ffff91152d31d9c0 ffff91153845b8a8 
> ffffffffc045936f
> [  928.739788]  ffff91152c051980 ffff91152d31d9c0 ffff91152c051540 
> ffff9115361b8a58
> [  928.740697] Call Trace:
> [  928.740998]  [<ffffffff8f463853>] dump_stack+0x86/0xc3
> [  928.741570]  [<ffffffffc045936f>] 
> nfsd4_recall_file_layout+0x17f/0x190 [nfsd]
> [  928.742380]  [<ffffffffc045939d>] nfsd4_layout_lm_break+0x1d/0x30 
> [nfsd]
> [  928.743115]  [<ffffffff8f3056d8>] __break_lease+0x118/0x6a0
> [  928.743759]  [<ffffffffc02dea69>] xfs_break_layouts+0x79/0x120 
> [xfs]
> [  928.744462]  [<ffffffffc029ea04>] 
> xfs_file_aio_write_checks+0x94/0x1f0 [xfs]
> [  928.745251]  [<ffffffffc029f36b>] 
> xfs_file_buffered_aio_write+0x7b/0x330 [xfs]
> [  928.746063]  [<ffffffffc029f70c>] xfs_file_write_iter+0xec/0x140 
> [xfs]
> [  928.746803]  [<ffffffff8f2a0599>] do_iter_readv_writev+0xb9/0x140
> [  928.747478]  [<ffffffff8f2a126b>] do_readv_writev+0x19b/0x240
> [  928.748146]  [<ffffffffc029f620>] ? 
> xfs_file_buffered_aio_write+0x330/0x330 [xfs]
> [  928.748956]  [<ffffffff8f29e02b>] ? do_dentry_open+0x28b/0x310
> [  928.749614]  [<ffffffffc029c800>] ? 
> xfs_extent_busy_ag_cmp+0x20/0x20 [xfs]
> [  928.750367]  [<ffffffff8f2a156f>] vfs_writev+0x3f/0x50
> [  928.750934]  [<ffffffffc04276ca>] nfsd_vfs_write+0xca/0x3a0 [nfsd]
> [  928.751608]  [<ffffffffc0429ec5>] nfsd_write+0x485/0x780 [nfsd]
> [  928.752263]  [<ffffffffc043144c>] nfsd3_proc_write+0xbc/0x150 
> [nfsd]
> [  928.752973]  [<ffffffffc0421388>] nfsd_dispatch+0xb8/0x1f0 [nfsd]
> [  928.753642]  [<ffffffffc036d78f>] svc_process_common+0x42f/0x690 
> [sunrpc]
> [  928.754395]  [<ffffffffc036e8e8>] svc_process+0x118/0x330 [sunrpc]
> [  928.755080]  [<ffffffffc04208ac>] nfsd+0x19c/0x2b0 [nfsd]
> [  928.755681]  [<ffffffffc0420715>] ? nfsd+0x5/0x2b0 [nfsd]
> [  928.756274]  [<ffffffffc0420710>] ? nfsd_destroy+0x190/0x190 [nfsd]
> [  928.756991]  [<ffffffff8f0d5891>] kthread+0x101/0x120
> [  928.757563]  [<ffffffff8f10dcc5>] ? 
> trace_hardirqs_on_caller+0xf5/0x1b0
> [  928.758282]  [<ffffffff8f8f2fef>] ret_from_fork+0x1f/0x40
> [  928.758875]  [<ffffffff8f0d5790>] ? 
> kthread_create_on_node+0x250/0x250
>
>
> So the client gets a flexfiles layout, and then tries to issue a v3
> WRITE against the file. XFS then recalls the layout, but the client
> can't return the layout until the v3 WRITE completes. Eventually this
> should resolve itself after 2 lease periods, but that's quite a long
> time.
>
> I guess XFS requires recalling block and SCSI layouts when the server
> wants to issue a write (or someone writes to it locally), but that
> seems like it shouldn't be happening when the layout is a flexfiles
> layout.
>
> Any thoughts on what the right fix is here?
>
> On a related note, knfsd will spam the heck out of the client with
> CB_LAYOUTRECALLs during this time. I think we ought to consider fixing
> the server not to treat an NFS_OK return from the client like
> NFS4ERR_DELAY there, but that would mean a different mechanism for
> timing out a CB_LAYOUTRECALL.

I'm getting into similar trouble with SCSI layouts when the client ends 
up
submitting a WRITE because the IO is not page aligned, but it already 
holds
a layout for that range.  It looks like the server sends a 
CB_LAYOUTRECALL,
but the client has to answer NFS4ERR_DELAY because it is still holding 
the
layout.

Probably, the client should return any layouts it holds for that range 
before
doing IO through the MDS.

Alternatively, shouldn't the MDS accept IO from the same client that 
holds a
layout for that range, rather than recall that layout?  RFC 5661 Section
20.3.4 talks about the client submitting WRITEs before responding to
CB_LAYOUTRECALL: "As always, the client may write the data through the
metadata server."

I'm trying to find the discussion that resulted in this commit:

commit 6b9b21073d3b250e17812cd562fffc9006962b39
Author: Jeff Layton <jlayton@poochiereds.net>
Date:   Tue Dec 8 07:23:48 2015 -0500

     nfsd: give up on CB_LAYOUTRECALLs after two lease periods

Why should we poll the client if the client answers with NFS4ERR_DELAY?  
Can
we instead just wait for the layout to be returned?

Also, I think the 2*lease period timeout is currently broken because we 
reset
tk_start after every call.. but that's not really causing any trouble.

Ben

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

* Re: CB_LAYOUTRECALL "deadlock" with in-kernel flexfiles server and XFS
  2018-01-27 15:39 ` Benjamin Coddington
@ 2018-01-27 21:41   ` Jeff Layton
  0 siblings, 0 replies; 10+ messages in thread
From: Jeff Layton @ 2018-01-27 21:41 UTC (permalink / raw)
  To: Benjamin Coddington
  Cc: open list:NFS, SUNRPC, AND...,
	Tom Haynes, Christoph Hellwig, Bruce Fields

On Sat, 2018-01-27 at 10:39 -0500, Benjamin Coddington wrote:
> On 11 Aug 2016, at 11:23, Jeff Layton wrote:
> 
> > I was playing around with the in-kernel flexfiles server today, and I
> > seem to be hitting a deadlock when using it on an XFS-exported
> > filesystem. Here's the stack trace of how the CB_LAYOUTRECALL occurs:
> > 
> > [  928.736139] CPU: 0 PID: 846 Comm: nfsd Tainted: G           OE   
> > 4.8.0-rc1+ #3
> > [  928.737040] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), 
> > BIOS 1.9.1-1.fc24 04/01/2014
> > [  928.738009]  0000000000000286 000000006125f50e ffff91153845b878 
> > ffffffff8f463853
> > [  928.738906]  ffff91152ec194d0 ffff91152d31d9c0 ffff91153845b8a8 
> > ffffffffc045936f
> > [  928.739788]  ffff91152c051980 ffff91152d31d9c0 ffff91152c051540 
> > ffff9115361b8a58
> > [  928.740697] Call Trace:
> > [  928.740998]  [<ffffffff8f463853>] dump_stack+0x86/0xc3
> > [  928.741570]  [<ffffffffc045936f>] 
> > nfsd4_recall_file_layout+0x17f/0x190 [nfsd]
> > [  928.742380]  [<ffffffffc045939d>] nfsd4_layout_lm_break+0x1d/0x30 
> > [nfsd]
> > [  928.743115]  [<ffffffff8f3056d8>] __break_lease+0x118/0x6a0
> > [  928.743759]  [<ffffffffc02dea69>] xfs_break_layouts+0x79/0x120 
> > [xfs]
> > [  928.744462]  [<ffffffffc029ea04>] 
> > xfs_file_aio_write_checks+0x94/0x1f0 [xfs]
> > [  928.745251]  [<ffffffffc029f36b>] 
> > xfs_file_buffered_aio_write+0x7b/0x330 [xfs]
> > [  928.746063]  [<ffffffffc029f70c>] xfs_file_write_iter+0xec/0x140 
> > [xfs]
> > [  928.746803]  [<ffffffff8f2a0599>] do_iter_readv_writev+0xb9/0x140
> > [  928.747478]  [<ffffffff8f2a126b>] do_readv_writev+0x19b/0x240
> > [  928.748146]  [<ffffffffc029f620>] ? 
> > xfs_file_buffered_aio_write+0x330/0x330 [xfs]
> > [  928.748956]  [<ffffffff8f29e02b>] ? do_dentry_open+0x28b/0x310
> > [  928.749614]  [<ffffffffc029c800>] ? 
> > xfs_extent_busy_ag_cmp+0x20/0x20 [xfs]
> > [  928.750367]  [<ffffffff8f2a156f>] vfs_writev+0x3f/0x50
> > [  928.750934]  [<ffffffffc04276ca>] nfsd_vfs_write+0xca/0x3a0 [nfsd]
> > [  928.751608]  [<ffffffffc0429ec5>] nfsd_write+0x485/0x780 [nfsd]
> > [  928.752263]  [<ffffffffc043144c>] nfsd3_proc_write+0xbc/0x150 
> > [nfsd]
> > [  928.752973]  [<ffffffffc0421388>] nfsd_dispatch+0xb8/0x1f0 [nfsd]
> > [  928.753642]  [<ffffffffc036d78f>] svc_process_common+0x42f/0x690 
> > [sunrpc]
> > [  928.754395]  [<ffffffffc036e8e8>] svc_process+0x118/0x330 [sunrpc]
> > [  928.755080]  [<ffffffffc04208ac>] nfsd+0x19c/0x2b0 [nfsd]
> > [  928.755681]  [<ffffffffc0420715>] ? nfsd+0x5/0x2b0 [nfsd]
> > [  928.756274]  [<ffffffffc0420710>] ? nfsd_destroy+0x190/0x190 [nfsd]
> > [  928.756991]  [<ffffffff8f0d5891>] kthread+0x101/0x120
> > [  928.757563]  [<ffffffff8f10dcc5>] ? 
> > trace_hardirqs_on_caller+0xf5/0x1b0
> > [  928.758282]  [<ffffffff8f8f2fef>] ret_from_fork+0x1f/0x40
> > [  928.758875]  [<ffffffff8f0d5790>] ? 
> > kthread_create_on_node+0x250/0x250
> > 
> > 
> > So the client gets a flexfiles layout, and then tries to issue a v3
> > WRITE against the file. XFS then recalls the layout, but the client
> > can't return the layout until the v3 WRITE completes. Eventually this
> > should resolve itself after 2 lease periods, but that's quite a long
> > time.
> > 
> > I guess XFS requires recalling block and SCSI layouts when the server
> > wants to issue a write (or someone writes to it locally), but that
> > seems like it shouldn't be happening when the layout is a flexfiles
> > layout.
> > 
> > Any thoughts on what the right fix is here?
> > 
> > On a related note, knfsd will spam the heck out of the client with
> > CB_LAYOUTRECALLs during this time. I think we ought to consider fixing
> > the server not to treat an NFS_OK return from the client like
> > NFS4ERR_DELAY there, but that would mean a different mechanism for
> > timing out a CB_LAYOUTRECALL.
> 
> I'm getting into similar trouble with SCSI layouts when the client ends 
> up
> submitting a WRITE because the IO is not page aligned, but it already 
> holds
> a layout for that range.  It looks like the server sends a 
> CB_LAYOUTRECALL,
> but the client has to answer NFS4ERR_DELAY because it is still holding 
> the
> layout.
> 
> Probably, the client should return any layouts it holds for that range 
> before
> doing IO through the MDS.
> 

Yes, that might be good. Could even prefix the WRITE compound with a
LAYOUTRETURN if you want to get fancy. :)

> Alternatively, shouldn't the MDS accept IO from the same client that 
> holds a
> layout for that range, rather than recall that layout?  RFC 5661 Section
> 20.3.4 talks about the client submitting WRITEs before responding to
> CB_LAYOUTRECALL: "As always, the client may write the data through the
> metadata server."
> 

Agreed. That seems reasonable too.


> I'm trying to find the discussion that resulted in this commit:
> 
> commit 6b9b21073d3b250e17812cd562fffc9006962b39
> Author: Jeff Layton <jlayton@poochiereds.net>
> Date:   Tue Dec 8 07:23:48 2015 -0500
> 
>      nfsd: give up on CB_LAYOUTRECALLs after two lease periods
> 
> Why should we poll the client if the client answers with NFS4ERR_DELAY?  
> Can
> we instead just wait for the layout to be returned?
> 

No. NFS4ERR_DELAY just means "I'm too busy to answer right now, please
call again later". You can't infer that the client has made any note of
the CB_LAYOUTRECALL at all since it didn't succeed.

Returning NFS4_OK on a CB_LAYOUTRECALL just means that you acknowledge
that it has been recalled and will eventually send a LAYOUTRETURN. It
doesn't mean that you are immediately returning it.

Probably what the client should do in this situation is mark the layout
as having been recalled and return NFS4_OK instead of NFS4ERR_DELAY. It
seems like that ought to be possible, but I haven't looked at the code
to see why that isn't occurring.

> Also, I think the 2*lease period timeout is currently broken because we 
> reset
> tk_start after every call.. but that's not really causing any trouble.
> 

It'd be good to fix that too, since you're in there...

-- 
Jeff Layton <jlayton@redhat.com>

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

end of thread, other threads:[~2018-01-27 21:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-11 15:23 CB_LAYOUTRECALL "deadlock" with in-kernel flexfiles server and XFS Jeff Layton
2016-08-11 15:55 ` Trond Myklebust
2016-08-11 16:06   ` Jeff Layton
2016-08-11 16:20     ` Trond Myklebust
2016-08-11 16:25       ` hch
2016-08-11 16:33         ` Jeff Layton
2016-08-11 16:59           ` hch
2016-08-11 17:10             ` Jeff Layton
2018-01-27 15:39 ` Benjamin Coddington
2018-01-27 21:41   ` Jeff Layton

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.