[PATCH] btrfs-progs: Fix segmentation fault

2013-06-22 Thread Kusanagi Kouichi
'btrfs subvolume delete' crashes with segv if it runs in a detached mount.

Steps to reprduce:
# mkfs.btrfs /dev/vdb

WARNING! - Btrfs v0.20-rc1 IS EXPERIMENTAL
WARNING! - see http://btrfs.wiki.kernel.org before using

fs created label (null) on /dev/vdb
nodesize 4096 leafsize 4096 sectorsize 4096 size 2.00GB
Btrfs v0.20-rc1
# mount -t btrfs /dev/vdb /mnt
[  333.689984] device fsid b242775b-5e34-4e8b-8f7f-7db585ba1392 devid 1 transid 
4 /dev/vdb
[  333.691756] btrfs: disk space caching is enabled
# cd /mnt
# btrfs subvolume create vol
Create subvolume './vol'
# btrfs subvolume snapshot vol snap
Create a snapshot of 'vol' in './snap'
# umount -l .
# btrfs subvolume delete snap
[  377.897175] btrfs[1875]: segfault at 0 ip 7f6f86100131 sp 
7fff17917318 error 4 in libc-2.17.so[7f6f8607c000+1a4000]
Segmentation fault (core dumped)


Backtrace:
#0  __strlen_sse2 () at ../sysdeps/x86_64/multiarch/../strlen.S:31
No locals.
#1  0x7f6f860ffda6 in __GI___strdup (s=0x0) at strdup.c:41
len = optimized out
new = optimized out
#2  0x00405a3d in cmd_subvol_delete (argc=2, argv=optimized out) at 
cmds-subvolume.c:228
res = optimized out
fd = optimized out
len = optimized out
e = optimized out
cnt = 1
ret = 0
args = {fd = 0, name = '\000' repeats 976 times...}
dname = optimized out
vname = optimized out
path = optimized out
#3  0x00403b1a in handle_command_group (grp=grp@entry=0x6500c0 
subvolume_cmd_group, argc=2, argv=0x7fff179184e8) at btrfs.c:154
cmd = 0x6500f8
#4  0x00405c26 in cmd_subvolume (argc=optimized out, argv=optimized 
out) at cmds-subvolume.c:969
No locals.
#5  0x00403d69 in main (argc=3, argv=0x7fff179184e0) at btrfs.c:295
cmd = 0x6515d0
bname = optimized out

Signed-off-by: Kusanagi Kouichi sl...@ac.auone-net.jp
---
 cmds-subvolume.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index ccb4762..f005ba8 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -203,7 +203,7 @@ static int cmd_subvol_delete(int argc, char **argv)
 {
int res, fd, len, e, cnt = 1, ret = 0;
struct btrfs_ioctl_vol_args args;
-   char*dname, *vname, *cpath;
+   char*dname, *vname;
char*path;
 
if (argc  2)
@@ -224,12 +224,10 @@ again:
goto out;
}
 
-   cpath = realpath(path, 0);
-   dname = strdup(cpath);
+   dname = strdup(path);
dname = dirname(dname);
-   vname = strdup(cpath);
+   vname = strdup(path);
vname = basename(vname);
-   free(cpath);
 
if( !strcmp(vname,.) || !strcmp(vname,..) ||
 strchr(vname, '/') ){
-- 
1.8.3.1

--
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-progs: btrfs requires version.h

2013-06-22 Thread Kusanagi Kouichi
$ make btrfs
[CC] ctree.o
[CC] disk-io.o
[CC] radix-tree.o
[CC] extent-tree.o
[CC] print-tree.o
[CC] root-tree.o
[CC] dir-item.o
[CC] file-item.o
[CC] inode-item.o
[CC] inode-map.o
[CC] extent-cache.o
[CC] extent_io.o
[CC] volumes.o
[CC] utils.o
[CC] repair.o
[CC] qgroup.o
[CC] raid6.o
[CC] free-space-cache.o
[CC] btrfs.o
btrfs.c:24:21: fatal error: version.h: No such file or directory
 #include version.h
 ^
compilation terminated.
make: *** [btrfs.o] Error 1

Signed-off-by: Kusanagi Kouichi sl...@ac.auone-net.jp
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index da7438e..0bca4d7 100644
--- a/Makefile
+++ b/Makefile
@@ -131,7 +131,7 @@ btrfs-%: version.h $(objects) $(libs) btrfs-%.o
@echo [LD] $@
$(Q)$(CC) $(CFLAGS) -o $@ $(objects) $@.o $(LDFLAGS) $(LIBS) $($(subst 
-,_,$@-libs))
 
-btrfs: $(objects) btrfs.o help.o $(cmds_objects) $(libs)
+btrfs: version.h $(objects) btrfs.o help.o $(cmds_objects) $(libs)
@echo [LD] $@
$(Q)$(CC) $(CFLAGS) -o btrfs btrfs.o help.o $(cmds_objects) \
$(objects) $(LDFLAGS) $(LIBS) -lpthread
-- 
1.8.3.1

--
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


Filebench varmail can not run in btrfs of kernel 3.8.2

2013-06-22 Thread ZHANG, Benlong
Hello,
When I run filebench varmail test under btrfs of Linux kernel 3.8.2, I got 
this error:

[11496.552440] WARNING: at fs/btrfs/tree-log.c:3825 
btrfs_log_inode_parent+0x28e/0x2f1 [btrfs]()
[11496.552560] Hardware name: PowerEdge R910
[11496.552644] Modules linked in: brd loop dm_crypt mperf coretemp kvm_intel 
snd_pcm kvm snd_timer snd usb_storage tpm_tis soundcore joydev psmouse 
snd_page_alloc tpm processor thermal_sys lpc_ich hid_generic serio_raw dcdbas 
ehci_pci evdev pcspkr tpm_bios microcode mfd_core button ext3 jbd mbcache 
dm_mod btrfs zlib_deflate crc32c libcrc32c sg sr_mod cdrom ses sd_mod enclosure 
crc_t10dif ata_generic usbhid hid qla2xxx scsi_transport_fc scsi_tgt 
crc32c_intel ata_piix uhci_hcd libata ehci_hcd megaraid_sas usbcore scsi_mod 
usb_common bnx2
[11496.556105] Pid: 4865, comm: filebench Tainted: G  D W3.8.2-debug #60
[11496.556198] Call Trace:
[11496.556291]  [81040a43] warn_slowpath_common+0x80/0x98
[11496.556384]  [81040a70] warn_slowpath_null+0x15/0x17
[11496.556506]  [a027e34c] btrfs_log_inode_parent+0x28e/0x2f1 [btrfs]
[11496.556634]  [a027e443] btrfs_log_dentry_safe+0x38/0x51 [btrfs]
[11496.556758]  [a025e597] btrfs_sync_file+0x162/0x1e5 [btrfs]
[11496.556854]  [8114e37d] vfs_fsync_range+0x18/0x21
[11496.556944]  [8114e39d] vfs_fsync+0x17/0x19
[11496.557033]  [8114e558] do_fsync+0x35/0x53
[11496.557125]  [811ef729] ? lockdep_sys_exit_thunk+0x35/0x67
[11496.557218]  [8114e593] sys_fsync+0xb/0xf
[11496.557309]  [813ba7a9] system_call_fastpath+0x16/0x1b
[11496.557400] ---[ end trace 568976af2f674ce7 ]---

And the benchmark will subsequently terminate in exception.  Is there any path 
towards this problem?

Thanks.
--
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


Re: Filebench varmail can not run in btrfs of kernel 3.8.2

2013-06-22 Thread Liu Bo
On Sat, Jun 22, 2013 at 03:35:23PM +0800, ZHANG, Benlong wrote:
 Hello,
 When I run filebench varmail test under btrfs of Linux kernel 3.8.2, I 
 got this error:
 
 [11496.552440] WARNING: at fs/btrfs/tree-log.c:3825 
 btrfs_log_inode_parent+0x28e/0x2f1 [btrfs]()
 [11496.552560] Hardware name: PowerEdge R910
 [11496.552644] Modules linked in: brd loop dm_crypt mperf coretemp kvm_intel 
 snd_pcm kvm snd_timer snd usb_storage tpm_tis soundcore joydev psmouse 
 snd_page_alloc tpm processor thermal_sys lpc_ich hid_generic serio_raw dcdbas 
 ehci_pci evdev pcspkr tpm_bios microcode mfd_core button ext3 jbd mbcache 
 dm_mod btrfs zlib_deflate crc32c libcrc32c sg sr_mod cdrom ses sd_mod 
 enclosure crc_t10dif ata_generic usbhid hid qla2xxx scsi_transport_fc 
 scsi_tgt crc32c_intel ata_piix uhci_hcd libata ehci_hcd megaraid_sas usbcore 
 scsi_mod usb_common bnx2
 [11496.556105] Pid: 4865, comm: filebench Tainted: G  D W3.8.2-debug 
 #60
 [11496.556198] Call Trace:
 [11496.556291]  [81040a43] warn_slowpath_common+0x80/0x98
 [11496.556384]  [81040a70] warn_slowpath_null+0x15/0x17
 [11496.556506]  [a027e34c] btrfs_log_inode_parent+0x28e/0x2f1 
 [btrfs]
 [11496.556634]  [a027e443] btrfs_log_dentry_safe+0x38/0x51 [btrfs]
 [11496.556758]  [a025e597] btrfs_sync_file+0x162/0x1e5 [btrfs]
 [11496.556854]  [8114e37d] vfs_fsync_range+0x18/0x21
 [11496.556944]  [8114e39d] vfs_fsync+0x17/0x19
 [11496.557033]  [8114e558] do_fsync+0x35/0x53
 [11496.557125]  [811ef729] ? lockdep_sys_exit_thunk+0x35/0x67
 [11496.557218]  [8114e593] sys_fsync+0xb/0xf
 [11496.557309]  [813ba7a9] system_call_fastpath+0x16/0x1b
 [11496.557400] ---[ end trace 568976af2f674ce7 ]---
 
 And the benchmark will subsequently terminate in exception.  Is there any 
 path towards this problem?

3.8.2 is quite old, and we've folded a great many fixes upon this part,
so the best bet is moving forward to the latest.

But I guess this warning issues EEXIST.

thanks,
liubo
--
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


Re: btrfs balance resume + raid5/6

2013-06-22 Thread Ilya Dryomov
On Sun, Jun 16, 2013 at 06:00:10AM +, Tim Castle wrote:
 Greetings! 
 
 I'm testing raid6, and recently added two drives. 
 I haven't been able to properly resume a balance operation: the number of
 total chunks is always too low.  
 
 It seems that the balance starts and pauses properly, but always resumes
 with ~7 chunks. 

Hi Tim,

This is the expected behaviour.  Balance does not actually remember
which chunks it had processed before it was paused, instead it uses a
heuristic which is based on the amount of space used out of each chunk.
As you have an almost full filesystem, all of your chunks, except for
those ~7, are fully (or almost fully) used, and balance resume simply
skips them.  If you really want to balance everything (why?) you would
have to run balance to completion, w/o pausing it.

Thanks,

Ilya
--
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


help: btrfs bad tree block start

2013-06-22 Thread Andrea Gelmini
Hi everybody,
   and thanks a lot for your work.

   I have this problem.
   With latest 3.9 kernel and btrfs-next I was close to full my home.
   The system went read only mode while I was copying in some files.

   Everything was good. I can't write, but I can read and copy last files.

   Then I rebooted, but since that moment I cannot mount.

   The kernel complain is:

[ 1026.226883] device label 16K devid 1 transid 66906 /dev/mapper/glen-home
[ 1026.227452] btrfs: disk space caching is enabled
[ 1026.311650] Btrfs detected SSD devices, enabling SSD mode
[ 1026.311825] btrfs bad tree block start 4262492213953725727 591596257280
[ 1026.312000] btrfs bad tree block start 4262492213953725727 591596257280
[ 1026.312010] btrfs: failed to read log tree
[ 1026.332708] btrfs: open_ctree failed

   If I use btrfsck (Joseph one) I got this:

root@glen:/home/gelma/dev/prg/btrfs_josef# ./btrfsck --repair
/dev/mapper/glen-home enabling repair mode
Check tree block failed, want=591596257280, have=4262492213953725727
Check tree block failed, want=591596257280, have=4262492213953725727
Check tree block failed, want=591596257280, have=4262492213953725727
Check tree block failed, want=591596257280, have=4262492213953725727
Check tree block failed, want=591596257280, have=4262492213953725727
read block failed check_tree_block
Checking filesystem on /dev/mapper/glen-home
UUID: 920ae0b9-55da-4606-af40-b58493c7882b
checking extents
checking free space cache
cache and super generation don't match, space cache will be invalidated
checking fs roots
checking csums
checking root refs
found 127643191167 bytes used err is 0
total csum bytes: 355191196
total tree bytes: 2457419776
total fs tree bytes: 1832763392
total extent tree bytes: 195133440
btree space waste bytes: 472140292
file data blocks allocated: 1525241155584
 referenced 396208013312
Btrfs v0.20-rc1

   The home partition is 352,70 GiB.

   I've got backup, but I would like to recover it.

Thanks a lot,
Gelma
--
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


Re: help: btrfs bad tree block start

2013-06-22 Thread Andrea Gelmini
2013/6/23 Andrea Gelmini andrea.gelm...@gmail.com:
The system went read only mode while I was copying in some files.

I reply to myself to add the kernel complain when BTFS switched to ro mode:

Jun 23 05:01:06 glen kernel: [46511.108103] device label GelmaWdUsb2T
devid 1 transid 1479 /dev/mapper/toshi
Jun 23 05:01:06 glen kernel: [46511.18] btrfs: use zlib compression
Jun 23 05:01:06 glen kernel: [46511.22] btrfs: turning off barriers
Jun 23 05:01:06 glen kernel: [46511.25] btrfs: disk space caching is enabled
Jun 23 05:01:59 glen kernel: [46564.107708] [ cut here ]
Jun 23 05:01:59 glen kernel: [46564.107718] WARNING: at
fs/btrfs/super.c:253 __btrfs_abort_transaction+0x11d/0x130()
Jun 23 05:01:59 glen kernel: [46564.107720] Hardware name: 239238G
Jun 23 05:01:59 glen kernel: [46564.107721] btrfs: Transaction aborted
(error -75)
Jun 23 05:01:59 glen kernel: [46564.107723] Modules linked in:
nls_iso8859_1 nls_cp850 vfat fat btusb pci_stub vboxpci(O)
vboxnetadp(O) vboxnetflt(O) joydev vboxdrv(O) cpufreq_userspace
cpufreq_powersave cpufreq_ondemand iscsi_tcp libiscsi_tcp libiscsi
scsi_transport_iscsi intel_powerclamp coretemp uvcvideo
videobuf2_vmalloc videobuf2_memops videobuf2_core videodev media
microcode snd_hda_codec_hdmi psmouse serio_raw snd_hda_codec_realtek
thinkpad_acpi nvram snd_hda_intel snd_hda_codec snd_hwdep arc4 snd_pcm
snd_page_alloc iwldvm snd_seq_midi snd_seq_midi_event mac80211
snd_rawmidi snd_seq iwlwifi lpc_ich tpm_tis cfg80211 tpm
snd_seq_device tpm_bios snd_timer snd soundcore mei bnep rfcomm
bluetooth binfmt_misc nfsd auth_rpcgss nfs_acl nfs lockd sunrpc
fscache raid10 raid456 async_raid6_recov async_memcpy async_pq
async_xor async_tx raid1 raid0 multipath hid_generic usbhid hid
crc32_pclmul usb_storage ghash_clmulni_intel wmi sdhci_pci sdhci
mmc_core e1000e ptp pps_core i915 video i2c_algo_bit drm_kms_helper
drm
Jun 23 05:01:59 glen kernel:
Jun 23 05:01:59 glen kernel: [46564.107784] Pid: 766, comm:
btrfs-transacti Tainted: G   O 3.9.7+ #3
Jun 23 05:01:59 glen kernel: [46564.107786] Call Trace:
Jun 23 05:01:59 glen kernel: [46564.107791]  [810894b0]
warn_slowpath_common+0x70/0xa0
Jun 23 05:01:59 glen kernel: [46564.107793]  [8108952c]
warn_slowpath_fmt+0x4c/0x50
Jun 23 05:01:59 glen kernel: [46564.107796]  [8128589d]
__btrfs_abort_transaction+0x11d/0x130
Jun 23 05:01:59 glen kernel: [46564.107800]  [812a3e1f]
btrfs_del_csums+0x2bf/0x2d0
Jun 23 05:01:59 glen kernel: [46564.107802]  [812963b8]
__btrfs_free_extent+0x7e8/0xa60
Jun 23 05:01:59 glen kernel: [46564.107806]  [8129a102]
run_clustered_refs+0x372/0xd90
Jun 23 05:01:59 glen kernel: [46564.107810]  [810b86d5] ?
check_preempt_curr+0x85/0xa0
Jun 23 05:01:59 glen kernel: [46564.107812]  [810b871c] ?
ttwu_do_wakeup+0x2c/0xe0
Jun 23 05:01:59 glen kernel: [46564.107815]  [8129eec0]
btrfs_run_delayed_refs+0xe0/0x530
Jun 23 05:01:59 glen kernel: [46564.107818]  [812aed0e]
btrfs_commit_transaction+0x4e/0x960
Jun 23 05:01:59 glen kernel: [46564.107821]  [812a68e5]
transaction_kthread+0x195/0x230
Jun 23 05:01:59 glen kernel: [46564.107824]  [812a6750] ?
free_fs_root+0xa0/0xa0
Jun 23 05:01:59 glen kernel: [46564.107828]  [810abdb0]
kthread+0xc0/0xd0
Jun 23 05:01:59 glen kernel: [46564.107831]  [810abcf0] ?
kthread_create_on_node+0x120/0x120
Jun 23 05:01:59 glen kernel: [46564.107835]  [8166125c]
ret_from_fork+0x7c/0xb0
Jun 23 05:01:59 glen kernel: [46564.107838]  [810abcf0] ?
kthread_create_on_node+0x120/0x120
Jun 23 05:01:59 glen kernel: [46564.107840] ---[ end trace 61ae1f206606f04b ]---
Jun 23 05:01:59 glen kernel: [46564.107842] BTRFS error (device dm-3)
in btrfs_del_csums:657: errno=-75 unknown
Jun 23 05:01:59 glen kernel: [46564.107844] BTRFS info (device dm-3):
forced readonly
Jun 23 05:01:59 glen kernel: [46564.107846] BTRFS error (device dm-3)
in __btrfs_free_extent:5801: errno=-75 unknown
Jun 23 05:01:59 glen kernel: [46564.107847] BTRFS debug (device dm-3):
run_one_delayed_ref returned -75
Jun 23 05:01:59 glen kernel: [46564.107850] BTRFS error (device dm-3)
in btrfs_run_delayed_refs:2677: errno=-75 unknown

Thanks a lot for your time,
Gelma
--
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