Re: [PATCH 2/2] Btrfs: make snapshot-aware defrag as a mount option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/31/2012 08:44 AM, David Sterba wrote:
> On Wed, Oct 31, 2012 at 08:34:38AM +0800, Liu Bo wrote:
>> Besides 'btrfs fi defrag', mounting with autodefrag may also do the same thing.
> 
> Ok, autodefrag, good point. Then I suggest to make the snapshot-aware a
> mode of autodefrag, not a separate option (because it would make no
> sense other than an alias for "autodefrag=snapshotaware")
> 

Hmm, you might be right.

But I have to say 'snapshot-aware defrag' is kind of trade-off.

1. The good case:
Say a file is full of fragments and make a snapshot based on file's root

        fs root, snapshot
       /        |        \
      /         |         \
| - - | ... | - - - | ... | - - - |
   p1           p2            p3

then we do a snapshot-aware defrag, it will be

fs root      snapshot
   \          /
    \        /
| - - - - - - - - |
 a whole new extent

We achieve the goal!


2. The bad case:
Say we have a file with an whole extent and a snapshot on it at the very first:

fs root      snapshot
   \          /
    \        /
| - - - - - - - - |

then, we write into part of the file, with COW it will be:

         
| - - || - - - || - - - |  ...  | - - - |
   p1      p2       p3            p2_new

(file in snapshot -> p1 + p2 + p3)
(file in fs root -> p1 + p2_new + p3)

then, we do a snapshot-aware defrag, it will be

| - - || - - - || - - - |  ...  | - - - |
   p1      p2      p3            p2_new

                  ||
                  VV

| - - |           | - - - |  ...            ... | - - | - - - | - - - |
   p1                 p3                             new extent

(file in snapshot -> p1 + p3 + middle of new extent)
(file in fs root -> new extent)

So we're making file in snapshot worse than before, although we get a good one for file in fs root.


thanks,
liubo

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

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


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux