Linux-BTRFS Archive on lore.kernel.org
 help / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-btrfs@vger.kernel.org, Jeff Mahoney <jeffm@suse.com>
Subject: Re: [PATCH v2 02/12] btrfs: combine device update operations during transaction commit
Date: Thu, 28 Feb 2019 17:52:21 +0100
Message-ID: <20190228165221.GL31119@twin.jikos.cz> (raw)
In-Reply-To: <20190211083510.27591-3-nborisov@suse.com>

On Mon, Feb 11, 2019 at 10:35:00AM +0200, Nikolay Borisov wrote:
> From: Jeff Mahoney <jeffm@suse.com>
> 
> We currently overload the pending_chunks list to handle updating
> btrfs_device->commit_bytes used.  We don't actually care about
> the extent mapping or even the device mapping for the chunk - we
> just need the device, and we can end up processing it multiple
> times.  The fs_devices->resized_list does more or less the same
> thing, but with the disk size.  They are called consecutively
> during commit and have more or less the same purpose.
> 
> We can combine the two lists into a single list that attaches
> to the transaction and contains a list of devices that need
> updating.  Since we always add the device to a list when we
> change bytes_used or disk_total_size, there's no harm in
> copying both values at once.

Agreed, overall sounds good.

> Signed-off-by: Jeff Mahoney <jeffm@suse.com>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
> --- a/fs/btrfs/transaction.c
> +++ b/fs/btrfs/transaction.c
> @@ -75,6 +75,7 @@ void btrfs_put_transaction(struct btrfs_transaction *transaction)
>  			btrfs_put_block_group_trimming(cache);
>  			btrfs_put_block_group(cache);
>  		}
> +		BUG_ON(!list_empty(&transaction->dev_update_list));

Why BUG_ON? Would ASSERT or WARN_ON enough?

>  		kfree(transaction);
>  	}
>  }
> @@ -334,6 +333,7 @@ static struct btrfs_fs_devices *alloc_fs_devices(const u8 *fsid,
>  
>  void btrfs_free_device(struct btrfs_device *device)
>  {
> +	BUG_ON(!list_empty(&device->post_commit_list));

Same here

>  	rcu_string_free(device->name);
>  	bio_put(device->flush_bio);
>  	kfree(device);
> +	/*
> +	 * We don't need the device_list_mutex here.  This list is owned
> +	 * by the transaction and the transaction must complete before
> +	 * the device is released.
> +	 */
> +	mutex_lock(&trans->fs_info->chunk_mutex);
> +	list_for_each_entry_safe(curr, next, &trans->dev_update_list,
> +				 post_commit_list) {
> +		list_del_init(&curr->post_commit_list);
> +		curr->commit_total_bytes = curr->disk_total_bytes;
> +		curr->commit_bytes_used = curr->bytes_used;

Agreed, the chunk_mutex should be enough from what I've seen.

>  	}
> -	mutex_unlock(&fs_info->chunk_mutex);
> +	mutex_unlock(&trans->fs_info->chunk_mutex);
>  }
>  
>  void btrfs_set_fs_info_ptr(struct btrfs_fs_info *fs_info)

  reply index

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-11  8:34 [PATCH v2 00/12] FITRIM improvements Nikolay Borisov
2019-02-11  8:34 ` [PATCH v2 01/12] btrfs: Honour FITRIM range constraints during free space trim Nikolay Borisov
2019-02-11  8:35 ` [PATCH v2 02/12] btrfs: combine device update operations during transaction commit Nikolay Borisov
2019-02-28 16:52   ` David Sterba [this message]
2019-02-11  8:35 ` [PATCH v2 03/12] btrfs: Handle pending/pinned chunks before blockgroup relocation during device shrink Nikolay Borisov
2019-02-11  8:35 ` [PATCH v2 04/12] btrfs: Rename and export clear_btree_io_tree Nikolay Borisov
2019-02-28 16:53   ` David Sterba
2019-02-11  8:35 ` [PATCH v2 05/12] btrfs: Populate ->orig_block_len during read_one_chunk Nikolay Borisov
2019-02-28 16:53   ` David Sterba
2019-02-11  8:35 ` [PATCH v2 06/12] btrfs: Introduce new bits for device allocation tree Nikolay Borisov
2019-02-28 16:57   ` David Sterba
2019-02-11  8:35 ` [PATCH v2 07/12] btrfs: replace pending/pinned chunks lists with io tree Nikolay Borisov
2019-02-12 14:13   ` [PATCH] btrfs: Transpose btrfs_close_devices/btrfs_mapping_tree_free in close_ctree Nikolay Borisov
2019-02-11  8:35 ` [PATCH v2 08/12] btrfs: Remove 'trans' argument from find_free_dev_extent(_start) Nikolay Borisov
2019-02-11  8:35 ` [PATCH v2 09/12] btrfs: Factor out in_range macro Nikolay Borisov
2019-02-28 18:00   ` David Sterba
2019-02-11  8:35 ` [PATCH v2 10/12] btrfs: Optimize unallocated chunks discard Nikolay Borisov
2019-02-11  8:35 ` [PATCH v2 11/12] btrfs: Implement find_first_clear_extent_bit Nikolay Borisov
2019-02-11  8:35 ` [PATCH v2 12/12] btrfs: Switch btrfs_trim_free_extents to find_first_clear_extent_bit Nikolay Borisov

Reply instructions:

You may reply publically 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=20190228165221.GL31119@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=jeffm@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /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

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org linux-btrfs@archiver.kernel.org
	public-inbox-index linux-btrfs


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox