Mitch Harder | 9 Feb 22:38

[PATCH/RFC] Btrfs: Add conditional ENOSPC debugging.

This patch isn't intended for inclusion in the kernel, but is provided
to facilitate ENOSPC debugging in a framework that will have no
impact on Btrfs unless compiled conditionally.

Debugging printk statements are wrapped in #ifdef macros
to allow btrfs to be built in its original form unless debugging
is explicitly requested when the kernel is built.

The debugging can be enabled as follows:
KCFLAGS="-DBTRFS_DEBUG_ENOSPC" \
KCPPFLAGS="-DBTRFS_DEBUG_ENOSPC" \
make

The patch was constructed by searching the Btrfs code for "ENOSPC",
and inserting printk statements as appropriate if the occurance
was a generation point for an ENOSPC.

I initially developed this patch to track down where ENOSPC errors were being
generated when using zlib compression.

This patch will occasionally generate some false positives, since ENOSPC
conditions are sometimes corrected before returning an error to the caller.

It is also interesting for highlighting all the places in Btrfs where an
ENOSPC can be generated.

Signed-off-by: Mitch Harder <mitch.harder <at> sabayonlinux.org>
---
 fs/btrfs/delayed-inode.c    |   10 ++++
 fs/btrfs/extent-tree.c      |   84 +++++++++++++++++++++++++++++++++
(Continue reading)

Jan Schmidt | 10 Feb 10:33

Re: [PATCH/RFC] Btrfs: Add conditional ENOSPC debugging.

Hi Mitch,

having this patch on the list is a good idea. I've two remarks, just in
case it will be included sometimes:

On 09.02.2012 22:38, Mitch Harder wrote:
> diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
> index fe4cd0f..31b717f 100644
> --- a/fs/btrfs/delayed-inode.c
> +++ b/fs/btrfs/delayed-inode.c
> @@ -656,8 +656,18 @@ static int btrfs_delayed_inode_reserve_metadata(
>  		 * EAGAIN to make us stop the transaction we have, so return
>  		 * ENOSPC instead so that btrfs_dirty_inode knows what to do.
>  		 */
> +#ifdef BTRFS_DEBUG_ENOSPC
> +		if (unlikely(ret == -EAGAIN)) {
> +			ret = -ENOSPC;
> +			if (printk_ratelimit())

From linux/printk.h:
/*
 * Please don't use printk_ratelimit(), because it shares ratelimiting state
 * with all other unrelated printk_ratelimit() callsites.  Instead use
 * printk_ratelimited() or plain old __ratelimit().
 */

printk_ratelimited() seems the right choice, here.

> +				printk(KERN_WARNING
> +				       "btrfs: ENOSPC set in "
(Continue reading)

Mitch Harder | 13 Feb 00:49

Re: [PATCH/RFC] Btrfs: Add conditional ENOSPC debugging.

On Fri, Feb 10, 2012 at 3:33 AM, Jan Schmidt <list.btrfs <at> jan-o-sch.net> wrote:
> Hi Mitch,
>
> having this patch on the list is a good idea. I've two remarks, just in
> case it will be included sometimes:
>
> On 09.02.2012 22:38, Mitch Harder wrote:
>> diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
>> index fe4cd0f..31b717f 100644
>> --- a/fs/btrfs/delayed-inode.c
>> +++ b/fs/btrfs/delayed-inode.c
>> @@ -656,8 +656,18 @@ static int btrfs_delayed_inode_reserve_metadata(
>>                * EAGAIN to make us stop the transaction we have, so return
>>                * ENOSPC instead so that btrfs_dirty_inode knows what to do.
>>                */
>> +#ifdef BTRFS_DEBUG_ENOSPC
>> +             if (unlikely(ret == -EAGAIN)) {
>> +                     ret = -ENOSPC;
>> +                     if (printk_ratelimit())
>
> From linux/printk.h:
> /*
>  * Please don't use printk_ratelimit(), because it shares ratelimiting state
>  * with all other unrelated printk_ratelimit() callsites.  Instead use
>  * printk_ratelimited() or plain old __ratelimit().
>  */
>
> printk_ratelimited() seems the right choice, here.
>

(Continue reading)


Gmane