All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Bartell <wingedtachikoma@gmail.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs: handle errors for FS_IOC_SETFLAGS
Date: Wed, 30 Jun 2010 20:05:22 -0400	[thread overview]
Message-ID: <20100701000522.GA5456@flcl.lan> (raw)

Makes btrfs_ioctl_setflags return -ENOSPC and other errors when
necessary.

Signed-off-by: Sean Bartell <wingedtachikoma@gmail.com>
---
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(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 4dbaf89..8db62c2 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -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)
-- 
1.7.1


                 reply	other threads:[~2010-07-01  0:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100701000522.GA5456@flcl.lan \
    --to=wingedtachikoma@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.