All of lore.kernel.org
 help / color / mirror / Atom feed
* Adding a non-empty subvol to a qgroup
@ 2013-03-22 10:34 Koen De Wit
  2013-03-22 11:27 ` Wang Shilong
  2013-03-22 12:03 ` Wang Shilong
  0 siblings, 2 replies; 4+ messages in thread
From: Koen De Wit @ 2013-03-22 10:34 UTC (permalink / raw)
  To: linux-btrfs

All,

When adding a subvolume to a qgroup, pre-existing files in that 
subvolume are not counted in the referenced/exclusive space of the 
qgroup. Is this intended behavior ?

I create a subvol with one file:

   # mkfs.btrfs /dev/sdg
   # mount /dev/sdg /mnt/fulldisk
   # cd /mnt/fulldisk
   # btrfs quota enable ./
   # btrfs sub create sub1
   # dd if=/dev/zero of=sub1/file1 bs=100000 count=1
   # sync
   # btrfs qgroup show ./
   0/257 106496 106496

Now I create a new qgroup on level 1 and add the qgroup of sub1 to it :

   # btrfs qgroup create 1/0 ./
   # btrfs qgroup assign 0/257 1/0 ./
   # sync
   # btrfs fi sync ./
   # btrfs quota rescan ./
   # btrfs quota rescan ./sub1
   # btrfs qgroup show ./
   0/257 106496 106496
   1/0 0 0

The pre-existing file does not contribute to the space numbers.

Let's create a new file:

   # dd if=/dev/zero of=sub1/file2 bs=50000 count=1
   # sync
   # btrfs qgroup show ./
   0/257 159744 159744
   1/0 53248 53248

We see that only the new file is included in the space numbers.

Now I remove the first file:

   # rm -f sub1/file1
   # sync
   # btrfs qgroup show ./
   0/257 57344 57344
   1/0 -49152 -49152

The space numbers go below zero. Even if the behavior above is intended, 
the removal of the pre-existing file should not result in negative space 
numbers.

Koen.

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

* Re: Adding a non-empty subvol to a qgroup
  2013-03-22 10:34 Adding a non-empty subvol to a qgroup Koen De Wit
@ 2013-03-22 11:27 ` Wang Shilong
  2013-03-22 12:03 ` Wang Shilong
  1 sibling, 0 replies; 4+ messages in thread
From: Wang Shilong @ 2013-03-22 11:27 UTC (permalink / raw)
  To: Koen De Wit; +Cc: linux-btrfs@vger.kernel.org

Hello,

> All,
> 
> When adding a subvolume to a qgroup, pre-existing files in that subvolume are not counted in the referenced/exclusive space of the qgroup. Is this intended behavior ?

Btrfs quota rescan has not been implemented yet. So until now, the pre-existing files are not counted.

> 
> I create a subvol with one file:
> 
>  # mkfs.btrfs /dev/sdg
>  # mount /dev/sdg /mnt/fulldisk
>  # cd /mnt/fulldisk
>  # btrfs quota enable ./
>  # btrfs sub create sub1
>  # dd if=/dev/zero of=sub1/file1 bs=100000 count=1
>  # sync
>  # btrfs qgroup show ./
>  0/257 106496 106496
> 
> Now I create a new qgroup on level 1 and add the qgroup of sub1 to it :
> 
>  # btrfs qgroup create 1/0 ./
>  # btrfs qgroup assign 0/257 1/0 ./
>  # sync
>  # btrfs fi sync ./
>  # btrfs quota rescan ./
>  # btrfs quota rescan ./sub1
>  # btrfs qgroup show ./
>  0/257 106496 106496
>  1/0 0 0
> 
> The pre-existing file does not contribute to the space numbers.
> 
> Let's create a new file:
> 
>  # dd if=/dev/zero of=sub1/file2 bs=50000 count=1
>  # sync
>  # btrfs qgroup show ./
>  0/257 159744 159744
>  1/0 53248 53248
> 
> We see that only the new file is included in the space numbers.
> 
> Now I remove the first file:
> 
>  # rm -f sub1/file1
>  # sync
>  # btrfs qgroup show ./
>  0/257 57344 57344
>  1/0 -49152 -49152
> 
> The space numbers go below zero. Even if the behavior above is intended, the removal of the pre-existing file should not result in negative space numbers.


Since rescan has not been implemented, the above case can not be avoided. but the referenced/exclusive value should not be negative because 
the type for referenced/exclusive is u64.  

if the overflow  happens, we may get a positive integer which is also wrong.
The problems come in btrfs-progs, i will correct it. thanks 

Maybe, we should have a check in the kernel and give a warning if overflow happens. 

Thanks,
Wang

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


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

* Re: Adding a non-empty subvol to a qgroup
  2013-03-22 10:34 Adding a non-empty subvol to a qgroup Koen De Wit
  2013-03-22 11:27 ` Wang Shilong
@ 2013-03-22 12:03 ` Wang Shilong
  2013-03-22 12:29   ` Arne Jansen
  1 sibling, 1 reply; 4+ messages in thread
From: Wang Shilong @ 2013-03-22 12:03 UTC (permalink / raw)
  To: Arne Jansen; +Cc: linux-btrfs, Koen De Wit

Hello Arne,

Since "quota rescan" has not been implemented yet,

overflow can happen, so until now, we can have a check when
doing accounting in the kernel, if the referenced/exclusive is not
enough to delete, we just make it to be 0 and give a warning.

Otherwise, user may get a strange integer(because of type u64).
How do you think ? or we just wait for the implement of rescan.

Thanks,
Wang

> All,
> 
> When adding a subvolume to a qgroup, pre-existing files in that subvolume are not counted in the referenced/exclusive space of the qgroup. Is this intended behavior ?
> 
> I create a subvol with one file:
> 
>  # mkfs.btrfs /dev/sdg
>  # mount /dev/sdg /mnt/fulldisk
>  # cd /mnt/fulldisk
>  # btrfs quota enable ./
>  # btrfs sub create sub1
>  # dd if=/dev/zero of=sub1/file1 bs=100000 count=1
>  # sync
>  # btrfs qgroup show ./
>  0/257 106496 106496
> 
> Now I create a new qgroup on level 1 and add the qgroup of sub1 to it :
> 
>  # btrfs qgroup create 1/0 ./
>  # btrfs qgroup assign 0/257 1/0 ./
>  # sync
>  # btrfs fi sync ./
>  # btrfs quota rescan ./
>  # btrfs quota rescan ./sub1
>  # btrfs qgroup show ./
>  0/257 106496 106496
>  1/0 0 0
> 
> The pre-existing file does not contribute to the space numbers.
> 
> Let's create a new file:
> 
>  # dd if=/dev/zero of=sub1/file2 bs=50000 count=1
>  # sync
>  # btrfs qgroup show ./
>  0/257 159744 159744
>  1/0 53248 53248
> 
> We see that only the new file is included in the space numbers.
> 
> Now I remove the first file:
> 
>  # rm -f sub1/file1
>  # sync
>  # btrfs qgroup show ./
>  0/257 57344 57344
>  1/0 -49152 -49152
> 
> The space numbers go below zero. Even if the behavior above is intended, the removal of the pre-existing file should not result in negative space numbers.
> 
> Koen.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: Adding a non-empty subvol to a qgroup
  2013-03-22 12:03 ` Wang Shilong
@ 2013-03-22 12:29   ` Arne Jansen
  0 siblings, 0 replies; 4+ messages in thread
From: Arne Jansen @ 2013-03-22 12:29 UTC (permalink / raw)
  To: Wang Shilong; +Cc: linux-btrfs, Koen De Wit

On 22.03.2013 13:03, Wang Shilong wrote:
> Hello Arne,
> 
> Since "quota rescan" has not been implemented yet,
> 
> overflow can happen, so until now, we can have a check when
> doing accounting in the kernel, if the referenced/exclusive is not
> enough to delete, we just make it to be 0 and give a warning.
> 
> Otherwise, user may get a strange integer(because of type u64).
> How do you think ? or we just wait for the implement of rescan.

I think we already print it negatively. Please just leave it as
it is.

Thanks,
Arne

> 
> Thanks,
> Wang
> 
>> All,
>>
>> When adding a subvolume to a qgroup, pre-existing files in that subvolume are not counted in the referenced/exclusive space of the qgroup. Is this intended behavior ?
>>
>> I create a subvol with one file:
>>
>>  # mkfs.btrfs /dev/sdg
>>  # mount /dev/sdg /mnt/fulldisk
>>  # cd /mnt/fulldisk
>>  # btrfs quota enable ./
>>  # btrfs sub create sub1
>>  # dd if=/dev/zero of=sub1/file1 bs=100000 count=1
>>  # sync
>>  # btrfs qgroup show ./
>>  0/257 106496 106496
>>
>> Now I create a new qgroup on level 1 and add the qgroup of sub1 to it :
>>
>>  # btrfs qgroup create 1/0 ./
>>  # btrfs qgroup assign 0/257 1/0 ./
>>  # sync
>>  # btrfs fi sync ./
>>  # btrfs quota rescan ./
>>  # btrfs quota rescan ./sub1
>>  # btrfs qgroup show ./
>>  0/257 106496 106496
>>  1/0 0 0
>>
>> The pre-existing file does not contribute to the space numbers.
>>
>> Let's create a new file:
>>
>>  # dd if=/dev/zero of=sub1/file2 bs=50000 count=1
>>  # sync
>>  # btrfs qgroup show ./
>>  0/257 159744 159744
>>  1/0 53248 53248
>>
>> We see that only the new file is included in the space numbers.
>>
>> Now I remove the first file:
>>
>>  # rm -f sub1/file1
>>  # sync
>>  # btrfs qgroup show ./
>>  0/257 57344 57344
>>  1/0 -49152 -49152
>>
>> The space numbers go below zero. Even if the behavior above is intended, the removal of the pre-existing file should not result in negative space numbers.
>>
>> Koen.
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

end of thread, other threads:[~2013-03-22 12:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-22 10:34 Adding a non-empty subvol to a qgroup Koen De Wit
2013-03-22 11:27 ` Wang Shilong
2013-03-22 12:03 ` Wang Shilong
2013-03-22 12:29   ` Arne Jansen

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.