* documentation of swapfile and nodatacow
@ 2022-10-14 18:04 Nikolaos Chatzikonstantinou
2022-10-14 19:21 ` Andrei Borzenkov
0 siblings, 1 reply; 3+ messages in thread
From: Nikolaos Chatzikonstantinou @ 2022-10-14 18:04 UTC (permalink / raw)
To: linux-btrfs
Hello list,
This question popped up during the writing of a swapfile
guide. Following
<https://btrfs.readthedocs.io/en/latest/Swapfile.html>, I chose to put
the swapfile on a separate subvolume which does not get
snapshotted. The steps I have:
btrfs subvolume create swap
chattr +C swap
chmod 0700 swap
fallocate -l 1G swap/swapfile
chmod 0600 swap/swapfile
mkswap swap/swapfile
I'm uncertain about the chattr step. In
<https://btrfs.readthedocs.io/en/latest/btrfs-man5.html#mount-options>
I find the note
"This means that (for example) you can’t set per-subvolume
nodatacow, nodatasum, or compress using mount options."
which applies for mount options. On btrfs(5) I find under FILE
ATTRIBUTES
C no copy-on-write, file data modifications are done in-place
When set on a directory, all newly created files will inherit
this attribute.
NOTE:
Due to implementation limitations, this flag can be
set/unset only on empty files.
This says that the +C attribute can only be set on files, not
directories, although it explains (in theory?) what should happen if a
directory has that attribute.
To summarize, I'd like to ask:
1) Can `chattr +C` be used on a subvolume? Is it different from mount
option nodatacow?
2) Should the man page be reworded 'only on files that are empty'?
3) Should the readthedocs page be changed to include the subvolume
creation step and remove the `truncate -s 0` step?
Regards,
Nikolaos Chatzikonstantinou
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: documentation of swapfile and nodatacow
2022-10-14 18:04 documentation of swapfile and nodatacow Nikolaos Chatzikonstantinou
@ 2022-10-14 19:21 ` Andrei Borzenkov
2022-10-15 5:37 ` Nikolaos Chatzikonstantinou
0 siblings, 1 reply; 3+ messages in thread
From: Andrei Borzenkov @ 2022-10-14 19:21 UTC (permalink / raw)
To: Nikolaos Chatzikonstantinou, linux-btrfs
On 14.10.2022 21:04, Nikolaos Chatzikonstantinou wrote:
> Hello list,
>
> This question popped up during the writing of a swapfile
> guide. Following
> <https://btrfs.readthedocs.io/en/latest/Swapfile.html>, I chose to put
> the swapfile on a separate subvolume which does not get
> snapshotted. The steps I have:
>
> btrfs subvolume create swap
> chattr +C swap
> chmod 0700 swap
> fallocate -l 1G swap/swapfile
> chmod 0600 swap/swapfile
> mkswap swap/swapfile
>
> I'm uncertain about the chattr step. In
> <https://btrfs.readthedocs.io/en/latest/btrfs-man5.html#mount-options>
> I find the note
>
> "This means that (for example) you can’t set per-subvolume
> nodatacow, nodatasum, or compress using mount options."
>
> which applies for mount options. On btrfs(5) I find under FILE
> ATTRIBUTES
>
> C no copy-on-write, file data modifications are done in-place
>
> When set on a directory, all newly created files will inherit
> this attribute.
>
> NOTE:
> Due to implementation limitations, this flag can be
> set/unset only on empty files.
>
> This says that the +C attribute can only be set on files, not
> directories, although it explains (in theory?) what should happen if a
> directory has that attribute.
>
> To summarize, I'd like to ask:
>
> 1) Can `chattr +C` be used on a subvolume? Is it different from mount
> option nodatacow?
>
chattr +C is not used "on a subvolume". It applies to top level
subvolume directory and then is inherited as per documentation.
> 2) Should the man page be reworded 'only on files that are empty'?
>
Which man page? Man page you quoted (btrfs(5)) already says it.
> 3) Should the readthedocs page be changed to include the subvolume
> creation step and remove the `truncate -s 0` step?
>
Why should it enforce any particular layout? It is up to each user to
decide where swap file is located. The commands in documentation work
also when file already exists.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: documentation of swapfile and nodatacow
2022-10-14 19:21 ` Andrei Borzenkov
@ 2022-10-15 5:37 ` Nikolaos Chatzikonstantinou
0 siblings, 0 replies; 3+ messages in thread
From: Nikolaos Chatzikonstantinou @ 2022-10-15 5:37 UTC (permalink / raw)
To: Andrei Borzenkov; +Cc: linux-btrfs
On Fri, Oct 14, 2022 at 3:21 PM Andrei Borzenkov <arvidjaar@gmail.com> wrote:
>
> On 14.10.2022 21:04, Nikolaos Chatzikonstantinou wrote:
> > Hello list,
> >
> > This question popped up during the writing of a swapfile
> > guide. Following
> > <https://btrfs.readthedocs.io/en/latest/Swapfile.html>, I chose to put
> > the swapfile on a separate subvolume which does not get
> > snapshotted. The steps I have:
> >
> > btrfs subvolume create swap
> > chattr +C swap
> > chmod 0700 swap
> > fallocate -l 1G swap/swapfile
> > chmod 0600 swap/swapfile
> > mkswap swap/swapfile
> >
> > I'm uncertain about the chattr step. In
> > <https://btrfs.readthedocs.io/en/latest/btrfs-man5.html#mount-options>
> > I find the note
> >
> > "This means that (for example) you can’t set per-subvolume
> > nodatacow, nodatasum, or compress using mount options."
> >
> > which applies for mount options. On btrfs(5) I find under FILE
> > ATTRIBUTES
> >
> > C no copy-on-write, file data modifications are done in-place
> >
> > When set on a directory, all newly created files will inherit
> > this attribute.
> >
> > NOTE:
> > Due to implementation limitations, this flag can be
> > set/unset only on empty files.
> >
> > This says that the +C attribute can only be set on files, not
> > directories, although it explains (in theory?) what should happen if a
> > directory has that attribute.
> >
> > To summarize, I'd like to ask:
> >
> > 1) Can `chattr +C` be used on a subvolume? Is it different from mount
> > option nodatacow?
> >
>
> chattr +C is not used "on a subvolume". It applies to top level
> subvolume directory and then is inherited as per documentation.
Correction: Can +C be used in a directory and is it different from
nodatacow in a subvolume?
> > 2) Should the man page be reworded 'only on files that are empty'?
> >
>
> Which man page? Man page you quoted (btrfs(5)) already says it.
The meaning is different; my proposition clarifies that the "only"
rule applies to files. Otherwise, I explained above that it is
contradictory: it implies +C cannot be used in directories, although
it explains what its purpose would be there. Alternatively, a
different rewording: it can be reworded to say "only on empty files or
directories", if that is true.
> > 3) Should the readthedocs page be changed to include the subvolume
> > creation step and remove the `truncate -s 0` step?
> >
>
> Why should it enforce any particular layout? It is up to each user to
> decide where swap file is located. The commands in documentation work
> also when file already exists.
The page has "To create and activate a swapfile run the following
commands:", which means the swapfile is created, it doesn't exist.
There is no reason to force the layout. What do you think of creating
the subvolume to indicate the inability to take snapshots? Wouldn't
most users want a dedicated swap subvolume?
Regards,
Nikolaos Chatzikonstantinou
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-15 5:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-14 18:04 documentation of swapfile and nodatacow Nikolaos Chatzikonstantinou
2022-10-14 19:21 ` Andrei Borzenkov
2022-10-15 5:37 ` Nikolaos Chatzikonstantinou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).