Skip to content
Snippets Groups Projects
Select Git revision
  • b48652c101cce7a54379a49cc0cf854cec2c94e2
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

ordered-data.c

Blame
  • ordered-data.c 18.57 KiB
    /*
     * Copyright (C) 2007 Oracle.  All rights reserved.
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public
     * License v2 as published by the Free Software Foundation.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     * General Public License for more details.
     *
     * You should have received a copy of the GNU General Public
     * License along with this program; if not, write to the
     * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     * Boston, MA 021110-1307, USA.
     */
    
    #include <linux/gfp.h>
    #include <linux/slab.h>
    #include <linux/blkdev.h>
    #include <linux/writeback.h>
    #include <linux/pagevec.h>
    #include "ctree.h"
    #include "transaction.h"
    #include "btrfs_inode.h"
    #include "extent_io.h"
    
    
    static u64 entry_end(struct btrfs_ordered_extent *entry)
    {
    	if (entry->file_offset + entry->len < entry->file_offset)
    		return (u64)-1;
    	return entry->file_offset + entry->len;
    }
    
    static struct rb_node *tree_insert(struct rb_root *root, u64 file_offset,
    				   struct rb_node *node)
    {
    	struct rb_node ** p = &root->rb_node;
    	struct rb_node * parent = NULL;
    	struct btrfs_ordered_extent *entry;
    
    	while(*p) {
    		parent = *p;
    		entry = rb_entry(parent, struct btrfs_ordered_extent, rb_node);
    
    		if (file_offset < entry->file_offset)
    			p = &(*p)->rb_left;
    		else if (file_offset >= entry_end(entry))
    			p = &(*p)->rb_right;
    		else
    			return parent;
    	}
    
    	rb_link_node(node, parent, p);
    	rb_insert_color(node, root);
    	return NULL;
    }
    
    static struct rb_node *__tree_search(struct rb_root *root, u64 file_offset,
    				     struct rb_node **prev_ret)
    {
    	struct rb_node * n = root->rb_node;
    	struct rb_node *prev = NULL;
    	struct rb_node *test;
    	struct btrfs_ordered_extent *entry;
    	struct btrfs_ordered_extent *prev_entry = NULL;
    
    	while(n) {