Skip to contentSkip to conversation

Btrfs: fix inode cache waiters hanging on path allocation failure

PATCH In review [email protected] 2 participants 3 messages Jul 4, 2019 – Jul 8, 2019 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 4/5 Btrfs: fix inode cache waiters hanging on path allocation failure

From: Filipe Manana <[email protected]>

If the caching thread fails to allocate a path, it returns without waking up any cache waiters, leaving them hang forever. Fix this by following the same approach as when we fail to start the caching thread: print an error message, disable inode caching and make the wakers fallback to non-caching mode behaviour (calling btrfs_find_free_objectid()).

Fixes 581bb050941b4f ("Btrfs: Cache free inode numbers in memory")
---
 fs/btrfs/inode-map.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/btrfs/inode-map.c +3 -1
index 05b8c9927f29..4820e05ea6bd 100644
@@ -41,8 +41,10 @@ static int caching_kthread(void *data)
 		return 0;
 
 	path = btrfs_alloc_path();
-	if (!path)
+	if (!path) {
+		fail_caching_thread(root);
 		return -ENOMEM;
+	}
 
 	/* Since the commit root is read-only, we can safely skip locking. */
 	path->skip_locking = 1;
Signature · 1 line
2.11.0
Reviewed-by on v1 4/5
#1 lore raw
Quoted 10 lines · On 4.07.19 г. 18:24 ч., [email protected] wrote:

From: Filipe Manana <[email protected]>

If the caching thread fails to allocate a path, it returns without waking up any cache waiters, leaving them hang forever. Fix this by following the same approach as when we fail to start the caching thread: print an error message, disable inode caching and make the wakers fallback to non-caching mode behaviour (calling btrfs_find_free_objectid()).

Fixes 581bb050941b4f ("Btrfs: Cache free inode numbers in memory")
Quoted 21 lines
---
 fs/btrfs/inode-map.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/btrfs/inode-map.c +3 -1
index 05b8c9927f29..4820e05ea6bd 100644
@@ -41,8 +41,10 @@ static int caching_kthread(void *data)
 		return 0;
 
 	path = btrfs_alloc_path();
-	if (!path)
+	if (!path) {
+		fail_caching_thread(root);
 		return -ENOMEM;
+	}
 
 	/* Since the commit root is read-only, we can safely skip locking. */
 	path->skip_locking = 1;
Reviewed-by on v1 4/5
#2 lore raw
In reply to [email protected]
Quoted 10 lines · On 4.07.19 г. 18:24 ч., [email protected] wrote:

From: Filipe Manana <[email protected]>

If the caching thread fails to allocate a path, it returns without waking up any cache waiters, leaving them hang forever. Fix this by following the same approach as when we fail to start the caching thread: print an error message, disable inode caching and make the wakers fallback to non-caching mode behaviour (calling btrfs_find_free_objectid()).

Fixes 581bb050941b4f ("Btrfs: Cache free inode numbers in memory")
Quoted 21 lines
---
 fs/btrfs/inode-map.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/btrfs/inode-map.c +3 -1
index 05b8c9927f29..4820e05ea6bd 100644
@@ -41,8 +41,10 @@ static int caching_kthread(void *data)
 		return 0;
 
 	path = btrfs_alloc_path();
-	if (!path)
+	if (!path) {
+		fail_caching_thread(root);
 		return -ENOMEM;
+	}
 
 	/* Since the commit root is read-only, we can safely skip locking. */
 	path->skip_locking = 1;