trivial cleanups
Hi gang,
Here's some trivial cleanups that I've built up while reading through the code. They've been run through xfstests -g quick.
- z
PATCH 1/3 btrfs: use get_seconds() instead of btrfs wrapper
--- fs/btrfs/dev-replace.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
fs/btrfs/dev-replace.c +4 -12
@@ -38,7 +38,6 @@#include "rcu-string.h" #include "dev-replace.h" -static u64 btrfs_get_seconds_since_1970 (void );static int btrfs_dev_replace_finishing (struct btrfs_fs_info *fs_info,int scrub_ret); static void btrfs_dev_replace_update_device_in_mapping_tree(
@@ -296,13 +295,6 @@ void btrfs_after_dev_replace_commit(struct btrfs_fs_info *fs_info) dev_replace->cursor_left_last_write_of_item; } -static u64 btrfs_get_seconds_since_1970 (void ) -{ -struct timespec t =CURRENT_TIME_SEC ; - -return t.tv_sec; -} -int btrfs_dev_replace_start (struct btrfs_root *root,struct btrfs_ioctl_dev_replace_args *args) {
@@ -390,7 +382,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,* go to the tgtdev as well (refer to btrfs_map_block()). */ dev_replace->replace_state =BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED ; - dev_replace->time_started =btrfs_get_seconds_since_1970 (); + dev_replace->time_started =get_seconds (); dev_replace->cursor_left =0 ; dev_replace->committed_cursor_left =0 ; dev_replace->cursor_left_last_write_of_item =0 ;
@@ -493,7 +485,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, : BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED; dev_replace->tgtdev =NULL ; dev_replace->srcdev =NULL ; - dev_replace->time_stopped =btrfs_get_seconds_since_1970 (); + dev_replace->time_stopped =get_seconds (); dev_replace->item_needs_writeback =1 ;if (scrub_ret) {
@@ -668,7 +660,7 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)break ; } dev_replace->replace_state =BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED ; - dev_replace->time_stopped =btrfs_get_seconds_since_1970 (); + dev_replace->time_stopped =get_seconds (); dev_replace->item_needs_writeback =1 ;btrfs_dev_replace_unlock (dev_replace);btrfs_scrub_cancel (fs_info);
@@ -703,7 +695,7 @@ void btrfs_dev_replace_suspend_for_unmount(struct btrfs_fs_info *fs_info)case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED : dev_replace->replace_state =BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED ; - dev_replace->time_stopped =btrfs_get_seconds_since_1970 (); + dev_replace->time_stopped =get_seconds (); dev_replace->item_needs_writeback =1 ;pr_info ("btrfs: suspending dev_replace for unmount\n" );break ;
Signature · 1 line
1.7.11.7
PATCH 2/3 btrfs: remove move_pages()
In reply to Zach Brownmove_pages() has an inefficient backwards byte copy of regions of two different pages. They're different pages so the regions won't overlap and it could use memcpy().
At that point, though, move_pages() would be a slightly dimmer re-implementation of copy_pages() that lacked the test for overlapping page regions.
So remove move_pages() and just call copy_pages().
--- fs/btrfs/extent_io.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
fs/btrfs/extent_io.c +1 -18
@@ -5093,23 +5093,6 @@ void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src, } } -static void move_pages (struct page *dst_page,struct page *src_page, -unsigned long dst_off,unsigned long src_off, -unsigned long len) -{ -char *dst_kaddr =page_address (dst_page); -if (dst_page == src_page) { -memmove (dst_kaddr + dst_off, dst_kaddr + src_off, len); - }else { -char *src_kaddr =page_address (src_page); -char *p = dst_kaddr + dst_off + len; -char *s = src_kaddr + src_off + len; - -while (len--) - *--p = *--s; - } -} -static inline bool areas_overlap (unsigned long src,unsigned long dst,unsigned long len) {unsigned long distance = (src > dst) ? src - dst : dst - src;
@@ -5220,7 +5203,7 @@ void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset, cur = min_t(unsigned long, len, src_off_in_page + 1); cur =min (cur, dst_off_in_page +1 ); -move_pages (extent_buffer_page (dst, dst_i), +copy_pages (extent_buffer_page (dst, dst_i),extent_buffer_page (dst, src_i), dst_off_in_page - cur +1 , src_off_in_page - cur +1 , cur);
Signature · 1 line
1.7.11.7
PATCH 3/3 btrfs: remove fs/btrfs/compat.h
In reply to Zach Brownfs/btrfs/compat.h only contained trivial macro wrappers of drop_nlink() and inc_nlink(). This doesn't belong in mainline.
--- fs/btrfs/compat.h | 7 ------- fs/btrfs/compression.c | 1 - fs/btrfs/dev-replace.c | 1 - fs/btrfs/disk-io.c | 1 - fs/btrfs/export.c | 1 - fs/btrfs/extent-tree.c | 1 - fs/btrfs/extent_io.c | 1 - fs/btrfs/file.c | 1 - fs/btrfs/inode.c | 5 ++--- fs/btrfs/ioctl.c | 1 - fs/btrfs/raid56.c | 1 - fs/btrfs/super.c | 1 - fs/btrfs/tree-log.c | 9 ++++----- fs/btrfs/volumes.c | 1 - 14 files changed, 6 insertions(+), 26 deletions(-) delete mode 100644 fs/btrfs/compat.h
fs/btrfs/compat.h deleted +0 -7
@@ -1,7 +0,0 @@ -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#define btrfs_drop_nlink (inode) drop_nlink(inode) -#define btrfs_inc_nlink (inode) inc_nlink(inode) - -#endif /* _COMPAT_H_ */
fs/btrfs/compression.c +0 -1
@@ -32,7 +32,6 @@#include <linux/writeback.h> #include <linux/bit_spinlock.h> #include <linux/slab.h> -#include "compat.h" #include "ctree.h" #include "disk-io.h" #include "transaction.h"
fs/btrfs/dev-replace.c +0 -1
@@ -26,7 +26,6 @@#include <linux/kthread.h> #include <linux/math64.h> #include <asm/div64.h> -#include "compat.h" #include "ctree.h" #include "extent_map.h" #include "disk-io.h"
fs/btrfs/disk-io.c +0 -1
@@ -33,7 +33,6 @@#include <linux/uuid.h> #include <linux/semaphore.h> #include <asm/unaligned.h> -#include "compat.h" #include "ctree.h" #include "disk-io.h" #include "transaction.h"
fs/btrfs/export.c +0 -1
@@ -5,7 +5,6 @@#include "btrfs_inode.h" #include "print-tree.h" #include "export.h" -#include "compat.h" #define BTRFS_FID_SIZE_NON_CONNECTABLE (offsetof(struct btrfs_fid, \ parent_objectid) / 4)
fs/btrfs/extent-tree.c +0 -1
@@ -25,7 +25,6 @@#include <linux/slab.h> #include <linux/ratelimit.h> #include <linux/percpu_counter.h> -#include "compat.h" #include "hash.h" #include "ctree.h" #include "disk-io.h"
fs/btrfs/extent_io.c +0 -1
@@ -13,7 +13,6 @@#include <linux/cleancache.h> #include "extent_io.h" #include "extent_map.h" -#include "compat.h" #include "ctree.h" #include "btrfs_inode.h" #include "volumes.h"
fs/btrfs/file.c +0 -1
@@ -39,7 +39,6 @@#include "print-tree.h" #include "tree-log.h" #include "locking.h" -#include "compat.h" #include "volumes.h" static struct kmem_cache *btrfs_inode_defrag_cachep;
fs/btrfs/inode.c +2 -3
@@ -43,7 +43,6 @@#include <linux/btrfs.h> #include <linux/blkdev.h> #include <linux/posix_acl_xattr.h> -#include "compat.h" #include "ctree.h" #include "disk-io.h" #include "transaction.h"
@@ -3645,7 +3644,7 @@ int btrfs_unlink_inode(struct btrfs_trans_handle *trans,int ret; ret =__btrfs_unlink_inode (trans, root, dir, inode, name, name_len);if (!ret) { -btrfs_drop_nlink (inode); +drop_nlink (inode); ret =btrfs_update_inode (trans, root, inode); }return ret;
@@ -5738,7 +5737,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, goto fail; } -btrfs_inc_nlink (inode); +inc_nlink (inode);inode_inc_iversion (inode); inode->i_ctime =CURRENT_TIME ;ihold (inode);
fs/btrfs/ioctl.c +0 -1
@@ -44,7 +44,6 @@#include <linux/uuid.h> #include <linux/btrfs.h> #include <linux/uaccess.h> -#include "compat.h" #include "ctree.h" #include "disk-io.h" #include "transaction.h"
fs/btrfs/raid56.c +0 -1
@@ -33,7 +33,6 @@#include <linux/raid/xor.h> #include <linux/vmalloc.h> #include <asm/div64.h> -#include "compat.h" #include "ctree.h" #include "extent_map.h" #include "disk-io.h"
fs/btrfs/super.c +0 -1
@@ -42,7 +42,6 @@#include <linux/cleancache.h> #include <linux/ratelimit.h> #include <linux/btrfs.h> -#include "compat.h" #include "delayed-inode.h" #include "ctree.h" #include "disk-io.h"
fs/btrfs/tree-log.c +4 -5
@@ -26,7 +26,6 @@#include "locking.h" #include "print-tree.h" #include "backref.h" -#include "compat.h" #include "tree-log.h" #include "hash.h"
@@ -936,7 +935,7 @@ again: parent_objectid, victim_name, victim_name_len)) { -btrfs_inc_nlink (inode ); +inc_nlink (inode );btrfs_release_path (path); ret = btrfs_unlink_inode(trans, root, dir,
@@ -1006,7 +1005,7 @@ again: victim_parent =read_one_inode (root, parent_objectid);if (victim_parent) { -btrfs_inc_nlink (inode); +inc_nlink (inode);btrfs_release_path (path); ret = btrfs_unlink_inode(trans, root,
@@ -1480,7 +1479,7 @@ static noinline int link_to_fixup_dir(struct btrfs_trans_handle *trans,if (!inode->i_nlink)set_nlink (inode,1 );else -btrfs_inc_nlink (inode); +inc_nlink (inode); ret =btrfs_update_inode (trans, root, inode); }else if (ret == -EEXIST ) { ret =0 ;
@@ -1841,7 +1840,7 @@ again: goto out; } -btrfs_inc_nlink (inode); +inc_nlink (inode); ret =btrfs_unlink_inode (trans, root, dir, inode, name, name_len);if (!ret)
fs/btrfs/volumes.c +0 -1
@@ -28,7 +28,6 @@#include <linux/raid/pq.h> #include <linux/semaphore.h> #include <asm/div64.h> -#include "compat.h" #include "ctree.h" #include "extent_map.h" #include "disk-io.h"
Signature · 1 line
1.7.11.7