btrfs: Return EAGAIN if we can't start no snpashot write in check_can_nocow
diff mbox series

Message ID 20190507072346.17964-1-nborisov@suse.com
State New
Headers show
Series
  • btrfs: Return EAGAIN if we can't start no snpashot write in check_can_nocow
Related show

Commit Message

Nikolay Borisov May 7, 2019, 7:23 a.m. UTC
The first thing code does in check_can_nocow is trying to block
concurrent snapshots. If this fails (due to snpashot already being in
progress) the function returns ENOSPC which makes no sense. Instead
return EAGAIN. Despite this return value not being propagated to callers
it's good practice to return the closest in terms of semantics error
code. No functional changes.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Sterba May 10, 2019, 12:03 p.m. UTC | #1
On Tue, May 07, 2019 at 10:23:46AM +0300, Nikolay Borisov wrote:
> The first thing code does in check_can_nocow is trying to block
> concurrent snapshots. If this fails (due to snpashot already being in
> progress) the function returns ENOSPC which makes no sense. Instead
> return EAGAIN. Despite this return value not being propagated to callers
> it's good practice to return the closest in terms of semantics error
> code. No functional changes.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

Added to 5.3 queue, thanks.

Patch
diff mbox series

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index d8abce428176..ae1fadae3d47 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1556,7 +1556,7 @@  static noinline int check_can_nocow(struct btrfs_inode *inode, loff_t pos,
 
 	ret = btrfs_start_write_no_snapshotting(root);
 	if (!ret)
-		return -ENOSPC;
+		return -EAGAIN;
 
 	lockstart = round_down(pos, fs_info->sectorsize);
 	lockend = round_up(pos + *write_bytes,