[PATCH v2] Btrfs: make xattr replace operations atomic

2014-11-07 Thread Filipe Manana
Oliva for reporting the non-atomicity of the xattr replace implementation. Reported-by: Alexandre Oliva ol...@gnu.org Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Added missing btrfs_mark_buffer_dirty() call for the case where a replace happens for an item with no other xattrs

[PATCH v3] Btrfs: make xattr replace operations atomic

2014-11-08 Thread Filipe Manana
Oliva for reporting the non-atomicity of the xattr replace implementation. Reported-by: Alexandre Oliva ol...@gnu.org Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Added missing btrfs_mark_buffer_dirty() call for the case where a replace happens for an item with no other xattrs

[PATCH v4] Btrfs: make xattr replace operations atomic

2014-11-09 Thread Filipe Manana
Oliva for reporting the non-atomicity of the xattr replace implementation. Reported-by: Alexandre Oliva ol...@gnu.org Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Added missing btrfs_mark_buffer_dirty() call for the case where a replace happens for an item with no other xattrs

[PATCH v2] fstests: add generic test to verify xattr replace operations are atomic

2014-11-09 Thread Filipe Manana
and listxattrs) not getting neither the old nor the new value during a short time window. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Several changes after Dave's review. Renamed test file, added test to the metadata category and filtered xattr value out of getfattr to include

[PATCH v2] fstests: btrfs, add regression test for clone ioctl

2014-11-10 Thread Filipe Manana
. This affected only buffered reads (i.e. didn't affect direct IO reads). This issue was fixed by the following linux kernel patch: Btrfs: ensure readers see new data after a clone operation (commit c125b8bff1d9f6c8c91ce4eb8bd5616058c7d510) Signed-off-by: Filipe Manana fdman...@suse.com --- V2

[PATCH] Btrfs: don't ignore log btree writeback errors

2014-11-13 Thread Filipe Manana
-by: Filipe Manana fdman...@suse.com --- fs/btrfs/tree-log.c | 21 +++-- 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 6d58d72..c8274d3 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -2599,12 +2599,14

[PATCH] Btrfs: collect only the necessary ordered extents on ranged fsync

2014-11-13 Thread Filipe Manana
Instead of collecting all ordered extents from the inode's ordered tree and then wait for all of them to complete, just collect the ones that overlap the fsync range. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/ordered-data.c | 16 +--- fs/btrfs/ordered-data.h | 4

[PATCH] Btrfs: ensure ordered extent errors aren't missed on fsync

2014-11-13 Thread Filipe Manana
from the inode's i_mapping. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/ctree.h| 1 + fs/btrfs/inode.c| 15 +++ fs/btrfs/tree-log.c | 21 + 3 files changed, 37 insertions(+) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 299c439

[PATCH 6/6] Btrfs: make btrfs_abort_transaction consider existence of new block groups

2014-11-26 Thread Filipe Manana
) in btrfs_free_chunk:2509: errno=-2 No such entry (Failed lookup while freeing chunk.) Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/extent-tree.c | 5 +++-- fs/btrfs/super.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c

[PATCH 5/6] Btrfs: fix race between writing free space cache and trimming

2014-11-26 Thread Filipe Manana
for 521764864-1103101952 cache appears valid but isnt 29360128 Checking filesystem on /dev/sdc UUID: b4789e27-4774-4626-98e9-ae8dfbfb0fb5 found 1235681286 bytes used err is -22 (...) Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/free-space-cache.c

[PATCH 0/6] Btrfs: fixes for block group remove/allocation and trim/discard

2014-11-26 Thread Filipe Manana
files), 4 virtual CPUs and 4Gb of ram. Some of these issues were hard to trigger and happened like once for every 10+ runs of the test (each test run takes nearly 30 minutes with my hardware and a debug kernel). Filipe Manana (6): Btrfs: fix invalid block group rbtree access after bg is removed

[PATCH 3/6] Btrfs: fix freeing used extents after removing empty block group

2014-11-26 Thread Filipe Manana
adding the block group to the unused_bgs list. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/extent-tree.c | 21 ++--- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index b7e40ef..92f61f2 100644 --- a/fs

[PATCH 1/6] Btrfs: fix invalid block group rbtree access after bg is removed

2014-11-26 Thread Filipe Manana
a block group's node after removing it from the tree, and have next_block_group() do a tree search to get the next block group instead of using rb_next() if our block group was removed. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/extent-tree.c | 13 + 1 file changed, 13

[PATCH 4/6] Btrfs: fix race between fs trimming and block group remove/allocation

2014-11-26 Thread Filipe Manana
count wrong unresolved ref dir 256 index 0 namelen 8 name foobar_5 filetype 1 errors 6, no dir index, no inode ref root 5 inode 263 errors 2001, no inode item, link count wrong (...) Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/ctree.h| 13

[PATCH 2/6] Btrfs: fix crash caused by block group removal

2014-11-26 Thread Filipe Manana
] ? btrfs_cleanup_transaction+0x3d8/0x3d8 [btrfs] [58380.443238] [8105966b] kthread+0xb7/0xbf [58380.443238] [810595b4] ? __kthread_parkme+0x67/0x67 [58380.443238] [813ebeac] ret_from_fork+0x7c/0xb0 [58380.443238] [810595b4] ? __kthread_parkme+0x67/0x67 Signed-off-by: Filipe Manana

[PATCH] fstests: add btrfs test to stress chunk allocation/removal and fstrim

2014-11-26 Thread Filipe Manana
ranging from invalid memory accesses, kernel crashes, metadata or data corruption, free space cache inconsistencies and free space leaks. Signed-off-by: Filipe Manana fdman...@suse.com --- tests/btrfs/082 | 148 tests/btrfs/082.out | 2

[PATCH v2 4/6] Btrfs: fix race between fs trimming and block group remove/allocation

2014-11-26 Thread Filipe Manana
count wrong unresolved ref dir 256 index 0 namelen 8 name foobar_5 filetype 1 errors 6, no dir index, no inode ref root 5 inode 263 errors 2001, no inode item, link count wrong (...) Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Added a comment to better

[PATCH v3 4/6] Btrfs: fix race between fs trimming and block group remove/allocation

2014-11-26 Thread Filipe Manana
count wrong unresolved ref dir 256 index 0 namelen 8 name foobar_5 filetype 1 errors 6, no dir index, no inode ref root 5 inode 263 errors 2001, no inode item, link count wrong (...) Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Added a comment to better

[PATCH v4 4/6] Btrfs: fix race between fs trimming and block group remove/allocation

2014-11-27 Thread Filipe Manana
count wrong unresolved ref dir 256 index 0 namelen 8 name foobar_5 filetype 1 errors 6, no dir index, no inode ref root 5 inode 263 errors 2001, no inode item, link count wrong (...) Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Added a comment to better

[PATCH v2 5/6] Btrfs: fix race between writing free space cache and trimming

2014-12-01 Thread Filipe Manana
to finish and doesn't miss any free space entry. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Enlonged the critical section to include the cache writeout of bitmaps, since I ran into this recently. The issue is that a concurrent trim can modify or free the bitmaps while

[PATCH] Btrfs: fix extent map leak on chunk allocation failure

2014-12-01 Thread Filipe Manana
] [8121261b] ? trace_hardirqs_on_thunk+0x3a/0x3c [20770.106184] [813ebf52] system_call_fastpath+0x16/0x1b Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/volumes.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 66a5a1e..e936fe3

[PATCH] Btrfs: fix memory leak after block remove + trimming

2014-12-01 Thread Filipe Manana
] [8122a7eb] ? trace_hardirqs_on_thunk+0x3a/0x3f [ 8234.642773] [814122d2] system_call_fastpath+0x16/0x1b This applies on top (depends on) of my previous patch titled: Btrfs: fix race between fs trimming and block group remove/allocation Signed-off-by: Filipe Manana fdman...@suse.com --- fs

[PATCH] fstests: add btrfs test to stress chunk allocation/removal and fstrim

2014-12-01 Thread Filipe Manana
ranging from invalid memory accesses, kernel crashes, metadata or data corruption, free space cache inconsistencies, free space leaks and memory leaks. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Addressed Dave's comments. tests/generic/038 | 152

[PATCH 2/2] Btrfs: fix unprotected deletion from pending_chunks list

2014-12-02 Thread Filipe Manana
was already present before that change, it only became easier to hit after Josef's 3.18 patch that added automatic removal of empty block groups. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/extent-tree.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/btrfs

[PATCH 1/2] Btrfs: fix fs mapping extent map leak

2014-12-02 Thread Filipe Manana
-off-by: Filipe Manana fdman...@suse.com --- This replaces my previous patch titled: Btrfs: fix extent map leak on chunk allocation failure fs/btrfs/extent-tree.c | 4 fs/btrfs/volumes.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c

[PATCH v3] fstests: add btrfs test to stress chunk allocation/removal and fstrim

2014-12-02 Thread Filipe Manana
ranging from invalid memory accesses, kernel crashes, metadata or data corruption, free space cache inconsistencies, free space leaks and memory leaks. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Addressed Dave's comments. V3: Missing s/_supported_fs btrfs/_supported_fs generic

[PATCH] Btrfs: ensure deletion from pinned_chunks list is protected

2014-12-04 Thread Filipe Manana
. This fixes an overlook of the patch titled Btrfs: fix race between fs trimming and block group remove/allocation following the same obvervation from the patch titled Btrfs: fix unprotected deletion from pending_chunks list. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/free-space-cache.c

[PATCH] Btrfs: always clear a block group node when removing it from the tree

2014-12-04 Thread Filipe Manana
invalid block group rbtree access after bg is removed Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/extent-tree.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a7b81b4..c2fc261 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs

[PATCH] Btrfs: fix fs corruption on transaction abort if device supports discard

2014-12-06 Thread Filipe Manana
2011 (git commit acce952b0263825da32cf10489413dec78053347). Cc: sta...@vger.kernel.org # any kernel released after 2011-01-06 Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/ctree.h | 2 -- fs/btrfs/disk-io.c | 7 --- fs/btrfs/extent-tree.c | 5 - 3 files changed, 14

[PATCH v2] Btrfs: fix fs corruption on transaction abort if device supports discard

2014-12-07 Thread Filipe Manana
2011 (git commit acce952b0263825da32cf10489413dec78053347). Cc: sta...@vger.kernel.org # any kernel released after 2011-01-06 Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Avoid a warning when freeing the block group objects, since they got their pinned field with a value 0 when

[PATCH] Btrfs: remove non-sense btrfs_error_discard_extent() function

2014-12-08 Thread Filipe Manana
It doesn't do anything special, it just calls btrfs_discard_extent(), so just remove it. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/ctree.h| 4 ++-- fs/btrfs/extent-tree.c | 10 ++ fs/btrfs/free-space-cache.c | 4 ++-- 3 files changed, 6 insertions

[PATCH] Btrfs: correctly get tree level in tree_backref_for_extent

2014-12-15 Thread Filipe Manana
at logical 42123264 on dev /dev/sde, sector 15840: metadata node (level 24) in tree 5 Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/backref.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 2d3e32e

[PATCH v2] Btrfs: fix fsync race leading to ordered extent memory leaks

2015-02-06 Thread Filipe Manana
: make sure logged extents complete in the current transaction V3 commit 50d9aa99bd35c77200e0e3dd7a72274f8304701f CC: sta...@vger.kernel.org # 3.19, 3.18 and 3.17 Signed-off-by: Filipe Manana fdman...@suse.com --- V2: No code changes, re-worded commit message and diagram. CC'ed stable too

[PATCH v3] Btrfs: fix fsync race leading to ordered extent memory leaks

2015-02-07 Thread Filipe Manana
: sta...@vger.kernel.org # 3.19, 3.18 and 3.17 Signed-off-by: Filipe Manana fdman...@suse.com --- V2: No code changes, re-worded commit message and diagram. CC'ed stable too. V3: No code changes, only adjusted commit message and its diagram to be more accurate. fs/btrfs/ordered-data.c

[PATCH] Btrfs: fix race waiting for ordered extents at transaction commit

2015-02-06 Thread Filipe Manana
was introduced with the following change (added in 3.19 and backported to stable 3.18 and 3.17): Btrfs: make sure logged extents complete in the current transaction V3 commit 50d9aa99bd35c77200e0e3dd7a72274f8304701f CC: sta...@vger.kernel.org # 3.19, 3.18 and 3.17 Signed-off-by: Filipe Manana fdman

[PATCH] Btrfs: fix fsync race leading to ordered extent memory leaks

2015-02-06 Thread Filipe Manana
logged extents complete in the current transaction V3 commit 50d9aa99bd35c77200e0e3dd7a72274f8304701f Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/ordered-data.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered

[PATCH v4] Btrfs: fix fsync race leading to ordered extent memory leaks

2015-02-07 Thread Filipe Manana
extents complete in the current transaction V3 commit 50d9aa99bd35c77200e0e3dd7a72274f8304701f CC: sta...@vger.kernel.org # 3.19, 3.18 and 3.17 Signed-off-by: Filipe Manana fdman...@suse.com --- V2: No code changes, re-worded commit message and diagram. CC'ed stable too. V3: No code changes

[PATCH] Btrfs: fix race deleting block group from space_info-ro_bgs list

2015-01-15 Thread Filipe Manana
another block group to readonly mode (which adds it to the list space_info-ro_bgs). This happened while running the stress test xfstests/generic/038 I recently made. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/extent-tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion

[PATCH] fstests: fix test btrfs/017 (qgroup shared extent accounting test)

2015-01-14 Thread Filipe Manana
. Signed-off-by: Filipe Manana fdman...@suse.com --- tests/btrfs/017 | 6 +- tests/btrfs/017.out | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/btrfs/017 b/tests/btrfs/017 index 7937607..d00d7c8 100755 --- a/tests/btrfs/017 +++ b/tests/btrfs/017 @@ -56,7

[PATCH] Btrfs: fix setup_leaf_for_split() to avoid leaf corruption

2015-01-20 Thread Filipe Manana
btrfs_header_nritems(path-nodes[0]) + 1, causing an invalid memory access if the leaf is full or nearly full. This issue has been present since the introduction of this function in 2009: Btrfs: Add btrfs_duplicate_item commit ad48fd754676bfae4139be1a897b1ea58f9aaf21 Signed-off-by: Filipe Manana

[PATCH v2] Btrfs: fix race deleting block group from space_info-ro_bgs list

2015-01-16 Thread Filipe Manana
. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Added a comment to struct btrfs_space_info mentioning the ro_bgs list is protected by the spinlock member 'lock'. Reworded a bit commit message to remove irrelevant details. fs/btrfs/ctree.h | 1 + fs/btrfs/extent-tree.c | 2 +- 2

[PATCH v2] Btrfs: fix fsync data loss after adding hard link to inode

2015-02-12 Thread Filipe Manana
/regression. This problem has been around since the log tree code was added in 2008: Btrfs: Add a write ahead tree log to optimize synchronous operations (commit e02119d5a7b4396c5a872582fddc8bd6d305a70a) Test cases for xfstests follow soon. CC: sta...@vger.kernel.org Signed-off-by: Filipe Manana fdman

[PATCH] fstests: generic, test fsync after adding hard link differently

2015-02-12 Thread Filipe Manana
-by: Filipe Manana fdman...@suse.com --- tests/generic/043 | 110 ++ tests/generic/043.out | 17 tests/generic/group | 1 + 3 files changed, 128 insertions(+) create mode 100755 tests/generic/043 create mode 100644 tests/generic/043

[PATCH v3] Btrfs: fix fsync data loss after adding hard link to inode

2015-02-12 Thread Filipe Manana
/regression. This problem has been around since the log tree code was added in 2008: Btrfs: Add a write ahead tree log to optimize synchronous operations (commit e02119d5a7b4396c5a872582fddc8bd6d305a70a) Test cases for xfstests follow soon. CC: sta...@vger.kernel.org Signed-off-by: Filipe Manana fdman

[PATCH] Btrfs: fix metadata inconsistencies after directory fsync

2015-02-19 Thread Filipe Manana
. A test case for xfstests follows. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/file.c | 5 +- fs/btrfs/tree-log.c | 175 ++-- fs/btrfs/tree-log.h | 2 + 3 files changed, 176 insertions(+), 6 deletions(-) diff --git a/fs/btrfs

[PATCH] fstests: generic test for directory fsync after adding hard links

2015-02-19 Thread Filipe Manana
that btrfs has the same behaviour as xfs and ext4. The btrfs issue was fixed by the following linux kernel patch: Btrfs: fix metadata inconsistencies after directory fsync Signed-off-by: Filipe Manana fdman...@suse.com --- tests/generic/060 | 150

[PATCH v2] Btrfs: fix scrub race leading to use-after-free

2015-01-27 Thread Filipe Manana
a2de733c78fa7af51ba9670482fa7d392aa67c57). Signed-off-by: Filipe Manana fdman...@suse.com --- V2: No code changes, updated only commit message's sequence diagram and added a second one for a slightly different case. fs/btrfs/scrub.c | 16 +++- 1 file changed, 15 insertions(+), 1 deletion

[PATCH] Btrfs: fix race between transaction commit and empty block group removal

2015-01-29 Thread Filipe Manana
in a synchronized fashion with removing the block group's range from freed_extents[] in btrfs_delete_unused_bgs() This race got introduced with the change: Btrfs: remove empty block groups automatically commit 47ab2a6c689913db23ccae38349714edf8365e0a Signed-off-by: Filipe Manana fdman

[PATCH] Btrfs: fix scrub race leading to use-after-free

2015-01-27 Thread Filipe Manana
, flags) Fix this by holding the scrub lock while doing the wakeup. This isn't a recent regression, the issue as been around since the scrub feature was added (2011, commit a2de733c78fa7af51ba9670482fa7d392aa67c57). Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/scrub.c | 16

[PATCH v2] fstests: add generic test for fsync after unlink

2015-01-10 Thread Filipe Manana
-off-by: Filipe Manana fdman...@suse.com --- V2: Fixed copyright year, s/2014/2015/. Updated comments to add more details about the issue. tests/generic/039 | 112 ++ tests/generic/039.out | 2 + tests/generic/group | 1 + 3 files

[PATCH v2] Btrfs: fix directory inconsistency after fsync log replay

2015-01-10 Thread Filipe Manana
. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: No changes, only updated commit message to be more detailed. fs/btrfs/tree-log.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 9a02da1..1d65a46 100644

[PATCH] fstests: add generic test for fsync after unlink

2015-01-06 Thread Filipe Manana
which prevented the directory from ever being removed (rmdir always failed with -ENOTEMPTY, even if the directory had no more child inodes). The btrfs issue was fixed by the following linux kernel patch: Btrfs: fix directory inconsistency after fsync log replay Signed-off-by: Filipe Manana

[PATCH] Btrfs: fix directory inconsistency after fsync log replay

2015-01-06 Thread Filipe Manana
is greater than 1 and its parent inode is not yet in the fsync log, we end up logging the parent inode. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/tree-log.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs

[PATCH] Btrfs: lookup for block group only if needed when freeing a tree block

2015-01-06 Thread Filipe Manana
of time we are holding the parent node's lock. For example, for a run of xfstests/generic/083, the block group cache object was needed only 682 times for a total of 226691 calls to free a tree block. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/extent-tree.c | 10 ++ 1 file

[PATCH v2] Btrfs: fix fsync log replay for inodes with a mix of regular refs and extrefs

2015-01-13 Thread Filipe Manana
feature (2012). A test case for xfstests follows soon. This test only passes if the previous patch titled Btrfs: fix fsync when extend references are added to an inode is applied too. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Deal with another case (and updated test case) where

[PATCH v3] Btrfs: fix fsync log replay for inodes with a mix of regular refs and extrefs

2015-01-13 Thread Filipe Manana
feature (2012). A test case for xfstests follows soon. This test only passes if the previous patch titled Btrfs: fix fsync when extend references are added to an inode is applied too. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Deal with another case (and updated test case) where

[PATCH v2 2/2] fstests: add another generic test for fsync on inode with many hard links

2015-01-13 Thread Filipe Manana
kernel patches: Btrfs: fix fsync when extend references are added to an inode Btrfs: fix fsync log replay for inodes with a mix of regular refs and extrefs This issue was present in btrfs since the extrefs (extend references) feature was added (2012). Signed-off-by: Filipe Manana fdman

[PATCH] Btrfs: fix fsync when extend references are added to an inode

2015-01-13 Thread Filipe Manana
case for xfstests follows soon. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/tree-log.c | 24 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 1d65a46..ecf462a 100644 --- a/fs/btrfs/tree-log.c

[PATCH] Btrfs: fix fsync log replay for inodes with a mix of regular refs and extrefs

2015-01-13 Thread Filipe Manana
Btrfs: fix fsync when extend references are added to an inode is applied too. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/tree-log.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index ecf462a..a1ce105 100644

[PATCH 2/2] fstests: add another generic test for fsync on inode with many hard links

2015-01-13 Thread Filipe Manana
kernel patches: Btrfs: fix fsync when extend references are added to an inode Btrfs: fix fsync log replay for inodes with a mix of regular refs and extrefs This issue was present in btrfs since the extrefs (extend references) feature was added (2012). Signed-off-by: Filipe Manana fdman

[PATCH 1/2] fstests: add generic test for fsync on inode with many hard links

2015-01-13 Thread Filipe Manana
, resulting in -ESTALE errors). The btrfs issue was fixed by the following linux kernel patch: Btrfs: fix fsync when extend references are added to an inode This issue was present in btrfs since the extrefs (extend references) feature was added (2012). Signed-off-by: Filipe Manana fdman...@suse.com

[PATCH v2] Btrfs: fix fsync when extend references are added to an inode

2015-01-13 Thread Filipe Manana
case for xfstests follows soon. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Removed existing useless if conditional. fs/btrfs/tree-log.c | 27 --- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index

[PATCH v5] Btrfs: fix fsync race leading to ordered extent memory leaks

2015-02-09 Thread Filipe Manana
] SyS_io_submit+0x10/0x12 [81429e92] system_call_fastpath+0x12/0x17 CC: sta...@vger.kernel.org # 3.19, 3.18 and 3.17 Signed-off-by: Filipe Manana fdman...@suse.com --- V2: No code changes, re-worded commit message and diagram. CC'ed stable too. V3: No code changes, only adjusted commit

[PATCH v3] Btrfs: don't remove extents and xattrs when logging new names

2015-02-13 Thread Filipe Manana
$SCRATCH_MNT/foo The test case for xfstests follows soon. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Added missing assignment to max_key.type for directory inode case. V3: Fixed the test/clear bit logic so that the bits are only cleared if we aren't logging new names. fs/btrfs

[PATCH v2] Btrfs: don't remove extents and xattrs when logging new names

2015-02-13 Thread Filipe Manana
$SCRATCH_MNT/foo The test case for xfstests follows soon. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Added missing assignment to max_key.type for directory inode case. fs/btrfs/tree-log.c | 23 +-- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/fs

[PATCH] Btrfs: fix scheduler warning when syncing log

2015-02-11 Thread Filipe Manana
[30736.832982] ---[ end trace c0b57df60d32ae5c ]--- Fix this my acquiring the mutex after calling finish_wait(), which sets the task's state to TASK_RUNNING. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/tree-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs

[PATCH] Btrfs: scrub, fix sleep in atomic context

2015-02-09 Thread Filipe Manana
instead of locking the scrub_lock mutex. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/scrub.c | 39 +++ 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index d5d790c..ec57687 100644 --- a/fs/btrfs

[PATCH v2] Btrfs: fix race waiting for ordered extents at transaction commit

2015-02-09 Thread Filipe Manana
was introduced with the following change (added in 3.19 and backported to stable 3.18 and 3.17): Btrfs: make sure logged extents complete in the current transaction V3 commit 50d9aa99bd35c77200e0e3dd7a72274f8304701f CC: sta...@vger.kernel.org # 3.19, 3.18 and 3.17 Signed-off-by: Filipe Manana

[PATCH] Btrfs: fix fsync data loss after adding hard link to inode

2015-02-12 Thread Filipe Manana
...@vger.kernel.org Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/tree-log.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index ea0431d..8d8ae1e 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -3263,14 +3263,13

[PATCH] fstests: add generic test for fsync after creating hard link

2015-02-12 Thread Filipe Manana
by the following linux kernel patch: Btrfs: fix fsync data loss after adding hard link to inode Signed-off-by: Filipe Manana fdman...@suse.com --- tests/generic/042 | 99 +++ tests/generic/042.out | 11 ++ tests/generic/group | 1 + 3

[PATCH v2] fstests: generic, test fsync after adding hard link differently

2015-02-13 Thread Filipe Manana
-by: Filipe Manana fdman...@suse.com --- V2: Updated two comments with more details about the issue. tests/generic/043 | 112 ++ tests/generic/043.out | 17 tests/generic/group | 1 + 3 files changed, 130 insertions(+) create mode

[PATCH v4] Btrfs: fix fsync data loss after adding hard link to inode

2015-02-13 Thread Filipe Manana
(commit e02119d5a7b4396c5a872582fddc8bd6d305a70a) Test cases for xfstests follow soon. CC: sta...@vger.kernel.org Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Fixed additional similar case where the inode already existed in the fs/subvol tree. Made an xfstest for that case too. V3

[PATCH] Btrfs: don't remove extents and xattrs when logging new names

2015-02-13 Thread Filipe Manana
$SCRATCH_MNT/foo The test case for xfstests follows soon. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/tree-log.c | 19 ++- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index b0fe52a..0f00569 100644

[PATCH] Btrfs: add missing inode update when punching hole

2015-02-15 Thread Filipe Manana
the punch hole implementation was added, commit 2aaa66558172 (Btrfs: add hole punching). A test case for xfstests follows soon. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/file.c | 31 --- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/fs/btrfs

[PATCH] fstests: generic test for fsync after punching hole

2015-02-15 Thread Filipe Manana
(or its metadata) was performed. The btrfs issue was fixed by the following linux kernel patch: Btrfs: add missing inode update when punching hole Signed-off-by: Filipe Manana fdman...@suse.com --- tests/generic/045 | 120 ++ tests/generic

[PATCH v2] Btrfs: fix metadata inconsistencies after directory fsync

2015-02-19 Thread Filipe Manana
. A test case for xfstests follows. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Speedup search when there's a gap between dentry indexes, and we reached the last slot of a leaf, by using btrfs_next_leaf(). fs/btrfs/file.c | 5 +- fs/btrfs/tree-log.c | 184

[PATCH v2] Btrfs: change the insertion criteria for the qgroup operations rbtree

2015-03-14 Thread Filipe Manana
as expected. This patch applies on top of the patch mentioned above from Liu. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Added a fancy example rbtree to the commit message in order to better explain the bug. No code changes. fs/btrfs/qgroup.c | 8 1 file changed, 4 insertions

[PATCH v5] Btrfs: fix metadata inconsistencies after directory fsync

2015-03-20 Thread Filipe Manana
So fix this by logging the inodes that the dentries point to when fsyncing a directory. A test case for xfstests follows. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Speedup search when there's a gap between dentry indexes, and we reached the last slot of a leaf, by using

[PATCH v6] Btrfs: fix metadata inconsistencies after directory fsync

2015-03-20 Thread Filipe Manana
So fix this by logging the inodes that the dentries point to when fsyncing a directory. A test case for xfstests follows. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Speedup search when there's a gap between dentry indexes, and we reached the last slot of a leaf, by using

[PATCH v6] Btrfs: fix metadata inconsistencies after directory fsync

2015-03-20 Thread Filipe Manana
So fix this by logging the inodes that the dentries point to when fsyncing a directory. A test case for xfstests follows. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Speedup search when there's a gap between dentry indexes, and we reached the last slot of a leaf, by using

[PATCH] Btrfs: change the insertion criteria for the qgroup operations rbtree

2015-03-13 Thread Filipe Manana
exists. Fix this by changing the insertion navigation function to use the ref_root field right after using the bytenr field and before using the seq field. This patch applies on top of the patch mentioned above from Liu. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/qgroup.c | 8

[PATCH] Btrfs: incremental send, clear name from cache after orphanization

2015-03-12 Thread Filipe Manana
of o263-6-o/p2 for the rename operation instead of the old path data/p1/p2 (the one before the orphanization of inode 263). A test case for xfstests follows soon. Reported-by: Robbie Ko robbi...@synology.com Signed-off-by: Filipe Manana fdman...@suse.com --- This is a re-send, since my git send

[PATCH] Btrfs: add missing inode item update in fallocate()

2015-03-12 Thread Filipe Manana
/foobar 000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 200 A test case for fstests follows soon. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/file.c | 21 - 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/file.c b/fs

[PATCH] fstests: generic test for fallocate

2015-03-12 Thread Filipe Manana
fallocate wouldn't update the inode's i_size on disk, fixed by the following btrfs patch: Btrfs: add missing inode item update in fallocate(). Signed-off-by: Filipe Manana fdman...@suse.com --- tests/generic/071 | 79 +++ tests/generic/071.out

[PATCH] Btrfs: incremental send, remove dead code

2015-03-12 Thread Filipe Manana
(as well as all the other test cases for send/receive). Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/send.c | 59 - 1 file changed, 59 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 00cb924..a1216f9 100644

[PATCH v2] Btrfs: add missing inode item update in fallocate()

2015-03-13 Thread Filipe Manana
/foobar 000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 200 A test case for fstests follows soon. Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Update the inode's sizes and ctime while holding a transaction open. fs/btrfs/file.c | 29

[PATCH] Btrfs: incremental send, clear name from cache after orphanization

2015-03-12 Thread Filipe Manana
of o263-6-o/p2 for the rename operation instead of the old path data/p1/p2 (the one before the orphanization of inode 263). A test case for xfstests follows soon. Reported-by: Robbie Ko robbi...@synology.com Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/send.c | 17

[PATCH] fstests: test for btrfs incremental send/receive

2015-03-12 Thread Filipe Manana
cache after orphanization Signed-off-by: Filipe Manana fdman...@suse.com --- tests/btrfs/084 | 132 tests/btrfs/084.out | 2 + tests/btrfs/group | 1 + 3 files changed, 135 insertions(+) create mode 100755 tests/btrfs/084 create mode

[PATCH] fstests: test for btrfs cloning of zero length ranges

2015-03-30 Thread Filipe Manana
linux kernel patch: Btrfs: fix inode eviction infinite loop after cloning into it Signed-off-by: Filipe Manana fdman...@suse.com --- tests/btrfs/086 | 77 + tests/btrfs/086.out | 2 ++ tests/btrfs/group | 1 + 3 files changed, 80

[PATCH] Btrfs: fix inode eviction infinite loop after cloning into it

2015-03-30 Thread Filipe Manana
-s 0 -d 4096 -l 0 $SCRATCH_MNT/foo $SCRATCH_MNT/bar umount $SCRATCH_MNT A test case for fstests follows soon. CC: sta...@vger.kernel.org Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/ioctl.c | 5 + 1 file changed, 5 insertions(+) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs

[PATCH] Btrfs: fix inode eviction infinite loop after extent_same ioctl

2015-03-30 Thread Filipe Manana
. This is the same problem that my previous patch titled Btrfs: fix inode eviction infinite loop after cloning into it addressed but for the extent_same ioctl instead of the clone ioctl. CC: sta...@vger.kernel.org Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/ioctl.c | 3 +++ 1 file

[PATCH v2] fstests: test for btrfs cloning of zero length ranges

2015-03-30 Thread Filipe Manana
linux kernel patch: Btrfs: fix inode eviction infinite loop after cloning into it Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Use an offset of 64Kb so that the test can run on platforms with any page size. In btrfs the fs block size must be a multiple of the page size, so

[PATCH] Btrfs: fix range cloning when same inode used as source and destination

2015-03-31 Thread Filipe Manana
soon. Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/ioctl.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 09a566a..869e39d 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3205,6 +3205,8 @@ static int

[PATCH] fstests: regression test for btrfs file range cloning

2015-03-31 Thread Filipe Manana
range cloning when same inode used as source and destination Signed-off-by: Filipe Manana fdman...@suse.com --- tests/btrfs/087 | 102 tests/btrfs/087.out | 35 ++ tests/btrfs/group | 1 + 3 files changed, 138 insertions

[PATCH] Btrfs: avoid syncing log in the fast fsync path when not necessary

2015-04-01 Thread Filipe Manana
ying.hu...@intel.com Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/file.c | 9 ++--- fs/btrfs/ordered-data.c | 14 ++ fs/btrfs/ordered-data.h | 3 +++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 309dd57

[PATCH] Btrfs: add debugfs file to test transaction aborts

2015-03-31 Thread Filipe Manana
*** end fsck.btrfs output [1] commit 678886bdc637 (Btrfs: fix fs corruption on transaction abort if device supports discard) Signed-off-by: Filipe Manana fdman...@suse.com --- If there are no objections to the feature/interface, I will submit a test for fstests. fs/btrfs

[PATCH v2] Btrfs: add debugfs file to test transaction aborts

2015-03-31 Thread Filipe Manana
when fs mounted with -o discard Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Allow this to select by label which filesystem will have its transaction aborted. The previous version made a transaction abort for every mounted btrfs filesystem. It was not a problem in my test vm since

[PATCH] Btrfs: fix log tree corruption when fs mounted with -o discard

2015-03-23 Thread Filipe Manana
the new super block is committed) at extent-tree.c:btrfs_finish_extent_commit(). Fixes: e688b7252f78 (Btrfs: fix extent pinning bugs in the tree log) CC: sta...@vger.kernel.org Signed-off-by: Filipe Manana fdman...@suse.com --- fs/btrfs/extent-tree.c | 5 ++--- 1 file changed, 2 insertions(+), 3

[PATCH v2] Btrfs: fix log tree corruption when fs mounted with -o discard

2015-03-23 Thread Filipe Manana
the new super block is committed) at extent-tree.c:btrfs_finish_extent_commit(). Fixes: e688b7252f78 (Btrfs: fix extent pinning bugs in the tree log) CC: sta...@vger.kernel.org Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Do the discard before returning the space to the free space cache

[PATCH v3] Btrfs: fix data loss in the fast fsync path

2015-03-03 Thread Filipe Manana
. CC: sta...@vger.kernel.org Signed-off-by: Filipe Manana fdman...@suse.com --- V2: Removed dead assignment of inode-last_trans in btrfs_file_write_iter (and the respective comment) since it's useless now. Added stable to cc because it's a data loss fix. V3: After removing the statement

<    1   2   3   4   5   6   7   8   >