Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc17ff8f authored by Chris Mason's avatar Chris Mason
Browse files

Btrfs: Add data=ordered support



This forces file data extents down the disk along with the metadata that
references them.  The current implementation is fairly simple, and just
writes out all of the dirty pages in an inode before the commit.

Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent e4204ded
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ obj-m := btrfs.o
btrfs-y := super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
	   hash.o file-item.o inode-item.o inode-map.o disk-io.o \
	   transaction.o bit-radix.o inode.o file.o tree-defrag.o \
	   extent_map.o sysfs.o struct-funcs.o xattr.o acl.o
	   extent_map.o sysfs.o struct-funcs.o xattr.o acl.o ordered-data.o

#btrfs-y := ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
#	  root-tree.o dir-item.o hash.o file-item.o inode-item.o \
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ struct btrfs_inode {
	struct extent_map_tree extent_tree;
	struct inode vfs_inode;

	u64 ordered_trans;
	/*
	 * transid of the trans_handle that last modified this inode
	 */
+5 −1
Original line number Diff line number Diff line
@@ -221,7 +221,9 @@ int btrfs_cow_block(struct btrfs_trans_handle *trans,
		    struct extent_buffer **cow_ret)
{
	u64 search_start;
	u64 header_trans;
	int ret;

	if (trans->transaction != root->fs_info->running_transaction) {
		printk(KERN_CRIT "trans %Lu running %Lu\n", trans->transid,
		       root->fs_info->running_transaction->transid);
@@ -232,7 +234,9 @@ int btrfs_cow_block(struct btrfs_trans_handle *trans,
		       root->fs_info->generation);
		WARN_ON(1);
	}
	if (btrfs_header_generation(buf) == trans->transid) {

	header_trans = btrfs_header_generation(buf);
	if (header_trans == trans->transid) {
		*cow_ret = buf;
		return 0;
	}
+4 −3
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@
 * Boston, MA 021110-1307, USA.
 */

#ifndef __BTRFS__
#define __BTRFS__
#ifndef __BTRFS_CTREE__
#define __BTRFS_CTREE__

#include <linux/version.h>
#include <linux/mm.h>
@@ -363,7 +363,6 @@ struct btrfs_root {
	struct inode *inode;
	struct kobject root_kobj;
	struct completion kobj_unregister;
	struct rw_semaphore snap_sem;
	u64 objectid;
	u64 last_trans;

@@ -1142,6 +1141,8 @@ void btrfs_destroy_cachep(void);
long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
struct inode *btrfs_iget_locked(struct super_block *s, u64 objectid,
				struct btrfs_root *root);
struct inode *btrfs_ilookup(struct super_block *s, u64 objectid,
			    u64 root_objectid);
int btrfs_commit_write(struct file *file, struct page *page,
		       unsigned from, unsigned to);
struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
+15 −1
Original line number Diff line number Diff line
@@ -406,7 +406,6 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
	memset(&root->defrag_progress, 0, sizeof(root->defrag_progress));
	memset(&root->root_kobj, 0, sizeof(root->root_kobj));
	init_completion(&root->kobj_unregister);
	init_rwsem(&root->snap_sem);
	root->defrag_running = 0;
	root->defrag_level = 0;
	root->root_key.objectid = objectid;
@@ -498,6 +497,21 @@ struct btrfs_root *btrfs_read_fs_root_no_radix(struct btrfs_fs_info *fs_info,
	return root;
}

struct btrfs_root *btrfs_lookup_fs_root(struct btrfs_fs_info *fs_info,
					u64 root_objectid)
{
	struct btrfs_root *root;

	if (root_objectid == BTRFS_ROOT_TREE_OBJECTID)
		return fs_info->tree_root;
	if (root_objectid == BTRFS_EXTENT_TREE_OBJECTID)
		return fs_info->extent_root;

	root = radix_tree_lookup(&fs_info->fs_roots_radix,
				 (unsigned long)root_objectid);
	return root;
}

struct btrfs_root *btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info,
					      struct btrfs_key *location)
{
Loading