diff --git a/Documentation/btrfs-man5.asciidoc b/Documentation/btrfs-man5.asciidoc
index dd296fac6fec..a2ed7eb582d9 100644
--- a/Documentation/btrfs-man5.asciidoc
+++ b/Documentation/btrfs-man5.asciidoc
@@ -712,7 +712,7 @@ To create and activate a swapfile run the following commands:
 
 --------------------
 # truncate -s 0 swapfile
-# chattr +C swapfile
+# btrfs property set swapfile datacow no
 # fallocate -l 2G swapfile
 # chmod 0600 swapfile
 # mkswap swapfile
diff --git a/Documentation/btrfs-property.rst b/Documentation/btrfs-property.rst
index 5896faa2b2e2..600f6e60d255 100644
--- a/Documentation/btrfs-property.rst
+++ b/Documentation/btrfs-property.rst
@@ -48,6 +48,9 @@ get [-t <type>] <object> [<name>]
         compression
                 compression algorithm set for an inode, possible values: *lzo*, *zlib*, *zstd*.
                 To disable compression use "" (empty string), *no* or *none*.
+        datacow
+                copy on write flag for an inode: *no* or *yes*.
+                This is the same as ``chattr``/``lsattr`` *+C* flag.
 
 list [-t <type>] <object>
         Lists available properties with their descriptions for the given object.
diff --git a/Documentation/ch-swapfile.rst b/Documentation/ch-swapfile.rst
index 9d121bc5c569..f682e868632a 100644
--- a/Documentation/ch-swapfile.rst
+++ b/Documentation/ch-swapfile.rst
@@ -36,7 +36,7 @@ To create and activate a swapfile run the following commands:
 .. code-block:: bash
 
         # truncate -s 0 swapfile
-        # chattr +C swapfile
+        # btrfs property set swapfile datacow no
         # fallocate -l 2G swapfile
         # chmod 0600 swapfile
         # mkswap swapfile
diff --git a/cmds/property.c b/cmds/property.c
index b3ccc0ff69b0..de9fde9e09e2 100644
--- a/cmds/property.c
+++ b/cmds/property.c
@@ -24,6 +24,7 @@
 #include <sys/xattr.h>
 #include <uuid/uuid.h>
 #include <btrfsutil.h>
+#include <linux/fs.h>
 #include "cmds/commands.h"
 #include "cmds/props.h"
 #include "kernel-shared/ctree.h"
@@ -232,6 +233,65 @@ static int prop_compression(enum prop_object_type type,
 	return ret;
 }
 
+static int prop_datacow(enum prop_object_type type,
+			const char *object,
+			const char *name,
+			const char *value,
+			bool force)
+{
+	int ret;
+	ssize_t sret;
+	int fd = -1;
+	DIR *dirstream = NULL;
+	//int open_flags = value ? O_RDWR : O_RDONLY;
+	int open_flags = O_RDONLY;
+	int attr;
+
+	fd = open_file_or_dir3(object, &dirstream, open_flags);
+	if (fd == -1) {
+		ret = -errno;
+		error("failed to open %s: %m", object);
+		goto out;
+	}
+
+	sret = ioctl(fd, FS_IOC_GETFLAGS, &attr);
+	if (sret < 0) {
+		ret = -errno;
+		error("failed to get attr flags on %s: %m", object);
+		goto out;
+	}
+
+	if (value) {
+		if (strcmp(value, "no") == 0) {
+			attr |= FS_NOCOW_FL;
+		} else if (strcmp(value, "yes") == 0) {
+			attr &= ~FS_NOCOW_FL;
+		} else {
+			ret = -EINVAL;
+			error("datacow value must be yes or no");
+			goto out;
+		}
+
+		sret = ioctl(fd, FS_IOC_SETFLAGS, &attr);
+		if (sret < 0) {
+			ret = -errno;
+			error("failed to set nocow flag on %s: %m",
+			      object);
+			goto out;
+		}
+	} else {
+		fprintf(stdout, "datacow=%s\n",
+			attr & FS_NOCOW_FL ? "no" : "yes");
+	}
+
+	ret = 0;
+out:
+	if (fd >= 0)
+		close_file_or_dir(fd, dirstream);
+
+	return ret;
+}
+
 const struct prop_handler prop_handlers[] = {
 	{
 		.name ="ro",
@@ -254,6 +314,13 @@ const struct prop_handler prop_handlers[] = {
 		.types = prop_object_inode,
 		.handler = prop_compression
 	},
+	{
+		.name = "datacow",
+		.desc = "copy on write status of a file",
+		.read_only = 0,
+		.types = prop_object_inode,
+		.handler = prop_datacow
+	},
 	{NULL, NULL, 0, 0, NULL}
 };
 
diff --git a/tests/cli-tests/017-btrfs-property/test.sh b/tests/cli-tests/017-btrfs-property/test.sh
new file mode 100755
index 000000000000..1da3eda4cd3a
--- /dev/null
+++ b/tests/cli-tests/017-btrfs-property/test.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+# test btrfs property commands
+
+source "$TEST_TOP/common"
+
+# compare with lsattr to make sure
+check_global_prereq lsattr
+
+setup_root_helper
+prepare_test_dev
+
+run_check_mkfs_test_dev
+run_check_mount_test_dev
+
+run_check $SUDO_HELPER touch "$TEST_MNT/file"
+run_check $SUDO_HELPER "$TOP/btrfs" property set "$TEST_MNT/file" datacow no
+run_check_stdout $SUDO_HELPER "$TOP/btrfs" property get "$TEST_MNT/file" datacow |
+	grep -q "datacow=no" || _fail "datacow wasn't no"
+run_check_stdout $SUDO_HELPER lsattr "$TEST_MNT/file" |
+	grep -q -- "C.* " || _fail "lsattr didn't agree NOCOW flag is set"
+run_check $SUDO_HELPER "$TOP/btrfs" property set "$TEST_MNT/file" datacow yes
+run_check_stdout $SUDO_HELPER "$TOP/btrfs" property get "$TEST_MNT/file" datacow |
+	grep -q "datacow=yes" || _fail "datacow wasn't yes"
+
+run_check_umount_test_dev
