Re: [PATCH] Btrfs: don't commit the transaction if we dont have enough pinned bytes V2

2011-05-26 Thread Adrian Hunter

On 25/05/11 22:30, Josef Bacik wrote:

I noticed when running an enospc test that we would get stuck committing the
transaction in check_data_space even though we truly didn't have enough space.
So check to see if bytes_pinned is bigger than num_bytes, if it's not don't
commit the transaction.  Thanks,

Signed-off-by: Josef Bacikjo...@redhat.com
---
V1-V2: Make it so it actually compiles ;)
  fs/btrfs/extent-tree.c |7 +++
  1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index c8c3184..b4f67e8 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3199,6 +3199,13 @@ alloc:
}
goto again;
}
+
+   /*
+* If we have less pinned bytes than we want to allocate then
+* don't bother committing the transaction, it won't help us.
+*/
+   if (data_sinfo-bytes_pinned  bytes)
+   committed = 1;
spin_unlock(data_sinfo-lock);

/* commit the current transaction and try again */


I tried that patch on 2.6.39 with the following:

sudo modprobe brd rd_size=262144
sudo mkfs.btrfs /dev/ram0
sudo mkdir -p /mnt/test
sudo mount -t btrfs /dev/ram0 /mnt/test
sudo mkdir -p /mnt/test/test
sudo chown $USER /mnt/test/test
sudo chgrp $USER /mnt/test/test
sudo umount /mnt/test
i=0
while true; do
sudo mount -t btrfs /dev/ram0 /mnt/test
fsstress -c -r -d /mnt/test/test -p 3 -n 1000 -l 10
sudo umount /mnt/test
i=`expr $i \+ 1`
echo $i
done


After 3 iterations it got really slow and then after some minutes it
still seems to lock up:

[ 2059.881182] SysRq : Show Blocked State
[ 2059.881188]   taskPC stack   pid father
[ 2059.881226] btrfs-transacti D 000100046afc 0  2212  2 
0x0080
[ 2059.881233]  880181483d60 0046 0003 
8801
[ 2059.881239]  00013a80 00013a80 00013a80 
880184dac530
[ 2059.881244]  00013a80 880181483fd8 00013a80 
00013a80

[ 2059.881249] Call Trace:
[ 2059.881273]  [a02e8780] wait_for_commit.clone.14+0x90/0xd5 
[btrfs]

[ 2059.881280]  [810692ab] ? wake_up_bit+0x2a/0x2a
[ 2059.881297]  [a02e95b4] 
btrfs_commit_transaction+0x102/0x665 [btrfs]
[ 2059.881312]  [a02e8eae] ? 
join_transaction.clone.21+0x180/0x18b [btrfs]

[ 2059.881316]  [810692ab] ? wake_up_bit+0x2a/0x2a
[ 2059.881331]  [a02e402e] transaction_kthread+0x17a/0x22f [btrfs]
[ 2059.881345]  [a02e3eb4] ? btrfs_congested_fn+0x82/0x82 [btrfs]
[ 2059.881349]  [81068dce] kthread+0x82/0x8a
[ 2059.881355]  [8147db64] kernel_thread_helper+0x4/0x10
[ 2059.881359]  [81068d4c] ? kthread_worker_fn+0x14b/0x14b
[ 2059.881364]  [8147db60] ? gs_change+0x13/0x13
[ 2059.881366] flush-btrfs-5   D 0001000f78a6 0  2219  2 
0x0080
[ 2059.881371]  8801828efb10 0046 0754 
8801
[ 2059.881376]  00013a80 00013a80 00013a80 
8801a53fc530
[ 2059.881382]  00013a80 8801828effd8 00013a80 
00013a80

[ 2059.881386] Call Trace:
[ 2059.881391]  [814750a4] schedule_timeout+0x36/0xe3
[ 2059.881396]  [8107b6c2] ? arch_local_irq_save+0x18/0x1e
[ 2059.881400]  [814762bf] ? _raw_spin_unlock_irqrestore+0x17/0x19
[ 2059.881404]  [8106953e] ? prepare_to_wait+0x6c/0x79
[ 2059.881419]  [a02e9764] 
btrfs_commit_transaction+0x2b2/0x665 [btrfs]

[ 2059.881423]  [810692ab] ? wake_up_bit+0x2a/0x2a
[ 2059.881440]  [a02f2d76] btrfs_write_inode+0x9b/0xa3 [btrfs]
[ 2059.881445]  [81138d78] writeback_single_inode+0x125/0x1bf
[ 2059.881450]  [81139055] writeback_sb_inodes+0xce/0x160
[ 2059.881454]  [81139d68] wb_writeback+0x257/0x3a7
[ 2059.881459]  [81139f40] wb_do_writeback+0x88/0x1a0
[ 2059.881464]  [8105b0a1] ? run_timer_softirq+0x298/0x298
[ 2059.881468]  [8113a0e3] bdi_writeback_thread+0x8b/0x20c
[ 2059.881473]  [8113a058] ? wb_do_writeback+0x1a0/0x1a0
[ 2059.881476]  [81068dce] kthread+0x82/0x8a
[ 2059.881481]  [8147db64] kernel_thread_helper+0x4/0x10
[ 2059.881485]  [81068d4c] ? kthread_worker_fn+0x14b/0x14b
[ 2059.881489]  [8147db60] ? gs_change+0x13/0x13
[ 2059.881493] fsstressD 8801a23f8000 0  2304  1 
0x0084
[ 2059.881497]  880189c93d48 0082  
0400
[ 2059.881502]  00013a80 00013a80 00013a80 
88017bc59710
[ 2059.881507]  00013a80 880189c93fd8 00013a80 
00013a80

[ 2059.881512] Call Trace:
[ 2059.881517]  [8103dadf] ? resched_task+0x48/0x72
[ 2059.881522]  [814750a4] schedule_timeout+0x36/0xe3
[ 

Re: [PATCH] Btrfs: don't commit the transaction if we dont have enough pinned bytes V2

2011-05-26 Thread Josef Bacik
On 05/26/2011 04:57 AM, Adrian Hunter wrote:
 On 25/05/11 22:30, Josef Bacik wrote:
 I noticed when running an enospc test that we would get stuck
 committing the
 transaction in check_data_space even though we truly didn't have
 enough space.
 So check to see if bytes_pinned is bigger than num_bytes, if it's not
 don't
 commit the transaction.  Thanks,

 Signed-off-by: Josef Bacikjo...@redhat.com
 ---
 V1-V2: Make it so it actually compiles ;)
   fs/btrfs/extent-tree.c |7 +++
   1 files changed, 7 insertions(+), 0 deletions(-)

 diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
 index c8c3184..b4f67e8 100644
 --- a/fs/btrfs/extent-tree.c
 +++ b/fs/btrfs/extent-tree.c
 @@ -3199,6 +3199,13 @@ alloc:
   }
   goto again;
   }
 +
 +/*
 + * If we have less pinned bytes than we want to allocate then
 + * don't bother committing the transaction, it won't help us.
 + */
 +if (data_sinfo-bytes_pinned  bytes)
 +committed = 1;
   spin_unlock(data_sinfo-lock);

   /* commit the current transaction and try again */
 
 I tried that patch on 2.6.39 with the following:
 
 sudo modprobe brd rd_size=262144
 sudo mkfs.btrfs /dev/ram0
 sudo mkdir -p /mnt/test
 sudo mount -t btrfs /dev/ram0 /mnt/test
 sudo mkdir -p /mnt/test/test
 sudo chown $USER /mnt/test/test
 sudo chgrp $USER /mnt/test/test
 sudo umount /mnt/test
 i=0
 while true; do
 sudo mount -t btrfs /dev/ram0 /mnt/test
 fsstress -c -r -d /mnt/test/test -p 3 -n 1000 -l 10
 sudo umount /mnt/test
 i=`expr $i \+ 1`
 echo $i
 done
 
 
 After 3 iterations it got really slow and then after some minutes it
 still seems to lock up:
 

Did you run without my patch?  I assume this will still happen even
without my patch.  The only possible negative side-effect of my patch is
we could ENOSPC early.  Thanks,

Josef
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Btrfs: don't commit the transaction if we dont have enough pinned bytes V2

2011-05-25 Thread Josef Bacik
I noticed when running an enospc test that we would get stuck committing the
transaction in check_data_space even though we truly didn't have enough space.
So check to see if bytes_pinned is bigger than num_bytes, if it's not don't
commit the transaction.  Thanks,

Signed-off-by: Josef Bacik jo...@redhat.com
---
V1-V2: Make it so it actually compiles ;)
 fs/btrfs/extent-tree.c |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index c8c3184..b4f67e8 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3199,6 +3199,13 @@ alloc:
}
goto again;
}
+
+   /*
+* If we have less pinned bytes than we want to allocate then
+* don't bother committing the transaction, it won't help us.
+*/
+   if (data_sinfo-bytes_pinned  bytes)
+   committed = 1;
spin_unlock(data_sinfo-lock);
 
/* commit the current transaction and try again */
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html