diff mbox

[38/50] nfs41: add a debug warning if we destroy an unempty layout

Message ID 1418756513-95187-39-git-send-email-loghyr@primarydata.com (mailing list archive)
State New, archived
Headers show

Commit Message

Thomas Haynes Dec. 16, 2014, 7:01 p.m. UTC
From: Peng Tao <tao.peng@primarydata.com>

So that we can detect the case if some layout segments are still
pinned which is surely a bug that we need to fix.

Signed-off-by: Peng Tao <tao.peng@primarydata.com>
---
 fs/nfs/pnfs.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Schumaker, Anna Dec. 16, 2014, 9:03 p.m. UTC | #1
On 12/16/2014 02:01 PM, Tom Haynes wrote:
> From: Peng Tao <tao.peng@primarydata.com>
> 
> So that we can detect the case if some layout segments are still
> pinned which is surely a bug that we need to fix.

How often is this hit?  A patch fixing the bug would be better than a patch just to detect it :).

Anna

> 
> Signed-off-by: Peng Tao <tao.peng@primarydata.com>
> ---
>  fs/nfs/pnfs.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
> index 5f7c422..e123cfc 100644
> --- a/fs/nfs/pnfs.c
> +++ b/fs/nfs/pnfs.c
> @@ -242,6 +242,8 @@ pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo)
>  	struct inode *inode = lo->plh_inode;
>  
>  	if (atomic_dec_and_lock(&lo->plh_refcount, &inode->i_lock)) {
> +		if (!list_empty(&lo->plh_segs))
> +			WARN_ONCE(1, "NFS: BUG unfreed layout segments.\n");
>  		pnfs_detach_layout_hdr(lo);
>  		spin_unlock(&inode->i_lock);
>  		pnfs_free_layout_hdr(lo);
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Peng Tao Dec. 22, 2014, 2:06 a.m. UTC | #2
On Wed, Dec 17, 2014 at 5:03 AM, Anna Schumaker
<Anna.Schumaker@netapp.com> wrote:
> On 12/16/2014 02:01 PM, Tom Haynes wrote:
>> From: Peng Tao <tao.peng@primarydata.com>
>>
>> So that we can detect the case if some layout segments are still
>> pinned which is surely a bug that we need to fix.
>
> How often is this hit?  A patch fixing the bug would be better than a patch just to detect it :).
>
Never yet :)

I was suspecting a bug in segment reference counting and thus added
the patch. That bug turns out to be somewhere else but I thought the
WARN makes sense in general sense because without it we silently
ignores unfreed reference counts.

Cheers,
Tao

> Anna
>
>>
>> Signed-off-by: Peng Tao <tao.peng@primarydata.com>
>> ---
>>  fs/nfs/pnfs.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
>> index 5f7c422..e123cfc 100644
>> --- a/fs/nfs/pnfs.c
>> +++ b/fs/nfs/pnfs.c
>> @@ -242,6 +242,8 @@ pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo)
>>       struct inode *inode = lo->plh_inode;
>>
>>       if (atomic_dec_and_lock(&lo->plh_refcount, &inode->i_lock)) {
>> +             if (!list_empty(&lo->plh_segs))
>> +                     WARN_ONCE(1, "NFS: BUG unfreed layout segments.\n");
>>               pnfs_detach_layout_hdr(lo);
>>               spin_unlock(&inode->i_lock);
>>               pnfs_free_layout_hdr(lo);
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 5f7c422..e123cfc 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -242,6 +242,8 @@  pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo)
 	struct inode *inode = lo->plh_inode;
 
 	if (atomic_dec_and_lock(&lo->plh_refcount, &inode->i_lock)) {
+		if (!list_empty(&lo->plh_segs))
+			WARN_ONCE(1, "NFS: BUG unfreed layout segments.\n");
 		pnfs_detach_layout_hdr(lo);
 		spin_unlock(&inode->i_lock);
 		pnfs_free_layout_hdr(lo);