From: Nikolaos Chatzikonstantinou <nchatz314@gmail.com>
To: Andrei Borzenkov <arvidjaar@gmail.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: documentation of swapfile and nodatacow
Date: Sat, 15 Oct 2022 01:37:23 -0400 [thread overview]
Message-ID: <CAAQmekdjMKAT_VRErYKmJ+aHjakWhvE_NgcQyCZ_jNF5ePUpVQ@mail.gmail.com> (raw)
In-Reply-To: <d345acda-9095-318f-9de6-b3eb83dc6921@gmail.com>
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
prev parent reply other threads:[~2022-10-15 5:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAQmekdjMKAT_VRErYKmJ+aHjakWhvE_NgcQyCZ_jNF5ePUpVQ@mail.gmail.com \
--to=nchatz314@gmail.com \
--cc=arvidjaar@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).