[PATCH v5] Move BTRFS RCU string to common library

2014-11-07 Thread Omar Sandoval
The RCU-friendly string API used internally by BTRFS is generic enough for
common use. This doesn't add any new functionality, but instead just moves the
code and documents the existing API.

Reviewed-by: Josh Triplett j...@joshtriplett.org
Acked-by: Paul E. McKenney paul...@linux.vnet.ibm.com
Signed-off-by: Omar Sandoval osan...@osandov.com
---
Chris, could you take a look at this again? It's just been rebased and should
be good to go. Thanks!

v5: Rebase against v3.18-rc3
v4: Don't return anything from the printk wrappers on the assumption that
printk will return void someday
v3: Add __rcu annotation to relevant functions, add Paul's ack and Josh's
review

 fs/btrfs/check-integrity.c |  6 ++--
 fs/btrfs/dev-replace.c | 19 +-
 fs/btrfs/disk-io.c |  6 ++--
 fs/btrfs/extent_io.c   |  4 +--
 fs/btrfs/ioctl.c   |  4 +--
 fs/btrfs/raid56.c  |  2 +-
 fs/btrfs/rcu-string.h  | 56 -
 fs/btrfs/scrub.c   | 15 
 fs/btrfs/super.c   |  2 +-
 fs/btrfs/volumes.c | 14 
 include/linux/rcustring.h  | 89 ++
 11 files changed, 126 insertions(+), 91 deletions(-)
 delete mode 100644 fs/btrfs/rcu-string.h
 create mode 100644 include/linux/rcustring.h

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index cb7f3fe..a894c94 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -94,6 +94,7 @@
 #include linux/mutex.h
 #include linux/genhd.h
 #include linux/blkdev.h
+#include linux/rcustring.h
 #include ctree.h
 #include disk-io.h
 #include hash.h
@@ -103,7 +104,6 @@
 #include print-tree.h
 #include locking.h
 #include check-integrity.h
-#include rcu-string.h
 
 #define BTRFSIC_BLOCK_HASHTABLE_SIZE 0x1
 #define BTRFSIC_BLOCK_LINK_HASHTABLE_SIZE 0x1
@@ -850,8 +850,8 @@ static int btrfsic_process_superblock_dev_mirror(
printk_in_rcu(KERN_INFO New initial S-block (bdev %p, 
%s)
  @%llu (%s/%llu/%d)\n,
 superblock_bdev,
-rcu_str_deref(device-name), dev_bytenr,
-dev_state-name, dev_bytenr,
+rcu_string_dereference(device-name),
+dev_bytenr, dev_state-name, dev_bytenr,
 superblock_mirror_num);
list_add(superblock_tmp-all_blocks_node,
 state-all_blocks_list);
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 6f662b3..f697899 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -25,6 +25,7 @@
 #include linux/capability.h
 #include linux/kthread.h
 #include linux/math64.h
+#include linux/rcustring.h
 #include asm/div64.h
 #include ctree.h
 #include extent_map.h
@@ -34,7 +35,6 @@
 #include volumes.h
 #include async-thread.h
 #include check-integrity.h
-#include rcu-string.h
 #include dev-replace.h
 #include sysfs.h
 
@@ -384,9 +384,9 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
printk_in_rcu(KERN_INFO
  BTRFS: dev_replace from %s (devid %llu) to %s started\n,
  src_device-missing ? missing disk :
-   rcu_str_deref(src_device-name),
+ rcu_string_dereference(src_device-name),
  src_device-devid,
- rcu_str_deref(tgt_device-name));
+ rcu_string_dereference(tgt_device-name));
 
/*
 * from now on, the writes to the srcdev are all duplicated to
@@ -531,9 +531,10 @@ static int btrfs_dev_replace_finishing(struct 
btrfs_fs_info *fs_info,
printk_in_rcu(KERN_ERR
  BTRFS: btrfs_scrub_dev(%s, %llu, %s) failed 
%d\n,
  src_device-missing ? missing disk :
-   rcu_str_deref(src_device-name),
+ rcu_string_dereference(src_device-name),
  src_device-devid,
- rcu_str_deref(tgt_device-name), scrub_ret);
+ rcu_string_dereference(tgt_device-name),
+ scrub_ret);
btrfs_dev_replace_unlock(dev_replace);
mutex_unlock(root-fs_info-chunk_mutex);
mutex_unlock(root-fs_info-fs_devices-device_list_mutex);
@@ -548,9 +549,9 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info 
*fs_info,
printk_in_rcu(KERN_INFO
  BTRFS: dev_replace from %s (devid %llu) to %s 
finished\n,
  src_device-missing ? missing disk :
-   rcu_str_deref(src_device-name),
+ rcu_string_dereference(src_device-name),
  src_device-devid,
- rcu_str_deref(tgt_device-name));
+

Re: [PATCH v5] Move BTRFS RCU string to common library

2014-11-07 Thread Chris Mason



On Fri, Nov 7, 2014 at 3:17 PM, Omar Sandoval osan...@osandov.com 
wrote:
The RCU-friendly string API used internally by BTRFS is generic 
enough for
common use. This doesn't add any new functionality, but instead just 
moves the

code and documents the existing API.

Reviewed-by: Josh Triplett j...@joshtriplett.org
Acked-by: Paul E. McKenney paul...@linux.vnet.ibm.com
Signed-off-by: Omar Sandoval osan...@osandov.com
---
Chris, could you take a look at this again? It's just been rebased 
and should

be good to go. Thanks!


Thanks Omar, I'm pulling this into a branch for the next merge window.  
Looks good to me.


-chris


--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5] Move BTRFS RCU string to common library

2014-11-07 Thread Joe Perches
On Fri, 2014-11-07 at 15:21 -0500, Chris Mason wrote:
 
 On Fri, Nov 7, 2014 at 3:17 PM, Omar Sandoval osan...@osandov.com 
 wrote:
  The RCU-friendly string API used internally by BTRFS is generic 
  enough for
  common use. This doesn't add any new functionality, but instead just 
  moves the
  code and documents the existing API.
  
  Reviewed-by: Josh Triplett j...@joshtriplett.org
  Acked-by: Paul E. McKenney paul...@linux.vnet.ibm.com
  Signed-off-by: Omar Sandoval osan...@osandov.com
  ---
  Chris, could you take a look at this again? It's just been rebased 
  and should
  be good to go. Thanks!
 
 Thanks Omar, I'm pulling this into a branch for the next merge window.  
 Looks good to me.

rcustring.h should probably #include any #include dependencies
it has.  types.h, printk.h, etc...


--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html