linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 3/5] Btrfs: fix inode cache waiters hanging on failure to start caching thread
Date: Fri, 5 Jul 2019 17:23:08 +0300	[thread overview]
Message-ID: <f83cbc6e-2efd-651d-6670-4d585c2d8451@suse.com> (raw)
In-Reply-To: <20190704152432.20765-1-fdmanana@kernel.org>



On 4.07.19 г. 18:24 ч., fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> If we fail to start the inode caching thread, we print an error message
> and disable the inode cache, however we never wake up any waiters, so they
> hang forever waiting for the caching to finish. Fix this by waking them
> up and have them fallback to a call to btrfs_find_free_objectid().
> 
> Fixes: e60efa84252c05 ("Btrfs: avoid triggering bug_on() when we fail to start inode caching task")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/inode-map.c | 23 ++++++++++++++++++-----
>  1 file changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
> index b210e8929c28..05b8c9927f29 100644
> --- a/fs/btrfs/inode-map.c
> +++ b/fs/btrfs/inode-map.c
> @@ -12,6 +12,19 @@
>  #include "inode-map.h"
>  #include "transaction.h"
>  
> +static void fail_caching_thread(struct btrfs_root *root)
> +{
> +	struct btrfs_fs_info *fs_info = root->fs_info;
> +
> +	btrfs_warn(fs_info, "failed to start inode caching task");
> +	btrfs_clear_pending_and_info(fs_info, INODE_MAP_CACHE,
> +				     "disabling inode map caching");
> +	spin_lock(&root->ino_cache_lock);
> +	root->ino_cache_state = BTRFS_CACHE_ERROR;
> +	spin_unlock(&root->ino_cache_lock);
> +	wake_up(&root->ino_cache_wait);
> +}
> +
>  static int caching_kthread(void *data)
>  {
>  	struct btrfs_root *root = data;
> @@ -164,11 +177,8 @@ static void start_caching(struct btrfs_root *root)
>  
>  	tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu",
>  			  root->root_key.objectid);
> -	if (IS_ERR(tsk)) {
> -		btrfs_warn(fs_info, "failed to start inode caching task");
> -		btrfs_clear_pending_and_info(fs_info, INODE_MAP_CACHE,
> -					     "disabling inode map caching");
> -	}
> +	if (IS_ERR(tsk))
> +		fail_caching_thread(root);
>  }
>  
>  int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid)
> @@ -186,11 +196,14 @@ int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid)
>  
>  	wait_event(root->ino_cache_wait,
>  		   root->ino_cache_state == BTRFS_CACHE_FINISHED ||
> +		   root->ino_cache_state == BTRFS_CACHE_ERROR ||
>  		   root->free_ino_ctl->free_space > 0);
>  
>  	if (root->ino_cache_state == BTRFS_CACHE_FINISHED &&
>  	    root->free_ino_ctl->free_space == 0)
>  		return -ENOSPC;
> +	else if (root->ino_cache_state == BTRFS_CACHE_ERROR)
> +		return btrfs_find_free_objectid(root, objectid);
>  	else
>  		goto again;
>  }
> 

      reply	other threads:[~2019-07-05 14:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-04 15:24 [PATCH 3/5] Btrfs: fix inode cache waiters hanging on failure to start caching thread fdmanana
2019-07-05 14:23 ` Nikolay Borisov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f83cbc6e-2efd-651d-6670-4d585c2d8451@suse.com \
    --to=nborisov@suse.com \
    --cc=fdmanana@kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).