public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Mingming <cmm@us.ibm.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] COW and checksumming ioctls
Date: Thu, 19 Jun 2008 17:26:48 -0700	[thread overview]
Message-ID: <1213921608.27507.152.camel@BVR-FS.beaverton.ibm.com> (raw)

COW and checksumming is enabled by default, and could be disable with
mount option.  These new ioctls below let a user application turn on/off
copy-on-write and checksumming on a per file basis.

Signed-off-by: Mingming Cao <cmm@us.ibm.com>

diff -r 79b81fd6dd78 ioctl.c
--- a/ioctl.c	Thu Jun 12 14:46:17 2008 -0400
+++ b/ioctl.c	Thu Jun 19 15:59:02 2008 -0700
@@ -471,6 +471,55 @@ static int btrfs_ioctl_defrag(struct fil
 
 	return 0;
 }
+
+static int btrfs_ioctl_disable_datacow(struct file *file)
+{
+	struct inode *inode = fdentry(file)->d_inode;
+
+	if ((inode->i_mode & S_IFMT) == S_IFREG) {
+		mutex_lock(&inode->i_mutex);
+		btrfs_set_flag(inode, NODATACOW);
+		mutex_unlock(&inode->i_mutex);
+	}
+
+	return 0;
+}
+
+static int btrfs_ioctl_enable_datacow(struct file *file)
+{
+	struct inode *inode = fdentry(file)->d_inode;
+
+	if ((inode->i_mode & S_IFMT) == S_IFREG) {
+		mutex_lock(&inode->i_mutex);
+		btrfs_clear_flag(inode, NODATACOW);
+		mutex_unlock(&inode->i_mutex);
+	}
+
+	return 0;
+}
+
+static int btrfs_ioctl_disable_datasum(struct file *file)
+{
+	struct inode *inode = fdentry(file)->d_inode;
+
+	mutex_lock(&inode->i_mutex);
+	btrfs_set_flag(inode, NODATASUM);
+	mutex_unlock(&inode->i_mutex);
+
+	return 0;
+}
+
+static int btrfs_ioctl_enable_datasum(struct file *file)
+{
+	struct inode *inode = fdentry(file)->d_inode;
+
+	mutex_lock(&inode->i_mutex);
+	btrfs_clear_flag(inode, NODATASUM);
+	mutex_unlock(&inode->i_mutex);
+
+	return 0;
+}
+
 
 long btrfs_ioctl_add_dev(struct btrfs_root *root, void __user *arg)
 {
@@ -775,6 +824,14 @@ long btrfs_ioctl(struct file *file, unsi
 		return btrfs_ioctl_trans_start(file);
 	case BTRFS_IOC_TRANS_END:
 		return btrfs_ioctl_trans_end(file);
+	case BTRFS_IOC_NODATACOW:
+		return btrfs_ioctl_disable_datacow(file);
+	case BTRFS_IOC_DATACOW:
+		return btrfs_ioctl_enable_datacow(file);
+	case BTRFS_IOC_NODATASUM:
+		return btrfs_ioctl_disable_datasum(file);
+	case BTRFS_IOC_DATASUM:
+		return btrfs_ioctl_enable_datasum(file);
 	case BTRFS_IOC_SYNC:
 		btrfs_sync_fs(file->f_dentry->d_sb, 1);
 		return 0;
diff -r 79b81fd6dd78 ioctl.h
--- a/ioctl.h	Thu Jun 12 14:46:17 2008 -0400
+++ b/ioctl.h	Thu Jun 19 15:32:40 2008 -0700
@@ -51,5 +51,8 @@ struct btrfs_ioctl_vol_args {
 				   struct btrfs_ioctl_vol_args)
 #define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
 				   struct btrfs_ioctl_vol_args)
-
+#define BTRFS_IOC_NODATACOW _IO(BTRFS_IOCTL_MAGIC, 13)
+#define BTRFS_IOC_DATACOW _IO(BTRFS_IOCTL_MAGIC, 14)
+#define BTRFS_IOC_NODATASUM _IO(BTRFS_IOCTL_MAGIC, 15)
+#define BTRFS_IOC_DATASUM _IO(BTRFS_IOCTL_MAGIC, 16)
 #endif



             reply	other threads:[~2008-06-20  0:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-20  0:26 Mingming [this message]
2008-06-20  5:23 ` [PATCH] COW and checksumming ioctls Zach Brown
2008-06-20 14:01   ` Joe Peterson
2008-06-20 13:58     ` Josef Bacik
2008-06-20 15:07       ` Joe Peterson
2008-06-20 16:37         ` Chris Mason
2008-06-21  6:07           ` Joe Peterson
2008-06-20 19:44         ` jim owens
2008-06-21  5:59           ` Joe Peterson
2008-06-21  7:27   ` Christoph Hellwig
2008-06-22 14:10     ` Chris Mason
2008-06-22 18:13       ` Joshua J. Berry
2008-06-30 18:38       ` Christoph Hellwig

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=1213921608.27507.152.camel@BVR-FS.beaverton.ibm.com \
    --to=cmm@us.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox