Skip to contentSkip to conversation

btrfs: Replace multiple atomic_inc() with atomic_add()

PATCH In review Rashika Kheria 2 participants 2 messages Oct 30, 2013 – Nov 2, 2013 1 message not in the archive Btrfs file system

lore
Share & tools
lore
#1 lore raw

PATCH v2 1/1 btrfs: Replace multiple atomic_inc() with atomic_add()

In reply to a message not in the archive

This patch replaces multiple atomic_inc() with atomic_add() in delayed-inode.c to reduce source code and have few instructions for compilation.

---

This revision fixes the following issues of the previous revision- Space in comment

 fs/btrfs/delayed-inode.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/delayed-inode.c +4 -4
index cbd9523..504a9b5 100644
@@ -108,8 +108,8 @@ static struct btrfs_delayed_node *btrfs_get_delayed_node(struct inode *inode)
 			return node;
 		}
 		btrfs_inode->delayed_node = node;
-		atomic_inc(&node->refs);	/* can be accessed */
-		atomic_inc(&node->refs);	/* cached in the inode */
+		/* can be accessed and cached in the inode */
+		atomic_add(2, &node->refs);
 		spin_unlock(&root->inode_lock);
 		return node;
 	}
@@ -138,8 +138,8 @@ again:
 		return ERR_PTR(-ENOMEM);
 	btrfs_init_delayed_node(node, root, ino);
 
-	atomic_inc(&node->refs);	/* cached in the btrfs inode */
-	atomic_inc(&node->refs);	/* can be accessed */
+	/* cached in the btrfs inode and can be accessed */
+	atomic_add(2, &node->refs);
 
 	ret = radix_tree_preload(GFP_NOFS & ~__GFP_HIGHMEM);
 	if (ret) {
Signature · 1 line
1.7.9.5
Reviewed-by on v2 1/1
#2 lore raw
Quoted 6 lines · Rashika Kheria

This patch replaces multiple atomic_inc() with atomic_add() in delayed-inode.c to reduce source code and have few instructions for compilation.

Quoted 40 lines

This revision fixes the following issues of the previous revision- Space in comment

 fs/btrfs/delayed-inode.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/delayed-inode.c +4 -4
index cbd9523..504a9b5 100644
@@ -108,8 +108,8 @@ static struct btrfs_delayed_node *btrfs_get_delayed_node(struct inode *inode)
 			return node;
 		}
 		btrfs_inode->delayed_node = node;
-		atomic_inc(&node->refs);	/* can be accessed */
-		atomic_inc(&node->refs);	/* cached in the inode */
+		/* can be accessed and cached in the inode */
+		atomic_add(2, &node->refs);
 		spin_unlock(&root->inode_lock);
 		return node;
 	}
@@ -138,8 +138,8 @@ again:
 		return ERR_PTR(-ENOMEM);
 	btrfs_init_delayed_node(node, root, ino);
 
-	atomic_inc(&node->refs);	/* cached in the btrfs inode */
-	atomic_inc(&node->refs);	/* can be accessed */
+	/* cached in the btrfs inode and can be accessed */
+	atomic_add(2, &node->refs);
 
 	ret = radix_tree_preload(GFP_NOFS & ~__GFP_HIGHMEM);
 	if (ret) {
Signature · 6 lines
1.7.9.5

-- 
You received this message because you are subscribed to the Google Groups "opw-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.