All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: subvol sync: fix memory corruption, undersized array
@ 2016-03-17 10:47 David Sterba
  2016-03-17 14:10 ` Blocks changed since previous snapshot of subvolume sri
  0 siblings, 1 reply; 5+ messages in thread
From: David Sterba @ 2016-03-17 10:47 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The subvol sync command crashed randomly at the end with

*** glibc detected *** btrfs: double free or corruption (out): 0x00000000006ab040 ***

This is caused by running out of the ids array in case there are more
than 128 subvolumes. The array is increased in steps but does not
account the size of the item, so there was room for 1024 / 8 = 128
subvolume ids.

Fixes: c9f885ec8963 ("btrfs-progs: subvol: let sync check only current deletions")
Signed-off-by: David Sterba <dsterba@suse.com>
---
 cmds-subvolume.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 02e1dec18ed2..32caaa5db9ec 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -1204,7 +1204,8 @@ static int enumerate_dead_subvols(int fd, u64 **ids)
 					u64 *newids;
 
 					count += SUBVOL_ID_BATCH;
-					newids = (u64*)realloc(*ids, count);
+					newids = (u64*)realloc(*ids,
+							count * sizeof(u64));
 					if (!newids)
 						return -ENOMEM;
 					*ids = newids;
-- 
2.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Blocks changed since previous snapshot of subvolume
@ 2016-03-17 14:10 ` sri
  2016-03-17 20:36   ` Henk Slager
  0 siblings, 1 reply; 5+ messages in thread
From: sri @ 2016-03-17 14:10 UTC (permalink / raw)
  To: linux-btrfs

Hi,

I Would like to know between 2 snapshots of a subvolume, can we identify 
what all blocks modified particular to that subvolume ?

there can be many subvolume and snapshots present on the btrfs but i want 
only blocks modified since first snapshot for the specific subvolume.

blocks should include metadata and data blocks. 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Blocks changed since previous snapshot of subvolume
  2016-03-17 14:10 ` Blocks changed since previous snapshot of subvolume sri
@ 2016-03-17 20:36   ` Henk Slager
  2016-03-18 13:36     ` sri
  0 siblings, 1 reply; 5+ messages in thread
From: Henk Slager @ 2016-03-17 20:36 UTC (permalink / raw)
  To: linux-btrfs

sri <toyours_sridhar <at> yahoo.co.in> writes:

> 
> Hi,
> 
> I Would like to know between 2 snapshots of a subvolume, can we identify 
> what all blocks modified particular to that subvolume ?
> 
> there can be many subvolume and snapshots present on the btrfs but i want 
> only blocks modified since first snapshot for the specific subvolume.
> 
> blocks should include metadata and data blocks. 

Not directly diff blocks, rather files, you could do something like this:

btrfs subvolume find-new <newer_snapshot> `btrfs subvolume show 
<older_snapshot> | grep Generation | awk '{print $2}'` |  awk '{ print $17 }' 
| sort | uniq



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Blocks changed since previous snapshot of subvolume
  2016-03-17 20:36   ` Henk Slager
@ 2016-03-18 13:36     ` sri
  2016-03-19  0:13       ` Duncan
  0 siblings, 1 reply; 5+ messages in thread
From: sri @ 2016-03-18 13:36 UTC (permalink / raw)
  To: linux-btrfs

Henk Slager <eye1tm <at> gmail.com> writes:

> 
> sri <toyours_sridhar <at> yahoo.co.in> writes:
> 
> > 
> > Hi,
> > 
> > I Would like to know between 2 snapshots of a subvolume, can we 
identify 
> > what all blocks modified particular to that subvolume ?
> > 
> > there can be many subvolume and snapshots present on the btrfs but i 
want 
> > only blocks modified since first snapshot for the specific 
subvolume.
> > 
> > blocks should include metadata and data blocks. 
> 
> Not directly diff blocks, rather files, you could do something like 
this:
> 
> btrfs subvolume find-new <newer_snapshot> `btrfs subvolume show 
> <older_snapshot> | grep Generation | awk '{print $2}'` |  awk '{ print 
$17 }' 
> | sort | uniq
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" 
in
> the body of a message to majordomo <at> vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

Thank you. As I checked only blocks related to file are shown. 

sample output:

btrfs subvolume find-new snap2 15
inode 264 file offset 0 len 8192 disk start 351559680 offset 0 gen 16 
flags NONE mman.h
inode 265 file offset 0 len 8192 disk start 351567872 offset 0 gen 16 
flags NONE mount.h
inode 266 file offset 0 len 2374 disk start 0 offset 0 gen 16 flags 
INLINE msg.h
inode 267 file offset 0 len 12288 disk start 351576064 offset 0 gen 16 
flags NONE mtio.h
transid marker was 16


I think it showed blocks changed w.r.t file data block.

is there a way to get other blocks modified such as meta data such as 
inodes blocks modified and corresponding directory inode blocks along 
with files?

Above fs is created on 2 disks /dev/sdd and /dev/sdd of 3 gb.  No raid 
configured. I think it is just strped with 6gb size around.

How should I interpret:
inode 266 file offset 0 len 2374 disk start 0 offset 0 gen 16 flags 
INLINE msg.h

??

disk start is 0 here. Is this w.r.t what?

and offset 0 is offset inside block represented by disk start ?


thank you.








^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Blocks changed since previous snapshot of subvolume
  2016-03-18 13:36     ` sri
@ 2016-03-19  0:13       ` Duncan
  0 siblings, 0 replies; 5+ messages in thread
From: Duncan @ 2016-03-19  0:13 UTC (permalink / raw)
  To: linux-btrfs

sri posted on Fri, 18 Mar 2016 13:36:50 +0000 as excerpted:

> Henk Slager <eye1tm <at> gmail.com> writes:
> 
>> sri <toyours_sridhar <at> yahoo.co.in> writes:
>> > 
>> > I Would like to know between 2 snapshots of a subvolume, can we
>> > identify what all blocks modified particular to that subvolume ?
>> > 
>> > there can be many subvolume and snapshots present on the btrfs but i
>> > want only blocks modified since first snapshot for the specific
>> > subvolume.  blocks should include metadata and data blocks.
>> 
>> Not directly diff blocks, rather files, you could do something like
>> this:
>> 
>> btrfs subvolume find-new [...]
>> 
>> 
> Thank you. As I checked only blocks related to file are shown.
> 
> is there a way to get other blocks modified such as meta data such as
> inodes blocks modified and corresponding directory inode blocks along
> with files?

This would include the change data itself as well, and I'm not sure if 
the format once the actual binary level changes themselves are removed is 
practically consumable by humans or not, but it occurs to me that this is 
precisely the information that btrfs send -p provides.  If you can strip 
the changes themselves out and what's left is either human readable or 
can be processed to human readable, then it should be exactly what you're 
after, the changed blocks, for data and metadata both.

-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-03-19  0:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-17 10:47 [PATCH] btrfs-progs: subvol sync: fix memory corruption, undersized array David Sterba
2016-03-17 14:10 ` Blocks changed since previous snapshot of subvolume sri
2016-03-17 20:36   ` Henk Slager
2016-03-18 13:36     ` sri
2016-03-19  0:13       ` Duncan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.