<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/">
  <channel rdf:about="http://blog.gmane.org/gmane.comp.file-systems.btrfs">
    <title>gmane.comp.file-systems.btrfs</title>
    <link>http://blog.gmane.org/gmane.comp.file-systems.btrfs</link>
    <description/>
    <syn:updatePeriod>hourly</syn:updatePeriod>
    <syn:updateFrequency>1</syn:updateFrequency>
    <syn:updateBase>1901-01-01T00:00+00:00</syn:updateBase>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26401"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26398"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26397"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26396"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26395"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26394"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26393"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26392"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26391"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26390"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26389"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26388"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26387"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26386"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26385"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26384"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26383"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26382"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26381"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26380"/>
      </rdf:Seq>
    </items>
    <image rdf:resource="http://gmane.org/img/gmane-25t.png"/>
    <textinput rdf:resource=""/>
  </channel>
  <image rdf:about="http://gmane.org/img/gmane-25t.png">
    <title>Gmane</title>
    <url>http://gmane.org/img/gmane-25t.png</url>
    <link>http://gmane.org</link>
  </image>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26401">
    <title>[PATCH V4] Btrfs: remove btrfs_sector_sum structure</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26401</link>
    <description>&lt;pre&gt;Using the structure btrfs_sector_sum to keep the checksum value is
unnecessary, because the extents that btrfs_sector_sum points to are
continuous, we can find out the expected checksums by btrfs_ordered_sum's
bytenr and the offset, so we can remove btrfs_sector_sum's bytenr. After
removing bytenr, there is only one member in the structure, so it makes
no sense to keep the structure, just remove it, and use a u32 array to
store the checksum value.

By this change, we don't use the while loop to get the checksums one by
one. Now, we can get several checksum value at one time, it improved the
performance by ~74% on my SSD (31MB/s -&amp;gt; 54MB/s).

test command:
 # dd if=/dev/zero of=/mnt/btrfs/file0 bs=1M count=1024 oflag=sync

Signed-off-by: Miao Xie &amp;lt;miaox&amp;lt; at &amp;gt;cn.fujitsu.com&amp;gt;
---
Changelog v3 -&amp;gt; v4:
- fix wrong csum clone when doing relocation.

Changelog v2 -&amp;gt; v3:
- address the problem that the csums was inserted into the wrong range, this bug
  was reported by Josef.

Changelog v1 -&amp;gt; v2:
- modify the changelog and the title which can not explain this patch clearly
- fix the 64bit division problem on 32bit machine
---
 fs/btrfs/file-item.c    | 144 ++++++++++++++++++------------------------------
 fs/btrfs/ordered-data.c |  19 +++----
 fs/btrfs/ordered-data.h |  25 ++-------
 fs/btrfs/relocation.c   |  14 +----
 fs/btrfs/scrub.c        |  16 ++----
 5 files changed, 76 insertions(+), 142 deletions(-)

diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index b193bf3..a7bfc95 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -34,8 +34,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
 
 #define MAX_ORDERED_SUM_BYTES(r) ((PAGE_SIZE - \
    sizeof(struct btrfs_ordered_sum)) / \
-   sizeof(struct btrfs_sector_sum) * \
-   (r)-&amp;gt;sectorsize - (r)-&amp;gt;sectorsize)
+   sizeof(u32) * (r)-&amp;gt;sectorsize)
 
 int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
      struct btrfs_root *root,
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -297,7 +296,6 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
 struct btrfs_path *path;
 struct extent_buffer *leaf;
 struct btrfs_ordered_sum *sums;
-struct btrfs_sector_sum *sector_sum;
 struct btrfs_csum_item *item;
 LIST_HEAD(tmplist);
 unsigned long offset;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -368,34 +366,28 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
       struct btrfs_csum_item);
 while (start &amp;lt; csum_end) {
 size = min_t(size_t, csum_end - start,
-MAX_ORDERED_SUM_BYTES(root));
+     MAX_ORDERED_SUM_BYTES(root));
 sums = kzalloc(btrfs_ordered_sum_size(root, size),
-GFP_NOFS);
+       GFP_NOFS);
 if (!sums) {
 ret = -ENOMEM;
 goto fail;
 }
 
-sector_sum = sums-&amp;gt;sums;
 sums-&amp;gt;bytenr = start;
-sums-&amp;gt;len = size;
+sums-&amp;gt;len = (int)size;
 
 offset = (start - key.offset) &amp;gt;&amp;gt;
 root-&amp;gt;fs_info-&amp;gt;sb-&amp;gt;s_blocksize_bits;
 offset *= csum_size;
+size &amp;gt;&amp;gt;= root-&amp;gt;fs_info-&amp;gt;sb-&amp;gt;s_blocksize_bits;
 
-while (size &amp;gt; 0) {
-read_extent_buffer(path-&amp;gt;nodes[0],
-&amp;amp;sector_sum-&amp;gt;sum,
-((unsigned long)item) +
-offset, csum_size);
-sector_sum-&amp;gt;bytenr = start;
-
-size -= root-&amp;gt;sectorsize;
-start += root-&amp;gt;sectorsize;
-offset += csum_size;
-sector_sum++;
-}
+read_extent_buffer(path-&amp;gt;nodes[0],
+   sums-&amp;gt;sums,
+   ((unsigned long)item) + offset,
+   csum_size * size);
+
+start += root-&amp;gt;sectorsize * size;
 list_add_tail(&amp;amp;sums-&amp;gt;list, &amp;amp;tmplist);
 }
 path-&amp;gt;slots[0]++;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -417,23 +409,20 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode,
        struct bio *bio, u64 file_start, int contig)
 {
 struct btrfs_ordered_sum *sums;
-struct btrfs_sector_sum *sector_sum;
 struct btrfs_ordered_extent *ordered;
 char *data;
 struct bio_vec *bvec = bio-&amp;gt;bi_io_vec;
 int bio_index = 0;
+int index;
 unsigned long total_bytes = 0;
 unsigned long this_sum_bytes = 0;
 u64 offset;
-u64 disk_bytenr;
 
 WARN_ON(bio-&amp;gt;bi_vcnt &amp;lt;= 0);
 sums = kzalloc(btrfs_ordered_sum_size(root, bio-&amp;gt;bi_size), GFP_NOFS);
 if (!sums)
 return -ENOMEM;
 
-sector_sum = sums-&amp;gt;sums;
-disk_bytenr = (u64)bio-&amp;gt;bi_sector &amp;lt;&amp;lt; 9;
 sums-&amp;gt;len = bio-&amp;gt;bi_size;
 INIT_LIST_HEAD(&amp;amp;sums-&amp;gt;list);
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -444,7 +433,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode,
 
 ordered = btrfs_lookup_ordered_extent(inode, offset);
 BUG_ON(!ordered); /* Logic error */
-sums-&amp;gt;bytenr = ordered-&amp;gt;start;
+sums-&amp;gt;bytenr = (u64)bio-&amp;gt;bi_sector &amp;lt;&amp;lt; 9;
+index = 0;
 
 while (bio_index &amp;lt; bio-&amp;gt;bi_vcnt) {
 if (!contig)
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -463,28 +453,27 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode,
 sums = kzalloc(btrfs_ordered_sum_size(root, bytes_left),
        GFP_NOFS);
 BUG_ON(!sums); /* -ENOMEM */
-sector_sum = sums-&amp;gt;sums;
 sums-&amp;gt;len = bytes_left;
 ordered = btrfs_lookup_ordered_extent(inode, offset);
 BUG_ON(!ordered); /* Logic error */
-sums-&amp;gt;bytenr = ordered-&amp;gt;start;
+sums-&amp;gt;bytenr = ((u64)bio-&amp;gt;bi_sector &amp;lt;&amp;lt; 9) +
+       total_bytes;
+index = 0;
 }
 
 data = kmap_atomic(bvec-&amp;gt;bv_page);
-sector_sum-&amp;gt;sum = ~(u32)0;
-sector_sum-&amp;gt;sum = btrfs_csum_data(data + bvec-&amp;gt;bv_offset,
-  sector_sum-&amp;gt;sum,
-  bvec-&amp;gt;bv_len);
+sums-&amp;gt;sums[index] = ~(u32)0;
+sums-&amp;gt;sums[index] = btrfs_csum_data(data + bvec-&amp;gt;bv_offset,
+    sums-&amp;gt;sums[index],
+    bvec-&amp;gt;bv_len);
 kunmap_atomic(data);
-btrfs_csum_final(sector_sum-&amp;gt;sum,
- (char *)&amp;amp;sector_sum-&amp;gt;sum);
-sector_sum-&amp;gt;bytenr = disk_bytenr;
+btrfs_csum_final(sums-&amp;gt;sums[index],
+ (char *)(sums-&amp;gt;sums + index));
 
-sector_sum++;
 bio_index++;
+index++;
 total_bytes += bvec-&amp;gt;bv_len;
 this_sum_bytes += bvec-&amp;gt;bv_len;
-disk_bytenr += bvec-&amp;gt;bv_len;
 offset += bvec-&amp;gt;bv_len;
 bvec++;
 }
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -672,62 +661,46 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; out:
 return ret;
 }
 
-static u64 btrfs_sector_sum_left(struct btrfs_ordered_sum *sums,
- struct btrfs_sector_sum *sector_sum,
- u64 total_bytes, u64 sectorsize)
-{
-u64 tmp = sectorsize;
-u64 next_sector = sector_sum-&amp;gt;bytenr;
-struct btrfs_sector_sum *next = sector_sum + 1;
-
-while ((tmp + total_bytes) &amp;lt; sums-&amp;gt;len) {
-if (next_sector + sectorsize != next-&amp;gt;bytenr)
-break;
-tmp += sectorsize;
-next_sector = next-&amp;gt;bytenr;
-next++;
-}
-return tmp;
-}
-
 int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
    struct btrfs_root *root,
    struct btrfs_ordered_sum *sums)
 {
-u64 bytenr;
-int ret;
 struct btrfs_key file_key;
 struct btrfs_key found_key;
-u64 next_offset;
-u64 total_bytes = 0;
-int found_next;
 struct btrfs_path *path;
 struct btrfs_csum_item *item;
 struct btrfs_csum_item *item_end;
 struct extent_buffer *leaf = NULL;
+u64 next_offset;
+u64 total_bytes = 0;
 u64 csum_offset;
-struct btrfs_sector_sum *sector_sum;
+u64 bytenr;
 u32 nritems;
 u32 ins_size;
+int index = 0;
+int found_next;
+int ret;
 u16 csum_size = btrfs_super_csum_size(root-&amp;gt;fs_info-&amp;gt;super_copy);
 
 path = btrfs_alloc_path();
 if (!path)
 return -ENOMEM;
-
-sector_sum = sums-&amp;gt;sums;
 again:
 next_offset = (u64)-1;
 found_next = 0;
+bytenr = sums-&amp;gt;bytenr + total_bytes;
 file_key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
-file_key.offset = sector_sum-&amp;gt;bytenr;
-bytenr = sector_sum-&amp;gt;bytenr;
+file_key.offset = bytenr;
 btrfs_set_key_type(&amp;amp;file_key, BTRFS_EXTENT_CSUM_KEY);
 
-item = btrfs_lookup_csum(trans, root, path, sector_sum-&amp;gt;bytenr, 1);
+item = btrfs_lookup_csum(trans, root, path, bytenr, 1);
 if (!IS_ERR(item)) {
-leaf = path-&amp;gt;nodes[0];
 ret = 0;
+leaf = path-&amp;gt;nodes[0];
+item_end = btrfs_item_ptr(leaf, path-&amp;gt;slots[0],
+  struct btrfs_csum_item);
+item_end = (struct btrfs_csum_item *)((char *)item_end +
+   btrfs_item_size_nr(leaf, path-&amp;gt;slots[0]));
 goto found;
 }
 ret = PTR_ERR(item);
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -807,8 +780,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; again:
 
 free_space = btrfs_leaf_free_space(root, leaf) -
  sizeof(struct btrfs_item) - csum_size;
-tmp = btrfs_sector_sum_left(sums, sector_sum, total_bytes,
-    root-&amp;gt;sectorsize);
+tmp = sums-&amp;gt;len - total_bytes;
 tmp &amp;gt;&amp;gt;= root-&amp;gt;fs_info-&amp;gt;sb-&amp;gt;s_blocksize_bits;
 WARN_ON(tmp &amp;lt; 1);
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -822,6 +794,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; again:
 diff *= csum_size;
 
 btrfs_extend_item(root, path, diff);
+ret = 0;
 goto csum;
 }
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -831,8 +804,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; insert:
 if (found_next) {
 u64 tmp;
 
-tmp = btrfs_sector_sum_left(sums, sector_sum, total_bytes,
-    root-&amp;gt;sectorsize);
+tmp = sums-&amp;gt;len - total_bytes;
 tmp &amp;gt;&amp;gt;= root-&amp;gt;fs_info-&amp;gt;sb-&amp;gt;s_blocksize_bits;
 tmp = min(tmp, (next_offset - file_key.offset) &amp;gt;&amp;gt;
  root-&amp;gt;fs_info-&amp;gt;sb-&amp;gt;s_blocksize_bits);
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -853,31 +825,25 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; insert:
 WARN_ON(1);
 goto fail_unlock;
 }
-csum:
 leaf = path-&amp;gt;nodes[0];
+csum:
 item = btrfs_item_ptr(leaf, path-&amp;gt;slots[0], struct btrfs_csum_item);
-ret = 0;
+item_end = (struct btrfs_csum_item *)((unsigned char *)item +
+      btrfs_item_size_nr(leaf, path-&amp;gt;slots[0]));
 item = (struct btrfs_csum_item *)((unsigned char *)item +
   csum_offset * csum_size);
 found:
-item_end = btrfs_item_ptr(leaf, path-&amp;gt;slots[0], struct btrfs_csum_item);
-item_end = (struct btrfs_csum_item *)((unsigned char *)item_end +
-      btrfs_item_size_nr(leaf, path-&amp;gt;slots[0]));
-next_sector:
-
-write_extent_buffer(leaf, &amp;amp;sector_sum-&amp;gt;sum, (unsigned long)item, csum_size);
-
-total_bytes += root-&amp;gt;sectorsize;
-sector_sum++;
-if (total_bytes &amp;lt; sums-&amp;gt;len) {
-item = (struct btrfs_csum_item *)((char *)item +
-  csum_size);
-if (item &amp;lt; item_end &amp;amp;&amp;amp; bytenr + PAGE_CACHE_SIZE ==
-    sector_sum-&amp;gt;bytenr) {
-bytenr = sector_sum-&amp;gt;bytenr;
-goto next_sector;
-}
-}
+ins_size = (u32)(sums-&amp;gt;len - total_bytes) &amp;gt;&amp;gt;
+   root-&amp;gt;fs_info-&amp;gt;sb-&amp;gt;s_blocksize_bits;
+ins_size *= csum_size;
+ins_size = min_t(u32, (unsigned long)item_end - (unsigned long)item,
+      ins_size);
+write_extent_buffer(leaf, sums-&amp;gt;sums + index, (unsigned long)item,
+    ins_size);
+
+ins_size /= csum_size;
+total_bytes += ins_size * root-&amp;gt;sectorsize;
+index += ins_size;
 
 btrfs_mark_buffer_dirty(path-&amp;gt;nodes[0]);
 if (total_bytes &amp;lt; sums-&amp;gt;len) {
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 665c640..8136982 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1032,7 +1032,6 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr,
    u32 *sum, int len)
 {
 struct btrfs_ordered_sum *ordered_sum;
-struct btrfs_sector_sum *sector_sums;
 struct btrfs_ordered_extent *ordered;
 struct btrfs_ordered_inode_tree *tree = &amp;amp;BTRFS_I(inode)-&amp;gt;ordered_tree;
 unsigned long num_sectors;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1050,18 +1049,16 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr,
     disk_bytenr &amp;lt; ordered_sum-&amp;gt;bytenr + ordered_sum-&amp;gt;len) {
 i = (disk_bytenr - ordered_sum-&amp;gt;bytenr) &amp;gt;&amp;gt;
     inode-&amp;gt;i_sb-&amp;gt;s_blocksize_bits;
-sector_sums = ordered_sum-&amp;gt;sums + i;
 num_sectors = ordered_sum-&amp;gt;len &amp;gt;&amp;gt;
       inode-&amp;gt;i_sb-&amp;gt;s_blocksize_bits;
-for (; i &amp;lt; num_sectors; i++) {
-if (sector_sums[i].bytenr == disk_bytenr) {
-sum[index] = sector_sums[i].sum;
-index++;
-if (index == len)
-goto out;
-disk_bytenr += sectorsize;
-}
-}
+num_sectors = min_t(int, len - index, num_sectors - i);
+memcpy(sum + index, ordered_sum-&amp;gt;sums + i,
+       num_sectors);
+
+index += (int)num_sectors;
+if (index == len)
+goto out;
+disk_bytenr += num_sectors * sectorsize;
 }
 }
 out:
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
index d082d43..68844d5 100644
--- a/fs/btrfs/ordered-data.h
+++ b/fs/btrfs/ordered-data.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -26,18 +26,6 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; struct btrfs_ordered_inode_tree {
 struct rb_node *last;
 };
 
-/*
- * these are used to collect checksums done just before bios submission.
- * They are attached via a list into the ordered extent, and
- * checksum items are inserted into the tree after all the blocks in
- * the ordered extent are on disk
- */
-struct btrfs_sector_sum {
-/* bytenr on disk */
-u64 bytenr;
-u32 sum;
-};
-
 struct btrfs_ordered_sum {
 /* bytenr is the start of this extent on disk */
 u64 bytenr;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -45,10 +33,10 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; struct btrfs_ordered_sum {
 /*
  * this is the length in bytes covered by the sums array below.
  */
-unsigned long len;
+int len;
 struct list_head list;
-/* last field is a variable length array of btrfs_sector_sums */
-struct btrfs_sector_sum sums[];
+/* last field is a variable length array of csums */
+u32 sums[];
 };
 
 /*
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -149,11 +137,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; struct btrfs_ordered_extent {
 static inline int btrfs_ordered_sum_size(struct btrfs_root *root,
  unsigned long bytes)
 {
-unsigned long num_sectors = (bytes + root-&amp;gt;sectorsize - 1) /
-root-&amp;gt;sectorsize;
-num_sectors++;
-return sizeof(struct btrfs_ordered_sum) +
-num_sectors * sizeof(struct btrfs_sector_sum);
+int num_sectors = (int)DIV_ROUND_UP(bytes, root-&amp;gt;sectorsize);
+return sizeof(struct btrfs_ordered_sum) + num_sectors * sizeof(u32);
 }
 
 static inline void
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index d91f106..1209649 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -4458,10 +4458,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; out:
 int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len)
 {
 struct btrfs_ordered_sum *sums;
-struct btrfs_sector_sum *sector_sum;
 struct btrfs_ordered_extent *ordered;
 struct btrfs_root *root = BTRFS_I(inode)-&amp;gt;root;
-size_t offset;
 int ret;
 u64 disk_bytenr;
 LIST_HEAD(list);
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -4475,19 +4473,13 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len)
 if (ret)
 goto out;
 
+disk_bytenr = ordered-&amp;gt;start;
 while (!list_empty(&amp;amp;list)) {
 sums = list_entry(list.next, struct btrfs_ordered_sum, list);
 list_del_init(&amp;amp;sums-&amp;gt;list);
 
-sector_sum = sums-&amp;gt;sums;
-sums-&amp;gt;bytenr = ordered-&amp;gt;start;
-
-offset = 0;
-while (offset &amp;lt; sums-&amp;gt;len) {
-sector_sum-&amp;gt;bytenr += ordered-&amp;gt;start - disk_bytenr;
-sector_sum++;
-offset += root-&amp;gt;sectorsize;
-}
+sums-&amp;gt;bytenr = disk_bytenr;
+disk_bytenr += sums-&amp;gt;len;
 
 btrfs_add_ordered_sum(inode, ordered, sums);
 }
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index cb308a3..63144e4 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -2126,8 +2126,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int scrub_find_csum(struct scrub_ctx *sctx, u64 logical, u64 len,
    u8 *csum)
 {
 struct btrfs_ordered_sum *sum = NULL;
-int ret = 0;
-unsigned long i;
+unsigned long index;
 unsigned long num_sectors;
 
 while (!list_empty(&amp;amp;sctx-&amp;gt;csum_list)) {
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -2146,19 +2145,14 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int scrub_find_csum(struct scrub_ctx *sctx, u64 logical, u64 len,
 if (!sum)
 return 0;
 
+index = ((u32)(logical - sum-&amp;gt;bytenr)) / sctx-&amp;gt;sectorsize;
 num_sectors = sum-&amp;gt;len / sctx-&amp;gt;sectorsize;
-for (i = 0; i &amp;lt; num_sectors; ++i) {
-if (sum-&amp;gt;sums[i].bytenr == logical) {
-memcpy(csum, &amp;amp;sum-&amp;gt;sums[i].sum, sctx-&amp;gt;csum_size);
-ret = 1;
-break;
-}
-}
-if (ret &amp;amp;&amp;amp; i == num_sectors - 1) {
+memcpy(csum, sum-&amp;gt;sums + index, sctx-&amp;gt;csum_size);
+if (index == num_sectors - 1) {
 list_del(&amp;amp;sum-&amp;gt;list);
 kfree(sum);
 }
-return ret;
+return 1;
 }
 
 /* scrub extent tries to collect up to 64 kB for each bio */
&lt;/pre&gt;</description>
    <dc:creator>Miao Xie</dc:creator>
    <dc:date>2013-06-19T02:36:09</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26398">
    <title>[PATCH] Btrfs: move btrfs_truncate_page to btrfs_cont_expand instead of btrfs_truncate V2</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26398</link>
    <description>&lt;pre&gt;This has plagued us forever and I'm so over working around it.  When we truncate
down to a non-page aligned offset we will call btrfs_truncate_page to zero out
the end of the page and write it back to disk, this will keep us from exposing
stale data if we truncate back up from that point.  The problem with this is it
requires data space to do this, and people don't really expect to get ENOSPC
from truncate() for these sort of things.  This also tends to bite the orphan
cleanup stuff too which keeps people from mounting.  To get around this we can
just move this into btrfs_cont_expand() to make sure if we are truncating up
from a non-page size aligned i_size we will zero out the rest of this page so
that we don't expose stale data.  This will give ENOSPC if you try to truncate()
up or if you try to write past the end of isize, which is much more reasonable.
This fixes xfstests generic/083 failing to mount because of the orphan cleanup
failing.  Thanks,

Signed-off-by: Josef Bacik &amp;lt;jbacik&amp;lt; at &amp;gt;fusionio.com&amp;gt;
---
V1-&amp;gt;V2:
-we need to call btrfs_truncate_page in fallocate()
-we need to zero the page in readpage endio

 fs/btrfs/extent_io.c |   11 ++++++++++-
 fs/btrfs/file.c      |   21 +++++++++++++++------
 fs/btrfs/inode.c     |   15 ++++++++++-----
 3 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 03ca3ab..a83d701 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -2477,11 +2477,12 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static void end_bio_extent_readpage(struct bio *bio, int err)
 struct extent_state *cached = NULL;
 struct extent_state *state;
 struct btrfs_io_bio *io_bio = btrfs_io_bio(bio);
+struct inode *inode = page-&amp;gt;mapping-&amp;gt;host;
 
 pr_debug("end_bio_extent_readpage: bi_sector=%llu, err=%d, "
  "mirror=%lu\n", (u64)bio-&amp;gt;bi_sector, err,
  io_bio-&amp;gt;mirror_num);
-tree = &amp;amp;BTRFS_I(page-&amp;gt;mapping-&amp;gt;host)-&amp;gt;io_tree;
+tree = &amp;amp;BTRFS_I(inode)-&amp;gt;io_tree;
 
 /* We always issue full-page reads, but if some block
  * in a page fails to read, blk_update_request() will
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -2555,6 +2556,14 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static void end_bio_extent_readpage(struct bio *bio, int err)
 unlock_extent_cached(tree, start, end, &amp;amp;cached, GFP_ATOMIC);
 
 if (uptodate) {
+loff_t i_size = i_size_read(inode);
+pgoff_t end_index = i_size &amp;gt;&amp;gt; PAGE_CACHE_SHIFT;
+unsigned offset;
+
+/* Zero out the end if this page straddles i_size */
+offset = i_size &amp;amp; (PAGE_CACHE_SIZE-1);
+if (page-&amp;gt;index == end_index &amp;amp;&amp;amp; offset)
+zero_user_segment(page, offset, PAGE_CACHE_SIZE);
 SetPageUptodate(page);
 } else {
 ClearPageUptodate(page);
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 185af15..5ffde56 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -2173,12 +2173,6 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static long btrfs_fallocate(struct file *file, int mode,
 goto out_reserve_fail;
 }
 
-/*
- * wait for ordered IO before we have any locks.  We'll loop again
- * below with the locks held.
- */
-btrfs_wait_ordered_range(inode, alloc_start, alloc_end - alloc_start);
-
 mutex_lock(&amp;amp;inode-&amp;gt;i_mutex);
 ret = inode_newsize_ok(inode, alloc_end);
 if (ret)
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -2189,8 +2183,23 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static long btrfs_fallocate(struct file *file, int mode,
 alloc_start);
 if (ret)
 goto out;
+} else {
+/*
+ * If we are fallocating from the end of the file onward we
+ * need to zero out the end of the page if i_size lands in the
+ * middle of a page.
+ */
+ret = btrfs_truncate_page(inode, inode-&amp;gt;i_size, 0, 0);
+if (ret)
+goto out;
 }
 
+/*
+ * wait for ordered IO before we have any locks.  We'll loop again
+ * below with the locks held.
+ */
+btrfs_wait_ordered_range(inode, alloc_start, alloc_end - alloc_start);
+
 locked_end = alloc_end - 1;
 while (1) {
 struct btrfs_ordered_extent *ordered;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 3dbfee9..ecf8b5b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -4253,6 +4253,15 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
 u64 hole_size;
 int err = 0;
 
+/*
+ * If our size started in the middle of a page we need to zero out the
+ * rest of the page before we expand the i_size, otherwise we could
+ * expose stale data.
+ */
+err = btrfs_truncate_page(inode, oldsize, 0, 0);
+if (err)
+return err;
+
 if (size &amp;lt;= hole_start)
 return 0;
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -7590,16 +7599,12 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int btrfs_truncate(struct inode *inode)
 {
 struct btrfs_root *root = BTRFS_I(inode)-&amp;gt;root;
 struct btrfs_block_rsv *rsv;
-int ret;
+int ret = 0;
 int err = 0;
 struct btrfs_trans_handle *trans;
 u64 mask = root-&amp;gt;sectorsize - 1;
 u64 min_size = btrfs_calc_trunc_metadata_size(root, 1);
 
-ret = btrfs_truncate_page(inode, inode-&amp;gt;i_size, 0, 0);
-if (ret)
-return ret;
-
 btrfs_wait_ordered_range(inode, inode-&amp;gt;i_size &amp;amp; (~mask), (u64)-1);
 btrfs_ordered_update_i_size(inode, inode-&amp;gt;i_size, NULL);
 
&lt;/pre&gt;</description>
    <dc:creator>Josef Bacik</dc:creator>
    <dc:date>2013-06-18T19:44:58</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26397">
    <title>Re: hang on 3.9, 3.10-rc5</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26397</link>
    <description>&lt;pre&gt;

..


I'm able to cause a complete kernel hang by defrag'ing even one 
file on 3.9.X (3.9.0 through 3.9.4, so far).



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Jon Nelson</dc:creator>
    <dc:date>2013-06-18T17:19:04</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26396">
    <title>Re: hang on 3.9, 3.10-rc5</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26396</link>
    <description>&lt;pre&gt;Quoting Josef Bacik (2013-06-18 12:37:06)

He attached it last week.


It's very suspect that both of the times he logged this
log_one_extent popped up.  That should be: 

                wait_event(ordered-&amp;gt;wait, ordered-&amp;gt;csum_bytes_left == 0);

But Sage it would definitely help if you could confirm.

If we follow log_one_extent all the way up to btrfs_log_inode:

               } else if (test_and_clear_bit(BTRFS_INODE_COPY_EVERYTHING,
                                              &amp;amp;BTRFS_I(inode)-&amp;gt;runtime_flags)) { 
                        if (inode_only == LOG_INODE_ALL)
                                fast_search = true;
                        max_key.type = BTRFS_XATTR_ITEM_KEY;
                        ret = drop_objectid_items(trans, log, path, ino,
                                                  max_key.type);

Now fast_search is true, but we don't jump directly to logging the
extent.  The while loop runs, we hit the first break.  ins_nr is zero.

Then we:
       if (fast_search) {
                btrfs_release_path(dst_path);
                ret = btrfs_log_changed_extents(trans, root, inode, dst_path);
                if (ret) {
                        err = ret;
                        goto out_unlock;
                }


Very long way of saying I think we're one release_path short.  Sage, I
haven't tested this at all yet, I was hoping to trigger it first.

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index c276ac9..c1954b3 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -3730,6 +3730,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; next_slot:
 log_extents:
 if (fast_search) {
 btrfs_release_path(dst_path);
+btrfs_release_path(path);
 ret = btrfs_log_changed_extents(trans, root, inode, dst_path);
 if (ret) {
 err = ret;
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Chris Mason</dc:creator>
    <dc:date>2013-06-18T16:59:52</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26395">
    <title>Re: hang on 3.9, 3.10-rc5</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26395</link>
    <description>&lt;pre&gt;
Have you gotten sysrq+w?  Can you tell me where

log_one_extent.isra.22+0x485

is on your box?  Thanks,

Josef
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Josef Bacik</dc:creator>
    <dc:date>2013-06-18T16:37:06</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26394">
    <title>Re: hang on 3.9, 3.10-rc5</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26394</link>
    <description>&lt;pre&gt;Quoting Sage Weil (2013-06-18 11:56:37)

No, I don't see anything in -next that should fix this.  Trying to
reproduce here...

-chris
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Chris Mason</dc:creator>
    <dc:date>2013-06-18T16:36:37</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26393">
    <title>Re: hang on 3.9, 3.10-rc5</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26393</link>
    <description>&lt;pre&gt;
Still seeing this hang with the latest from linus' tree.  Is there another 
tree I should try testing against?

Thanks!
sage

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Sage Weil</dc:creator>
    <dc:date>2013-06-18T15:56:37</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26392">
    <title>[PATCH] btrfs: allow mounting btrfs subvolumes with different ro/rw options</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26392</link>
    <description>&lt;pre&gt;From: Harald Hoyer &amp;lt;harald&amp;lt; at &amp;gt;redhat.com&amp;gt;

Given the following /etc/fstab entries:

/dev/sda3 /mnt/foo btrfs subvol=foo,ro 0
/dev/sda3 /mnt/bar btrfs subvol=bar,rw 0

you can't issue:

$ mount /mnt/foo
$ mount /mnt/bar

You would have to do:

$ mount /mnt/foo
$ mount -o remount,rw /mnt/foo
$ mount --bind -o remount,ro /mnt/foo
$ mount /bar

or

$ mount /mnt/bar
$ mount --rw /mnt/foo
$ mount --bind -o remount,ro /mnt/foo

With this patch you can do

$ mount /mnt/foo
$ mount /mnt/bar

$ cat /proc/self/mountinfo
49 33 0:41 /foo /mnt/foo ro,relatime shared:36 - btrfs /dev/sda3 rw,ssd,space_cache
87 33 0:41 /bar /mnt/bar rw,relatime shared:74 - btrfs /dev/sda3 rw,ssd,space_cache
---
 fs/btrfs/super.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index f0857e0..80ed3e2 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -64,6 +64,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
 static const struct super_operations btrfs_super_ops;
 static struct file_system_type btrfs_fs_type;
 
+static int btrfs_remount(struct super_block *sb, int *flags, char *data);
+
 static const char *btrfs_decode_error(int errno)
 {
 char *errstr = "unknown";
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1036,6 +1038,26 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static struct dentry *mount_subvol(const char *subvol_name, int flags,
 mnt = vfs_kern_mount(&amp;amp;btrfs_fs_type, flags, device_name,
      newargs);
 kfree(newargs);
+
+if (PTR_RET(mnt) == -EBUSY) {
+if (flags &amp;amp; MS_RDONLY) {
+mnt = vfs_kern_mount(&amp;amp;btrfs_fs_type, flags &amp;amp; ~MS_RDONLY, device_name,
+     newargs);
+} else {
+int r;
+mnt = vfs_kern_mount(&amp;amp;btrfs_fs_type, flags | MS_RDONLY, device_name,
+     newargs);
+if (IS_ERR(mnt))
+return ERR_CAST(mnt);
+
+r = btrfs_remount(mnt-&amp;gt;mnt_sb, &amp;amp;flags, NULL);
+if (r &amp;lt; 0) {
+/* FIXME: release vfsmount mnt ??*/
+return ERR_PTR(r);
+}
+}
+}
+
 if (IS_ERR(mnt))
 return ERR_CAST(mnt);
 
&lt;/pre&gt;</description>
    <dc:creator>harald&lt; at &gt;redhat.com</dc:creator>
    <dc:date>2013-06-18T15:29:04</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26391">
    <title>Re: My multi-device btrfs (3*2TB) won't mount anymore.</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26391</link>
    <description>&lt;pre&gt;Does anything show up in dmesg when you mount?

If mount just hangs, do an alt-sysrq-w, and then post what that sends to dmesg.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>cwillu</dc:creator>
    <dc:date>2013-06-18T14:02:06</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26390">
    <title>Re: [PATCH] Btrfs: fix wrong csum clone when doing relocation</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26390</link>
    <description>&lt;pre&gt;
Just fold it into the original patch, since it corrupts the file system I'd
rather people not be able to bisect across them.  Thanks,

Josef
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Josef Bacik</dc:creator>
    <dc:date>2013-06-18T12:23:28</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26389">
    <title>Re: BUG at fs/btrfs/print-tree when trying to mount after a crash</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26389</link>
    <description>&lt;pre&gt;Thanks for the reply.

On Tue, 2013-06-18 at 06:04 +0000, Duncan wrote:
[...]

Tried it out, but still BUGs the same way. I'm using a full-disk backup
on a regular HDD, so I can try everything without worrying if it makes
the situation worse.


Unfortunately, I already tried using 3.10-rc6 in my first mail.


I'm often upgrading the kernel on my desktop, since I have to
shutdown/boot it anyways because with xen it crashes on resume. But I
don't reboot the notebook much. Probably only every few months when a
new a major version is released.

Anyway, I tried using btrfsck from Josef Bacik's tree (commit f392a28d,
git://github.com/josefbacik/btrfs-progs.git) and it doesn't crash.
Output is this:

[ ... ]

Any Ideas?


Thanks
Michael

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Michael Zugelder</dc:creator>
    <dc:date>2013-06-18T12:11:54</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26388">
    <title>My multi-device btrfs (3*2TB) won't mount anymore.</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26388</link>
    <description>&lt;pre&gt;My multi-device btrfs (3*2TB) won't mount anymore.
The fs was created with lubuntu 13.04 (amd64) and the default kernel
with -n 8192 -d single -m raid1, first with two devices the third was
added later.
Quotas where enabled after fs creation (btrfs quota enable) but
nothing else, there are several subvolumes and there should be around
100GB of free space.
Now I tried a more recent kernel but that does not help, I'm now
running mainline kernel 3.10-rc6 (amd64).

I tried btrfsck but it does nothing and won't react to ctrl-c (same
thing with mount), dmesg shows a lot of these
[ 1679.162829] INFO: task btrfsck:2786 blocked for more than 120 seconds.
[ 1679.162838] "echo 0 &amp;gt; /proc/sys/kernel/hung_task_
timeout_secs" disables this message.
[ 1679.162843] btrfsck         D 0000000000000000     0  2786   2785 0x00000004
[ 1679.162853]  ffff8800a1cc3d78 0000000000000046 ffff880115e1de00
ffff8800a1cdc8a0
[ 1679.162862]  ffff8800a1cc3fd8 ffff8800a1cc3fd8 ffff8800a1cc3fd8
0000000000013240
[ 1679.162869]  ffffffff81c11440 ffff880115b48000 ffff88011ac27000
ffffffffa0130ac0
[ 1679.162876] Call Trace:
[ 1679.162903]  [&amp;lt;ffffffff816cb899&amp;gt;] schedule+0x29/0x70
[ 1679.162911]  [&amp;lt;ffffffff816cbb9e&amp;gt;] schedule_preempt_disabled+0xe/0x10
[ 1679.162919]  [&amp;lt;ffffffff816c9fd2&amp;gt;] __mutex_lock_slowpath+0x112/0x1b0
[ 1679.162931]  [&amp;lt;ffffffff816c9b4a&amp;gt;] mutex_lock+0x2a/0x50
[ 1679.162981]  [&amp;lt;ffffffffa00d856b&amp;gt;] btrfs_scan_one_device+0x3b/0x200 [btrfs]
[ 1679.163011]  [&amp;lt;ffffffffa0085b89&amp;gt;] btrfs_control_ioctl+0xd9/0xf0 [btrfs]
[ 1679.163021]  [&amp;lt;ffffffff81198767&amp;gt;] do_vfs_ioctl+0x87/0x330
[ 1679.163029]  [&amp;lt;ffffffff81191ed6&amp;gt;] ? final_putname+0x26/0x50
[ 1679.163037]  [&amp;lt;ffffffff81198aa1&amp;gt;] SyS_ioctl+0x91/0xb0
[ 1679.163045]  [&amp;lt;ffffffff816d5586&amp;gt;] system_call_fastpath+0x1a/0x1f
[ 1799.027976] INFO: task btrfsck:2786 blocked for more than 120 seconds.
[ 1799.027985] "echo 0 &amp;gt; /proc/sys/kernel/hung_task_timeout_secs"
disables this message.
[ 1799.027991] btrfsck         D 0000000000000000     0  2786   2785 0x00000004
[ 1799.028000]  ffff8800a1cc3d78 0000000000000046 ffff880115e1de00
ffff8800a1cdc8a0
[ 1799.028009]  ffff8800a1cc3fd8 ffff8800a1cc3fd8 ffff8800a1cc3fd8
0000000000013240
[ 1799.028017]  ffffffff81c11440 ffff880115b48000 ffff88011ac27000
ffffffffa0130ac0
[ 1799.028024] Call Trace:
[ 1799.028050]  [&amp;lt;ffffffff816cb899&amp;gt;] schedule+0x29/0x70
[ 1799.028059]  [&amp;lt;ffffffff816cbb9e&amp;gt;] schedule_preempt_disabled+0xe/0x10
[ 1799.028067]  [&amp;lt;ffffffff816c9fd2&amp;gt;] __mutex_lock_slowpath+0x112/0x1b0
[ 1799.028080]  [&amp;lt;ffffffff816c9b4a&amp;gt;] mutex_lock+0x2a/0x50
[ 1799.028129]  [&amp;lt;ffffffffa00d856b&amp;gt;] btrfs_scan_one_device+0x3b/0x200 [btrfs]
[ 1799.028159]  [&amp;lt;ffffffffa0085b89&amp;gt;] btrfs_control_ioctl+0xd9/0xf0 [btrfs]
[ 1799.028169]  [&amp;lt;ffffffff81198767&amp;gt;] do_vfs_ioctl+0x87/0x330
[ 1799.028177]  [&amp;lt;ffffffff81191ed6&amp;gt;] ? final_putname+0x26/0x50
[ 1799.028185]  [&amp;lt;ffffffff81198aa1&amp;gt;] SyS_ioctl+0x91/0xb0
[ 1799.028193]  [&amp;lt;ffffffff816d5586&amp;gt;] system_call_fastpath+0x1a/0x1f


iostat
sde               0.11         0.45         0.00        776          0
sdg               0.11         0.44         0.00        764          0
sdf               0.11         0.44         0.00        764          0


btrfs fi sho
Label: none  uuid:
    Total devices 3 FS bytes used 5.37TB
    devid    1 size 1.82TB used 1.79TB path /dev/sdf
    devid    2 size 1.82TB used 1.79TB path /dev/sdg
    devid    3 size 1.82TB used 1.79TB path /dev/sde


How do I get the fs to mount again?
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Retro Pirate</dc:creator>
    <dc:date>2013-06-18T10:30:23</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26387">
    <title>Re: BUG at fs/btrfs/print-tree when trying to mount after a crash</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26387</link>
    <description>&lt;pre&gt;Michael Zugelder posted on Mon, 17 Jun 2013 21:10:27 +0200 as excerpted:

[snipped]


The technical debugging's for others, but two suggestions as a btrfs user/
tester:

1) I had an similar issue some time back that turned out to be a 
corrupted space-cache.  Try mounting with the "nospace_cache" option.  If 
that works that's it; mount with the "clear_cache" option to clear the 
bad cache and perhaps once again with space_cache to turn it back on. 
(Space-cache is one of the few options that's persistent, but I'm not 
sure if no-cache is equally persistent, making it a toggle, or if once 
it's on there's no way to turn it off permanently.)

The clear_cache option will trigger a cache rebuild, so will take some 
time on slower devices (you said SSD but didn't say whether it was a slow 
one or a fast one).  See the mount-options page at the wiki for more.

https://btrfs.wiki.kernel.org/index.php/Mount_options#Space_cache_control

2) Apparently some corruption bugs in 3.9 were fixed for 3.10.  It's 
worth trying say the latest 3.10-rc kernel, to see if can handle it.

As the wiki mentions in several places and as is frequently repeated 
here, btrfs is still under heavy development and the development kernels 
often have fixes missing in even latest stable.  So unless there's a 
known regression in the current development kernel that you're 
purposefully avoiding, really, relatively speaking, in terms of btrfs 
development, latest mainline kernel stable is in practice already a bit 
dated, and btrfs testers are encouraged to run the development kernels 
from rc2 or rc3 at least.  (I can understand not wanting to run them 
during the commit window, or until rc2/3, as I often hold off during the 
commit window here, too.  Some even run btrfs-next, before it hits 
mainline, but I've chosen to stick with mainline here.  That's just 
simpler all around for me, and the rcs are still current /enough/.)

&lt;/pre&gt;</description>
    <dc:creator>Duncan</dc:creator>
    <dc:date>2013-06-18T06:04:50</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26386">
    <title>[PATCH] Btrfs-progs: do not print uuid 0 when printing root item</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26386</link>
    <description>&lt;pre&gt;Signed-off-by: Wang Shilong &amp;lt;wangshilong1991&amp;lt; at &amp;gt;gmail.com&amp;gt;
---
 print-tree.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/print-tree.c b/print-tree.c
index aae47a9..c1d8d18 100644
--- a/print-tree.c
+++ b/print-tree.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -355,8 +355,10 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static void print_root(struct extent_buffer *leaf, int slot)
 (unsigned long long)btrfs_root_generation(&amp;amp;root_item));
 
 if (root_item.generation == root_item.generation_v2) {
-uuid_unparse(root_item.uuid, uuid_str);
-printf("\t\tuuid %s\n", uuid_str);
+if (count_bytes(root_item.uuid, BTRFS_UUID_SIZE, 0) != BTRFS_UUID_SIZE) {
+uuid_unparse(root_item.uuid, uuid_str);
+printf("\t\tuuid %s\n", uuid_str);
+}
 if (count_bytes(root_item.parent_uuid, BTRFS_UUID_SIZE, 0) != BTRFS_UUID_SIZE) {
 uuid_unparse(root_item.parent_uuid, uuid_str);
 printf("\t\tparent_uuid %s\n", uuid_str);
&lt;/pre&gt;</description>
    <dc:creator>Wang Shilong</dc:creator>
    <dc:date>2013-06-18T03:52:06</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26385">
    <title>[PATCH] Btrfs: fix wrong csum clone when doing relocation</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26385</link>
    <description>&lt;pre&gt;From: Josef Bacik &amp;lt;jbacik&amp;lt; at &amp;gt;fusionio.com&amp;gt;

Patch "Btrfs: remove btrfs_sector_sum structure" introduced a problem
that we copied the checksum value to the wrong address when doing
relocation.

The reason is:
It is very likely that one ordered extent has two or more checksum
structures to keep the relative checksum value, and -&amp;gt;bytenr in each
checksum structure should point to the start of its extent, not the
start of the ordered extent. Fix it.

Signed-off-by: Josef Bacik &amp;lt;jbacik&amp;lt; at &amp;gt;fusionio.com&amp;gt;
Signed-off-by: Miao Xie &amp;lt;miaox&amp;lt; at &amp;gt;cn.fujitsu.com&amp;gt;
---
 fs/btrfs/relocation.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 35c0cf7..e3108e5 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -4410,11 +4410,13 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len)
 if (ret)
 goto out;
 
+disk_bytenr = ordered-&amp;gt;start;
 while (!list_empty(&amp;amp;list)) {
 sums = list_entry(list.next, struct btrfs_ordered_sum, list);
 list_del_init(&amp;amp;sums-&amp;gt;list);
 
-sums-&amp;gt;bytenr = ordered-&amp;gt;start;
+sums-&amp;gt;bytenr = disk_bytenr;
+disk_bytenr += sums-&amp;gt;len;
 
 btrfs_add_ordered_sum(inode, ordered, sums);
 }
&lt;/pre&gt;</description>
    <dc:creator>Miao Xie</dc:creator>
    <dc:date>2013-06-18T03:13:37</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26384">
    <title>Re: [RFC PATCH] Btrfs: optimize csums insertion function</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26384</link>
    <description>&lt;pre&gt;Any comments?

Thanks
Miao

On thu, 13 Jun 2013 20:22:17 +0800, Miao Xie wrote:

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Miao Xie</dc:creator>
    <dc:date>2013-06-18T02:59:11</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26383">
    <title>(unknown)</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26383</link>
    <description>&lt;pre&gt;


Loan Syndicacion

Am AFG Guaranty Trust Bank, zu strukturieren wir Kreditlinien treffen Sie
unsere
Kunden spezifischen geschäftlichen Anforderungen und einen deutlichen
Mehrwert für unsere
Kunden Unternehmen.
eine Division der AFG Finance und Private Bank plc.

Wenn Sie erwägen, eine große Akquisition oder ein Großprojekt sind, können
Sie
brauchen eine erhebliche Menge an Kredit. AFG Guaranty Trust Bank setzen
können
zusammen das Syndikat, das die gesamte Kredit schnürt für
Sie.


Als Bank mit internationaler Reichweite, sind wir gekommen, um Darlehen zu
identifizieren
Syndizierungen als Teil unseres Kerngeschäfts und durch spitzte diese Zeile
aggressiv sind wir an einem Punkt, wo wir kommen, um als erkannt haben
Hauptakteur in diesem Bereich.


öffnen Sie ein Girokonto heute mit einem Minimum Bankguthaben von 500 £ und
Getup zu £ 10.000 als Darlehen und auch den Hauch einer Chance und gewann
die Sterne
Preis von £ 500.000 in die sparen und gewinnen promo in may.aply jetzt.


mit dem Folowing Informationen über Rechtsanwalt steven lee das Konto
Offizier.


FULL NAME;


Wohnadresse;


E-MAIL-ADRESSE;

Telefonnummer;

Nächsten KINS;

MUTTER MAIDEN NAME;


Familienstand;


BÜROADRESSE;

ALTERNATIVE Telefonnummer;

TO &amp;lt; at &amp;gt; yahoo.com bar.stevenlee
NOTE; ALLE Darlehen sind für 10JAHRE RATE VALID
ANGEBOT ENDET BALD SO JETZT HURRY

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>AFG GTBANK LOAN</dc:creator>
    <dc:date>2013-06-17T19:28:00</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26382">
    <title>[PATCH] btrfs-progs: update man page for btrfs filesystem label</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26382</link>
    <description>&lt;pre&gt;btrfs filesystem label can work on a mounted filesystem, also on a
multi-devices filesystem. And the restriction of label name is
changed, too. The man page should be updated accordingly.

Signed-off-by: Guangyu Sun &amp;lt;guangyu.sun&amp;lt; at &amp;gt;oracle.com&amp;gt;
---
 man/btrfs.8.in |   17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/man/btrfs.8.in b/man/btrfs.8.in
index af7df4d..1da4ff1 100644
--- a/man/btrfs.8.in
+++ b/man/btrfs.8.in
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -263,22 +263,13 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; it with the new desired size.  When recreating the partition make sure to use
 the same starting disk cylinder as before.
 .TP
 
-\fBfilesystem label\fP\fI &amp;lt;dev&amp;gt; [newlabel]\fP
-Show or update the label of a filesystem. \fI&amp;lt;dev&amp;gt;\fR is used to identify the
-filesystem. 
+\fBfilesystem label\fP\fI [&amp;lt;device&amp;gt;|&amp;lt;mountpoint&amp;gt;] [newlabel]\fP
+Show or update the label of a filesystem. \fI[&amp;lt;device&amp;gt;|&amp;lt;mountpoint&amp;gt;]\fR is used
+to identify the filesystem. 
 If a \fInewlabel\fR optional argument is passed, the label is changed. The
 following constraints exist for a label:
 .IP
&lt;/pre&gt;</description>
    <dc:creator>Guangyu Sun</dc:creator>
    <dc:date>2013-06-17T21:45:23</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26381">
    <title>Re: Filesystem "somewhat" destroyed - need help for recovery/fixing</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26381</link>
    <description>&lt;pre&gt;Hello Josef

On Mon, Jun 17, 2013 at 11:21 PM, Josef Bacik &amp;lt;jbacik&amp;lt; at &amp;gt;fusionio.com&amp;gt; wrote:


I just gave it a try, but wasn't successful, it seems… Kernel still
crashes.
Maybe checkout the screenphotos at http://goo.gl/DWkRH or
http://imgur.com/a/00pTx

Thanks,

Alexander
--
=&amp;gt;        Google+ =&amp;gt; http://plus.skwar.me         &amp;lt;==
=&amp;gt; Chat (Jabber/Google Talk) =&amp;gt; a.skwar&amp;lt; at &amp;gt;gmail.com &amp;lt;==
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Alexander Skwar</dc:creator>
    <dc:date>2013-06-17T21:43:02</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26380">
    <title>Re: Filesystem "somewhat" destroyed - need help for recovery/fixing</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26380</link>
    <description>&lt;pre&gt;
Pull down my tree

git://github.com/josefbacik/btrfs-progs.git

and build and run the fsck in there and see if it's a bit more friendly.
Thanks,

Josef
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Josef Bacik</dc:creator>
    <dc:date>2013-06-17T21:21:32</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26379">
    <title>[PATCH] Btrfs: move btrfs_truncate_page to btrfs_cont_expand instead of btrfs_truncate</title>
    <link>http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26379</link>
    <description>&lt;pre&gt;This has plagued us forever and I'm so over working around it.  When we truncate
down to a non-page aligned offset we will call btrfs_truncate_page to zero out
the end of the page and write it back to disk, this will keep us from exposing
stale data if we truncate back up from that point.  The problem with this is it
requires data space to do this, and people don't really expect to get ENOSPC
from truncate() for these sort of things.  This also tends to bite the orphan
cleanup stuff too which keeps people from mounting.  To get around this we can
just move this into btrfs_cont_expand() to make sure if we are truncating up
from a non-page size aligned i_size we will zero out the rest of this page so
that we don't expose stale data.  This will give ENOSPC if you try to truncate()
up or if you try to write past the end of isize, which is much more reasonable.
This fixes xfstests generic/083 failing to mount because of the orphan cleanup
failing.  Thanks,

Signed-off-by: Josef Bacik &amp;lt;jbacik&amp;lt; at &amp;gt;fusionio.com&amp;gt;
---
 fs/btrfs/inode.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 3dbfee9..ecf8b5b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -4253,6 +4253,15 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
 u64 hole_size;
 int err = 0;
 
+/*
+ * If our size started in the middle of a page we need to zero out the
+ * rest of the page before we expand the i_size, otherwise we could
+ * expose stale data.
+ */
+err = btrfs_truncate_page(inode, oldsize, 0, 0);
+if (err)
+return err;
+
 if (size &amp;lt;= hole_start)
 return 0;
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -7590,16 +7599,12 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int btrfs_truncate(struct inode *inode)
 {
 struct btrfs_root *root = BTRFS_I(inode)-&amp;gt;root;
 struct btrfs_block_rsv *rsv;
-int ret;
+int ret = 0;
 int err = 0;
 struct btrfs_trans_handle *trans;
 u64 mask = root-&amp;gt;sectorsize - 1;
 u64 min_size = btrfs_calc_trunc_metadata_size(root, 1);
 
-ret = btrfs_truncate_page(inode, inode-&amp;gt;i_size, 0, 0);
-if (ret)
-return ret;
-
 btrfs_wait_ordered_range(inode, inode-&amp;gt;i_size &amp;amp; (~mask), (u64)-1);
 btrfs_ordered_update_i_size(inode, inode-&amp;gt;i_size, NULL);
 
&lt;/pre&gt;</description>
    <dc:creator>Josef Bacik</dc:creator>
    <dc:date>2013-06-17T21:19:24</dc:date>
  </item>
  <textinput rdf:about="http://search.gmane.org/?group=$group=gmane.comp.file-systems.btrfs">
    <title>Search Engine</title>
    <description>Search the mailing list at Gmane</description>
    <name>query</name>
    <link>http://search.gmane.org/?group=$group=gmane.comp.file-systems.btrfs</link>
  </textinput>
</rdf:RDF>
