All of lore.kernel.org
 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: Tue, 12 Jun 2012 10:33:06 -0700	[thread overview]
Message-ID: <4FD77D52.8000203@zabbo.net> (raw)
In-Reply-To: <20120612134318.GD1565@localhost.localdomain>


> #define device_name_printk(dev, level, fmt, ...) do {		\
> 	struct rcu_string *name;				\
> 								\
> 	rcu_read_lock();					\
> 	name = rcu_dereference(dev->name);			\
> 	printk(level "%s: " fmt, name->str, ##__VA_ARGS__);	\
> 	rcu_read_unlock();					\
> 	} while (0)

Right, that has the same problem of limiting flexibility in the device
name args.  That's why I gave that example of a specific macro for
dereferencing a device name arg's rcu_string.

Does this diff make it more clear?  It's generated on your patch, only
build tested..

- z

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 2c07e80..614024e 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -844,18 +844,13 @@ static int btrfsic_process_superblock_dev_mirror(
  		superblock_tmp->never_written = 0;
  		superblock_tmp->mirror_num = 1 + superblock_mirror_num;
  		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)"
+			printk_in_rcu(KERN_INFO "New initial S-block (bdev %p, %s)"
  			       " @%llu (%s/%llu/%d)\n",
-			       superblock_bdev, name->str,
+			       superblock_bdev, rcu_str_deref(device->name),
  			       (unsigned long long)dev_bytenr,
  			       dev_state->name,
  			       (unsigned long long)dev_bytenr,
  			       superblock_mirror_num);
-			rcu_read_unlock();
  		}
  		list_add(&superblock_tmp->all_blocks_node,
  			 &state->all_blocks_list);
diff --git a/fs/btrfs/rcu-string.h b/fs/btrfs/rcu-string.h
index 4af8f61..a3a86bb 100644
--- a/fs/btrfs/rcu-string.h
+++ b/fs/btrfs/rcu-string.h
@@ -37,3 +37,14 @@ static inline void rcu_string_free(struct rcu_string 
*str)
  	if (str)
  		kfree_rcu(str, rcu);
  }
+
+#define printk_in_rcu(args...) do {	\
+	rcu_read_lock();		\
+	printk(##args);			\
+	rcu_read_unlock();		\
+} while (0)
+
+#define rcu_str_deref(rcu_str) ({				\
+	struct rcu_string *__str = rcu_dereference(rcu_str);	\
+	__str->str;						\
+})

  reply	other threads:[~2012-06-12 17:33 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
2012-06-12 13:25   ` Josef Bacik
2012-06-12 13:43   ` Josef Bacik
2012-06-12 17:33     ` Zach Brown [this message]
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=4FD77D52.8000203@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.