btrfs: Return EAGAIN if we can't start no snpashot write in check_can_nocow
authorNikolay Borisov <nborisov@suse.com>
Tue, 7 May 2019 07:23:46 +0000 (10:23 +0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 1 Jul 2019 11:34:59 +0000 (13:34 +0200)
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>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/file.c

index 007652ff5cb6a91f9e068cb9d35d388dea09cc54..5370152ea7e3affd8b587c99d3a70049b7a4c779 100644 (file)
@@ -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,