Skip to contentSkip to conversation

btrfs: Return EBUSY in case btrfs_start_write_no_snapshotting fails

PATCH In review Nikolay Borisov 2 participants 3 messages Apr 23, 2019 – May 2, 2019 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: Return EBUSY in case btrfs_start_write_no_snapshotting fails

If btrfs_start_write_no_snapshotting fails (returns 0) it means there is snapshot in progress hence resource is busy and not that we are out of space. Change the return value to correctly reflect this.

---
 fs/btrfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/file.c +1 -1
index 2030b9bcb977..ce1dec51ff92 100644
@@ -1547,7 +1547,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 -EBUSY;
 
 	lockstart = round_down(pos, fs_info->sectorsize);
 	lockend = round_up(pos + *write_bytes,
Signature · 1 line
2.17.1
#1 lore raw
Quoted 14 lines · Nikolay Borisov

If btrfs_start_write_no_snapshotting fails (returns 0) it means there is snapshot in progress hence resource is busy and not that we are out of space. Change the return value to correctly reflect this.

---
 fs/btrfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/file.c +0 -0
index 2030b9bcb977..ce1dec51ff92 100644

fs/btrfs/file.c static noinline int check_can_nocow(struct btrfs_inode *inode, loff_t pos, · line 1550

Quoted 5 lines
fs/btrfs/file.c +1 -1
@@ -1547,7 +1547,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 -EBUSY;

This error is not returned to userspace, nevertheless write won't expect EBUSY in case it ever is. Perhaps EAGAIN makes more sense?

Quoted 4 lines
fs/btrfs/file.c +0 -0
 	lockstart = round_down(pos, fs_info->sectorsize);
 	lockend = round_up(pos + *write_bytes,
 
#2 lore raw
Quoted 18 lines · Nikolay Borisov
Quoted 15 lines · Nikolay Borisov

If btrfs_start_write_no_snapshotting fails (returns 0) it means there is snapshot in progress hence resource is busy and not that we are out of space. Change the return value to correctly reflect this.

---
 fs/btrfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/file.c +0 -0
index 2030b9bcb977..ce1dec51ff92 100644
@@ -1547,7 +1547,7 @@ static noinline int check_can_nocow(struct btrfs_inode *inode, loff_t pos,
 
Quoted 7 lines

fs/btrfs/file.c static noinline int check_can_nocow(struct btrfs_inode *inode, loff_t pos, · line 1550

Quoted 4 lines
fs/btrfs/file.c +1 -1
 	ret = btrfs_start_write_no_snapshotting(root);
 	if (!ret)
-		return -ENOSPC;
+		return -EBUSY;

This error is not returned to userspace, nevertheless write won't expect EBUSY in case it ever is. Perhaps EAGAIN makes more sense?

Yeah, EAGAIN sounds better.