linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sage Weil <sage@newdream.net>
To: linux-btrfs@vger.kernel.org
Cc: Sage Weil <sage@newdream.net>
Subject: [PATCH 5/5] btrfs: add SNAP_DESTROY_ASYNC ioctl
Date: Mon, 22 Mar 2010 12:13:30 -0700	[thread overview]
Message-ID: <1269285210-19085-6-git-send-email-sage@newdream.net> (raw)
In-Reply-To: <1269285210-19085-5-git-send-email-sage@newdream.net>

There is no reason (aside from user expectations that space be
freed RIGHT NOW) that transaction removing the root reference
commit immediately.  Add an alternative ioctl that does not
commit immediately for those who don't need it to.

Signed-off-by: Sage Weil <sage@newdream.net>
---
 fs/btrfs/ioctl.c |   12 +++++++++---
 fs/btrfs/ioctl.h |    2 ++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index fd824a7..c8e6470 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1255,7 +1255,8 @@ static noinline int btrfs_ioctl_ino_lookup(struct file *file,
 }
 
 static noinline int btrfs_ioctl_snap_destroy(struct file *file,
-					     void __user *arg)
+					     void __user *arg,
+					     int async)
 {
 	struct dentry *parent = fdentry(file);
 	struct dentry *dentry;
@@ -1338,7 +1339,10 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
 				dest->root_key.objectid);
 	BUG_ON(ret);
 
-	ret = btrfs_commit_transaction(trans, root);
+	if (async)
+		ret = btrfs_end_transaction(trans, root);
+	else
+		ret = btrfs_commit_transaction(trans, root);
 	BUG_ON(ret);
 	inode->i_flags |= S_DEAD;
 out_up_write:
@@ -2037,7 +2041,9 @@ long btrfs_ioctl(struct file *file, unsigned int
 	case BTRFS_IOC_SUBVOL_CREATE:
 		return btrfs_ioctl_snap_create(file, argp, 1, 0);
 	case BTRFS_IOC_SNAP_DESTROY:
-		return btrfs_ioctl_snap_destroy(file, argp);
+		return btrfs_ioctl_snap_destroy(file, argp, 0);
+	case BTRFS_IOC_SNAP_DESTROY_ASYNC:
+		return btrfs_ioctl_snap_destroy(file, argp, 1);
 	case BTRFS_IOC_DEFAULT_SUBVOL:
 		return btrfs_ioctl_default_subvol(file, argp);
 	case BTRFS_IOC_DEFRAG:
diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h
index 4f7fe37..8109257 100644
--- a/fs/btrfs/ioctl.h
+++ b/fs/btrfs/ioctl.h
@@ -184,4 +184,6 @@ struct btrfs_ioctl_space_args {
 #define BTRFS_IOC_WAIT_SYNC  _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
 #define BTRFS_IOC_SNAP_CREATE_ASYNC _IOW(BTRFS_IOCTL_MAGIC, 23, \
 				   struct btrfs_ioctl_vol_args)
+#define BTRFS_IOC_SNAP_DESTROY_ASYNC _IOW(BTRFS_IOCTL_MAGIC, 24, \
+				   struct btrfs_ioctl_vol_args)
 #endif
-- 
1.6.6.1


      reply	other threads:[~2010-03-22 19:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-22 19:13 [PATCH 0/5] asynchronous commit, snapshot ponies Sage Weil
2010-03-22 19:13 ` [PATCH 1/5] Btrfs: async transaction commit Sage Weil
2010-03-22 19:13   ` [PATCH 2/5] Btrfs: add START_SYNC, WAIT_SYNC ioctls Sage Weil
2010-03-22 19:13     ` [PATCH 3/5] Btrfs: add SNAP_CREATE_ASYNC ioctl Sage Weil
2010-03-22 19:13       ` [PATCH 4/5] Btrfs: return transid to userspace from " Sage Weil
2010-03-22 19:13         ` Sage Weil [this message]

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=1269285210-19085-6-git-send-email-sage@newdream.net \
    --to=sage@newdream.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).