linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: dsterba@suse.cz, clm@fb.com
Cc: dhowells@redhat.com, linux-btrfs@vger.kernel.org
Subject: Re: Do btrfs compression option changes need to be atomic?
Date: Tue, 21 Aug 2018 15:34:06 +0100	[thread overview]
Message-ID: <4150.1534862046@warthog.procyon.org.uk> (raw)
In-Reply-To: <20180821142000.GC24025@twin.jikos.cz>

David Sterba <dsterba@suse.cz> wrote:

> Do you mean the compression type (btrfs_fs_info::compress_type) and the
> related bits in btrfs_fs_info::mount_opt ? There are more compression
> types but not used in the mount context.  I assume you're interested
> only in the mount-time settings, otherwise the defrag and per-inode
> compression has higher priority over the global settings.

Yes.  However, it would appear that remount can race with using the fs_info
variables, so the settings can be changing whilst you're going through the
compress_file_range() function.

I'm not sure it'll hurt exactly, but you can also find, say, DATACOW being
disabled whilst you're considering compressing.

> > Further to that, how much of an issue is it if the configuration is split
> > out into its own struct that is accessed from struct btrfs_fs_info using
> > RCU?
> 
> Depends on how intrusive it's going to be, the mount opions are tested
> at many places. The RCU overhead and "locking" is lightweight enough so
> it should not be a problem in principle, but without seeing the code I
> can't tell.

Actually, a better way of doing this might be to put a subset of the settings
into a single variable, say:

	struct btrfs_fs_info {
		...
		unsigned int	data_storage_opt;
	#define BTRFS_DATA_NONE			0x0000
	#define BTRFS_DATA_COW			0x0001
	#define BTRFS_DATA_SUM			0x0002
	#define BTRFS_DATA_COMPRESS		0x0003
	#define BTRFS_DATA_FORCE_COMPRESS	0x0004
	#define BTRFS_DATA__STORAGE_OPT		0x000f
	#define BTRFS_DATA_COMPRESS_ZLIB	0x0000
	#define BTRFS_DATA_COMPRESS_LZO		0x0010
	#define BTRFS_DATA_COMPRESS_ZSTD	0x0020
	#define BTRFS_DATA__COMPRESS_TYPE	0x00f0
	#define BTRFS_DATA__COMPRESS_LEVEL	0x0f00
		...
	};

That way it might be possible for the datacow, datasum, compress and
compress-force options to be handled atomically.

David

  parent reply	other threads:[~2018-08-21 17:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-16 11:01 Are the btrfs mount options inconsistent? David Howells
2018-08-16 13:05 ` David Sterba
2018-08-20 12:24 ` David Howells
2018-08-20 12:39   ` Qu Wenruo
2018-08-21 13:43   ` David Howells
2018-08-21 14:13     ` Austin S. Hemmelgarn
2018-08-21 14:24     ` David Sterba
2018-08-21 14:26       ` Qu Wenruo
2018-08-21 14:35     ` David Howells
2018-08-21 14:40       ` Qu Wenruo
2018-08-20 12:35 ` David Howells
2018-08-21 13:46 ` Do btrfs compression option changes need to be atomic? David Howells
2018-08-21 14:02   ` Chris Mason
2018-08-21 14:20   ` David Sterba
2018-08-21 14:34   ` David Howells [this message]
2018-08-21 15:11     ` David Sterba
2018-08-21 16:13     ` David Howells

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=4150.1534862046@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.cz \
    --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).