On Wed, Apr 29, 2020 at 08:30:33PM +0200, Stefanie Leisestreichler wrote: > Hi. > From the chattr man page: > A file with the 'C' attribute set will not be subject to copy-on-write > updates. This flag is only supported on file systems which perform > copy-on-write. (Note: For btrfs, the 'C' flag should be set on new or empty > files. If it is set on a file which already has data blocks, it is undefined > when the blocks assigned to the file will be fully stable. If the 'C' flag > is set on a directory, it will have no effect on the directory, but new > files created in that directory will have the No_COW attribute set.) > > Question 1) > If /var/lib/mysql is a own subvolume and chattr +C /var/lib/mysql is set and > mysql is configured to use one directory for every database, will nodatacow > apply for a new dir which is created when a new db is created? Just asking, > because the last sentence of the man above which states "...new files > created in that directory...". Is a dir a file in the context of chattr? Yes. > Question 2) > I guess CoW will still happen, if I hold a snapshot of the subvolume which > will be mounted to /var/lib/mysql. Is this correct? Correct, but only once. Subsequent writes to the same region will revert to nodatacow. > Question 3) > How to solve this and avoid defragmentation if my assumption in 2) is > correct? Don't use snapshots, or don't use nodatacow. Set autodefrag and don't use nodatacow would be my recommendation. Hugo. -- Hugo Mills | 2 + 2 = 5, for sufficiently large values of 2. hugo@... carfax.org.uk | http://carfax.org.uk/ | PGP: E2AB1DE4 |
