2014-10-07 18:00:09

by Thomas Haynes

[permalink] [raw]
Subject: [PATCH] pnfs: Do not schedule layout segment work if there is no work to be done.

From: Tom Haynes <[email protected]>

Callers of pnfs_put_lseg_async() might encounter no writes to
be committed, etc. As such, do not attempt to add work if none
is needed. Also, don't oops if that is the case.

Signed-off-by: Tom Haynes <[email protected]>
---
fs/nfs/pnfs.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 76de7f5..08b1060 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -373,6 +373,9 @@ static void pnfs_put_lseg_async_work(struct work_struct *work)
void
pnfs_put_lseg_async(struct pnfs_layout_segment *lseg)
{
+ if (!lseg)
+ return;
+
INIT_WORK(&lseg->pls_work, pnfs_put_lseg_async_work);
schedule_work(&lseg->pls_work);
}
--
1.9.3



2014-10-07 18:02:50

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH] pnfs: Do not schedule layout segment work if there is no work to be done.

On Tue, Oct 07, 2014 at 10:59:47AM -0700, Thomas Haynes wrote:
> From: Tom Haynes <[email protected]>
>
> Callers of pnfs_put_lseg_async() might encounter no writes to
> be committed, etc. As such, do not attempt to add work if none
> is needed. Also, don't oops if that is the case.

I think that last issue is the main culprit, isn't it? :)

I still think adding the NULL check to filelayout_clear_request_commit
would be more reasonable, as it's clear that freeme can be NULL there,
but as pnfs_put_lseg accepts a NULL lseg it's probably wise to keep
the two in sync.