linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zach Brown <zab@zabbo.net>
To: Josef Bacik <josef@redhat.com>
Cc: linux-btrfs@vger.kernel.org, wfg@linux.intel.com
Subject: Re: [PATCH] Btrfs: use rcu to protect device->name V2
Date: Mon, 11 Jun 2012 14:10:34 -0700	[thread overview]
Message-ID: <4FD65ECA.1030502@zabbo.net> (raw)
In-Reply-To: <1339421426-1921-1-git-send-email-josef@redhat.com>


> -		if (state->print_mask&  BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE)
> +		if (state->print_mask&  BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE) {
> +			struct rcu_string *name;
> +
> +			rcu_read_lock();
> +			name = rcu_dereference(device->name);
>   			printk(KERN_INFO "New initial S-block (bdev %p, %s)"
>   			       " @%llu (%s/%llu/%d)\n",
> -			       superblock_bdev, device->name,
> +			       superblock_bdev, name->str,
>   			       (unsigned long long)dev_bytenr,
>   			       dev_state->name,
>   			       (unsigned long long)dev_bytenr,
>   			       superblock_mirror_num);
> +			rcu_read_unlock();
> +		}

That's a whole lot of noise at every call site.  How about some helpers?
In sloppy-code..

#define printk_in_rcu(args) do { rcu; printk; rcu; } while (0)

#define device_name_rcu(dev) ({
	struct rcu_string *name = rcu_dereference(dev->name);
	name->str; )}

	printk_in_rcu("HELLO FRIENDS %s", device_name_rcu(dev));

It's kind of annoying to have a wrapper for printk(), pr_debug(), etc,
but it sure seems better than implementing the rcu consistency rules
around every output.  (And multiple rcu_string locals for multiple
device names..)

- z

  reply	other threads:[~2012-06-11 21:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-11 13:30 [PATCH] Btrfs: use rcu to protect device->name V2 Josef Bacik
2012-06-11 21:10 ` Zach Brown [this message]
2012-06-12 13:25   ` Josef Bacik
2012-06-12 13:43   ` Josef Bacik
2012-06-12 17:33     ` Zach Brown
2012-06-12 18:08       ` Josef Bacik

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=4FD65ECA.1030502@zabbo.net \
    --to=zab@zabbo.net \
    --cc=josef@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wfg@linux.intel.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
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).