Skip to contentSkip to conversation

btrfs: handle errors for FS_IOC_SETFLAGS

PATCH New Sean Bartell 1 participant 1 message Jul 1, 2010 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: handle errors for FS_IOC_SETFLAGS

Makes btrfs_ioctl_setflags return -ENOSPC and other errors when necessary.

---
I ran chattr -R on a full FS and btrfs crashed. This overlaps with the patch series being worked on by Jeff Mahoney.

 fs/btrfs/ioctl.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
fs/btrfs/ioctl.c +12 -5
index 4dbaf89..8db62c2 100644
@@ -200,19 +200,26 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
 
 
 	trans = btrfs_join_transaction(root, 1);
-	BUG_ON(!trans);
+	if (IS_ERR(trans)) {
+		ret = PTR_ERR(trans);
+		goto out_drop_write;
+	}
 
 	ret = btrfs_update_inode(trans, root, inode);
-	BUG_ON(ret);
+	if (ret)
+		goto out_endtrans;
 
 	btrfs_update_iflags(inode);
 	inode->i_ctime = CURRENT_TIME;
-	btrfs_end_transaction(trans, root);
 
+	ret = 0;
+out_endtrans:
+	btrfs_end_transaction(trans, root);
+out_drop_write:
 	mnt_drop_write(file->f_path.mnt);
- out_unlock:
+out_unlock:
 	mutex_unlock(&inode->i_mutex);
-	return 0;
+	return ret;
 }
 
 static int btrfs_ioctl_getversion(struct file *file, int __user *arg)
Signature · 1 line
1.7.1